capistrano_multiconfig_parallel 0.23.2 → 0.23.3
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 +4 -4
- data/.reek +4 -0
- data/lib/capistrano_multiconfig_parallel/celluloid/terminal_table.rb +14 -9
- data/lib/capistrano_multiconfig_parallel/classes/interactive_menu.rb +3 -3
- data/lib/capistrano_multiconfig_parallel/classes/job.rb +12 -8
- data/lib/capistrano_multiconfig_parallel/classes/job_command.rb +10 -11
- data/lib/capistrano_multiconfig_parallel/cli.rb +10 -2
- data/lib/capistrano_multiconfig_parallel/helpers/application_helper.rb +25 -14
- data/lib/capistrano_multiconfig_parallel/initializers/terminal-table.rb +3 -0
- data/lib/capistrano_multiconfig_parallel/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fc16361255623968a8072c114d5bc7a6129be46d
|
4
|
+
data.tar.gz: 2c6477dede330ad276c6b985aea54fddeb2a0e2b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cd160acb58df0e43783156957ced50e4cd67d142c3173240d2bac8aa1a0161e36eb6ea034d1d94aa903bec150783fc2033bc79daa56b84d15a7bf0ac0fdb00f0
|
7
|
+
data.tar.gz: afed88d835ba15464fb6413ceb0cea5294745e91919441a0cb3624e3d98517ea2edbcbe3a653999694a5e4f87f4f840b83ccf0ff89bcf9eb2042333c326812af
|
data/.reek
CHANGED
@@ -14,20 +14,25 @@ module CapistranoMulticonfigParallel
|
|
14
14
|
def initialize(manager, job_manager)
|
15
15
|
@manager = manager
|
16
16
|
@job_manager = job_manager
|
17
|
+
@table = Terminal::Table.new(title: 'Deployment Status Table', headings: default_heaadings)
|
17
18
|
async.run
|
18
19
|
rescue => ex
|
19
20
|
rescue_exception(ex)
|
20
21
|
end
|
21
22
|
|
23
|
+
def default_heaadings
|
24
|
+
['Job ID', 'Job UUID', 'App/Stage', 'Action', 'ENV Variables', 'Current Task']
|
25
|
+
end
|
26
|
+
|
22
27
|
def run
|
23
28
|
subscribe(CapistranoMulticonfigParallel::TerminalTable.topic, :notify_time_change)
|
24
29
|
end
|
25
30
|
|
26
|
-
def notify_time_change(
|
27
|
-
table =
|
31
|
+
def notify_time_change(_channel, _message)
|
32
|
+
@table.rows = []
|
28
33
|
jobs = @manager.alive? ? @manager.jobs.dup : []
|
29
|
-
setup_table_jobs(
|
30
|
-
display_table_on_terminal
|
34
|
+
setup_table_jobs(jobs)
|
35
|
+
display_table_on_terminal
|
31
36
|
end
|
32
37
|
|
33
38
|
def rescue_exception(ex)
|
@@ -36,16 +41,16 @@ module CapistranoMulticonfigParallel
|
|
36
41
|
terminate
|
37
42
|
end
|
38
43
|
|
39
|
-
def display_table_on_terminal
|
44
|
+
def display_table_on_terminal
|
40
45
|
terminal_clear
|
41
|
-
puts "\n#{table}\n"
|
46
|
+
puts "\n#{@table}\n"
|
42
47
|
signal_complete
|
43
48
|
end
|
44
49
|
|
45
|
-
def setup_table_jobs(
|
50
|
+
def setup_table_jobs(jobs)
|
46
51
|
jobs.each_with_index do |(_job_id, job), count|
|
47
|
-
table.add_row(job.terminal_row(count))
|
48
|
-
table.add_separator
|
52
|
+
@table.add_row(job.terminal_row(count))
|
53
|
+
@table.add_separator
|
49
54
|
end
|
50
55
|
end
|
51
56
|
|
@@ -14,17 +14,17 @@ module CapistranoMulticonfigParallel
|
|
14
14
|
|
15
15
|
def fetch_menu
|
16
16
|
print_menu_choices
|
17
|
-
|
18
|
-
result = show_all_websites_interactive_menu
|
17
|
+
result = print_selections
|
19
18
|
print "#{@msg}\n"
|
20
19
|
result.present? ? result.split(',') : []
|
21
20
|
end
|
22
21
|
|
23
22
|
private
|
24
23
|
|
25
|
-
def
|
24
|
+
def print_selections
|
26
25
|
print "\nYou selected"
|
27
26
|
@msg = ' nothing'
|
27
|
+
show_all_websites_interactive_menu
|
28
28
|
end
|
29
29
|
|
30
30
|
def show_all_websites_interactive_menu
|
@@ -12,7 +12,7 @@ module CapistranoMulticonfigParallel
|
|
12
12
|
:capistrano_action,
|
13
13
|
:build_capistrano_task,
|
14
14
|
:execute_standard_deploy,
|
15
|
-
:
|
15
|
+
:setup_command_line,
|
16
16
|
to: :command
|
17
17
|
|
18
18
|
def initialize(application, options)
|
@@ -29,14 +29,18 @@ module CapistranoMulticonfigParallel
|
|
29
29
|
@command ||= CapistranoMulticonfigParallel::JobCommand.new(self)
|
30
30
|
end
|
31
31
|
|
32
|
+
def terminal_env_variables
|
33
|
+
setup_command_line(filtered_keys: [env_variable])
|
34
|
+
end
|
35
|
+
|
32
36
|
def terminal_row(index)
|
33
37
|
[
|
34
38
|
{ value: (index + 1).to_s },
|
35
39
|
{ value: id.to_s },
|
36
|
-
{ value: job_stage },
|
37
|
-
{ value: capistrano_action },
|
38
|
-
{ value:
|
39
|
-
{ value: worker_state }
|
40
|
+
{ value: wrap_string(job_stage) },
|
41
|
+
{ value: wrap_string(capistrano_action) },
|
42
|
+
{ value: terminal_env_variables.map { |str| wrap_string(str) }.join("\n") },
|
43
|
+
{ value: wrap_string(worker_state) }
|
40
44
|
]
|
41
45
|
end
|
42
46
|
|
@@ -58,15 +62,15 @@ module CapistranoMulticonfigParallel
|
|
58
62
|
end
|
59
63
|
|
60
64
|
def id
|
61
|
-
@id ||= SecureRandom.uuid
|
65
|
+
@id ||= @options.fetch('id', SecureRandom.uuid)
|
62
66
|
end
|
63
67
|
|
64
68
|
def status
|
65
|
-
@status ||= :unstarted
|
69
|
+
@status ||= @options.fetch('status', :unstarted)
|
66
70
|
end
|
67
71
|
|
68
72
|
def exit_status
|
69
|
-
@exit_status ||= nil
|
73
|
+
@exit_status ||= @options.fetch('exit_status', nil)
|
70
74
|
end
|
71
75
|
|
72
76
|
[
|
@@ -26,28 +26,27 @@ module CapistranoMulticonfigParallel
|
|
26
26
|
"#{rake_action}#{argv}"
|
27
27
|
end
|
28
28
|
|
29
|
+
def env_option_filtered?(key, filtered_keys_array = [])
|
30
|
+
filtered_env_keys.include?(key) || filtered_keys_array.include?(key.to_s)
|
31
|
+
end
|
32
|
+
|
29
33
|
def setup_env_options(options = {})
|
30
|
-
options.stringify_keys!
|
31
34
|
array_options = []
|
32
35
|
env_options.each do |key, value|
|
33
|
-
array_options << "#{key}=#{value}" if value.present? &&
|
36
|
+
array_options << "#{key}=#{value}" if value.present? && !env_option_filtered?(key, options.fetch(:filtered_keys, []))
|
34
37
|
end
|
35
38
|
array_options << '--trace' if app_debug_enabled?
|
36
39
|
array_options
|
37
40
|
end
|
38
41
|
|
39
|
-
def
|
40
|
-
options = args
|
41
|
-
|
42
|
-
args.each do |arg|
|
43
|
-
array_options << arg if arg.present?
|
44
|
-
end
|
45
|
-
array_options
|
42
|
+
def setup_command_line(*args)
|
43
|
+
new_arguments, options = setup_command_line_standard(*args)
|
44
|
+
setup_env_options(options).concat(new_arguments)
|
46
45
|
end
|
47
46
|
|
48
|
-
def build_capistrano_task(rake_action = nil,
|
47
|
+
def build_capistrano_task(rake_action = nil, *args)
|
49
48
|
rake_action = rake_action.present? ? rake_action : action
|
50
|
-
environment_options =
|
49
|
+
environment_options = setup_command_line(*args).join(' ')
|
51
50
|
"cd #{detect_root} && RAILS_ENV=#{@stage} bundle exec multi_cap #{job_stage} #{capistrano_action(rake_action)} #{environment_options}"
|
52
51
|
end
|
53
52
|
|
@@ -7,9 +7,12 @@ module CapistranoMulticonfigParallel
|
|
7
7
|
|
8
8
|
# method used to start
|
9
9
|
def start
|
10
|
-
|
11
|
-
CapistranoMulticonfigParallel.original_args = ARGV.dup
|
10
|
+
before_start
|
12
11
|
arguments = multi_fetch_argv(original_args)
|
12
|
+
execute_start(arguments)
|
13
|
+
end
|
14
|
+
|
15
|
+
def execute_start(arguments)
|
13
16
|
if arguments[CapistranoMulticonfigParallel::ENV_KEY_JOB_ID].blank?
|
14
17
|
require_relative './application'
|
15
18
|
run_the_application
|
@@ -18,6 +21,11 @@ module CapistranoMulticonfigParallel
|
|
18
21
|
end
|
19
22
|
end
|
20
23
|
|
24
|
+
def before_start
|
25
|
+
check_terminal_tty
|
26
|
+
CapistranoMulticonfigParallel.original_args = ARGV.dup
|
27
|
+
end
|
28
|
+
|
21
29
|
def run_the_application
|
22
30
|
execute_with_rescue('stderr') do
|
23
31
|
configuration_valid?
|
@@ -14,6 +14,17 @@ module CapistranoMulticonfigParallel
|
|
14
14
|
|
15
15
|
module_function
|
16
16
|
|
17
|
+
def setup_command_line_standard(*args)
|
18
|
+
options = args.extract_options!
|
19
|
+
args.select(&:present?)
|
20
|
+
[args, options]
|
21
|
+
end
|
22
|
+
|
23
|
+
def wrap_string(string, options = {})
|
24
|
+
options.stringify_keys!
|
25
|
+
string.scan(/.{#{options.fetch('length', 80)}}|.+/).map(&:strip).join(options.fetch('character', $INPUT_RECORD_SEPARATOR))
|
26
|
+
end
|
27
|
+
|
17
28
|
def find_loaded_gem(name)
|
18
29
|
Gem.loaded_specs.values.find { |repo| repo.name == name }
|
19
30
|
end
|
@@ -79,28 +90,28 @@ module CapistranoMulticonfigParallel
|
|
79
90
|
end
|
80
91
|
|
81
92
|
def parse_task_string(string) # :nodoc:
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
remaining_args = regex_last_match(2)
|
93
|
+
name, remaining_args = fetch_parsed_string(string)
|
94
|
+
name.present? ? find_remaining_args(name, remaining_args) : [string, []]
|
95
|
+
end
|
86
96
|
|
87
|
-
|
88
|
-
|
97
|
+
def fetch_parsed_string(string)
|
98
|
+
/^([^\[]+)(?:\[(.*)\])$/ =~ string.to_s
|
99
|
+
[regex_last_match(1), regex_last_match(2)]
|
100
|
+
end
|
89
101
|
|
90
|
-
|
91
|
-
[
|
102
|
+
def fetch_remaining_arguments(args, remaining_args)
|
103
|
+
/((?:[^\\,]|\\.)*?)\s*(?:,\s*(.*))?$/ =~ remaining_args
|
104
|
+
args << regex_last_match(1).gsub(/\\(.)/, '\1')
|
105
|
+
regex_last_match(2)
|
92
106
|
end
|
93
107
|
|
94
|
-
def find_remaining_args(remaining_args)
|
108
|
+
def find_remaining_args(name, remaining_args)
|
95
109
|
args = []
|
96
110
|
loop do
|
97
|
-
|
98
|
-
|
99
|
-
remaining_args = regex_last_match(2)
|
100
|
-
args << regex_last_match(1).gsub(/\\(.)/, '\1')
|
111
|
+
remaining_args = fetch_remaining_arguments(args, remaining_args)
|
101
112
|
break if remaining_args.blank?
|
102
113
|
end
|
103
|
-
args
|
114
|
+
[name, args]
|
104
115
|
end
|
105
116
|
end
|
106
117
|
end
|
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.23.
|
4
|
+
version: 0.23.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- bogdanRada
|
@@ -662,6 +662,7 @@ files:
|
|
662
662
|
- lib/capistrano_multiconfig_parallel/helpers/core_helper.rb
|
663
663
|
- lib/capistrano_multiconfig_parallel/helpers/internal_helper.rb
|
664
664
|
- lib/capistrano_multiconfig_parallel/initializers/rake.rb
|
665
|
+
- lib/capistrano_multiconfig_parallel/initializers/terminal-table.rb
|
665
666
|
- lib/capistrano_multiconfig_parallel/version.rb
|
666
667
|
homepage: http://github.com/bogdanRada/capistrano_multiconfig_parallel/
|
667
668
|
licenses:
|