Class: CapistranoMulticonfigParallel::JobCommand

Inherits:
Object
  • Object
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

Methods included from ApplicationHelper

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

Methods included from CapistranoHelper

env_key_format, env_prefix, filtered_env_keys_format, trace_flag

Methods included from GemHelper

fetch_gem_version, find_loaded_gem, find_loaded_gem_property, get_parsed_version, verify_gem_version

Methods included from StagesHelper

check_stage_path, checks_paths, fetch_stages_paths, sorted_paths, stages, stages_paths

Methods included from ParseHelper

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

Methods included from InternalHelper

arg_is_in_default_config?, check_file, config_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_capfile

Constructor Details

#initialize(job) ⇒ JobCommand

Returns a new instance of JobCommand.



12
13
14
# File 'lib/capistrano_multiconfig_parallel/classes/job_command.rb', line 12

def initialize(job)
  @job = job
end

Instance Attribute Details

#jobObject (readonly)

Returns the value of attribute job.



9
10
11
# File 'lib/capistrano_multiconfig_parallel/classes/job_command.rb', line 9

def job
  @job
end

Instance Method Details

#capistrano_actionObject



24
25
26
27
# File 'lib/capistrano_multiconfig_parallel/classes/job_command.rb', line 24

def capistrano_action
  argv = task_arguments.present? ? "[#{task_arguments}]" : ''
  "#{action}#{argv}"
end

#env_option_filtered?(key, filtered_keys_array = []) ⇒ Boolean

Returns:

  • (Boolean)


29
30
31
# File 'lib/capistrano_multiconfig_parallel/classes/job_command.rb', line 29

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



57
58
59
60
61
62
# File 'lib/capistrano_multiconfig_parallel/classes/job_command.rb', line 57

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_keysObject



16
17
18
# File 'lib/capistrano_multiconfig_parallel/classes/job_command.rb', line 16

def filtered_env_keys
  filtered_env_keys_format(%w(STAGES ACTION))
end

#job_stageObject



20
21
22
# File 'lib/capistrano_multiconfig_parallel/classes/job_command.rb', line 20

def job_stage
  app.present? ? "#{app}:#{stage}" : "#{stage}"
end

#setup_command_line(*args) ⇒ Object



42
43
44
45
# File 'lib/capistrano_multiconfig_parallel/classes/job_command.rb', line 42

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



33
34
35
36
37
38
39
40
# File 'lib/capistrano_multiconfig_parallel/classes/job_command.rb', line 33

def setup_env_options(options = {})
  array_options = []
  env_options.each do |key, value|
    array_options << "#{env_prefix} #{env_key_format(key)}=#{value}" if value.present? && !env_option_filtered?(key, options.fetch(:filtered_keys, []))
  end
  array_options << trace_flag if app_debug_enabled?
  array_options
end

#to_jsonObject



53
54
55
# File 'lib/capistrano_multiconfig_parallel/classes/job_command.rb', line 53

def to_json
  { command: to_s }
end

#to_sObject



47
48
49
50
51
# File 'lib/capistrano_multiconfig_parallel/classes/job_command.rb', line 47

def to_s
  configuration_options = CapistranoMulticonfigParallel.original_args.select { |arg| arg.include?('--') }
  environment_options = setup_command_line(configuration_options).join(' ')
  "cd #{detect_root} && RAILS_ENV=#{stage}  bundle exec multi_cap #{job_stage} #{capistrano_action}  #{environment_options}"
end