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(options = {}) ⇒ 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 40 |
# File 'lib/capistrano/cli/execute.rb', line 23 def execute! config = instantiate_configuration() config.debug = [:debug] config.dry_run = [:dry_run] config.preserve_roles = [:preserve_roles] 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
42 43 44 45 46 47 48 |
# File 'lib/capistrano/cli/execute.rb', line 42 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:
74 75 76 77 78 79 80 81 82 |
# File 'lib/capistrano/cli/execute.rb', line 74 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(options = {}) ⇒ Object
Primarily useful for testing, but subclasses of CLI could conceivably override this method to return a Configuration subclass or replacement.
70 71 72 |
# File 'lib/capistrano/cli/execute.rb', line 70 def instantiate_configuration(={}) #:nodoc: Capistrano::Configuration.new() end |
#load_recipes(config) ⇒ Object
:nodoc:
55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/capistrano/cli/execute.rb', line 55 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:
50 51 52 53 |
# File 'lib/capistrano/cli/execute.rb', line 50 def set_pre_vars(config) #:nodoc: config.set :password, [:password] Array([:pre_vars]).each { |name, value| config.set(name, value) } end |