Class: Sprinkle::Actors::Capistrano
- Defined in:
- lib/sprinkle/actors/capistrano.rb
Overview
Capistrano Delivery Method
Capistrano is one of the delivery method options available out of the box with Sprinkle. If you have the capistrano gem install, you may use this delivery. The only configuration option available, and which is mandatory to include is recipes
. An example:
deployment do
delivery :capistrano do
recipes 'deploy'
end
end
Recipes is given a list of files which capistrano will include and load. These recipes are mainly to set variables such as :user, :password, and to set the app domain which will be sprinkled.
Instance Attribute Summary collapse
-
#config ⇒ Object
:nodoc:.
-
#loaded_recipes ⇒ Object
:nodoc:.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(&block) ⇒ Capistrano
constructor
:nodoc:.
-
#process(name, commands, roles, suppress_and_return_failures = false) ⇒ Object
:nodoc:.
-
#recipes(script) ⇒ Object
Defines a recipe file which will be included by capistrano.
- #transfer(name, source, destination, roles, recursive = true, suppress_and_return_failures = false) ⇒ Object
Constructor Details
#initialize(&block) ⇒ Capistrano
:nodoc:
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/sprinkle/actors/capistrano.rb', line 24 def initialize(&block) #:nodoc: @config = ::Capistrano::Configuration.new @config.logger.level = Sprinkle::OPTIONS[:verbose] ? ::Capistrano::Logger::INFO : ::Capistrano::Logger::IMPORTANT @config.set(:password) { ::Capistrano::CLI.password_prompt } @config.set(:_sprinkle_actor, self) def @config.recipes(script) _sprinkle_actor.recipes(script) end if block @config.instance_eval &block else @config.load 'deploy' # normally in the config directory for rails end end |
Instance Attribute Details
#config ⇒ Object
:nodoc:
22 23 24 |
# File 'lib/sprinkle/actors/capistrano.rb', line 22 def config @config end |
#loaded_recipes ⇒ Object
:nodoc:
22 23 24 |
# File 'lib/sprinkle/actors/capistrano.rb', line 22 def loaded_recipes @loaded_recipes end |
Class Method Details
.recipes(script) ⇒ Object
31 32 33 |
# File 'lib/sprinkle/actors/capistrano.rb', line 31 def @config.recipes(script) _sprinkle_actor.recipes(script) end |
Instance Method Details
#process(name, commands, roles, suppress_and_return_failures = false) ⇒ Object
:nodoc:
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/sprinkle/actors/capistrano.rb', line 60 def process(name, commands, roles, suppress_and_return_failures = false) #:nodoc: define_task(name, roles) do via = fetch(:run_method, :sudo) commands.each do |command| invoke_command command, :via => via end end begin run(name) return true rescue ::Capistrano::CommandError => e return false if suppress_and_return_failures # Reraise error if we're not suppressing it raise end end |
#recipes(script) ⇒ Object
Defines a recipe file which will be included by capistrano. Use these recipe files to set capistrano specific configurations. Default recipe included is “deploy.” But if any other recipe is specified, it will include that instead. Multiple recipes may be specified through multiple recipes calls, an example:
deployment do
delivery :capistrano do
recipes 'deploy'
recipes 'magic_beans'
end
end
54 55 56 57 58 |
# File 'lib/sprinkle/actors/capistrano.rb', line 54 def recipes(script) @loaded_recipes ||= [] @config.load script @loaded_recipes << script end |
#transfer(name, source, destination, roles, recursive = true, suppress_and_return_failures = false) ⇒ Object
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/sprinkle/actors/capistrano.rb', line 79 def transfer(name, source, destination, roles, recursive = true, suppress_and_return_failures = false) define_task(name, roles) do upload source, destination, :via => :scp, :recursive => recursive end begin run(name) return true rescue ::Capistrano::CommandError => e return false if suppress_and_return_failures # Reraise error if we're not suppressing it raise end end |