Sha256: 52ca22eadbb9492f3f492c4abd3b70635cf934222cce893c63105461d1ad98de

Contents?: true

Size: 714 Bytes

Versions: 14

Compression:

Stored size: 714 Bytes

Contents

require 'yaml'

module  Cfnlego
  class Resource
    attr_reader :type, :name

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

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

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

    private

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

    def definition
      if File::exists?(type2file)
        @definition ||= YAML.load_file(type2file)
      else
        raise RuntimeError, "unknown #{@type}, no matching definition found"
      end
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
cfnlego-0.4.0 lib/cfnlego/resource.rb
cfnlego-0.3.6 lib/cfnlego/resource.rb
cfnlego-0.3.5 lib/cfnlego/resource.rb
cfnlego-0.3.4 lib/cfnlego/resource.rb
cfnlego-0.3.3 lib/cfnlego/resource.rb
cfnlego-0.3.2 lib/cfnlego/resource.rb
cfnlego-0.3.1 lib/cfnlego/resource.rb
cfnlego-0.3.0 lib/cfnlego/resource.rb
cfnlego-0.2.9 lib/cfnlego/resource.rb
cfnlego-0.2.8 lib/cfnlego/resource.rb
cfnlego-0.2.7 lib/cfnlego/resource.rb
cfnlego-0.2.6 lib/cfnlego/resource.rb
cfnlego-0.2.5 lib/cfnlego/resource.rb
cfnlego-0.2.4 lib/cfnlego/resource.rb