Class: Capistrano::Configuration::Servers

### Home Classes Methods

### In Files

- lib/capistrano/configuration/servers.rb

### Parent

Object

### Methods

- #add_host
- #add_role
- #each
- #fetch_primary
- #role_properties_for
- #roles_for

### Included Modules

- Enumerable

### Files

- Capfile
- Capfile

### Class/Module Index

Quicksearch

- Capistrano
- Capistrano::Application
- Capistrano::Configuration
- Capistrano::Configuration::Filter
- Capistrano::Configuration::Question
- Capistrano::Configuration::Server
- Capistrano::Configuration::Server::Properties
- Capistrano::Configuration::Servers
- Capistrano::DSL
- Capistrano::DSL::Env
- Capistrano::DSL::Paths
- Capistrano::DSL::Stages
- Capistrano::Git
- Capistrano::Git::DefaultStrategy
- Capistrano::Hg
- Capistrano::Hg::DefaultStrategy
- Capistrano::SCM
- Capistrano::Svn
- Capistrano::Svn::DefaultStrategy
- Capistrano::TaskEnhancements
- Capistrano::UploadTask
- Capistrano::VersionValidator
- Object

No matching classes.

# Capistrano::Configuration::Servers

### Public Instance Methods

add_host(host, properties={}) click to toggle source

    # File lib/capistrano/configuration/servers.rb, line 10
    def add_host(host, properties={})
      new_host = Server[host]
      if server = servers.find { |s| s.matches? new_host }
        server.user = new_host.user if new_host.user
        server.port = new_host.port if new_host.port
        server.with(properties)
      else
        servers << new_host.with(properties)
      end
    end

add_role(role, hosts, options={}) click to toggle source

    # File lib/capistrano/configuration/servers.rb, line 21
    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

each() click to toggle source

    # File lib/capistrano/configuration/servers.rb, line 54
    def each
      servers.each { |server| yield server }
    end

fetch_primary(role) click to toggle source

    # File lib/capistrano/configuration/servers.rb, line 49
    def fetch_primary(role)
      hosts = roles_for([role])
      hosts.find(&:primary) || hosts.first
    end

role_properties_for(rolenames) click to toggle source

    # File lib/capistrano/configuration/servers.rb, line 32
    def role_properties_for(rolenames)
      roles = rolenames.to_set
      rps = Set.new unless block_given?
      roles_for(rolenames).each do |host|
        host.roles.intersection(roles).each do |role|
          [host.properties.fetch(role)].flatten(1).each do |props|
            if block_given?
              yield host, role, props
            else
              rps << (props || {}).merge( role: role, hostname: host.hostname )
            end
          end
        end
      end
      block_given? ? nil: rps
    end

roles_for(names) click to toggle source

    # File lib/capistrano/configuration/servers.rb, line 26
    def roles_for(names)
      options = extract_options(names)
      s = Filter.new(:role, names).filter(servers)
      s.select { |server| server.select?(options) }
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.