Class: TddDeploy::Capfile

Inherits:
Object
  • Object
show all
Defined in:
lib/tdd_deploy/capfile.rb

Overview

TddDeploy::Capfile - interface to capistrano capfile

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

Instance Method Summary collapse

Constructor Details

#initializeCapfile

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



10
11
12
# File 'lib/tdd_deploy/capfile.rb', line 10

def initialize
  @capfile_config = Capistrano::Configuration.new
end

Instance Method Details

#load_recipes(path = './config/deploy.rb') ⇒ Object

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



36
37
38
39
40
41
# 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_listObject

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



25
26
27
# 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) ⇒ Object

returns list of host strings defined for specified ‘role’



20
21
22
# File 'lib/tdd_deploy/capfile.rb', line 20

def role_to_host_list role
  servers(role).map { |srv| srv.to_s }
end

#rolesObject

returns the Capistrano::Configuration::Roles object



15
16
17
# File 'lib/tdd_deploy/capfile.rb', line 15

def roles
  @capfile_config.roles
end

#servers(role) ⇒ Object

returns the array of Capistrano::ServerDefinition objects defined for ‘role’



30
31
32
# File 'lib/tdd_deploy/capfile.rb', line 30

def servers role
  @capfile_config.roles[role].servers
end