Class: CapistranoMulticonfigParallel::StandardDeploy

Inherits:
Object
  • Object
show all
Includes:
ApplicationHelper, FileUtils
Defined in:
lib/capistrano_multiconfig_parallel/classes/standard_deploy.rb

Overview

class used to find application dependencies

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from ApplicationHelper

parse_task_string, strip_characters_from_string

Methods included from StagesHelper

check_stage_path, checks_paths, fetch_stages, fetch_stages_paths, stages_paths

Methods included from CoreHelper

app_configuration, app_debug_enabled?, app_logger, ask_confirm, check_terminal_tty, debug_websocket?, execute_with_rescue, find_config_type, find_loaded_gem, find_worker_log, force_confirmation, format_error, log_error, log_to_file, rescue_error, rescue_interrupt, show_warning, websocket_config, websocket_server_config

Methods included from InternalHelper

config_file, custom_commands, default_internal_config, detect_root, enable_main_log_file, find_env_multi_cap_root, internal_config_directory, internal_config_file, log_directory, main_log_file, root, try_detect_capfile

Constructor Details

#initialize(options) ⇒ StandardDeploy

Returns a new instance of StandardDeploy.



10
11
12
13
14
15
16
17
# File 'lib/capistrano_multiconfig_parallel/classes/standard_deploy.rb', line 10

def initialize(options)
  @app = options.fetch('app', '')
  @stage = options.fetch('env', '')
  @action = options.fetch('action', '')
  @task_arguments = options.fetch('task_arguments:', [])
  @env_options = options.fetch('env_options', {})
  execute_standard_deploy
end

Instance Attribute Details

#action ⇒ Object (readonly)

Returns the value of attribute action.



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

def action
  @action
end

#app ⇒ Object (readonly)

Returns the value of attribute app.



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

def app
  @app
end

#env_options ⇒ Object (readonly)

Returns the value of attribute env_options.



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

def env_options
  @env_options
end

#stage ⇒ Object (readonly)

Returns the value of attribute stage.



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

def stage
  @stage
end

#task_arguments ⇒ Object (readonly)

Returns the value of attribute task_arguments.



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

def task_arguments
  @task_arguments
end

Instance Method Details

#build_capistrano_task(action = @action, env = {}) ⇒ Object



36
37
38
39
# File 'lib/capistrano_multiconfig_parallel/classes/standard_deploy.rb', line 36

def build_capistrano_task(action = @action, env = {})
  environment_options = setup_command_line_standard(@env_options.merge(env))
  "bundle exec cap #{job_stage} #{capistrano_action(action)}  #{environment_options} --trace"
end

#capistrano_action(action) ⇒ Object



23
24
25
26
# File 'lib/capistrano_multiconfig_parallel/classes/standard_deploy.rb', line 23

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

#execute_standard_deploy(action = @action) ⇒ Object



41
42
43
44
45
46
47
48
# File 'lib/capistrano_multiconfig_parallel/classes/standard_deploy.rb', line 41

def execute_standard_deploy(action = @action)
  command = build_capistrano_task(action)
  puts("\n\n\n Executing '#{command}' \n\n\n .")
  sh("#{command}")
rescue => ex
  log_error(ex)
  execute_standard_deploy('deploy:rollback') if action.blank? && @name == 'deploy'
end

#job_stage ⇒ Object



19
20
21
# File 'lib/capistrano_multiconfig_parallel/classes/standard_deploy.rb', line 19

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

#setup_command_line_standard(options) ⇒ Object



28
29
30
31
32
33
34
# File 'lib/capistrano_multiconfig_parallel/classes/standard_deploy.rb', line 28

def setup_command_line_standard(options)
  opts = ''
  options.each do |key, value|
    opts << "#{key}=#{value} " if value.present?
  end
  opts
end