Class: Huck::Generators::YamlGenerator
- Inherits:
-
Huck::Generator
- Object
- Huck::Generator
- Huck::Generators::YamlGenerator
- Defined in:
- lib/huck/generators/yaml.rb
Overview
YAML generator reads yaml files for data
Instance Attribute Summary
Attributes inherited from Huck::Generator
Instance Method Summary collapse
-
#generate ⇒ Object
Reads in a configured YAML file and returns the data.
-
#initialize ⇒ YamlGenerator
constructor
Load required modules for yaml generator.
-
#verify_config ⇒ Object
Ensure that all YAML config items are properly set.
Methods inherited from Huck::Generator
Constructor Details
#initialize ⇒ YamlGenerator
Load required modules for yaml generator
9 10 11 |
# File 'lib/huck/generators/yaml.rb', line 9 def initialize require 'yaml' end |
Instance Method Details
#generate ⇒ Object
Reads in a configured YAML file and returns the data
Returns:
A hash of facts read from the YAML file
27 28 29 30 |
# File 'lib/huck/generators/yaml.rb', line 27 def generate verify_config YAML.load_file @config['yaml']['file'] end |
#verify_config ⇒ Object
Ensure that all YAML config items are properly set
14 15 16 17 18 19 20 21 |
# File 'lib/huck/generators/yaml.rb', line 14 def verify_config if !@config.has_key? 'yaml' raise RuntimeError, 'missing yaml config' end if !@config['yaml'].has_key? 'file' raise RuntimeError, 'missing yaml config: file' end end |