capistrano_multiconfig_parallel 0.21.6 → 0.21.7

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: 243c50e263028d3c6b611e0f53f21c76166dacda
4
- data.tar.gz: 43fd764e806b2d26a4ea90430f973a36eca1d24e
3
+ metadata.gz: 7f87a7482ae60ee3c54f450c9e20d6f489a7d2a4
4
+ data.tar.gz: 7716965e21fe4d4faf52ad69aadbb9dfb0039597
5
5
  SHA512:
6
- metadata.gz: c271ca088192b718525c8fb0af6545c951f5ab4412b7749b476efd891098fb696b9dc002c0debcd3ef8b94808ad9aafb7ef4fa8a771e06fe98f302271da1d011
7
- data.tar.gz: aaa5ab2e3217d90e8f355e5dad260c34d1c835f2336d774f7c9a5a8c70b70e8c631456815e5911014f80054c5c6041667a3ddd1912d48838cd358eaee2cf0939
6
+ metadata.gz: 3ac991a6da052876428b36d49dbe2e37007b01623b53427ac497bb1983c71e0dff89ef7bd8cc2ab7a07b477d5f126bf2953debe5094d12ff3ee12e1ff3357a03
7
+ data.tar.gz: 7a244b45ad63e01d0224490fa24ed153d0fcbdfe9cce6b4761f10ce6914c15e94d2e182eb75c84c051afb9f2237b157a60ae8945f2fac2538da356570fa85101
@@ -1,3 +1,4 @@
1
+
1
2
  require_relative '../helpers/application_helper'
2
3
  module CapistranoMulticonfigParallel
3
4
  # class used to display the progress of each worker on terminal screen using a table
@@ -14,6 +15,8 @@ module CapistranoMulticonfigParallel
14
15
  @manager = manager
15
16
  @job_manager = job_manager
16
17
  async.run
18
+ rescue => ex
19
+ rescue_exception(ex)
17
20
  end
18
21
 
19
22
  def run
@@ -21,91 +24,57 @@ module CapistranoMulticonfigParallel
21
24
  end
22
25
 
23
26
  def notify_time_change(_topic, _message)
24
- default_headings = ['Job ID', 'Job UUID', 'App/Stage', 'Action', 'ENV Variables', 'Current Task']
25
- # default_headings << 'Total'
26
- # default_headings << 'Progress'
27
- table = Terminal::Table.new(title: 'Deployment Status Table', headings: default_headings)
28
- jobs = @manager.alive? ? @manager.jobs.dup : []
29
- if jobs.present?
30
- jobs.each_with_index do |(job_id, job), count|
31
- add_job_to_table(table, job_id, job, count)
32
- end
33
- end
34
- show_terminal_screen(table)
35
- rescue => ex
36
- log_to_file("Terminal Table client disconnected due to error #{ex.inspect}")
27
+ table = Terminal::Table.new(title: 'Deployment Status Table', headings: ['Job ID', 'Job UUID', 'App/Stage', 'Action', 'ENV Variables', 'Current Task'])
28
+ jobs = @manager.alive? ? @manager.jobs : []
29
+ setup_table_jobs(table, jobs)
30
+ display_table_on_terminal(table)
31
+ end
32
+
33
+ def rescue_exception(ex)
34
+ log_to_file("Terminal Table client disconnected due to error #{ex.inspect}")
37
35
  log_error(ex, 'stderr')
38
36
  terminate
39
37
  end
40
38
 
39
+ def display_table_on_terminal(table)
40
+ terminal_clear
41
+ puts "\n#{table}\n"
42
+ signal_complete
43
+ end
44
+
45
+ def setup_table_jobs(table, jobs)
46
+ jobs.each_with_index do |(_job_id, job), count|
47
+ add_job_to_table(table, job, count)
48
+ table.add_separator
49
+ end
50
+ end
51
+
41
52
  def show_confirmation(message, default)
42
53
  exclusive do
43
54
  ask_confirm(message, default)
44
55
  end
45
56
  end
46
57
 
47
- def show_terminal_screen(table)
48
- return unless table.rows.present?
49
- terminal_clear
50
- # table.style = { width: 20 }
51
- puts "\n#{table}\n"
52
- sleep(1)
53
- if @job_manager.alive? && @manager.alive? && @manager.all_workers_finished?
54
- @job_manager.condition.signal('completed')
55
- end
58
+ def signal_complete
59
+ return if !@job_manager.alive? || @manager.alive?
60
+ @job_manager.condition.signal('completed') if @manager.all_workers_finished?
56
61
  end
57
62
 
58
- def worker_state(job_id, job)
63
+ def worker_state(job)
59
64
  default = job.status.to_s.upcase.red
60
65
  return default unless @manager.alive?
61
- worker = @manager.get_worker_for_job(job_id)
66
+ worker = @manager.get_worker_for_job(job.id)
62
67
  worker.alive? ? worker.worker_state : default
63
68
  end
64
69
 
65
- def filtered_env_keys
66
- %w(STAGES ACTION)
67
- end
68
-
69
- def add_job_to_table(table, job_id, job, index)
70
- row = [{ value: (index + 1).to_s },
71
- { value: job_id.to_s },
72
- { value: job.job_stage },
73
- { value: job.capistrano_action },
74
- { value: job.setup_command_line_standard(filtered_keys: [CapistranoMulticonfigParallel::ENV_KEY_JOB_ID]).join("\n") },
75
- { value: worker_state(job_id, job) }
76
- ]
77
-
78
- # if worker.alive?
79
- # row << { value: job.rake_tasks.size }
80
- # row << { value: worker_progress(job_id, job) }
81
- # else
82
- # row << { value: 0 }
83
- # row << { value: worker_state(job_id) }
84
- # end
85
- table.add_row(row)
86
- table.add_separator
87
- table
70
+ def add_job_to_table(table, job, index)
71
+ job_state = worker_state(job)
72
+ job_row = job.terminal_row(index, job_state)
73
+ table.add_row(job_row)
88
74
  end
89
75
 
90
76
  def terminal_clear
91
77
  system('cls') || system('clear') || puts("\e[H\e[2J")
92
78
  end
93
-
94
- # def worker_progress(job)
95
- # tasks = job.rake_tasks.size
96
- # current_task = job.status
97
- # show_worker_percent(tasks, current_task, job)
98
- # end
99
- #
100
- # def show_worker_percent(tasks, current_task, job)
101
- # task_index = tasks.index(current_task.to_s).to_i + 1
102
- # percent = percent_of(task_index, total_tasks)
103
- # result = "Progress [#{format('%.2f', percent)}%] (executed #{task_index} of #{total_tasks})"
104
- # job.crashed? ? result.red : result.green
105
- # end
106
- #
107
- # def percent_of(index, total)
108
- # index.to_f / total.to_f * 100.0
109
- # end
110
79
  end
111
80
  end
@@ -9,20 +9,35 @@ module CapistranoMulticonfigParallel
9
9
  attr_writer :status, :exit_status
10
10
 
11
11
  delegate :job_stage,
12
- :capistrano_action,
13
- :build_capistrano_task,
14
- :execute_standard_deploy,
15
- :setup_command_line_standard,
16
- to: :command
12
+ :capistrano_action,
13
+ :build_capistrano_task,
14
+ :execute_standard_deploy,
15
+ :setup_command_line_standard,
16
+ to: :command
17
17
 
18
18
  def initialize(options)
19
19
  @options = options
20
20
  end
21
21
 
22
+ def env_variable
23
+ CapistranoMulticonfigParallel::ENV_KEY_JOB_ID
24
+ end
25
+
22
26
  def command
23
27
  @command ||= CapistranoMulticonfigParallel::JobCommand.new(self)
24
28
  end
25
29
 
30
+ def terminal_row(index, job_state)
31
+ [
32
+ { value: (index + 1).to_s },
33
+ { value: id.to_s },
34
+ { value: job_stage },
35
+ { value: capistrano_action },
36
+ { value: setup_command_line_standard(filtered_keys: [CapistranoMulticonfigParallel::ENV_KEY_JOB_ID]).join("\n") },
37
+ { value: job_state }
38
+ ]
39
+ end
40
+
26
41
  def job_writer_attributes
27
42
  %w(status exit_status)
28
43
  end
@@ -54,7 +69,7 @@ module CapistranoMulticonfigParallel
54
69
  ].each do |hash|
55
70
  define_method hash[:name] do
56
71
  value = @options.fetch(hash[:name], hash[:default])
57
- value["#{CapistranoMulticonfigParallel::ENV_KEY_JOB_ID}"] = id if hash[:name] == 'env_options'
72
+ value["#{env_variable}"] = id if hash[:name] == 'env_options'
58
73
  verify_empty_options(value)
59
74
  end
60
75
  # define_method "#{hash[:name]}=" do |value|
@@ -16,6 +16,10 @@ module CapistranoMulticonfigParallel
16
16
 
17
17
  module_function
18
18
 
19
+ def percent_of(index, total)
20
+ index.to_f / total.to_f * 100.0
21
+ end
22
+
19
23
  def multi_fetch_argv(args)
20
24
  options = {}
21
25
  args.each do |arg|
@@ -8,7 +8,7 @@ module CapistranoMulticonfigParallel
8
8
  module VERSION
9
9
  MAJOR = 0
10
10
  MINOR = 21
11
- TINY = 6
11
+ TINY = 7
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.21.6
4
+ version: 0.21.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - bogdanRada