Class: CapConfig

Inherits:
Object
  • Object
show all
Defined in:
lib/xnlogic/server_profile.rb

Overview

Captures Capistrano-relevant configuration from a server profile.

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.rolesObject (readonly)

Returns the value of attribute roles.



80
81
82
# File 'lib/xnlogic/server_profile.rb', line 80

def roles
  @roles
end

.variablesObject (readonly)

Returns the value of attribute variables.



80
81
82
# File 'lib/xnlogic/server_profile.rb', line 80

def variables
  @variables
end

Class Method Details

.api_hostname(hn) ⇒ Object



105
106
107
# File 'lib/xnlogic/server_profile.rb', line 105

def api_hostname(hn)
  @variables[:api_hostname] = hn
end

.apply_cap_config(config_binding) ⇒ Object Also known as: apply_config

config_binding is the binding taken from the Capistrano configuration file



89
90
91
92
93
94
95
96
# File 'lib/xnlogic/server_profile.rb', line 89

def apply_cap_config(config_binding)
  roles.each do |role, user|
    config_binding.eval("role #{role.inspect}, #{user.inspect}")
  end
  variables.each do |name, val|
    config_binding.eval("set #{name.inspect}, #{val.inspect}")
  end
end

.configure(&config_block) ⇒ Object



82
83
84
85
86
# File 'lib/xnlogic/server_profile.rb', line 82

def configure(&config_block)
  @roles = {}
  @variables = {}
  instance_eval &config_block
end

.hostname(hn) ⇒ Object

Setters



101
102
103
# File 'lib/xnlogic/server_profile.rb', line 101

def hostname(hn)
  @roles[:web] = hn
end

.method_missing(symbol, *args) ⇒ Object



113
114
115
# File 'lib/xnlogic/server_profile.rb', line 113

def method_missing(symbol, *args)
  # Swallow config settings we don't care about
end

.user(u) ⇒ Object



109
110
111
# File 'lib/xnlogic/server_profile.rb', line 109

def user(u)
  @variables[:user] = u
end