Sha256: 157a6522af7c76b0b5c525041bbb29d0debfaea5e127a2828896a0e9b4298d85

Contents?: true

Size: 642 Bytes

Versions: 1

Compression:

Stored size: 642 Bytes

Contents

require 'yaml'

module  Cfnlego
  class Resource
    attr_reader :type, :name

    def initialize(type, name)
      @type = type
      @name = name 
    end

    def attributes
      definition["AWS::#{@type}"]["Attributes"]
    end

    def properties
      definition["AWS::#{@type}"]['Properties']
    end

    private

    # example AutoScaling::AutoScalingGroup
    def type2file
      @file ||= "#{File.dirname(__FILE__)}/resources/#{@type.gsub(/::/, "/")}.yaml"
    end

    def definition
      @definition ||= YAML.load_file(type2file)
    rescue
      $stderr.puts "unknown #{@type}, no matching definition found"
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
cfnlego-0.0.1 lib/cfnlego/resource.rb