Class: Gusteau::SSHConfig

Inherits:
Object
  • Object
show all
Defined in:
lib/gusteau/ssh_config.rb

Instance Method Summary collapse

Constructor Details

#initialize(nodes) ⇒ SSHConfig

Returns a new instance of SSHConfig.



6
7
8
9
10
11
12
13
14
# File 'lib/gusteau/ssh_config.rb', line 6

def initialize(nodes)
  @config = []

  nodes.sort.each do |name, node|
    if server = node.server
      @config << section(name, server)
    end
  end
end

Instance Method Details

#section(name, server) ⇒ Object



16
17
18
19
20
21
22
23
# File 'lib/gusteau/ssh_config.rb', line 16

def section(name, server)
  "Host \#{name}\n  HostName \#{server.host}\n  Port \#{server.port}\n  User \#{server.user}\n  eos\nend\n"

#to_sObject



25
26
27
28
29
30
31
32
# File 'lib/gusteau/ssh_config.rb', line 25

def to_s
  "# BEGIN GUSTEAU NODES\n\n\#{@config.join(\"\\n\")}\n# END GUSTEAU NODES\n  eos\nend\n"