Class: Capistrano::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/capistrano/configuration.rb,
lib/capistrano/configuration/server.rb,
lib/capistrano/configuration/servers.rb,
lib/capistrano/configuration/question.rb,
lib/capistrano/configuration/servers/host_filter.rb,
lib/capistrano/configuration/servers/role_filter.rb

Defined Under Namespace

Classes: Question, Server, Servers

Instance Attribute Summary (collapse)

Class Method Summary (collapse)

Instance Method Summary (collapse)

Instance Attribute Details

- (Object) backend



63
64
65
# File 'lib/capistrano/configuration.rb', line 63

def backend
  @backend ||= SSHKit
end

Class Method Details

+ (Object) env



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

def env
  @env ||= new
end

+ (Object) reset!



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

def reset!
  @env = new
end

Instance Method Details

- (Object) ask(key, default = nil, options = {})



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

def ask(key, default=nil, options={})
  question = Question.new(self, key, default, options)
  set(key, question)
end

- (Object) configure_backend



69
70
71
72
73
74
75
76
77
78
79
80
81
# File 'lib/capistrano/configuration.rb', line 69

def configure_backend
  backend.configure do |sshkit|
    sshkit.format           = fetch(:format)
    sshkit.output_verbosity = fetch(:log_level)
    sshkit.default_env      = fetch(:default_env)
    sshkit.backend          = fetch(:sshkit_backend, SSHKit::Backend::Netssh)
    sshkit.backend.configure do |backend|
      backend.pty                = fetch(:pty)
      backend.connection_timeout = fetch(:connection_timeout)
      backend.ssh_options        = fetch(:ssh_options) if fetch(:ssh_options)
    end
  end
end

- (Object) delete(key)



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

def delete(key)
  config.delete(key)
end

- (Object) fetch(key, default = nil, &block)



31
32
33
34
35
36
37
# File 'lib/capistrano/configuration.rb', line 31

def fetch(key, default=nil, &block)
  value = fetch_for(key, default, &block)
  while callable_without_parameters?(value)
    value = set(key, value.call)
  end
  return value
end

- (Object) keys



39
40
41
# File 'lib/capistrano/configuration.rb', line 39

def keys
  config.keys
end

- (Object) primary(role)



59
60
61
# File 'lib/capistrano/configuration.rb', line 59

def primary(role)
  servers.fetch_primary(role)
end

- (Object) role(name, hosts, options = {})



43
44
45
46
47
48
49
# File 'lib/capistrano/configuration.rb', line 43

def role(name, hosts, options={})
  if name == :all
    raise ArgumentError.new("#{name} reserved name for role. Please choose another name")
  end

  servers.add_role(name, hosts, options)
end

- (Object) roles_for(names)



55
56
57
# File 'lib/capistrano/configuration.rb', line 55

def roles_for(names)
  servers.roles_for(names)
end

- (Object) server(name, properties = {})



51
52
53
# File 'lib/capistrano/configuration.rb', line 51

def server(name, properties={})
  servers.add_host(name, properties)
end

- (Object) set(key, value)



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

def set(key, value)
  config[key] = value
end

- (Object) timestamp



83
84
85
# File 'lib/capistrano/configuration.rb', line 83

def timestamp
  @timestamp ||= Time.now.utc
end