Class: ExtendedYAML
- Inherits:
-
Object
- Object
- ExtendedYAML
- Defined in:
- lib/extended_yaml.rb,
lib/extended_yaml/version.rb,
lib/extended_yaml/deep_merge.rb
Defined Under Namespace
Modules: DeepMerge
Constant Summary collapse
- VERSION =
"0.1.0"
Instance Attribute Summary collapse
-
#file ⇒ Object
readonly
Returns the value of attribute file.
-
#key ⇒ Object
readonly
Returns the value of attribute key.
Class Method Summary collapse
-
.load(file, key: 'extends') ⇒ Hash, Array
The parsed YAML.
Instance Method Summary collapse
-
#evaluate ⇒ String
The YAML string, with evaluated and ERB.
-
#initialize(file, key: 'extends') ⇒ ExtendedYAML
constructor
A new instance of ExtendedYAML.
-
#result ⇒ Hash, Array
The parsed YAML.
Constructor Details
#initialize(file, key: 'extends') ⇒ ExtendedYAML
Returns a new instance of ExtendedYAML.
16 17 18 |
# File 'lib/extended_yaml.rb', line 16 def initialize(file, key: 'extends') @file, @key = file, key end |
Instance Attribute Details
#file ⇒ Object (readonly)
Returns the value of attribute file.
7 8 9 |
# File 'lib/extended_yaml.rb', line 7 def file @file end |
#key ⇒ Object (readonly)
Returns the value of attribute key.
7 8 9 |
# File 'lib/extended_yaml.rb', line 7 def key @key end |
Class Method Details
.load(file, key: 'extends') ⇒ Hash, Array
Returns the parsed YAML.
12 13 14 |
# File 'lib/extended_yaml.rb', line 12 def self.load(file, key: 'extends') new(file, key: key).result end |
Instance Method Details
#evaluate ⇒ String
Returns the YAML string, with evaluated and ERB.
27 28 29 |
# File 'lib/extended_yaml.rb', line 27 def evaluate ERB.new(File.read file).result end |
#result ⇒ Hash, Array
Returns the parsed YAML.
21 22 23 24 |
# File 'lib/extended_yaml.rb', line 21 def result data = ::YAML.load evaluate resolve_extends data end |