capistrano_multiconfig_parallel 0.12.2 → 0.12.3

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: 788c14a8757342d82a178672d1fbd0a853159538
4
- data.tar.gz: d401ebfc5b7712a78f1cb7cc66e0ffe3cdede58c
3
+ metadata.gz: 1134ef03c3259ddc2f47c87618a95352e1150ba7
4
+ data.tar.gz: febbbf3bc691468932a2f06fe6fed0ae101f059a
5
5
  SHA512:
6
- metadata.gz: 0ccc2e45aa9916f7ca7c2d487fab2f915bf9203165e988378fb9d30d07a0cb0d3f8fcfbbdc306d6ceca2398f6edc907ebc2271ce14e1d2a1482810bb05075c89
7
- data.tar.gz: 39b87f2d84a6b2d2d38c02a78dcc8eec68f35bc24b90ff0630c92ef8969be7b768977c815960433c75d916c32b80986dbba82367676e7727be6bdff03a29e75d
6
+ metadata.gz: 7cada320b380bc82737932fe73429542745a8d0dc4539355963a0fa3cf4ac64929b7abf0b93dd124438f4b77198ff46534db850065b6d21aaced499ec483b6f6
7
+ data.tar.gz: 052bce86fe81fe36fa5a3f7ca7349dc293fda8b12b8d8df9b5a89db7979568d7ae9f4a19a8fa525d4f54aaa035db1acfc08a98bf1d4667b580c10f1a86bfc8e6
@@ -31,21 +31,21 @@ Gem::Specification.new do |s|
31
31
  s.add_runtime_dependency 'inquirer', '~> 0.2', '>= 0.2'
32
32
  s.add_runtime_dependency 'devnull','~> 0.1', '>= 0.1'
33
33
 
34
- s.add_development_dependency 'rspec-rails', '~> 2.0', '>= 2.0'
35
- s.add_development_dependency 'guard', '~> 2.6', '>= 2.6.1'
36
- s.add_development_dependency 'guard-rspec', '~> 4.2', '>= 4.2.9'
37
- s.add_development_dependency 'simplecov', '~> 0.9', '>= 0.9'
34
+ s.add_development_dependency 'rspec-rails', '~> 3.3', '>= 3.3'
35
+ s.add_development_dependency 'guard', '~> 2.13', '>= 2.13'
36
+ s.add_development_dependency 'guard-rspec', '~> 4.6', '>= 4.6'
37
+ s.add_development_dependency 'simplecov', '~> 0.10', '>= 0.10'
38
38
  s.add_development_dependency 'simplecov-summary', '~> 0.0.4', '>= 0.0.4'
39
39
  s.add_development_dependency 'mocha', '~> 1.1', '>= 1.1'
40
40
  s.add_development_dependency 'coveralls', '~> 0.7', '>= 0.7'
41
41
  s.add_development_dependency 'rvm-tester', '~> 1.1', '>= 1.1'
42
42
 
43
- s.add_development_dependency 'rubocop', '~> 0', '>= 0.29'
44
- s.add_development_dependency 'phare', '~> 0', '>= 0.6'
45
- s.add_development_dependency 'yard', '~> 0', '>= 0.8.7'
46
- s.add_development_dependency 'yard-rspec', '~> 0', '>= 0.1'
47
- s.add_development_dependency 'redcarpet', '~> 3', '>= 3.2.2'
48
- s.add_development_dependency 'github-markup', '~> 1', '>= 1.3.3'
49
- s.add_development_dependency 'inch', '~> 0', '>= 0.5.10'
50
- s.add_development_dependency 'guard-inch', '~> 0', '>= 0.1.0'
43
+ s.add_development_dependency 'rubocop', '~> 0.33', '>= 0.33'
44
+ s.add_development_dependency 'phare', '~> 0.7', '>= 0.7'
45
+ s.add_development_dependency 'yard', '~> 0.8', '>= 0.8.7'
46
+ s.add_development_dependency 'yard-rspec', '~> 0.1', '>= 0.1'
47
+ s.add_development_dependency 'redcarpet', '~> 3.3', '>= 3.3'
48
+ s.add_development_dependency 'github-markup', '~> 1.3', '>= 1.3.3'
49
+ s.add_development_dependency 'inch', '~> 0.6', '>= 0.6'
50
+ s.add_development_dependency 'guard-inch', '~> 0.1', '>= 0.1.0'
51
51
  end
@@ -19,7 +19,7 @@ module CapistranoMulticonfigParallel
19
19
  }
20
20
 
21
21
  class << self
22
- attr_accessor :execute_in_sequence, :logger, :original_args, :interactive_menu
22
+ attr_accessor :execute_in_sequence, :logger, :original_args, :interactive_menu
23
23
 
24
24
  def root
25
25
  File.expand_path(File.dirname(__dir__))
@@ -94,9 +94,9 @@ module CapistranoMulticonfigParallel
94
94
  end
95
95
 
96
96
  def all_workers_finished?
97
- @job_to_worker.all? { |job_id, worker| @jobs[job_id]['worker_action'] == 'finished' }
97
+ @job_to_worker.all? { |job_id, _worker| @jobs[job_id]['worker_action'] == 'finished' }
98
98
  end
99
-
99
+
100
100
  def process_jobs
101
101
  @workers_terminated = Celluloid::Condition.new
102
102
  if syncronized_confirmation?
@@ -110,7 +110,7 @@ module CapistranoMulticonfigParallel
110
110
  sleep(0.1) # keep current thread alive
111
111
  end
112
112
  debug("all jobs have completed #{condition}") if self.class.debug_enabled?
113
- Celluloid::Actor[:terminal_server].async.notify_time_change( CapistranoMulticonfigParallel::TerminalTable::TOPIC, :type => "output") if Celluloid::Actor[:terminal_server].alive?
113
+ Celluloid::Actor[:terminal_server].async.notify_time_change(CapistranoMulticonfigParallel::TerminalTable::TOPIC, type: 'output') if Celluloid::Actor[:terminal_server].alive?
114
114
  end
115
115
 
116
116
  def apply_confirmations?
@@ -196,10 +196,10 @@ module CapistranoMulticonfigParallel
196
196
  @jobs.pmap do |job_id, job|
197
197
  worker = get_worker_for_job(job_id)
198
198
  worker.publish_rake_event('approved' => 'yes',
199
- 'action' => 'invoke',
200
- 'job_id' => job['id'],
201
- 'task' => task
202
- )
199
+ 'action' => 'invoke',
200
+ 'job_id' => job['id'],
201
+ 'task' => task
202
+ )
203
203
  end
204
204
  end
205
205
 
@@ -236,20 +236,20 @@ module CapistranoMulticonfigParallel
236
236
  if job['processed']
237
237
  @jobs[job['job_id']]
238
238
  else
239
- env_options = {}
240
- job['env_options'].each do |key, value|
241
- env_options[key] = value if value.present? && !filtered_env_keys.include?(key)
242
- end
243
- {
244
- 'job_id' => job['id'],
245
- 'app_name' => job['app'],
246
- 'env_name' => job['env'],
247
- 'action_name' => job['action'],
248
- 'env_options' => env_options,
249
- 'task_arguments' => job['task_arguments'],
250
- 'job_argv' => job.fetch("job_argv", []),
251
- 'processed' => true
252
- }
239
+ env_options = {}
240
+ job['env_options'].each do |key, value|
241
+ env_options[key] = value if value.present? && !filtered_env_keys.include?(key)
242
+ end
243
+ {
244
+ 'job_id' => job['id'],
245
+ 'app_name' => job['app'],
246
+ 'env_name' => job['env'],
247
+ 'action_name' => job['action'],
248
+ 'env_options' => env_options,
249
+ 'task_arguments' => job['task_arguments'],
250
+ 'job_argv' => job.fetch('job_argv', []),
251
+ 'processed' => true
252
+ }
253
253
  end
254
254
  end
255
255
 
@@ -47,14 +47,13 @@ module CapistranoMulticonfigParallel
47
47
  def start_task
48
48
  @manager.setup_worker_conditions(Actor.current)
49
49
  debug("exec worker #{@job_id} starts task with #{@job.inspect}") if debug_enabled?
50
- @client = CelluloidPubsub::Client.connect(actor: Actor.current, enable_debug: @manager.class.debug_websocket?, :channel => subscription_channel)
50
+ @client = CelluloidPubsub::Client.connect(actor: Actor.current, enable_debug: @manager.class.debug_websocket?, channel: subscription_channel)
51
51
  end
52
52
 
53
53
  def publish_rake_event(data)
54
54
  @client.publish(rake_actor_id(data), data)
55
55
  end
56
56
 
57
-
58
57
  def rake_actor_id(data)
59
58
  data['action'].present? && data['action'] == 'count' ? "rake_worker_#{@job_id}_count" : "rake_worker_#{@job_id}"
60
59
  end
@@ -70,7 +69,7 @@ module CapistranoMulticonfigParallel
70
69
  end
71
70
 
72
71
  def execute_after_succesfull_subscription
73
- async.execute_deploy
72
+ async.execute_deploy
74
73
  end
75
74
 
76
75
  def rake_tasks
@@ -78,7 +77,7 @@ module CapistranoMulticonfigParallel
78
77
  end
79
78
 
80
79
  def dry_run_tasks
81
- @dry_run_tasks ||= []
80
+ @dry_run_tasks ||= []
82
81
  end
83
82
 
84
83
  def cd_working_directory
@@ -116,13 +115,13 @@ module CapistranoMulticonfigParallel
116
115
  end
117
116
 
118
117
  def check_gitflow
119
- return if dry_running? || @env_name != 'staging' || !@manager.can_tag_staging? || !executed_task?(CapistranoMulticonfigParallel::GITFLOW_TAG_STAGING_TASK)
118
+ return if dry_running? || @env_name != 'staging' || !@manager.can_tag_staging? || !executed_task?(CapistranoMulticonfigParallel::GITFLOW_TAG_STAGING_TASK)
120
119
  @manager.dispatch_new_job(@job.merge('env' => 'production'))
121
120
  end
122
121
 
123
122
  def handle_subscription(message)
124
- @executing_dry_run = message['action'] == 'count' ? true : false
125
- @manager.jobs[@job_id]['job_argv'] = @job_argv
123
+ @executing_dry_run = message['action'] == 'count' ? true : false
124
+ @manager.jobs[@job_id]['job_argv'] = @job_argv
126
125
  if message_is_about_a_task?(message)
127
126
  check_gitflow
128
127
  save_tasks_to_be_executed(message)
@@ -130,16 +129,16 @@ module CapistranoMulticonfigParallel
130
129
  debug("worker #{@job_id} state is #{@machine.state}") if debug_enabled?
131
130
  task_approval(message)
132
131
  elsif message_is_for_stdout?(message)
133
- result = Celluloid::Actor[:terminal_server].show_confirmation(message['question'],message['default'])
134
- publish_rake_event(message.merge('action' => "stdin",'result' => result, "client_action" => "stdin"))
132
+ result = Celluloid::Actor[:terminal_server].show_confirmation(message['question'], message['default'])
133
+ publish_rake_event(message.merge('action' => 'stdin', 'result' => result, 'client_action' => 'stdin'))
135
134
  else
136
135
  debug("worker #{@job_id} could not handle #{message}") if debug_enabled?
137
136
  end
138
137
  end
139
138
 
140
- def message_is_for_stdout?(message)
139
+ def message_is_for_stdout?(message)
141
140
  message.present? && message.is_a?(Hash) && message['action'].present? && message['job_id'].present? && message['action'] == 'stdout'
142
- end
141
+ end
143
142
 
144
143
  def message_is_about_a_task?(message)
145
144
  message.present? && message.is_a?(Hash) && message['action'].present? && message['job_id'].present? && message['task'].present?
@@ -162,7 +161,7 @@ module CapistranoMulticonfigParallel
162
161
  def save_tasks_to_be_executed(message)
163
162
  debug("worler #{@job_id} current invocation chain : #{rake_tasks.inspect}") if debug_enabled?
164
163
  rake_tasks << message['task'] if rake_tasks.last != message['task']
165
- dry_run_tasks << message['task'] if dry_running? && dry_run_tasks.last != message['task']
164
+ dry_run_tasks << message['task'] if dry_running? && dry_run_tasks.last != message['task']
166
165
  end
167
166
 
168
167
  def update_machine_state(name)
@@ -193,7 +192,7 @@ module CapistranoMulticonfigParallel
193
192
  end
194
193
 
195
194
  def worker_action
196
- "#{@action_name}[#{@task_arguments.join(',')}]"
195
+ "#{@action_name}[#{@task_arguments.join(',')}]"
197
196
  end
198
197
 
199
198
  def setup_task_arguments(*args)
@@ -201,14 +200,14 @@ module CapistranoMulticonfigParallel
201
200
  array_options = []
202
201
  @env_options.each do |key, value|
203
202
  array_options << "#{key}=#{value}" if value.present?
204
- end
203
+ end
205
204
  array_options << '--trace' if debug_enabled?
206
205
  args.each do |arg|
207
206
  array_options << arg
208
207
  end
209
- @job_argv= array_options.clone
208
+ @job_argv = array_options.clone
210
209
  array_options.unshift("#{worker_action}")
211
- array_options.unshift("#{worker_stage}")
210
+ array_options.unshift("#{worker_stage}")
212
211
  setup_command_line(*array_options)
213
212
  end
214
213
 
@@ -233,17 +232,17 @@ module CapistranoMulticonfigParallel
233
232
  def finish_worker
234
233
  @manager.mark_completed_remaining_tasks(Actor.current)
235
234
  @manager.jobs[@job_id]['worker_action'] = 'finished'
236
- @manager.workers_terminated.signal('completed') if @manager.all_workers_finished?
235
+ @manager.workers_terminated.signal('completed') if @manager.all_workers_finished?
237
236
  end
238
237
 
239
238
  def worker_finshed?
240
- @manager.jobs[@job_id]['worker_action'] == 'finished'
239
+ @manager.jobs[@job_id]['worker_action'] == 'finished'
241
240
  end
242
241
 
243
242
  def notify_finished(exit_status)
244
243
  if exit_status.exitstatus != 0
245
244
  debug("worker #{job_id} tries to terminate") if debug_enabled?
246
- raise(CapistranoMulticonfigParallel::CelluloidWorker::TaskFailed, "task failed with exit status #{exit_status.inspect} ") # force worker to rollback
245
+ raise(CapistranoMulticonfigParallel::CelluloidWorker::TaskFailed, "task failed with exit status #{exit_status.inspect} ") # force worker to rollback
247
246
  else
248
247
  update_machine_state('FINISHED')
249
248
  debug("worker #{job_id} notifies manager has finished") if debug_enabled?
@@ -7,7 +7,7 @@ module CapistranoMulticonfigParallel
7
7
  attr_accessor :actor, :pid, :exit_status, :process, :filename, :worker_log, :job_id, :debug_enabled
8
8
 
9
9
  finalizer :process_finalizer
10
-
10
+
11
11
  def work(cmd, options = {})
12
12
  @options = options
13
13
  @actor = @options.fetch(:actor, nil)
@@ -45,10 +45,10 @@ module CapistranoMulticonfigParallel
45
45
  @timer.cancel
46
46
  EM.stop if EM.reactor_running?
47
47
  end
48
-
48
+
49
49
  def check_exit_status
50
50
  return unless @exit_status.present?
51
- if @exit_status.exitstatus == 0 && @options[:dry_run]
51
+ if @exit_status.exitstatus == 0 && @options[:dry_run]
52
52
  debug("worker #{@actor.job_id} starts execute deploy") if @debug_enabled
53
53
  @actor.async.execute_deploy
54
54
  elsif !@actor.worker_finshed?
@@ -63,7 +63,7 @@ module CapistranoMulticonfigParallel
63
63
  target: self,
64
64
  environment: options[:environment].present? ? options[:environment] : nil,
65
65
  pid_handler: :on_pid,
66
- input: :on_input_stdin ,
66
+ input: :on_input_stdin,
67
67
  stdout_handler: :on_read_stdout,
68
68
  stderr_handler: :on_read_stderr,
69
69
  watch_handler: :watch_handler,
@@ -88,7 +88,7 @@ module CapistranoMulticonfigParallel
88
88
  end
89
89
 
90
90
  def on_exit(status)
91
- @worker_log.debug "Child process for worker #{@job_id} on_exit disconnected due to error #{status.inspect}" if @debug_enabled
91
+ @worker_log.debug "Child process for worker #{@job_id} on_exit disconnected due to error #{status.inspect}" if @debug_enabled
92
92
  @exit_status = status
93
93
  end
94
94
 
@@ -5,18 +5,16 @@ module CapistranoMulticonfigParallel
5
5
  include Celluloid::Logger
6
6
 
7
7
  attr_accessor :env, :client, :job_id, :action, :task,
8
- :task_approved, :successfull_subscription,
9
- :subscription_channel, :publisher_channel, :stdin_result
8
+ :task_approved, :successfull_subscription,
9
+ :subscription_channel, :publisher_channel, :stdin_result
10
10
 
11
-
12
-
13
- def work(env, options = {})
11
+ def work(env, options = {})
14
12
  @options = options.stringify_keys
15
13
  @env = env
16
14
  default_settings
17
15
  custom_attributes
18
16
  initialize_subscription
19
- end
17
+ end
20
18
 
21
19
  def custom_attributes
22
20
  @publisher_channel = "worker_#{@job_id}"
@@ -24,10 +22,10 @@ module CapistranoMulticonfigParallel
24
22
  @task = @options['task']
25
23
  end
26
24
 
27
- def publish_new_work(env, new_options = {})
25
+ def publish_new_work(env, new_options = {})
28
26
  work(env, @options.merge(new_options))
29
- publish_to_worker(task_data)
30
- end
27
+ publish_to_worker(task_data)
28
+ end
31
29
 
32
30
  def wait_execution(name = task_name, time = 0.1)
33
31
  # info "Before waiting #{name}"
@@ -35,7 +33,7 @@ module CapistranoMulticonfigParallel
35
33
  # info "After waiting #{name}"
36
34
  end
37
35
 
38
- def wait_for(name, time)
36
+ def wait_for(_name, time)
39
37
  # info "waiting for #{time} seconds on #{name}"
40
38
  sleep time
41
39
  # info "done waiting on #{name} "
@@ -51,11 +49,11 @@ module CapistranoMulticonfigParallel
51
49
 
52
50
  def initialize_subscription
53
51
  return if defined?(@client) && @client.present?
54
- @client = CelluloidPubsub::Client.connect(actor: Actor.current, enable_debug: debug_enabled?, :channel => @subscription_channel )
52
+ @client = CelluloidPubsub::Client.connect(actor: Actor.current, enable_debug: debug_enabled?, channel: @subscription_channel)
55
53
  end
56
54
 
57
55
  def debug_enabled?
58
- CapistranoMulticonfigParallel::CelluloidManager.debug_websocket?
56
+ CapistranoMulticonfigParallel::CelluloidManager.debug_websocket?
59
57
  end
60
58
 
61
59
  def task_name
@@ -70,17 +68,16 @@ module CapistranoMulticonfigParallel
70
68
  }
71
69
  end
72
70
 
73
-
74
71
  def publish_to_worker(data)
75
72
  @client.publish(@publisher_channel, data)
76
73
  end
77
74
 
78
75
  def on_message(message)
79
- debug("Rake worker #{@job_id} received after parse #{message}") #if debug_enabled?
76
+ debug("Rake worker #{@job_id} received after parse #{message}") # if debug_enabled?
80
77
  if @client.succesfull_subscription?(message)
81
- debug("Rake worker #{@job_id} received parse #{message}") if debug_enabled?
82
- @successfull_subscription = true
83
- publish_to_worker(task_data)
78
+ debug("Rake worker #{@job_id} received parse #{message}") if debug_enabled?
79
+ @successfull_subscription = true
80
+ publish_to_worker(task_data)
84
81
  elsif message.present? && message['task'].present?
85
82
  task_approval(message)
86
83
  elsif message.present? && message['action'].present? && message['action'] == 'stdin'
@@ -95,13 +92,10 @@ module CapistranoMulticonfigParallel
95
92
  end
96
93
 
97
94
  def publish_subscription_successfull
98
-
99
95
  end
100
96
 
101
97
  def wait_for_stdin_input
102
- until @stdin_result.present?
103
- wait_execution
104
- end
98
+ wait_execution until @stdin_result.present?
105
99
  output = @stdin_result.clone
106
100
  Actor.current.stdin_result = nil
107
101
  output
@@ -143,20 +137,15 @@ module CapistranoMulticonfigParallel
143
137
  end
144
138
 
145
139
  def user_prompt_needed?(data)
146
- return if !printing_question?(data) || @action != "invoke"
147
-
148
- details = get_question_details(data)
149
- default = details.second.present? ? details.second : nil
150
- publish_to_worker({
151
- action: "stdout",
152
- question: details.first,
153
- default: default.delete('()'),
154
- job_id: @job_id
155
- })
156
- wait_for_stdin_input
140
+ return if !printing_question?(data) || @action != 'invoke'
157
141
 
142
+ details = get_question_details(data)
143
+ default = details.second.present? ? details.second : nil
144
+ publish_to_worker(action: 'stdout',
145
+ question: details.first,
146
+ default: default.delete('()'),
147
+ job_id: @job_id)
148
+ wait_for_stdin_input
158
149
  end
159
-
160
-
161
150
  end
162
151
  end
@@ -38,17 +38,16 @@ module CapistranoMulticonfigParallel
38
38
  terminate
39
39
  end
40
40
 
41
-
42
41
  def show_confirmation(message, default)
43
42
  exclusive do
44
43
  CapistranoMulticonfigParallel.ask_confirm(message, default)
45
44
  end
46
45
  end
47
-
46
+
48
47
  def message_valid?(message)
49
48
  message[:type].present? && message[:type] == 'output' || message[:type] == 'event'
50
49
  end
51
-
50
+
52
51
  def show_terminal_screen(table)
53
52
  return unless table.rows.present?
54
53
  terminal_clear
@@ -57,7 +56,7 @@ module CapistranoMulticonfigParallel
57
56
  puts table
58
57
  puts "\n"
59
58
  sleep(1)
60
- @job_manager.condition.signal('completed') if @manager.all_workers_finished?
59
+ @job_manager.condition.signal('completed') if @manager.all_workers_finished?
61
60
  end
62
61
 
63
62
  def worker_state(worker)
@@ -76,7 +75,7 @@ module CapistranoMulticonfigParallel
76
75
  end
77
76
  worker_optons
78
77
  end
79
-
78
+
80
79
  def worker_action(processed_job)
81
80
  processed_job['task_arguments'].present? ? "#{processed_job['action_name']}[#{processed_job['task_arguments'].join(',')}]" : processed_job['action_name']
82
81
  end
@@ -88,7 +87,7 @@ module CapistranoMulticonfigParallel
88
87
  def get_worker_details(job_id, worker)
89
88
  job = @manager.jobs[job_id]
90
89
  processed_job = @manager.process_job(job)
91
-
90
+
92
91
  {
93
92
  'job_id' => job_id,
94
93
  'app_name' => processed_job['app_name'],
@@ -104,14 +103,14 @@ module CapistranoMulticonfigParallel
104
103
  def add_job_to_table(table, job_id)
105
104
  worker = @manager.get_worker_for_job(job_id)
106
105
  details = get_worker_details(job_id, worker)
107
-
106
+
108
107
  row = [{ value: job_id.to_s },
109
- { value: details['full_stage'] },
110
- { value: details['action_name'] },
111
- { value: details['env_options'] },
112
- { value: "#{details['state']}" }
113
- ]
114
- # if CapistranoMulticonfigParallel.show_task_progress
108
+ { value: details['full_stage'] },
109
+ { value: details['action_name'] },
110
+ { value: details['env_options'] },
111
+ { value: "#{details['state']}" }
112
+ ]
113
+ # if CapistranoMulticonfigParallel.show_task_progress
115
114
  # if worker.alive?
116
115
  # row << { value: worker.rake_tasks.size }
117
116
  # row << { value: worker_progress(details, worker) }
@@ -131,26 +130,25 @@ module CapistranoMulticonfigParallel
131
130
  def worker_dry_running?(worker)
132
131
  worker.alive? && worker.dry_running?
133
132
  end
134
-
135
- def worker_progress(details, worker)
136
- return worker_state(worker) unless worker.alive?
133
+
134
+ def worker_progress(_details, worker)
135
+ return worker_state(worker) unless worker.alive?
137
136
  return if worker.executing_dry_run.nil?
138
- tasks = worker.alive? ? worker.dry_run_tasks : []
139
- current_task = worker.alive? ? worker.machine.state.to_s : ""
140
- total_tasks = worker_dry_running?(worker) ? nil : tasks.size
141
- task_index = worker_dry_running?(worker) ? 0 : tasks.index(current_task.to_s).to_i + 1
137
+ tasks = worker.alive? ? worker.dry_run_tasks : []
138
+ current_task = worker.alive? ? worker.machine.state.to_s : ''
139
+ total_tasks = worker_dry_running?(worker) ? nil : tasks.size
140
+ task_index = worker_dry_running?(worker) ? 0 : tasks.index(current_task.to_s).to_i + 1
142
141
  percent = percent_of(task_index, total_tasks)
143
- result = worker_dry_running?(worker) ? "Please wait.. building the progress bars" : "Progress [#{sprintf('%.2f', percent)}%] (executed #{task_index} of #{total_tasks})"
142
+ result = worker_dry_running?(worker) ? 'Please wait.. building the progress bars' : "Progress [#{sprintf('%.2f', percent)}%] (executed #{task_index} of #{total_tasks})"
144
143
  if worker.alive?
145
144
  worker.crashed? ? result.red : result.green
146
145
  else
147
146
  worker_state(worker)
148
147
  end
149
148
  end
150
-
149
+
151
150
  def percent_of(index, total)
152
- index.to_f / total.to_f * 100.0
151
+ index.to_f / total.to_f * 100.0
153
152
  end
154
-
155
153
  end
156
154
  end
@@ -7,12 +7,12 @@ module CapistranoMulticonfigParallel
7
7
  CapistranoMulticonfigParallel.check_terminal_tty
8
8
  CapistranoMulticonfigParallel.original_args = ARGV.dup
9
9
  CapistranoMulticonfigParallel::Application.new.run
10
- rescue Interrupt
11
- `stty icanon echo`
12
- $stderr.puts 'Command cancelled.'
13
- rescue => error
14
- $stderr.puts error
15
- exit(1)
10
+ rescue Interrupt
11
+ `stty icanon echo`
12
+ $stderr.puts 'Command cancelled.'
13
+ rescue => error
14
+ $stderr.puts error
15
+ exit(1)
16
16
  end
17
17
  end
18
18
  end
@@ -1,32 +1,28 @@
1
1
  require 'celluloid/autostart'
2
- require_relative "../celluloid/rake_worker"
2
+ require_relative '../celluloid/rake_worker'
3
3
  require_relative './input_stream'
4
4
  require_relative './output_stream'
5
5
  module CapistranoMulticonfigParallel
6
6
  class ExtensionHelper
7
-
8
7
  attr_accessor :task, :env
9
8
  def initialize(env, task)
10
9
  @env = env
11
10
  @task = task
12
11
  end
13
-
12
+
14
13
  def work(&block)
15
- if job_id.present?
14
+ if job_id.present?
16
15
  actor_start_working
17
16
  actor.wait_execution until actor.task_approved
18
- return unless actor.task_approved
17
+ return unless actor.task_approved
19
18
  actor_execute_block(&block)
20
19
  else
21
20
  block.call
22
21
  end
23
22
  end
24
23
 
24
+ private
25
25
 
26
-
27
- private
28
-
29
-
30
26
  def actor_execute_block(&block)
31
27
  stringio = StringIO.new
32
28
  CapistranoMulticonfigParallel::OutputStream.hook(stringio)
@@ -35,7 +31,7 @@ module CapistranoMulticonfigParallel
35
31
  CapistranoMulticonfigParallel::InputStream.unhook
36
32
  CapistranoMulticonfigParallel::OutputStream.unhook
37
33
  end
38
-
34
+
39
35
  def actor_start_working
40
36
  if actor.blank?
41
37
  CapistranoMulticonfigParallel::RakeWorker.supervise_as rake_actor_id
@@ -44,25 +40,23 @@ module CapistranoMulticonfigParallel
44
40
  actor.publish_new_work(@env, task: @task)
45
41
  end
46
42
  end
47
-
43
+
48
44
  def supervise_actor
49
- CapistranoMulticonfigParallel::RakeWorker.supervise_as(rake_actor_id,
50
- actor_id: rake_actor_id,
51
- job_id: job_id) if actor.blank?
45
+ CapistranoMulticonfigParallel::RakeWorker.supervise_as(rake_actor_id,
46
+ actor_id: rake_actor_id,
47
+ job_id: job_id) if actor.blank?
52
48
  end
53
-
49
+
54
50
  def actor
55
51
  Celluloid::Actor[rake_actor_id]
56
52
  end
57
-
53
+
58
54
  def job_id
59
55
  @env[CapistranoMulticonfigParallel::ENV_KEY_JOB_ID]
60
56
  end
61
-
62
57
 
63
58
  def rake_actor_id
64
59
  @env['count_rake'].present? ? "rake_worker_#{job_id}_count" : "rake_worker_#{job_id}"
65
60
  end
66
-
67
61
  end
68
62
  end
@@ -17,14 +17,13 @@ module CapistranoMulticonfigParallel
17
17
  self.stringio = stringio
18
18
  end
19
19
 
20
- def gets(*args)
20
+ def gets(*_args)
21
21
  @stringio.rewind
22
22
  data = @stringio.read
23
- @actor.user_prompt_needed?(data)
23
+ @actor.user_prompt_needed?(data)
24
24
  end
25
25
 
26
26
  def finish
27
-
28
27
  end
29
28
 
30
29
  def method_missing(name, *args, &block)
@@ -32,4 +31,3 @@ module CapistranoMulticonfigParallel
32
31
  end
33
32
  end
34
33
  end
35
-
@@ -12,26 +12,21 @@ module CapistranoMulticonfigParallel
12
12
  attr_accessor :real, :stringio
13
13
 
14
14
  def initialize(real_stdout, stringio)
15
- self.real= real_stdout
15
+ self.real = real_stdout
16
16
  self.stringio = stringio
17
17
  end
18
18
 
19
19
  def write(*args)
20
20
  @stringio.print(*args)
21
- @real.write(*args)
21
+ @real.write(*args)
22
22
  @real.flush
23
23
  end
24
24
 
25
+ def finish
26
+ end
25
27
 
26
-
27
-
28
- def finish
29
-
28
+ def method_missing(name, *args, &block)
29
+ @real.send name, *args, &block
30
30
  end
31
-
32
- def method_missing(name, *args, &block)
33
- @real.send name, *args, &block
34
- end
35
31
  end
36
32
  end
37
-
@@ -3,7 +3,7 @@ Rake::Task.class_eval do
3
3
  alias_method :original_execute, :execute
4
4
 
5
5
  def execute(*args)
6
- rake = CapistranoMulticonfigParallel::ExtensionHelper.new(ENV, self)
6
+ rake = CapistranoMulticonfigParallel::ExtensionHelper.new(ENV, self)
7
7
  rake.work do
8
8
  original_execute(*args)
9
9
  end
@@ -221,7 +221,7 @@ module CapistranoMulticonfigParallel
221
221
  value = options['value'].present? ? options['value'] : fetch(options.fetch('key', :app_branch_name))
222
222
  if value.present?
223
223
  branch = value.gsub("\r\n", '')
224
- branch = branch.gsub("\n", '') if branch.present?
224
+ branch = branch.delete("\n") if branch.present?
225
225
  branch = branch.gsub(/\s+/, ' ') if branch.present?
226
226
  branch = branch.strip if branch.present?
227
227
  return branch
@@ -19,7 +19,7 @@ module CapistranoMulticonfigParallel
19
19
  action = "#{action_name}[#{options.fetch('task_arguments:', []).join(',')}]"
20
20
  arguments = setup_command_line_standard(options.fetch('env_options', {}))
21
21
  job_stage = app.present? ? "#{app}:#{stage}" : "#{stage}"
22
-
22
+
23
23
  command = "bundle exec cap #{job_stage} #{action} #{arguments}"
24
24
  puts("\n\n\n Executing '#{command}' \n\n\n .")
25
25
  sh("#{command}")
@@ -20,7 +20,7 @@ module CapistranoMulticonfigParallel
20
20
  interactive_menu = CapistranoMulticonfigParallel::InteractiveMenu.new
21
21
  applications_selected = interactive_menu.show_all_websites_interactive_menu(applications)
22
22
  applications_selected = applications_selected.gsub("\r\n", '') if applications_selected.present?
23
- applications_selected = applications_selected.gsub("\n", '') if applications_selected.present?
23
+ applications_selected = applications_selected.delete("\n") if applications_selected.present?
24
24
  applications_selected = applications_selected.split(',') if applications_selected.present?
25
25
  applications_selected.present? ? applications_selected : []
26
26
  end
@@ -8,7 +8,7 @@ module CapistranoMulticonfigParallel
8
8
  module VERSION
9
9
  MAJOR = 0
10
10
  MINOR = 12
11
- TINY = 2
11
+ TINY = 3
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.12.2
4
+ version: 0.12.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - bogdanRada
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-11-06 00:00:00.000000000 Z
11
+ date: 2015-11-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: celluloid-pmap
@@ -276,80 +276,80 @@ dependencies:
276
276
  requirements:
277
277
  - - "~>"
278
278
  - !ruby/object:Gem::Version
279
- version: '2.0'
279
+ version: '3.3'
280
280
  - - ">="
281
281
  - !ruby/object:Gem::Version
282
- version: '2.0'
282
+ version: '3.3'
283
283
  type: :development
284
284
  prerelease: false
285
285
  version_requirements: !ruby/object:Gem::Requirement
286
286
  requirements:
287
287
  - - "~>"
288
288
  - !ruby/object:Gem::Version
289
- version: '2.0'
289
+ version: '3.3'
290
290
  - - ">="
291
291
  - !ruby/object:Gem::Version
292
- version: '2.0'
292
+ version: '3.3'
293
293
  - !ruby/object:Gem::Dependency
294
294
  name: guard
295
295
  requirement: !ruby/object:Gem::Requirement
296
296
  requirements:
297
297
  - - "~>"
298
298
  - !ruby/object:Gem::Version
299
- version: '2.6'
299
+ version: '2.13'
300
300
  - - ">="
301
301
  - !ruby/object:Gem::Version
302
- version: 2.6.1
302
+ version: '2.13'
303
303
  type: :development
304
304
  prerelease: false
305
305
  version_requirements: !ruby/object:Gem::Requirement
306
306
  requirements:
307
307
  - - "~>"
308
308
  - !ruby/object:Gem::Version
309
- version: '2.6'
309
+ version: '2.13'
310
310
  - - ">="
311
311
  - !ruby/object:Gem::Version
312
- version: 2.6.1
312
+ version: '2.13'
313
313
  - !ruby/object:Gem::Dependency
314
314
  name: guard-rspec
315
315
  requirement: !ruby/object:Gem::Requirement
316
316
  requirements:
317
317
  - - "~>"
318
318
  - !ruby/object:Gem::Version
319
- version: '4.2'
319
+ version: '4.6'
320
320
  - - ">="
321
321
  - !ruby/object:Gem::Version
322
- version: 4.2.9
322
+ version: '4.6'
323
323
  type: :development
324
324
  prerelease: false
325
325
  version_requirements: !ruby/object:Gem::Requirement
326
326
  requirements:
327
327
  - - "~>"
328
328
  - !ruby/object:Gem::Version
329
- version: '4.2'
329
+ version: '4.6'
330
330
  - - ">="
331
331
  - !ruby/object:Gem::Version
332
- version: 4.2.9
332
+ version: '4.6'
333
333
  - !ruby/object:Gem::Dependency
334
334
  name: simplecov
335
335
  requirement: !ruby/object:Gem::Requirement
336
336
  requirements:
337
337
  - - "~>"
338
338
  - !ruby/object:Gem::Version
339
- version: '0.9'
339
+ version: '0.10'
340
340
  - - ">="
341
341
  - !ruby/object:Gem::Version
342
- version: '0.9'
342
+ version: '0.10'
343
343
  type: :development
344
344
  prerelease: false
345
345
  version_requirements: !ruby/object:Gem::Requirement
346
346
  requirements:
347
347
  - - "~>"
348
348
  - !ruby/object:Gem::Version
349
- version: '0.9'
349
+ version: '0.10'
350
350
  - - ">="
351
351
  - !ruby/object:Gem::Version
352
- version: '0.9'
352
+ version: '0.10'
353
353
  - !ruby/object:Gem::Dependency
354
354
  name: simplecov-summary
355
355
  requirement: !ruby/object:Gem::Requirement
@@ -436,47 +436,47 @@ dependencies:
436
436
  requirements:
437
437
  - - "~>"
438
438
  - !ruby/object:Gem::Version
439
- version: '0'
439
+ version: '0.33'
440
440
  - - ">="
441
441
  - !ruby/object:Gem::Version
442
- version: '0.29'
442
+ version: '0.33'
443
443
  type: :development
444
444
  prerelease: false
445
445
  version_requirements: !ruby/object:Gem::Requirement
446
446
  requirements:
447
447
  - - "~>"
448
448
  - !ruby/object:Gem::Version
449
- version: '0'
449
+ version: '0.33'
450
450
  - - ">="
451
451
  - !ruby/object:Gem::Version
452
- version: '0.29'
452
+ version: '0.33'
453
453
  - !ruby/object:Gem::Dependency
454
454
  name: phare
455
455
  requirement: !ruby/object:Gem::Requirement
456
456
  requirements:
457
457
  - - "~>"
458
458
  - !ruby/object:Gem::Version
459
- version: '0'
459
+ version: '0.7'
460
460
  - - ">="
461
461
  - !ruby/object:Gem::Version
462
- version: '0.6'
462
+ version: '0.7'
463
463
  type: :development
464
464
  prerelease: false
465
465
  version_requirements: !ruby/object:Gem::Requirement
466
466
  requirements:
467
467
  - - "~>"
468
468
  - !ruby/object:Gem::Version
469
- version: '0'
469
+ version: '0.7'
470
470
  - - ">="
471
471
  - !ruby/object:Gem::Version
472
- version: '0.6'
472
+ version: '0.7'
473
473
  - !ruby/object:Gem::Dependency
474
474
  name: yard
475
475
  requirement: !ruby/object:Gem::Requirement
476
476
  requirements:
477
477
  - - "~>"
478
478
  - !ruby/object:Gem::Version
479
- version: '0'
479
+ version: '0.8'
480
480
  - - ">="
481
481
  - !ruby/object:Gem::Version
482
482
  version: 0.8.7
@@ -486,7 +486,7 @@ dependencies:
486
486
  requirements:
487
487
  - - "~>"
488
488
  - !ruby/object:Gem::Version
489
- version: '0'
489
+ version: '0.8'
490
490
  - - ">="
491
491
  - !ruby/object:Gem::Version
492
492
  version: 0.8.7
@@ -496,7 +496,7 @@ dependencies:
496
496
  requirements:
497
497
  - - "~>"
498
498
  - !ruby/object:Gem::Version
499
- version: '0'
499
+ version: '0.1'
500
500
  - - ">="
501
501
  - !ruby/object:Gem::Version
502
502
  version: '0.1'
@@ -506,7 +506,7 @@ dependencies:
506
506
  requirements:
507
507
  - - "~>"
508
508
  - !ruby/object:Gem::Version
509
- version: '0'
509
+ version: '0.1'
510
510
  - - ">="
511
511
  - !ruby/object:Gem::Version
512
512
  version: '0.1'
@@ -516,27 +516,27 @@ dependencies:
516
516
  requirements:
517
517
  - - "~>"
518
518
  - !ruby/object:Gem::Version
519
- version: '3'
519
+ version: '3.3'
520
520
  - - ">="
521
521
  - !ruby/object:Gem::Version
522
- version: 3.2.2
522
+ version: '3.3'
523
523
  type: :development
524
524
  prerelease: false
525
525
  version_requirements: !ruby/object:Gem::Requirement
526
526
  requirements:
527
527
  - - "~>"
528
528
  - !ruby/object:Gem::Version
529
- version: '3'
529
+ version: '3.3'
530
530
  - - ">="
531
531
  - !ruby/object:Gem::Version
532
- version: 3.2.2
532
+ version: '3.3'
533
533
  - !ruby/object:Gem::Dependency
534
534
  name: github-markup
535
535
  requirement: !ruby/object:Gem::Requirement
536
536
  requirements:
537
537
  - - "~>"
538
538
  - !ruby/object:Gem::Version
539
- version: '1'
539
+ version: '1.3'
540
540
  - - ">="
541
541
  - !ruby/object:Gem::Version
542
542
  version: 1.3.3
@@ -546,7 +546,7 @@ dependencies:
546
546
  requirements:
547
547
  - - "~>"
548
548
  - !ruby/object:Gem::Version
549
- version: '1'
549
+ version: '1.3'
550
550
  - - ">="
551
551
  - !ruby/object:Gem::Version
552
552
  version: 1.3.3
@@ -556,27 +556,27 @@ dependencies:
556
556
  requirements:
557
557
  - - "~>"
558
558
  - !ruby/object:Gem::Version
559
- version: '0'
559
+ version: '0.6'
560
560
  - - ">="
561
561
  - !ruby/object:Gem::Version
562
- version: 0.5.10
562
+ version: '0.6'
563
563
  type: :development
564
564
  prerelease: false
565
565
  version_requirements: !ruby/object:Gem::Requirement
566
566
  requirements:
567
567
  - - "~>"
568
568
  - !ruby/object:Gem::Version
569
- version: '0'
569
+ version: '0.6'
570
570
  - - ">="
571
571
  - !ruby/object:Gem::Version
572
- version: 0.5.10
572
+ version: '0.6'
573
573
  - !ruby/object:Gem::Dependency
574
574
  name: guard-inch
575
575
  requirement: !ruby/object:Gem::Requirement
576
576
  requirements:
577
577
  - - "~>"
578
578
  - !ruby/object:Gem::Version
579
- version: '0'
579
+ version: '0.1'
580
580
  - - ">="
581
581
  - !ruby/object:Gem::Version
582
582
  version: 0.1.0
@@ -586,7 +586,7 @@ dependencies:
586
586
  requirements:
587
587
  - - "~>"
588
588
  - !ruby/object:Gem::Version
589
- version: '0'
589
+ version: '0.1'
590
590
  - - ">="
591
591
  - !ruby/object:Gem::Version
592
592
  version: 0.1.0