Sha256: e35f6ee029360f04e2bbdfd09c6677e75a2aa6527ad148ae0c478743506d2f08

Contents?: true

Size: 1.16 KB

Versions: 104

Compression:

Stored size: 1.16 KB

Contents

# Implements:
#
#   template - uses @definition to build a CloudFormation template section
#
class Jets::Stack
  class Output
    autoload :Dsl, "jets/stack/output/dsl"
    autoload :Lookup, "jets/stack/output/lookup"

    include Definition

    def template
      camelize(standarize(@definition))
    end

    # Value is the only required property: https://amzn.to/2xbhmk3
    def standarize(definition)
      first, second, _ = definition
      if definition.size == 1 && first.is_a?(Hash) # long form
        first # pass through
      elsif definition.size == 2 && second.is_a?(Hash) # medium form
        logical_id, properties = first, second
        { logical_id => properties }
      elsif definition.size == 2 && second.is_a?(String) # short form
        logical_id = first
        properties = second.is_a?(String) ? { value: second } : {}
        { logical_id => properties }
      elsif definition.size == 1
        logical_id = first.to_s
        properties = {value: "!Ref #{logical_id.camelize}"}
        { logical_id => properties }
      else # I dont know what form
        raise "Invalid form provided. definition #{definition.inspect}"
      end
    end
  end
end

Version data entries

104 entries across 104 versions & 2 rubygems

Version Path
jets-1.9.7 lib/jets/stack/output.rb
jets-1.9.6 lib/jets/stack/output.rb
jets-1.9.5 lib/jets/stack/output.rb
jets-1.9.4 lib/jets/stack/output.rb
jets-1.9.3 lib/jets/stack/output.rb
jets-1.9.2 lib/jets/stack/output.rb
jets-1.9.1 lib/jets/stack/output.rb
jets-1.9.0 lib/jets/stack/output.rb
jets-1.8.14 lib/jets/stack/output.rb
jets-1.8.13 lib/jets/stack/output.rb
jets-1.8.12 lib/jets/stack/output.rb
jets-1.8.11 lib/jets/stack/output.rb
jets-1.8.10 lib/jets/stack/output.rb
jets-1.8.9 lib/jets/stack/output.rb
jets-1.8.8 lib/jets/stack/output.rb
jets-1.8.7 lib/jets/stack/output.rb
jets-1.8.6 lib/jets/stack/output.rb
jets-1.8.5 lib/jets/stack/output.rb
jets-1.8.4 lib/jets/stack/output.rb
jets-1.8.3 lib/jets/stack/output.rb