capistrano_multiconfig_parallel 0.30.0 → 0.30.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a451d8cf78447457a14a882d28bb9cb98efd36d9
4
- data.tar.gz: d4ba430159980b1346ff58d554a1e22f3d27659f
3
+ metadata.gz: 9f8bd1e8d2bba139b5f06d0d2fa855cc2a3f030a
4
+ data.tar.gz: a155314cc93bf556b955d53574f712db877e3b4b
5
5
  SHA512:
6
- metadata.gz: 1a154c1b6321741ae5a219ec3de41be089709ecb83de60a26d3ee9eb39c9c749d57f702916297dbf305c549a86302e3ed8c06a918a3cd411559a0a4cf87312c5
7
- data.tar.gz: a3d40118f76c522917acb9d51285b15f9d6fca60a5a3ef2d41c638240f3817d6c2bd17921dfe1214cbf1a6b73a64de85b7b3fe7a7575fab9086bc4b8bb30c51d
6
+ metadata.gz: f95cf147ee0237298c9b04a1f518cb674ebeb25585cfd6cb57a300fc302c0e8a488a6cc7619604d5f63f3015d03b09f8142b165b880b5f64d4d66f5cb36268b9
7
+ data.tar.gz: 9fef095a975df04cba640842fc9b06803b1dc27545d830a4d9556cb8dab426c307a5aef466db276ea4c599e8cb3b1e8cfd2d459dad9079a08cf4e07c917e780f
data/.rubocop.yml CHANGED
@@ -7,7 +7,10 @@ AllCops:
7
7
  - Rakefile
8
8
 
9
9
  ClassLength:
10
- Max: 500
10
+ Max: 900
11
+
12
+ ModuleLength:
13
+ Max: 900
11
14
 
12
15
  Documentation:
13
16
  Enabled: true
@@ -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, :terminal_rows
11
+ attr_reader :options, :errors, :manager, :position, :job_manager, :terminal_rows, :screen_erased
12
12
 
13
13
  def self.topic
14
14
  'sshkit_terminal'
@@ -21,6 +21,7 @@ module CapistranoMulticonfigParallel
21
21
  @errors = []
22
22
  @options = options.is_a?(Hash) ? options.stringify_keys : options
23
23
  @job_manager = job_manager
24
+ @screen_erased = false
24
25
  async.run
25
26
  rescue => ex
26
27
  rescue_exception(ex)
@@ -36,8 +37,8 @@ module CapistranoMulticonfigParallel
36
37
 
37
38
  def notify_time_change(_channel, _message)
38
39
  table = Terminal::Table.new(title: 'Deployment Status Table', headings: default_heaadings)
39
- setup_table_jobs(table)
40
- display_table_on_terminal(table)
40
+ jobs = setup_table_jobs(table)
41
+ display_table_on_terminal(table, jobs)
41
42
  end
42
43
 
43
44
  def rescue_exception(ex)
@@ -46,11 +47,15 @@ module CapistranoMulticonfigParallel
46
47
  terminate
47
48
  end
48
49
 
49
- def display_table_on_terminal(table)
50
- table_size = (table.rows.size + 2)**2
51
- @position, @terminal_rows = CapistranoMulticonfigParallel::Cursor.fetch_cursor_position(table_size, @position)
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
50
+ def fetch_table_size(jobs)
51
+ job_rows = jobs.sum { |_job_id, job| job.row_size }
52
+ (job_rows + 2)**2
53
+ end
54
+
55
+ def display_table_on_terminal(table, jobs)
56
+ table_size = fetch_table_size(jobs)
57
+ @position, @terminal_rows, @screen_erased = CapistranoMulticonfigParallel::Cursor.display_on_screen("\n#{table}\n", @options.merge(position: @position, table_size: table_size))
58
+ # puts [@position, @terminal_rows, table_size , (@terminal_rows[:rows] - @position[:row]), screen_erased].inspect
54
59
  print_errors
55
60
  signal_complete
56
61
  end
@@ -65,6 +70,7 @@ module CapistranoMulticonfigParallel
65
70
  table.add_row(job.terminal_row)
66
71
  table.add_separator
67
72
  end
73
+ jobs
68
74
  end
69
75
 
70
76
  def show_confirmation(message, default)
@@ -25,24 +25,22 @@ module CapistranoMulticonfigParallel
25
25
  def fetch_cursor_position(table_size, position)
26
26
  final_position = position
27
27
  terminal_rows = fetch_terminal_size
28
- if refetch_position?(table_size, terminal_rows, position)
28
+ screen_erased = refetch_position?(table_size, terminal_rows, position)
29
+ if screen_erased
29
30
  move_to_home! if position.present?
30
31
  final_position = fetch_position
31
32
  terminal_rows = fetch_terminal_size
32
33
  end
33
- [final_position,terminal_rows]
34
+ [final_position, terminal_rows, screen_erased]
34
35
  end
35
36
 
36
- def refetch_position?(table_size,terminal_size, position)
37
+ def refetch_position?(table_size, terminal_size, position)
37
38
  return true if position.blank?
38
39
  terminal_rows = terminal_size[:rows]
39
40
  row_position = position[:row]
40
- terminal_rows.zero? || (terminal_rows.nonzero? && row_position >= (terminal_rows / 2)) || (table_size >= (terminal_rows -row_position))
41
+ terminal_rows.zero? || (terminal_rows.nonzero? && row_position >= (terminal_rows / 2)) || (table_size >= (terminal_rows - row_position))
41
42
  end
42
43
 
43
- private
44
-
45
-
46
44
  def fetch_position
47
45
  res = ''
48
46
  $stdin.raw do |stdin|
@@ -68,11 +66,15 @@ module CapistranoMulticonfigParallel
68
66
  end
69
67
 
70
68
  def handle_string_display(string, options)
71
- position = options.fetch('position',nil)
69
+ position = options.fetch('position', nil)
70
+ table_size = options.fetch('table_size', 0)
72
71
  if options.fetch('clear_screen', false).to_s == 'true'
73
72
  terminal_clear_display(string)
74
- elsif position.present?
75
- display_string_at_position(position, string)
73
+ [0, 0, false]
74
+ else
75
+ new_position, terminal_rows, screen_erased = fetch_cursor_position(table_size, position)
76
+ display_string_at_position(new_position, string)
77
+ [new_position, terminal_rows, screen_erased]
76
78
  end
77
79
  end
78
80
 
@@ -93,7 +95,7 @@ module CapistranoMulticonfigParallel
93
95
  end
94
96
 
95
97
  def erase_screen
96
- puts("\e[2J")
98
+ puts("\e[2J")
97
99
  end
98
100
 
99
101
  def go_to_position(position)
@@ -44,6 +44,13 @@ module CapistranoMulticonfigParallel
44
44
  ]
45
45
  end
46
46
 
47
+ def row_size
48
+ longest_hash = terminal_row.max_by do |hash|
49
+ hash[:value].size
50
+ end
51
+ (longest_hash[:value].size.to_f / 80.0).ceil
52
+ end
53
+
47
54
  def worker_state
48
55
  default = status.to_s.upcase.red
49
56
  return default unless @manager.alive?
@@ -8,7 +8,7 @@ module CapistranoMulticonfigParallel
8
8
  module VERSION
9
9
  MAJOR = 0
10
10
  MINOR = 30
11
- TINY = 0
11
+ TINY = 1
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: 0.30.0
4
+ version: 0.30.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - bogdanRada
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-12-30 00:00:00.000000000 Z
11
+ date: 2016-01-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: celluloid-pmap