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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 23a276b744f5b10886de516ebe9f1171d801cf40
4
- data.tar.gz: 2abbb61d095c7b5ac3735596fad3cc0bd416dfa3
3
+ metadata.gz: 7850da2d68285258db1d775ca37bae04c3953267
4
+ data.tar.gz: 832c4718cce677196834dbc0bb2037e63b2ad1f1
5
5
  SHA512:
6
- metadata.gz: a4b775ff7cd574643e5cb97059a9c9e3fb53f4cb000f63122c0b3c569cbf0a91d72fa6504f3d221240660c7cc2787affa450da923c32080ab85d1346923bc8d2
7
- data.tar.gz: 36b362acbcc91d464d1bf7f9c9fdc5951ac34cba0d89794c9a54dc0f111bd60d504c6fcb7e37e21a8e96b698b42e674e7b1c128c27f2ddce451169d8297765e8
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: self,
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 = CapistranoMulticonfigParallel::Cursor.display_on_screen(
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
- class << self
7
- include CapistranoMulticonfigParallel::ApplicationHelper
6
+ include CapistranoMulticonfigParallel::ApplicationHelper
8
7
 
9
- def display_on_screen(string, options = {})
10
- options = options.is_a?(Hash) ? options.stringify_keys : {}
11
- handle_string_display(string, options)
12
- end
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
- def move_to_home!(row = 0, column = 1)
17
- erase_screen
18
- position_cursor(row, column)
19
- end
15
+ def move_to_home!(row = 0, column = 1)
16
+ erase_screen
17
+ position_cursor(row, column)
18
+ end
20
19
 
21
- def fetch_terminal_size
22
- size = (dynamic_size_stty || dynamic_size_tput || `echo $LINES $COLUMNS`)
23
- size = strip_characters_from_string(size).split(' ')
24
- { rows: size[0].to_i, columns: size[1].to_i }
25
- end
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
- def fetch_cursor_position(table_size, position, previously_erased_screen)
28
- final_position = position || fetch_position
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
- def refetch_position?(table_size, terminal_size, position)
40
- terminal_rows = terminal_size[:rows]
41
- row_position = position[:row]
42
- terminal_rows.zero? || (terminal_rows.nonzero? && row_position >= (terminal_rows / 2)) || (table_size >= (terminal_rows - row_position))
43
- end
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
- def fetch_position
46
- res = ''
47
- $stdin.raw do |stdin|
48
- $stdout << "\e[6n"
49
- $stdout.flush
50
- while (line = stdin.getc) != 'R'
51
- res << line if line
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
- def dynamic_size_stty
59
- size = `stty size 2>/dev/null`
60
- size.present? ? size : nil
61
- end
57
+ def dynamic_size_stty
58
+ size = `stty size 2>/dev/null`
59
+ size.present? ? size : nil
60
+ end
62
61
 
63
- def dynamic_size_tput
64
- lines = `tput lines 2>/dev/null`
65
- cols = `tput cols 2>/dev/null`
66
- lines.present? && cols.present? ? "#{lines} #{cols}" : nil
67
- end
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
- def handle_string_display(string, options)
70
- position = options.fetch('position', nil)
71
- table_size = options.fetch('table_size', 0)
72
- if options.fetch('clear_screen', false).to_s == 'true'
73
- terminal_clear_display(string)
74
- [0, 0, false]
75
- else
76
- new_position, terminal_rows, screen_erased = fetch_cursor_position(table_size, position, options.fetch('screen_erased', false))
77
- display_string_at_position(new_position, string)
78
- [new_position, terminal_rows, screen_erased]
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
- def terminal_clear_display(string)
83
- terminal_clear
84
- puts string
85
- end
81
+ def terminal_clear_display(string)
82
+ terminal_clear
83
+ puts string
84
+ end
86
85
 
87
- def display_string_at_position(position, string)
88
- go_to_position(position)
89
- erase_from_current_line_to_bottom
90
- go_to_position(position)
91
- puts string
92
- end
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
- def erase_from_current_line_to_bottom
95
- puts "\e[J"
96
- end
93
+ def erase_from_current_line_to_bottom
94
+ puts "\e[J"
95
+ end
97
96
 
98
- def erase_screen
99
- puts("\e[2J")
100
- end
97
+ def erase_screen
98
+ puts("\e[2J")
99
+ end
101
100
 
102
- def go_to_position(position)
103
- position_cursor(position[:row], position[:column])
104
- end
101
+ def go_to_position(position)
102
+ position_cursor(position[:row], position[:column])
103
+ end
105
104
 
106
- def position_cursor(line, column)
107
- puts("\e[#{line};#{column}H")
108
- end
105
+ def position_cursor(line, column)
106
+ puts("\e[#{line};#{column}H")
107
+ end
109
108
 
110
- def terminal_clear
111
- system('cls') || system('clear') || puts("\e[H\e[2J")
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
@@ -26,6 +26,7 @@ module CapistranoMulticonfigParallel
26
26
  end
27
27
 
28
28
  def save_stderr_error(data)
29
+ return unless development_debug?
29
30
  return unless @manager.alive?
30
31
  stderr_buffer.rewind
31
32
  old_data = stderr_buffer.read.dup
@@ -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)
@@ -7,8 +7,8 @@ module CapistranoMulticonfigParallel
7
7
  # module used for generating the version
8
8
  module VERSION
9
9
  MAJOR = 1
10
- MINOR = 4
11
- TINY = 2
10
+ MINOR = 5
11
+ TINY = 0
12
12
  PRE = nil
13
13
 
14
14
  STRING = [MAJOR, MINOR, TINY, PRE].compact.join('.')
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.2
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-13 00:00:00.000000000 Z
11
+ date: 2016-06-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: celluloid