Class: Aws::Cfn::Yats::Yaml2Json

Inherits:
Base
  • Object
show all
Defined in:
lib/aws/cfn/yats/yaml2json.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#yamlObject

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, options)
  pprint_value({ name => options })
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, options)
  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