Module: Capistrano::CLI::Execute
- Included in:
- Capistrano::CLI
- Defined in:
- lib/capistrano/cli/execute.rb
Defined Under Namespace
Modules: ClassMethods
Class Method Summary collapse
-
.included(base) ⇒ Object
:nodoc:.
Instance Method Summary collapse
-
#execute! ⇒ Object
Using the options build when the command-line was parsed, instantiate a new Capistrano configuration, initialize it, and execute the requested actions.
- #execute_requested_actions(config) ⇒ Object
-
#handle_error(error) ⇒ Object
:nodoc:.
-
#instantiate_configuration ⇒ Object
Primarily useful for testing, but subclasses of CLI could conceivably override this method to return a Configuration subclass or replacement.
-
#load_recipes(config) ⇒ Object
:nodoc:.
-
#set_pre_vars(config) ⇒ Object
:nodoc:.
Class Method Details
.included(base) ⇒ Object
:nodoc:
6 7 8 |
# File 'lib/capistrano/cli/execute.rb', line 6 def self.included(base) #:nodoc: base.extend(ClassMethods) end |
Instance Method Details
#execute! ⇒ Object
Using the options build when the command-line was parsed, instantiate a new Capistrano configuration, initialize it, and execute the requested actions.
Returns the Configuration instance used, if successful.
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/capistrano/cli/execute.rb', line 23 def execute! config = instantiate_configuration config.debug = [:debug] config.dry_run = [:dry_run] config.logger.level = [:verbose] set_pre_vars(config) load_recipes(config) config.trigger(:load) execute_requested_actions(config) config.trigger(:exit) config rescue Exception => error handle_error(error) end |
#execute_requested_actions(config) ⇒ Object
41 42 43 44 45 46 47 |
# File 'lib/capistrano/cli/execute.rb', line 41 def execute_requested_actions(config) Array([:vars]).each { |name, value| config.set(name, value) } Array([:actions]).each do |action| config.find_and_execute_task(action, :before => :start, :after => :finish) end end |
#handle_error(error) ⇒ Object
:nodoc:
73 74 75 76 77 78 79 80 81 |
# File 'lib/capistrano/cli/execute.rb', line 73 def handle_error(error) #:nodoc: case error when Net::SSH::AuthenticationFailed abort "authentication failed for `#{error.}'" when Capistrano::Error abort(error.) else raise error end end |
#instantiate_configuration ⇒ Object
Primarily useful for testing, but subclasses of CLI could conceivably override this method to return a Configuration subclass or replacement.
69 70 71 |
# File 'lib/capistrano/cli/execute.rb', line 69 def instantiate_configuration #:nodoc: Capistrano::Configuration.new end |
#load_recipes(config) ⇒ Object
:nodoc:
54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/capistrano/cli/execute.rb', line 54 def load_recipes(config) #:nodoc: # load the standard recipe definition config.load "standard" # load systemwide config/recipe definition config.load([:sysconf]) if [:sysconf] && File.file?([:sysconf]) # load user config/recipe definition config.load([:dotfile]) if [:dotfile] && File.file?([:dotfile]) Array([:recipes]).each { |recipe| config.load(recipe) } end |
#set_pre_vars(config) ⇒ Object
:nodoc:
49 50 51 52 |
# File 'lib/capistrano/cli/execute.rb', line 49 def set_pre_vars(config) #:nodoc: config.set :password, [:password] Array([:pre_vars]).each { |name, value| config.set(name, value) } end |