Class: Stackup::YAML::CloudFormationToRuby

Inherits:
Psych::Visitors::ToRuby
  • Object
show all
Defined in:
lib/stackup/yaml.rb

Overview

Custom Psych node visitor, with CloudFormation extensions.

Instance Method Summary collapse

Instance Method Details

#accept(target) ⇒ Object



53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/stackup/yaml.rb', line 53

def accept(target)
  case target.tag
  when "!Ref"
    { "Ref" => super }
  when "!GetAtt"
    { "Fn::GetAtt" => array_or_dotted_string(super) }
  when "!GetAZs"
    { "Fn::GetAZs" => (super || "") }
  when /^!(\w+)$/
    { "Fn::#{Regexp.last_match(1)}" => super }
  else
    super
  end
end

#array_or_dotted_string(arg) ⇒ Object



68
69
70
71
72
73
74
# File 'lib/stackup/yaml.rb', line 68

def array_or_dotted_string(arg)
  if arg.respond_to?(:split)
    arg.split(".", 2)
  else
    arg
  end
end