Class: CapistranoMulticonfigParallel::BaseManager
- Inherits:
-
Object
- Object
- CapistranoMulticonfigParallel::BaseManager
- Includes:
- Celluloid, Celluloid::Logger
- Defined in:
- lib/capistrano_multiconfig_parallel/helpers/base_manager.rb
Overview
finds app dependencies, shows menu and delegates jobs to celluloid manager rubocop:disable ClassLength
Direct Known Subclasses
Instance Attribute Summary collapse
-
#application ⇒ Object
Returns the value of attribute application.
-
#args ⇒ Object
Returns the value of attribute args.
-
#argv ⇒ Object
Returns the value of attribute argv.
-
#condition ⇒ Object
Returns the value of attribute condition.
-
#default_stage ⇒ Object
Returns the value of attribute default_stage.
-
#deps ⇒ Object
Returns the value of attribute deps.
-
#job_registered_condition ⇒ Object
Returns the value of attribute job_registered_condition.
-
#jobs ⇒ Object
Returns the value of attribute jobs.
-
#manager ⇒ Object
Returns the value of attribute manager.
-
#name ⇒ Object
Returns the value of attribute name.
-
#stage ⇒ Object
Returns the value of attribute stage.
Instance Method Summary collapse
- #can_start? ⇒ Boolean
- #collect_jobs(options = {}, &block) ⇒ Object
- #custom_command? ⇒ Boolean
- #custom_commands ⇒ Object
- #deploy_app(options = {}) ⇒ Object
- #fetch_multi_stages ⇒ Object
-
#initialize(cap_app, top_level_tasks, stages) ⇒ BaseManager
constructor
A new instance of BaseManager.
- #multi_apps? ⇒ Boolean
- #process_jobs(&block) ⇒ Object
- #start(&block) ⇒ Object
Constructor Details
#initialize(cap_app, top_level_tasks, stages) ⇒ BaseManager
Returns a new instance of BaseManager.
11 12 13 14 15 16 17 18 |
# File 'lib/capistrano_multiconfig_parallel/helpers/base_manager.rb', line 11 def initialize(cap_app, top_level_tasks, stages) @cap_app = cap_app @top_level_tasks = top_level_tasks @stages = stages @jobs = [] CapistranoMulticonfigParallel.configuration_valid? CapistranoMulticonfigParallel.verify_app_dependencies(@stages) if CapistranoMulticonfigParallel.configuration.track_dependencies end |
Instance Attribute Details
#application ⇒ Object
Returns the value of attribute application.
9 10 11 |
# File 'lib/capistrano_multiconfig_parallel/helpers/base_manager.rb', line 9 def application @application end |
#args ⇒ Object
Returns the value of attribute args.
9 10 11 |
# File 'lib/capistrano_multiconfig_parallel/helpers/base_manager.rb', line 9 def args @args end |
#argv ⇒ Object
Returns the value of attribute argv.
9 10 11 |
# File 'lib/capistrano_multiconfig_parallel/helpers/base_manager.rb', line 9 def argv @argv end |
#condition ⇒ Object
Returns the value of attribute condition.
9 10 11 |
# File 'lib/capistrano_multiconfig_parallel/helpers/base_manager.rb', line 9 def condition @condition end |
#default_stage ⇒ Object
Returns the value of attribute default_stage.
9 10 11 |
# File 'lib/capistrano_multiconfig_parallel/helpers/base_manager.rb', line 9 def default_stage @default_stage end |
#deps ⇒ Object
Returns the value of attribute deps.
9 10 11 |
# File 'lib/capistrano_multiconfig_parallel/helpers/base_manager.rb', line 9 def deps @deps end |
#job_registered_condition ⇒ Object
Returns the value of attribute job_registered_condition.
9 10 11 |
# File 'lib/capistrano_multiconfig_parallel/helpers/base_manager.rb', line 9 def job_registered_condition @job_registered_condition end |
#jobs ⇒ Object
Returns the value of attribute jobs.
9 10 11 |
# File 'lib/capistrano_multiconfig_parallel/helpers/base_manager.rb', line 9 def jobs @jobs end |
#manager ⇒ Object
Returns the value of attribute manager.
9 10 11 |
# File 'lib/capistrano_multiconfig_parallel/helpers/base_manager.rb', line 9 def manager @manager end |
#name ⇒ Object
Returns the value of attribute name.
9 10 11 |
# File 'lib/capistrano_multiconfig_parallel/helpers/base_manager.rb', line 9 def name @name end |
#stage ⇒ Object
Returns the value of attribute stage.
9 10 11 |
# File 'lib/capistrano_multiconfig_parallel/helpers/base_manager.rb', line 9 def stage @stage end |
Instance Method Details
#can_start? ⇒ Boolean
20 21 22 |
# File 'lib/capistrano_multiconfig_parallel/helpers/base_manager.rb', line 20 def can_start? @top_level_tasks.size > 1 && (stages.include?(@top_level_tasks.first) || custom_command?) && ENV[CapistranoMulticonfigParallel::ENV_KEY_JOB_ID].blank? end |
#collect_jobs(options = {}, &block) ⇒ Object
47 48 49 50 51 52 |
# File 'lib/capistrano_multiconfig_parallel/helpers/base_manager.rb', line 47 def collect_jobs( = {}, &block) = () block.call() if block_given? rescue => e raise [e, e.backtrace].inspect end |
#custom_command? ⇒ Boolean
24 25 26 |
# File 'lib/capistrano_multiconfig_parallel/helpers/base_manager.rb', line 24 def custom_command? @top_level_tasks.first == 'ensure_stage' && !stages.include?(@top_level_tasks.second) && !stages.include?(@top_level_tasks.first) && custom_commands.values.include?(@top_level_tasks.second) end |
#custom_commands ⇒ Object
28 29 30 31 |
# File 'lib/capistrano_multiconfig_parallel/helpers/base_manager.rb', line 28 def custom_commands key = multi_apps? ? CapistranoMulticonfigParallel::MULTI_KEY : CapistranoMulticonfigParallel::SINGLE_KEY CapistranoMulticonfigParallel::CUSTOM_COMMANDS[key] end |
#deploy_app(options = {}) ⇒ Object
69 70 71 72 73 74 75 76 77 78 |
# File 'lib/capistrano_multiconfig_parallel/helpers/base_manager.rb', line 69 def deploy_app( = {}) = .stringify_keys app = ['app'].is_a?(Hash) ? ['app'] : { 'app' => ['app'] } branch = @branch_backup.present? ? @branch_backup : @argv['BRANCH'].to_s call_task_deploy_app({ branch: branch, app: app, action: ['action'] }.reverse_merge()) end |
#fetch_multi_stages ⇒ Object
63 64 65 66 67 |
# File 'lib/capistrano_multiconfig_parallel/helpers/base_manager.rb', line 63 def fetch_multi_stages stages = @argv['STAGES'].blank? ? '' : @argv['STAGES'] stages = parse_inputted_value(value: stages).split(',').compact if stages.present? stages end |
#multi_apps? ⇒ Boolean
33 34 35 |
# File 'lib/capistrano_multiconfig_parallel/helpers/base_manager.rb', line 33 def multi_apps? @cap_app.multi_apps? end |
#process_jobs(&block) ⇒ Object
54 55 56 57 58 59 60 61 |
# File 'lib/capistrano_multiconfig_parallel/helpers/base_manager.rb', line 54 def process_jobs(&block) return unless @jobs.present? if CapistranoMulticonfigParallel.execute_in_sequence @jobs.each { |job| CapistranoMulticonfigParallel::StandardDeploy.execute_standard_deploy(job) } else run_async_jobs(&block) end end |
#start(&block) ⇒ Object
37 38 39 40 41 42 43 44 45 |
# File 'lib/capistrano_multiconfig_parallel/helpers/base_manager.rb', line 37 def start(&block) @application = custom_command? ? nil : @top_level_tasks.first.split(':').reverse[1] @stage = custom_command? ? nil : @top_level_tasks.first.split(':').reverse[0] @name, @args = @cap_app.parse_task_string(@top_level_tasks.second) @argv = @cap_app..delete_if { |arg| arg == @stage || arg == @name || arg == @top_level_tasks.first } @argv = multi_fetch_argv(@argv) block.call if block_given? run end |