Class: Capistrano::Configuration::Servers

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/capistrano/configuration/servers.rb

Instance Method Summary collapse

Instance Method Details

#add_host(host, properties = {}) ⇒ Object



10
11
12
# File 'lib/capistrano/configuration/servers.rb', line 10

def add_host(host, properties={})
  servers.add server(host).with(properties)
end

#add_role(role, hosts, options = {}) ⇒ Object



14
15
16
17
# File 'lib/capistrano/configuration/servers.rb', line 14

def add_role(role, hosts, options={})
  options_deepcopy = Marshal.dump(options.merge(roles: role))
  Array(hosts).each { |host| add_host(host, Marshal.load(options_deepcopy)) }
end

#eachObject



30
31
32
# File 'lib/capistrano/configuration/servers.rb', line 30

def each
  servers.each { |server| yield server }
end

#fetch_primary(role) ⇒ Object



25
26
27
28
# File 'lib/capistrano/configuration/servers.rb', line 25

def fetch_primary(role)
  hosts = roles_for([role])
  hosts.find(&:primary) || hosts.first
end

#roles_for(names) ⇒ Object



19
20
21
22
23
# File 'lib/capistrano/configuration/servers.rb', line 19

def roles_for(names)
  options = extract_options(names)
  s = Filter.new(:role, names).filter(servers)
  s.select { |server| server.select?(options) }
end