Class: Capistrano::Configuration::Server

Inherits:
SSHKit::Host
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/capistrano/configuration/server.rb

Defined Under Namespace

Classes: Properties, Selector

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.[](host) ⇒ Object



8
9
10
# File 'lib/capistrano/configuration/server.rb', line 8

def self.[](host)
  host.is_a?(Server) ? host : new(host)
end

Instance Method Details

#add_role(role) ⇒ Object



18
19
20
21
# File 'lib/capistrano/configuration/server.rb', line 18

def add_role(role)
  roles.add role.to_sym
  self
end

#add_roles(roles) ⇒ Object Also known as: roles=



12
13
14
15
# File 'lib/capistrano/configuration/server.rb', line 12

def add_roles(roles)
  Array(roles).each { |role| add_role(role) }
  self
end

#has_role?(role) ⇒ Boolean

Returns:

  • (Boolean)


23
24
25
# File 'lib/capistrano/configuration/server.rb', line 23

def has_role?(role)
  roles.include? role.to_sym
end

#matches?(other) ⇒ Boolean

Returns:

  • (Boolean)


53
54
55
# File 'lib/capistrano/configuration/server.rb', line 53

def matches?(other)
  user == other.user && hostname == other.hostname && port == other.port
end

#netssh_optionsObject



45
46
47
# File 'lib/capistrano/configuration/server.rb', line 45

def netssh_options
  @netssh_options ||= super.merge( fetch(:ssh_options) || {} )
end

#primaryObject



32
33
34
# File 'lib/capistrano/configuration/server.rb', line 32

def primary
  self if fetch(:primary)
end

#propertiesObject



41
42
43
# File 'lib/capistrano/configuration/server.rb', line 41

def properties
  @properties ||= Properties.new
end

#roles_arrayObject



49
50
51
# File 'lib/capistrano/configuration/server.rb', line 49

def roles_array
  roles.to_a
end

#select?(options) ⇒ Boolean

Returns:

  • (Boolean)


27
28
29
30
# File 'lib/capistrano/configuration/server.rb', line 27

def select?(options)
  selector = Selector.for(options)
  selector.call(self)
end

#with(properties) ⇒ Object



36
37
38
39
# File 'lib/capistrano/configuration/server.rb', line 36

def with(properties)
  properties.each { |key, value| add_property(key, value) }
  self
end