Class: Assh::Generator

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(output_file = File.expand_path(Assh::GENERATED_CONFIG)) ⇒ Generator

Returns a new instance of Generator.



6
7
8
# File 'lib/generator.rb', line 6

def initialize(output_file = File.expand_path(Assh::GENERATED_CONFIG))
  @output_file = output_file
end

Instance Attribute Details

#output_fileObject

Returns the value of attribute output_file.



4
5
6
# File 'lib/generator.rb', line 4

def output_file
  @output_file
end

Instance Method Details

#run!(hosts) ⇒ Object



10
11
12
13
14
15
16
# File 'lib/generator.rb', line 10

def run!(hosts)
  File.open(@output_file, 'w') do |f|
    hosts.each do |_, host|
      f << host.to_ssh_config
    end
  end
end