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.



5
6
7
# File 'lib/xnlogic/server_profile.rb', line 5

def roles
  @roles
end

.variablesObject (readonly)

Returns the value of attribute variables.



5
6
7
# File 'lib/xnlogic/server_profile.rb', line 5

def variables
  @variables
end

Class Method Details

.api_hostname(hn) ⇒ Object



25
26
27
# File 'lib/xnlogic/server_profile.rb', line 25

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

.apply_config(config_binding) ⇒ Object

config_binding is the binding taken from the Capistrano configuration file



14
15
16
17
# File 'lib/xnlogic/server_profile.rb', line 14

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

.configure(&config_block) ⇒ Object



7
8
9
10
11
# File 'lib/xnlogic/server_profile.rb', line 7

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

.hostname(hn) ⇒ Object

Setters



21
22
23
# File 'lib/xnlogic/server_profile.rb', line 21

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

.method_missing(symbol, *args) ⇒ Object



33
34
35
# File 'lib/xnlogic/server_profile.rb', line 33

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

.user(u) ⇒ Object



29
30
31
# File 'lib/xnlogic/server_profile.rb', line 29

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