class TddDeploy::Capfile

TddDeploy::Capfile - interface to capistrano capfile

uses Capistrano to parse recipe file(s) and provides convenient access to server definitions

Public Class Methods

new() click to toggle source

creates a Capfile::Configuration object to use, but does not read any Capistrano Recipe files

# File lib/tdd_deploy/capfile.rb, line 10
def initialize
  @capfile_config = Capistrano::Configuration.new
end

Public Instance Methods

load_recipes(path = './config/deploy.rb') click to toggle source

loads the specified recipie file. Defaults to './config/deploy.rb' which is standard for rails apps. May be called multiple times

# File lib/tdd_deploy/capfile.rb, line 36
def load_recipes(path = './config/deploy.rb')
  @capfile_config.load path
rescue LoadError => e
  msg = "Unable to load capistrano config file: #{path} - #{e}"
  raise LoadError.new msg
end
migration_host_list() click to toggle source

returns list of host strings which are in the 'db' role and for which 'primary' is true

# File lib/tdd_deploy/capfile.rb, line 25
def migration_host_list
  servers(:db).select { |srv| srv.options[:primary] == true }.map { |x| x.to_s }
end
role_to_host_list(role) click to toggle source

returns list of host strings defined for specified 'role'

# File lib/tdd_deploy/capfile.rb, line 20
def role_to_host_list role
  servers(role).map { |srv| srv.to_s }
end
roles() click to toggle source

returns the Capistrano::Configuration::Roles object

# File lib/tdd_deploy/capfile.rb, line 15
def roles
  @capfile_config.roles
end
servers(role) click to toggle source

returns the array of Capistrano::ServerDefinition objects defined for 'role'

# File lib/tdd_deploy/capfile.rb, line 30
def servers role
  @capfile_config.roles[role].servers
end