Class: PackerFiles::Utils::Generator
- Inherits:
-
HashSerializer
- Object
- HashSerializer
- PackerFiles::Utils::Generator
- Defined in:
- lib/PackerFiles/Utils/Generator.rb
Overview
Generates the top level JSON file for Packer to operate upon.
Instance Method Summary collapse
-
#create_json(filename) ⇒ Object
Create the JSON file in the given directory.
-
#initialize ⇒ Generator
constructor
Constructor.
Methods inherited from HashSerializer
hash_attributes, hash_variable, #merge_hs, #to_hash
Constructor Details
#initialize ⇒ Generator
Constructor
17 18 19 20 21 |
# File 'lib/PackerFiles/Utils/Generator.rb', line 17 def initialize self.builders = Array.new self.variables = Hash.new self.provisioners = Array.new end |
Instance Method Details
#create_json(filename) ⇒ Object
Create the JSON file in the given directory
24 25 26 27 28 |
# File 'lib/PackerFiles/Utils/Generator.rb', line 24 def create_json(filename) hash = self.to_hash content = JSON.pretty_generate(hash) + "\n" File.write(filename, content) end |