capistrano_multiconfig_parallel 1.4.2 → 1.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/capistrano_multiconfig_parallel/celluloid/child_process.rb +3 -2
- data/lib/capistrano_multiconfig_parallel/celluloid/terminal_table.rb +3 -2
- data/lib/capistrano_multiconfig_parallel/classes/cursor.rb +82 -84
- data/lib/capistrano_multiconfig_parallel/classes/job.rb +1 -0
- data/lib/capistrano_multiconfig_parallel/helpers/core_helper.rb +5 -1
- data/lib/capistrano_multiconfig_parallel/version.rb +2 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7850da2d68285258db1d775ca37bae04c3953267
|
4
|
+
data.tar.gz: 832c4718cce677196834dbc0bb2037e63b2ad1f1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ac16a865357e133e767330c957fe78f5fee9198f1a3144f8041d4350cb1ab5a597e5352dfaba92a0b740965b45c4de6e64a2d8ec166a873e1663fbbb9770c78f
|
7
|
+
data.tar.gz: 8a16667cb2b53b5c5629a069dfbfaffd0cbd36baf09de2eaeffa3c7620a65cd4b66adc9be0bc21a427bf3c72c8c719531ab6eda6efa5f4acf59fbcc0ce5f4997
|
@@ -65,6 +65,7 @@ module CapistranoMulticonfigParallel
|
|
65
65
|
end
|
66
66
|
|
67
67
|
def print_error_if_exist
|
68
|
+
return unless development_debug?
|
68
69
|
[@job.stderr_buffer].each do |buffer|
|
69
70
|
buffer.rewind
|
70
71
|
data = buffer.read
|
@@ -75,7 +76,7 @@ module CapistranoMulticonfigParallel
|
|
75
76
|
def start_async_deploy
|
76
77
|
RightScale::RightPopen.popen3_async(
|
77
78
|
@cmd,
|
78
|
-
target:
|
79
|
+
target: Actor.current,
|
79
80
|
environment: @options.fetch(:environment, nil),
|
80
81
|
pid_handler: :on_pid,
|
81
82
|
input: :on_input_stdin,
|
@@ -99,7 +100,7 @@ module CapistranoMulticonfigParallel
|
|
99
100
|
end
|
100
101
|
|
101
102
|
def on_read_stderr(data)
|
102
|
-
@job.save_stderr_error(data)
|
103
|
+
@job.save_stderr_error(data) if development_debug?
|
103
104
|
io_callback('stderr', data)
|
104
105
|
end
|
105
106
|
|
@@ -21,6 +21,7 @@ module CapistranoMulticonfigParallel
|
|
21
21
|
@manager = manager
|
22
22
|
@position = nil
|
23
23
|
@terminal_rows = nil
|
24
|
+
@cursor = CapistranoMulticonfigParallel::Cursor.new
|
24
25
|
@errors = []
|
25
26
|
@options = options.is_a?(Hash) ? options.stringify_keys : options
|
26
27
|
@job_manager = job_manager
|
@@ -57,7 +58,7 @@ module CapistranoMulticonfigParallel
|
|
57
58
|
|
58
59
|
def display_table_on_terminal(table, jobs)
|
59
60
|
table_size = fetch_table_size(jobs)
|
60
|
-
@position, @terminal_rows, @screen_erased =
|
61
|
+
@position, @terminal_rows, @screen_erased = @cursor.display_on_screen(
|
61
62
|
"#{table}",
|
62
63
|
@options.merge(
|
63
64
|
position: @position,
|
@@ -70,7 +71,7 @@ module CapistranoMulticonfigParallel
|
|
70
71
|
end
|
71
72
|
|
72
73
|
def print_errors
|
73
|
-
puts(@errors.join("\n")) if @errors.present? && @options.fetch('clear_screen', false).to_s == 'false'
|
74
|
+
puts(@errors.join("\n")) if @errors.present? && @options.fetch('clear_screen', false).to_s == 'false' && development_debug?
|
74
75
|
end
|
75
76
|
|
76
77
|
def setup_table_jobs(table)
|
@@ -3,113 +3,111 @@ module CapistranoMulticonfigParallel
|
|
3
3
|
# class used to fetch cursor position before displaying terminal table
|
4
4
|
# http://ispltd.org/mini_howto:ansi_terminal_codes
|
5
5
|
class Cursor
|
6
|
-
|
7
|
-
include CapistranoMulticonfigParallel::ApplicationHelper
|
6
|
+
include CapistranoMulticonfigParallel::ApplicationHelper
|
8
7
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
8
|
+
def display_on_screen(string, options = {})
|
9
|
+
options = options.is_a?(Hash) ? options.stringify_keys : {}
|
10
|
+
handle_string_display(string, options)
|
11
|
+
end
|
13
12
|
|
14
13
|
private
|
15
14
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
15
|
+
def move_to_home!(row = 0, column = 1)
|
16
|
+
erase_screen
|
17
|
+
position_cursor(row, column)
|
18
|
+
end
|
20
19
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
20
|
+
def fetch_terminal_size
|
21
|
+
size = (dynamic_size_stty || dynamic_size_tput || `echo $LINES $COLUMNS`)
|
22
|
+
size = strip_characters_from_string(size).split(' ')
|
23
|
+
{ rows: size[0].to_i, columns: size[1].to_i }
|
24
|
+
end
|
26
25
|
|
27
|
-
|
28
|
-
|
26
|
+
def fetch_cursor_position(table_size, position, previously_erased_screen)
|
27
|
+
final_position = position || fetch_position
|
28
|
+
terminal_rows = fetch_terminal_size
|
29
|
+
if previously_erased_screen == false && refetch_position?(table_size, terminal_rows, final_position)
|
30
|
+
screen_erased = true
|
31
|
+
move_to_home!
|
32
|
+
final_position = fetch_position
|
29
33
|
terminal_rows = fetch_terminal_size
|
30
|
-
if previously_erased_screen == false && refetch_position?(table_size, terminal_rows, final_position)
|
31
|
-
screen_erased = true
|
32
|
-
move_to_home!
|
33
|
-
final_position = fetch_position
|
34
|
-
terminal_rows = fetch_terminal_size
|
35
|
-
end
|
36
|
-
[final_position, terminal_rows, screen_erased]
|
37
34
|
end
|
35
|
+
[final_position, terminal_rows, screen_erased]
|
36
|
+
end
|
38
37
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
38
|
+
def refetch_position?(table_size, terminal_size, position)
|
39
|
+
terminal_rows = terminal_size[:rows]
|
40
|
+
row_position = position[:row]
|
41
|
+
terminal_rows.zero? || (terminal_rows.nonzero? && row_position >= (terminal_rows / 2)) || (table_size >= (terminal_rows - row_position))
|
42
|
+
end
|
44
43
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
end
|
44
|
+
def fetch_position
|
45
|
+
res = ''
|
46
|
+
$stdin.raw do |stdin|
|
47
|
+
$stdout << "\e[6n"
|
48
|
+
$stdout.flush
|
49
|
+
while (line = stdin.getc) != 'R'
|
50
|
+
res << line if line
|
53
51
|
end
|
54
|
-
position = res.match(/(?<row>\d+);(?<column>\d+)/)
|
55
|
-
{ row: position[:row].to_i, column: position[:column].to_i }
|
56
52
|
end
|
53
|
+
position = res.match(/(?<row>\d+);(?<column>\d+)/)
|
54
|
+
{ row: position[:row].to_i, column: position[:column].to_i }
|
55
|
+
end
|
57
56
|
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
57
|
+
def dynamic_size_stty
|
58
|
+
size = `stty size 2>/dev/null`
|
59
|
+
size.present? ? size : nil
|
60
|
+
end
|
62
61
|
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
62
|
+
def dynamic_size_tput
|
63
|
+
lines = `tput lines 2>/dev/null`
|
64
|
+
cols = `tput cols 2>/dev/null`
|
65
|
+
lines.present? && cols.present? ? "#{lines} #{cols}" : nil
|
66
|
+
end
|
68
67
|
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
end
|
68
|
+
def handle_string_display(string, options)
|
69
|
+
position = options.fetch('position', nil)
|
70
|
+
table_size = options.fetch('table_size', 0)
|
71
|
+
if options.fetch('clear_screen', false).to_s == 'true'
|
72
|
+
terminal_clear_display(string)
|
73
|
+
[0, 0, false]
|
74
|
+
else
|
75
|
+
new_position, terminal_rows, screen_erased = fetch_cursor_position(table_size, position, options.fetch('screen_erased', false))
|
76
|
+
display_string_at_position(new_position, string)
|
77
|
+
[new_position, terminal_rows, screen_erased]
|
80
78
|
end
|
79
|
+
end
|
81
80
|
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
81
|
+
def terminal_clear_display(string)
|
82
|
+
terminal_clear
|
83
|
+
puts string
|
84
|
+
end
|
86
85
|
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
86
|
+
def display_string_at_position(position, string)
|
87
|
+
go_to_position(position)
|
88
|
+
erase_from_current_line_to_bottom
|
89
|
+
go_to_position(position)
|
90
|
+
puts string
|
91
|
+
end
|
93
92
|
|
94
|
-
|
95
|
-
|
96
|
-
|
93
|
+
def erase_from_current_line_to_bottom
|
94
|
+
puts "\e[J"
|
95
|
+
end
|
97
96
|
|
98
|
-
|
99
|
-
|
100
|
-
|
97
|
+
def erase_screen
|
98
|
+
puts("\e[2J")
|
99
|
+
end
|
101
100
|
|
102
|
-
|
103
|
-
|
104
|
-
|
101
|
+
def go_to_position(position)
|
102
|
+
position_cursor(position[:row], position[:column])
|
103
|
+
end
|
105
104
|
|
106
|
-
|
107
|
-
|
108
|
-
|
105
|
+
def position_cursor(line, column)
|
106
|
+
puts("\e[#{line};#{column}H")
|
107
|
+
end
|
109
108
|
|
110
|
-
|
111
|
-
|
112
|
-
end
|
109
|
+
def terminal_clear
|
110
|
+
system('cls') || system('clear') || puts("\e[H\e[2J")
|
113
111
|
end
|
114
112
|
end
|
115
113
|
end
|
@@ -52,6 +52,10 @@ module CapistranoMulticonfigParallel
|
|
52
52
|
[CapistranoMulticonfigParallel::CelluloidWorker::TaskFailed, SystemExit].find { |class_name| error.is_a?(class_name) }.present?
|
53
53
|
end
|
54
54
|
|
55
|
+
def development_debug?
|
56
|
+
ENV['MULTICAP_DEBUG'].to_s == 'true'
|
57
|
+
end
|
58
|
+
|
55
59
|
def log_error(error, options = {})
|
56
60
|
message = format_error(error)
|
57
61
|
log_output_error(error, options.fetch(:output, nil), message)
|
@@ -63,7 +67,7 @@ module CapistranoMulticonfigParallel
|
|
63
67
|
end
|
64
68
|
|
65
69
|
def terminal_errors?
|
66
|
-
terminal_actor.present? && terminal_actor.alive? && terminal_actor.errors.is_a?(Array)
|
70
|
+
development_debug? && terminal_actor.present? && terminal_actor.alive? && terminal_actor.errors.is_a?(Array)
|
67
71
|
end
|
68
72
|
|
69
73
|
def log_output_error(error, output, message)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: capistrano_multiconfig_parallel
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- bogdanRada
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-06-
|
11
|
+
date: 2016-06-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: celluloid
|