Class: Pero::History::Attribute

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

Instance Method Summary collapse

Constructor Details

#initialize(specinfra, options) ⇒ Attribute

Returns a new instance of Attribute.



23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/pero/history.rb', line 23

def initialize(specinfra, options)
  name = if options["node-name"].nil? || options["node-name"].empty?
           specinfra.run_command("hostname").stdout.chomp
         else
           options["node-name"]
         end
  options.delete("noop")
  options.delete("tags")
  options.delete("user")
  @h = {
    name: name,
    last_options: options
  }
end

Instance Method Details

#save(dir = "nodes") ⇒ Object



38
39
40
41
# File 'lib/pero/history.rb', line 38

def save(dir="nodes")
  FileUtils.mkdir_p(dir)
  File.write("#{File.join(dir, @h[:name])}.json", @h.to_json)
end