Class: Sprinkle::Actors::Capistrano

Inherits:
Object
  • Object
show all
Defined in:
lib/sprinkle/actors/capistrano.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(&block) ⇒ Capistrano



8
9
10
11
12
13
14
15
16
17
# File 'lib/sprinkle/actors/capistrano.rb', line 8

def initialize(&block)
  @config = ::Capistrano::Configuration.new
  @config.logger.level = Sprinkle::OPTIONS[:verbose] ? ::Capistrano::Logger::INFO : ::Capistrano::Logger::IMPORTANT
  @config.set(:password) { ::Capistrano::CLI.password_prompt }
  if block
    self.instance_eval &block
  else
    @config.load 'deploy' # normally in the config directory for rails
  end
end

Instance Attribute Details

#configObject

Returns the value of attribute config.



6
7
8
# File 'lib/sprinkle/actors/capistrano.rb', line 6

def config
  @config
end

#loaded_recipesObject

Returns the value of attribute loaded_recipes.



6
7
8
# File 'lib/sprinkle/actors/capistrano.rb', line 6

def loaded_recipes
  @loaded_recipes
end

Instance Method Details

#process(name, commands, roles) ⇒ Object



25
26
27
28
29
30
31
32
33
# File 'lib/sprinkle/actors/capistrano.rb', line 25

def process(name, commands, roles)
  define_task(name, roles) do
    via = fetch(:run_method, :sudo)
    commands.each do |command|
      invoke_command command, :via => via
    end
  end
  run(name)
end

#recipes(script) ⇒ Object



19
20
21
22
23
# File 'lib/sprinkle/actors/capistrano.rb', line 19

def recipes(script)
  @loaded_recipes ||= []
  @config.load script
  @loaded_recipes << script
end