capistrano_multiconfig_parallel 0.29.3 → 0.30.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: b46dc59e0272cf452cd04ad75a77bd0eafa664c9
4
- data.tar.gz: a40e63eb0a7df1f623db2262f051991f4b38eef0
3
+ metadata.gz: a451d8cf78447457a14a882d28bb9cb98efd36d9
4
+ data.tar.gz: d4ba430159980b1346ff58d554a1e22f3d27659f
5
5
  SHA512:
6
- metadata.gz: a4305d81d1a7bb49a9dc44377c9c90503e952ce54e3481fd6da7ec63342db89c683ed9426b87ac8020230d02d47a6ec0a349a9eb68684f2a7b868c914819cc10
7
- data.tar.gz: ebc2361a965820426e792bb21c90265df0ab2ab45001940a4f759452a2e1e5d48e33a27e07d4de28ef7ab3de3dd8c9721306c6b2a66c2fbeb433824f41748ca8
6
+ metadata.gz: 1a154c1b6321741ae5a219ec3de41be089709ecb83de60a26d3ee9eb39c9c749d57f702916297dbf305c549a86302e3ed8c06a918a3cd411559a0a4cf87312c5
7
+ data.tar.gz: a3d40118f76c522917acb9d51285b15f9d6fca60a5a3ef2d41c638240f3817d6c2bd17921dfe1214cbf1a6b73a64de85b7b3fe7a7575fab9086bc4b8bb30c51d
@@ -8,7 +8,7 @@ module CapistranoMulticonfigParallel
8
8
  include Celluloid::Logger
9
9
  include CapistranoMulticonfigParallel::ApplicationHelper
10
10
 
11
- attr_reader :options, :errors, :manager, :position, :job_manager
11
+ attr_reader :options, :errors, :manager, :position, :job_manager, :terminal_rows
12
12
 
13
13
  def self.topic
14
14
  'sshkit_terminal'
@@ -17,6 +17,7 @@ module CapistranoMulticonfigParallel
17
17
  def initialize(manager, job_manager, options = {})
18
18
  @manager = manager
19
19
  @position = nil
20
+ @terminal_rows = nil
20
21
  @errors = []
21
22
  @options = options.is_a?(Hash) ? options.stringify_keys : options
22
23
  @job_manager = job_manager
@@ -46,8 +47,10 @@ module CapistranoMulticonfigParallel
46
47
  end
47
48
 
48
49
  def display_table_on_terminal(table)
49
- @position ||= CapistranoMulticonfigParallel::Cursor.fetch_cursor_position
50
+ table_size = (table.rows.size + 2)**2
51
+ @position, @terminal_rows = CapistranoMulticonfigParallel::Cursor.fetch_cursor_position(table_size, @position)
50
52
  CapistranoMulticonfigParallel::Cursor.display_on_screen("\n#{table}\n", @options.merge(position: @position))
53
+ #puts [@position, @terminal_rows, table_size , (@terminal_rows[:rows] - @position[:row]), CapistranoMulticonfigParallel::Cursor.refetch_position?(table_size, @terminal_rows, @position)].inspect
51
54
  print_errors
52
55
  signal_complete
53
56
  end
@@ -1,10 +1,20 @@
1
1
  require_relative '../helpers/application_helper'
2
2
  module CapistranoMulticonfigParallel
3
3
  # class used to fetch cursor position before displaying terminal table
4
+ # http://ispltd.org/mini_howto:ansi_terminal_codes
4
5
  class Cursor
5
6
  class << self
6
7
  include CapistranoMulticonfigParallel::ApplicationHelper
7
- attr_accessor :position
8
+
9
+ def display_on_screen(string, options = {})
10
+ options = options.is_a?(Hash) ? options.stringify_keys : {}
11
+ handle_string_display(string, options)
12
+ end
13
+
14
+ def move_to_home!(row = 0, column = 1)
15
+ erase_screen
16
+ position_cursor(row, column)
17
+ end
8
18
 
9
19
  def fetch_terminal_size
10
20
  size = (dynamic_size_stty || dynamic_size_tput || `echo $LINES $COLUMNS`)
@@ -12,27 +22,26 @@ module CapistranoMulticonfigParallel
12
22
  { rows: size[0].to_i, columns: size[1].to_i }
13
23
  end
14
24
 
15
- def fetch_cursor_position
16
- terminal_size = fetch_terminal_size
17
- position = fetch_position
18
- return position if terminal_size[:rows].nonzero? && position[:row] < (terminal_size[:rows] / 2)
19
- move_to_home!(0, 0)
20
- fetch_position
25
+ def fetch_cursor_position(table_size, position)
26
+ final_position = position
27
+ terminal_rows = fetch_terminal_size
28
+ if refetch_position?(table_size, terminal_rows, position)
29
+ move_to_home! if position.present?
30
+ final_position = fetch_position
31
+ terminal_rows = fetch_terminal_size
32
+ end
33
+ [final_position,terminal_rows]
21
34
  end
22
35
 
23
- def display_on_screen(string, options = {})
24
- options = options.is_a?(Hash) ? options.stringify_keys : {}
25
- position = options.fetch('position', nil)
26
- clear_scren = options.fetch('clear_screen', false)
27
- handle_string_display(position, clear_scren, string)
36
+ def refetch_position?(table_size,terminal_size, position)
37
+ return true if position.blank?
38
+ terminal_rows = terminal_size[:rows]
39
+ row_position = position[:row]
40
+ terminal_rows.zero? || (terminal_rows.nonzero? && row_position >= (terminal_rows / 2)) || (table_size >= (terminal_rows -row_position))
28
41
  end
29
42
 
30
- def move_to_home!(row = 2, column = 1)
31
- position_cursor(row, column)
32
- erase_from_current_line_to_bottom
33
- end
43
+ private
34
44
 
35
- private
36
45
 
37
46
  def fetch_position
38
47
  res = ''
@@ -58,8 +67,9 @@ module CapistranoMulticonfigParallel
58
67
  lines.present? && cols.present? ? "#{lines} #{cols}" : nil
59
68
  end
60
69
 
61
- def handle_string_display(position, clear_scren, string)
62
- if clear_scren.to_s == 'true'
70
+ def handle_string_display(string, options)
71
+ position = options.fetch('position',nil)
72
+ if options.fetch('clear_screen', false).to_s == 'true'
63
73
  terminal_clear_display(string)
64
74
  elsif position.present?
65
75
  display_string_at_position(position, string)
@@ -82,6 +92,10 @@ module CapistranoMulticonfigParallel
82
92
  puts "\e[J"
83
93
  end
84
94
 
95
+ def erase_screen
96
+ puts("\e[2J")
97
+ end
98
+
85
99
  def go_to_position(position)
86
100
  position_cursor(position[:row], position[:column])
87
101
  end
@@ -50,10 +50,9 @@ module CapistranoMulticonfigParallel
50
50
  end
51
51
 
52
52
  def log_output_error(output, message)
53
- return if output.blank?
53
+ puts message if output.present?
54
54
  terminal = Celluloid::Actor[:terminal_server]
55
- terminal.errors.push(message) if terminal.present? && terminal.alive? && !terminal.errors.include?(message)
56
- puts message
55
+ terminal.errors.push(message) if terminal.present? && terminal.alive?
57
56
  end
58
57
 
59
58
  def format_error(exception)
@@ -7,8 +7,8 @@ module CapistranoMulticonfigParallel
7
7
  # module used for generating the version
8
8
  module VERSION
9
9
  MAJOR = 0
10
- MINOR = 29
11
- TINY = 3
10
+ MINOR = 30
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.29.3
4
+ version: 0.30.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - bogdanRada