capistrano_multiconfig_parallel 0.29.3 → 0.30.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/capistrano_multiconfig_parallel/celluloid/terminal_table.rb +5 -2
- data/lib/capistrano_multiconfig_parallel/classes/cursor.rb +33 -19
- data/lib/capistrano_multiconfig_parallel/helpers/core_helper.rb +2 -3
- data/lib/capistrano_multiconfig_parallel/version.rb +2 -2
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a451d8cf78447457a14a882d28bb9cb98efd36d9
|
4
|
+
data.tar.gz: d4ba430159980b1346ff58d554a1e22f3d27659f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
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
|
-
|
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
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
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
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
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
|
-
|
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(
|
62
|
-
|
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
|
-
|
53
|
+
puts message if output.present?
|
54
54
|
terminal = Celluloid::Actor[:terminal_server]
|
55
|
-
terminal.errors.push(message) if terminal.present? && terminal.alive?
|
56
|
-
puts message
|
55
|
+
terminal.errors.push(message) if terminal.present? && terminal.alive?
|
57
56
|
end
|
58
57
|
|
59
58
|
def format_error(exception)
|