Class: CapistranoMulticonfigParallel::JobCommand
- Inherits:
-
Object
- Object
- CapistranoMulticonfigParallel::JobCommand
show all
- Includes:
- ApplicationHelper, FileUtils
- Defined in:
- lib/capistrano_multiconfig_parallel/classes/job_command.rb
Overview
class used to find application dependencies
Instance Attribute Summary collapse
Instance Method Summary
collapse
action_confirmed?, fetch_parsed_string, fetch_remaining_arguments, find_remaining_args, get_question_details, msg_for_stdin?, msg_for_task?, parse_task_string, percent_of, regex_last_match, setup_command_line_standard, wrap_string
env_key_format, env_prefix, filtered_env_keys_format, setup_flags_for_job, trace_flag
Methods included from GemHelper
fetch_gem_version, find_loaded_gem, find_loaded_gem_property, format_gem_version, get_parsed_version, verify_gem_version
app_names_from_stages, check_stage_path, checks_paths, fetch_stages_app, fetch_stages_from_file, fetch_stages_paths, independent_deploy?, multi_apps?, sorted_paths, stages, stages_paths, stages_root
check_hash_set, check_numeric, strip_characters_from_string, value_is_array?, verify_array_of_strings, verify_empty_options, warn_array_without_strings
Methods included from CoreHelper
app_debug_enabled?, ask_confirm, ask_stdout_confirmation, check_terminal_tty, debug_websocket?, error_filtered?, execute_with_rescue, find_worker_log, force_confirmation, format_error, log_error, log_output_error, log_to_file, multi_fetch_argv, print_to_log_file, rescue_error, rescue_interrupt, setup_filename_logger, setup_logger_formatter, show_warning, terminal_actor, terminal_errors?, websocket_config, websocket_server_config
arg_is_in_default_config?, check_file, create_log_file, custom_commands, default_config_keys, default_internal_config, default_internal_configuration_params, detect_root, enable_main_log_file, fail_capfile_not_found, fetch_default_internal_config, find_config_type, find_env_multi_cap_root, find_file_in_directory, internal_config_directory, internal_config_file, log_directory, main_log_file, multi_level_prop, pathname_is_root?, pwd_directory, pwd_parent_dir, root, setup_default_configuration_types, sliced_default_config, try_detect_file
Constructor Details
Returns a new instance of JobCommand.
12
13
14
15
|
# File 'lib/capistrano_multiconfig_parallel/classes/job_command.rb', line 12
def initialize(job)
@job = job
@legacy_capistrano = legacy_capistrano? ? true : false
end
|
Instance Attribute Details
#job ⇒ Object
Returns the value of attribute job.
9
10
11
|
# File 'lib/capistrano_multiconfig_parallel/classes/job_command.rb', line 9
def job
@job
end
|
#job_capistrano_version ⇒ Object
Returns the value of attribute job_capistrano_version.
9
10
11
|
# File 'lib/capistrano_multiconfig_parallel/classes/job_command.rb', line 9
def job_capistrano_version
@job_capistrano_version
end
|
#legacy_capistrano ⇒ Object
Returns the value of attribute legacy_capistrano.
9
10
11
|
# File 'lib/capistrano_multiconfig_parallel/classes/job_command.rb', line 9
def legacy_capistrano
@legacy_capistrano
end
|
Instance Method Details
#bundle_gemfile_env ⇒ Object
21
22
23
|
# File 'lib/capistrano_multiconfig_parallel/classes/job_command.rb', line 21
def bundle_gemfile_env
"BUNDLE_GEMFILE=#{job_path}/Gemfile"
end
|
#capistrano_action ⇒ Object
34
35
36
37
|
# File 'lib/capistrano_multiconfig_parallel/classes/job_command.rb', line 34
def capistrano_action
argv = task_arguments.present? ? "[#{task_arguments}]" : ''
"#{action}#{argv}"
end
|
#command_prefix ⇒ Object
75
76
77
78
|
# File 'lib/capistrano_multiconfig_parallel/classes/job_command.rb', line 75
def command_prefix
bundle_install = path.present? ? "&& #{bundle_gemfile_env} bundle install" : ''
"cd #{job_path} #{bundle_install}"
end
|
#env_option_filtered?(key, filtered_keys_array = []) ⇒ Boolean
39
40
41
|
# File 'lib/capistrano_multiconfig_parallel/classes/job_command.rb', line 39
def env_option_filtered?(key, filtered_keys_array = [])
filtered_env_keys.include?(env_key_format(key)) || filtered_keys_array.include?(key.to_s)
end
|
#execute_standard_deploy(action = nil) ⇒ Object
90
91
92
93
94
95
|
# File 'lib/capistrano_multiconfig_parallel/classes/job_command.rb', line 90
def execute_standard_deploy(action = nil)
run_shell_command(to_s)
rescue => ex
rescue_error(ex, 'stderr')
execute_standard_deploy('deploy:rollback') if action.blank? && @name == 'deploy'
end
|
#filtered_env_keys ⇒ Object
17
18
19
|
# File 'lib/capistrano_multiconfig_parallel/classes/job_command.rb', line 17
def filtered_env_keys
%w(STAGES ACTION)
end
|
#gitflow ⇒ Object
25
26
27
28
|
# File 'lib/capistrano_multiconfig_parallel/classes/job_command.rb', line 25
def gitflow
gitflow = `#{command_prefix} && #{bundle_gemfile_env} bundle show capistrano-gitflow`
@gitflow ||= gitflow.include?('Could not find') ? false : true
end
|
#job_path ⇒ Object
71
72
73
|
# File 'lib/capistrano_multiconfig_parallel/classes/job_command.rb', line 71
def job_path
path || detect_root
end
|
#job_stage ⇒ Object
30
31
32
|
# File 'lib/capistrano_multiconfig_parallel/classes/job_command.rb', line 30
def job_stage
multi_apps?(job_path) && app.present? ? "#{app}:#{stage}" : "#{stage}"
end
|
#legacy_capistrano? ⇒ Boolean
67
68
69
|
# File 'lib/capistrano_multiconfig_parallel/classes/job_command.rb', line 67
def legacy_capistrano?
verify_gem_version(job_capistrano_version, '3.0', operator: '<')
end
|
#setup_command_line(*args) ⇒ Object
57
58
59
60
|
# File 'lib/capistrano_multiconfig_parallel/classes/job_command.rb', line 57
def setup_command_line(*args)
new_arguments, options = setup_command_line_standard(*args)
setup_env_options(options).concat(new_arguments)
end
|
#setup_env_options(options = {}) ⇒ Object
43
44
45
46
47
48
49
50
|
# File 'lib/capistrano_multiconfig_parallel/classes/job_command.rb', line 43
def setup_env_options(options = {})
array_options = []
filtered_keys = options.delete(:filtered_keys) || []
env_options.each do |key, value|
array_options << "#{env_prefix(key, @legacy_capistrano)} #{env_key_format(key, @legacy_capistrano)}=#{value}" if value.present? && !env_option_filtered?(key, filtered_keys)
end
setup_remaining_flags(array_options, options)
end
|
#setup_remaining_flags(array_options, options) ⇒ Object
52
53
54
55
|
# File 'lib/capistrano_multiconfig_parallel/classes/job_command.rb', line 52
def setup_remaining_flags(array_options, options)
array_options << trace_flag(@legacy_capistrano) if app_debug_enabled?
array_options.concat(setup_flags_for_job(options))
end
|
#to_json ⇒ Object
86
87
88
|
# File 'lib/capistrano_multiconfig_parallel/classes/job_command.rb', line 86
def to_json
{ command: to_s }
end
|
#to_s ⇒ Object
80
81
82
83
84
|
# File 'lib/capistrano_multiconfig_parallel/classes/job_command.rb', line 80
def to_s
config_flags = CapistranoMulticonfigParallel.configuration_flags
environment_options = setup_command_line(config_flags).join(' ')
"#{command_prefix} && #{bundle_gemfile_env} RAILS_ENV=#{stage} bundle exec multi_cap #{job_stage} #{capistrano_action} #{environment_options}"
end
|