capistrano_multiconfig_parallel 0.28.5 → 0.29.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0840903a620f1a8c95af1785a6b67573cf6ae648
4
- data.tar.gz: 5fce9f63bf9592a01bbc2f8426592fbf62b1b2cd
3
+ metadata.gz: 660d0cf7532dbcd193a3f3613c7159b5eeb6c578
4
+ data.tar.gz: 51019e097631dedf3919bdbdc40a5d2fb3693c96
5
5
  SHA512:
6
- metadata.gz: d1fb82220d05bcfc06ab07cffd2ba609186c6141774948cc5ff0b1ab2afbf2e0536c1caed32e29edad7c6a5748e6b0c7508ea1ecc9735bc2089c86fd0bf52088
7
- data.tar.gz: 863b07e6e964e29ddfba9d12ec76fa08762aed9cea5374159978d1a3fae289d504d44929230fa80e84a7027fe4421d576a152359c7495d1f7caa8fa386afb63a
6
+ metadata.gz: 7b7ba4b612bf0e868053342799e49f997f4e69118fdc6d48827fdf878ed34bc15cf5bd351c4f2814ffd06bc2d15ff911c50a32a192830a30bd2e42ead108729c
7
+ data.tar.gz: 5e475541a89d3c395c0740f11f6df42757781141f3ce88f4edd2b7b25df960043fde83b99c0bb43624b2d481273fc06ba701da8e2070dc90b911dadebc281a89
@@ -24,6 +24,7 @@ require 'fileutils'
24
24
  require 'pp'
25
25
  require 'yaml'
26
26
  require 'stringio'
27
+ require 'io/console'
27
28
 
28
29
  # capistrano requirements
29
30
  require 'rake'
@@ -45,8 +45,17 @@ module CapistranoMulticonfigParallel
45
45
  terminate
46
46
  end
47
47
 
48
- def display_table_on_terminal(table)
48
+ def fetch_cursor_position
49
+ terminal_size = CapistranoMulticonfigParallel::Cursor.fetch_terminal_size
49
50
  @position ||= CapistranoMulticonfigParallel::Cursor.fetch_position
51
+ return @position if terminal_size[:rows].nonzero? && position[:row] < (terminal_size[:rows] / 2)
52
+ CapistranoMulticonfigParallel::Cursor.move_to_home!(0,0)
53
+ @position = CapistranoMulticonfigParallel::Cursor.fetch_position
54
+ @position
55
+ end
56
+
57
+ def display_table_on_terminal(table)
58
+ cursor_position = fetch_cursor_position
50
59
  CapistranoMulticonfigParallel::Cursor.display_on_screen("\n#{table}\n", @options.merge(position: @position))
51
60
  puts(@errors.join("\n")) if @errors.present? && options.fetch('clear_screen', false).to_s == 'false'
52
61
  signal_complete
@@ -1,8 +1,15 @@
1
- require 'io/console'
1
+ require_relative '../helpers/application_helper'
2
2
  module CapistranoMulticonfigParallel
3
3
  # class used to fetch cursor position before displaying terminal table
4
4
  class Cursor
5
5
  class << self
6
+ include CapistranoMulticonfigParallel::ApplicationHelper
7
+
8
+ def fetch_terminal_size
9
+ size = (dynamic_size_stty || dynamic_size_tput || `echo $LINES $COLUMNS`)
10
+ size = strip_characters_from_string(size).split(' ')
11
+ { rows: size[0].to_i, columns: size[1].to_i }
12
+ end
6
13
 
7
14
  def fetch_position
8
15
  res = ''
@@ -25,13 +32,24 @@ module CapistranoMulticonfigParallel
25
32
  handle_string_display(position, clear_scren, string)
26
33
  end
27
34
 
28
- def move_to_home!
29
- position_cursor(2, 1)
35
+ def move_to_home!(row = 2, column = 1)
36
+ position_cursor(row, column)
30
37
  erase_from_current_line_to_bottom
31
38
  end
32
39
 
33
40
  private
34
41
 
42
+ def dynamic_size_stty
43
+ size = %x{stty size 2>/dev/null}
44
+ size.present? ? size : nil
45
+ end
46
+
47
+ def dynamic_size_tput
48
+ lines %x{tput lines 2>/dev/null}
49
+ cols = %x{tput cols 2>/dev/null}
50
+ lines.present? && cols.present? ? "#{lines} #{cols}" : nil
51
+ end
52
+
35
53
  def handle_string_display(position, clear_scren, string)
36
54
  if clear_scren.to_s == 'true'
37
55
  terminal_clear_display(string)
@@ -7,8 +7,8 @@ module CapistranoMulticonfigParallel
7
7
  # module used for generating the version
8
8
  module VERSION
9
9
  MAJOR = 0
10
- MINOR = 28
11
- TINY = 5
10
+ MINOR = 29
11
+ TINY = 0
12
12
  PRE = nil
13
13
 
14
14
  STRING = [MAJOR, MINOR, TINY, PRE].compact.join('.')
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: capistrano_multiconfig_parallel
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.28.5
4
+ version: 0.29.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - bogdanRada