capistrano_multiconfig_parallel 1.0.6 → 1.0.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: 26035c748d3494c6c5159791823939332b62f001
4
- data.tar.gz: 53592e1501a707b02dbf946a7debb71827f8b9f8
3
+ metadata.gz: 3969bb2312c4d58de611a321420226dd9a556bed
4
+ data.tar.gz: 40b5524432fe09ff8240ad910bd784a67e292e91
5
5
  SHA512:
6
- metadata.gz: 8b680cf811f4dd24cf7374cb69c18ffb25a1335f307b7172c47e85d086c48198ced14301cb7c188050ec242fcdf3b2c85804dbf030da034f02d03dfe76fc5d0a
7
- data.tar.gz: 1a746e0c0116857eed89bdfa92b913171858fe6c2fecdaf42cb6be25f74b2d5d1687d91ef02e22d5112992f7d7c4281a6edce03b2b70a2c47414bbe8668c1102
6
+ metadata.gz: 401ef05ba36d18fb6ac2871c7a4287267cb65c6539e573d4d97bc409ed81874dace93abfdba6ca1106b523694edd9aedcb2cb86f707dadbea82695940fed4afa
7
+ data.tar.gz: c63ef76946c39e239266876b5166ff20f17cc0aee213d3fd6dcd864f0384ff7a1bdb48b7713a3f48f5749ad4a04db3702f66040ce6ccaa31701eaa2d7791978c
@@ -159,7 +159,7 @@ module CapistranoMulticonfigParallel
159
159
  end
160
160
 
161
161
  def worker_environments
162
- @jobs.map { |job| job['env'] }
162
+ @jobs.map(&:stage)
163
163
  end
164
164
 
165
165
  def run
@@ -15,6 +15,15 @@ module CapistranoMulticonfigParallel
15
15
  @config
16
16
  end
17
17
 
18
+ def configuration_flags
19
+ default_internal_config.each_with_object({}) do |array_item, hash|
20
+ key = array_item[0].to_s
21
+ value = get_prop_config(key, configuration)
22
+ hash[key] = value.is_a?(Array) ? value.join(',') : value
23
+ hash
24
+ end.except('application_dependencies')
25
+ end
26
+
18
27
  def enable_logging
19
28
  enable_file_logging
20
29
  set_celluloid_exception_handling
@@ -24,12 +33,16 @@ module CapistranoMulticonfigParallel
24
33
  multi_fetch_argv(original_args.dup)
25
34
  end
26
35
 
36
+ def job_id
37
+ original_args_hash.fetch(CapistranoMulticonfigParallel::ENV_KEY_JOB_ID, nil)
38
+ end
39
+
27
40
  def capistrano_version
28
41
  find_loaded_gem_property('capistrano', 'version')
29
42
  end
30
43
 
31
44
  def capistrano_version_2?
32
- verify_gem_version('capistrano', '3.0', operator: '<')
45
+ verify_gem_version(capistrano_version, '3.0', operator: '<')
33
46
  end
34
47
 
35
48
  private
@@ -28,7 +28,7 @@ module CapistranoMulticonfigParallel
28
28
  stderr_buffer.rewind
29
29
  old_data = stderr_buffer.read.dup
30
30
  new_data = old_data.to_s + data
31
- stderr_buffer.write(new_data) if new_data.include?('aborted!')
31
+ stderr_buffer.write(new_data) if new_data.include?('aborted!') || new_data.include?('Terminating')
32
32
  end
33
33
 
34
34
  def env_variable
@@ -32,11 +32,16 @@ module CapistranoMulticonfigParallel
32
32
 
33
33
  def setup_env_options(options = {})
34
34
  array_options = []
35
+ filtered_keys = options.delete(:filtered_keys) || []
35
36
  env_options.each do |key, value|
36
- array_options << "#{env_prefix(key)} #{env_key_format(key)}=#{value}" if value.present? && !env_option_filtered?(key, options.fetch(:filtered_keys, []))
37
+ array_options << "#{env_prefix(key)} #{env_key_format(key)}=#{value}" if value.present? && !env_option_filtered?(key, filtered_keys)
37
38
  end
39
+ setup_remaining_flags(array_options, options)
40
+ end
41
+
42
+ def setup_remaining_flags(array_options, options)
38
43
  array_options << trace_flag if app_debug_enabled?
39
- array_options
44
+ array_options.concat(setup_flags_for_job(options))
40
45
  end
41
46
 
42
47
  def setup_command_line(*args)
@@ -45,7 +50,7 @@ module CapistranoMulticonfigParallel
45
50
  end
46
51
 
47
52
  def to_s
48
- configuration_options = CapistranoMulticonfigParallel.original_args.select { |arg| arg.include?('--') }
53
+ configuration_options = CapistranoMulticonfigParallel.configuration_flags
49
54
  environment_options = setup_command_line(configuration_options).join(' ')
50
55
  "cd #{detect_root} && RAILS_ENV=#{stage} bundle exec multi_cap #{job_stage} #{capistrano_action} #{environment_options}"
51
56
  end
@@ -6,9 +6,9 @@ module CapistranoMulticonfigParallel
6
6
  # class used to handle the rake worker and sets all the hooks before and after running the worker
7
7
  class RakeTaskHooks
8
8
  include CapistranoMulticonfigParallel::ApplicationHelper
9
- attr_accessor :task, :env, :config
10
- def initialize(task)
11
- @env = CapistranoMulticonfigParallel.original_args_hash
9
+ attr_accessor :job_id, :task
10
+ def initialize(task = nil)
11
+ @job_id = CapistranoMulticonfigParallel.job_id
12
12
  @task = task.respond_to?(:fully_qualified_name) ? task.fully_qualified_name : task
13
13
  end
14
14
 
@@ -76,10 +76,6 @@ module CapistranoMulticonfigParallel
76
76
  CapistranoMulticonfigParallel::RakeWorker.supervise_as(rake_actor_id)
77
77
  end
78
78
 
79
- def job_id
80
- @env.fetch(CapistranoMulticonfigParallel::ENV_KEY_JOB_ID, nil)
81
- end
82
-
83
79
  def rake_actor_id
84
80
  "rake_worker_#{job_id}"
85
81
  end
@@ -4,7 +4,7 @@ module CapistranoMulticonfigParallel
4
4
  module_function
5
5
 
6
6
  def filtered_env_keys_format(keys)
7
- capistrano_version_2? ? keys.map(&:downcase) : keys
7
+ keys.map { |key| env_key_format(key) }
8
8
  end
9
9
 
10
10
  def env_prefix(key)
@@ -18,5 +18,13 @@ module CapistranoMulticonfigParallel
18
18
  def trace_flag
19
19
  capistrano_version_2? ? '--verbose' : '--trace'
20
20
  end
21
+
22
+ def setup_flags_for_job(options)
23
+ array_options = []
24
+ options.each do |key, value|
25
+ array_options << "--#{key}=#{value}"
26
+ end
27
+ array_options
28
+ end
21
29
  end
22
30
  end
@@ -76,8 +76,7 @@ module CapistranoMulticonfigParallel
76
76
  end
77
77
  end
78
78
 
79
- def get_prop_config(prop)
80
- config = @check_config
79
+ def get_prop_config(prop, config = @check_config)
81
80
  if prop.include?('.')
82
81
  multi_level_prop(config, prop)
83
82
  else
@@ -3,13 +3,13 @@ module CapistranoMulticonfigParallel
3
3
  module GemHelper
4
4
  module_function
5
5
 
6
- def find_loaded_gem(name)
7
- Gem.loaded_specs.values.find { |repo| repo.name == name }
6
+ def find_loaded_gem(name, property = nil)
7
+ gem_spec = Gem.loaded_specs.values.find { |repo| repo.name == name }
8
+ property.present? ? gem_spec.send(property) : gem_spec
8
9
  end
9
10
 
10
11
  def find_loaded_gem_property(gem_name, property = 'version')
11
- gem_spec = find_loaded_gem(gem_name)
12
- gem_spec.respond_to?(property) ? gem_spec.send(property) : nil
12
+ find_loaded_gem(gem_name, property)
13
13
  end
14
14
 
15
15
  def fetch_gem_version(gem_name)
@@ -23,11 +23,9 @@ module CapistranoMulticonfigParallel
23
23
  version.join('.').to_f
24
24
  end
25
25
 
26
- def verify_gem_version(gem_name, version, options = {})
27
- options.stringify_keys!
26
+ def verify_gem_version(gem_version, version, options = {})
28
27
  version = get_parsed_version(version)
29
- gem_version = fetch_gem_version(gem_name)
30
- gem_version.blank? ? false : gem_version.send(options.fetch('operator', '<='), version)
28
+ get_parsed_version(gem_version).send(options.fetch('operator', '<='), version)
31
29
  end
32
30
  end
33
31
  end
@@ -74,7 +74,7 @@ module CapistranoMulticonfigParallel
74
74
  end
75
75
 
76
76
  def fail_capfile_not_found(root)
77
- fail "Can't detect Capfile in the application root".red if pathname_is_root?(root)
77
+ fail "Can't detect Capfile in the application root".red if root.blank?
78
78
  end
79
79
 
80
80
  def pwd_parent_dir
@@ -93,11 +93,10 @@ module CapistranoMulticonfigParallel
93
93
  root.children.find { |file| check_file(file, filename) }.present? || pathname_is_root?(root)
94
94
  end
95
95
 
96
- def try_detect_capfile
96
+ def try_detect_file(filename = 'capfile')
97
97
  root = pwd_parent_dir
98
- root = root.parent until find_file_in_directory(root, 'capfile')
99
- fail_capfile_not_found(root)
100
- root
98
+ root = root.parent until find_file_in_directory(root, filename)
99
+ pathname_is_root?(root) ? nil : root
101
100
  end
102
101
 
103
102
  def detect_root
@@ -106,7 +105,9 @@ module CapistranoMulticonfigParallel
106
105
  elsif defined?(::Rails)
107
106
  ::Rails.root
108
107
  else
109
- try_detect_capfile
108
+ root = try_detect_file
109
+ fail_capfile_not_found(root)
110
+ root
110
111
  end
111
112
  end
112
113
 
@@ -5,7 +5,7 @@ if CapistranoMulticonfigParallel.capistrano_version_2?
5
5
  alias_method :original_ask, :ask
6
6
 
7
7
  def ask(question, answer_type = String, &details)
8
- rake = CapistranoMulticonfigParallel::RakeTaskHooks.new(nil)
8
+ rake = CapistranoMulticonfigParallel::RakeTaskHooks.new
9
9
  rake.print_question?(question) do
10
10
  original_ask(question, answer_type, &details)
11
11
  end
@@ -8,7 +8,7 @@ module CapistranoMulticonfigParallel
8
8
  module VERSION
9
9
  MAJOR = 1
10
10
  MINOR = 0
11
- TINY = 6
11
+ TINY = 7
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.0.6
4
+ version: 1.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - bogdanRada
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-01-12 00:00:00.000000000 Z
11
+ date: 2016-01-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: celluloid-pmap