Class: Aws::Cfn::Yats::Yaml2Json
- Defined in:
- lib/aws/cfn/yats/yaml2json.rb
Instance Attribute Summary collapse
-
#yaml ⇒ Object
Returns the value of attribute yaml.
Instance Method Summary collapse
- #pprint_cfn_resource(name, options) ⇒ Object
- #pprint_cfn_section(section, name, options) ⇒ Object
- #pprint_cfn_template(tpl) ⇒ Object
- #pprint_value(val, indent = "\t") ⇒ Object
- #transform(template) ⇒ Object
Instance Attribute Details
#yaml ⇒ Object
Returns the value of attribute yaml.
10 11 12 |
# File 'lib/aws/cfn/yats/yaml2json.rb', line 10 def yaml @yaml end |
Instance Method Details
#pprint_cfn_resource(name, options) ⇒ Object
27 28 29 |
# File 'lib/aws/cfn/yats/yaml2json.rb', line 27 def pprint_cfn_resource(name, ) pprint_value({ name => }) end |
#pprint_cfn_section(section, name, options) ⇒ Object
23 24 25 |
# File 'lib/aws/cfn/yats/yaml2json.rb', line 23 def pprint_cfn_section(section, name, ) pprint_value(section) end |
#pprint_cfn_template(tpl) ⇒ Object
19 20 21 |
# File 'lib/aws/cfn/yats/yaml2json.rb', line 19 def pprint_cfn_template(tpl) pprint_value(tpl) end |
#pprint_value(val, indent = "\t") ⇒ Object
31 32 33 34 35 36 37 38 39 40 |
# File 'lib/aws/cfn/yats/yaml2json.rb', line 31 def pprint_value(val, indent="\t") @json = JSON.pretty_generate(val, { :indent => indent, :space => ' ', :object_nl => "\n", :array_nl => "\n" } ) puts @json end |
#transform(template) ⇒ Object
12 13 14 15 16 17 |
# File 'lib/aws/cfn/yats/yaml2json.rb', line 12 def transform(template) @template = template @yaml = YAML.load(template) @simple = simplify(@yaml) pprint(@simple) end |