class BBC::Cosmos::Tools::Types::BaseType

Public Class Methods

new(id, options, config) click to toggle source
# File lib/bbc/cosmos/tools/types/base_type.rb, line 9
def initialize(id, options, config)
  @id      = id
  @options = options
  @config  = config
end

Public Instance Methods

generate_data(to_json = false) click to toggle source
# File lib/bbc/cosmos/tools/types/base_type.rb, line 15
def generate_data(to_json = false)
  if valid_component_and_stack
    get_parameters.each do |key, value|
      if data.has_key?("Parameters") && data["Parameters"][key]
        data["Parameters"][key]["Default"] = value
      end
    end
    to_json ? JSON.pretty_generate(data) : data
  end
end

Protected Instance Methods

construct_file_path(type) click to toggle source
# File lib/bbc/cosmos/tools/types/base_type.rb, line 32
def construct_file_path(type)
  File.join(@config.base_path, "stacks", @id, "#{@options[:stack]}.#{type}")
end
data() click to toggle source
# File lib/bbc/cosmos/tools/types/base_type.rb, line 28
def data
  fail NotImplementedError
end

Private Instance Methods

get_parameters() click to toggle source
# File lib/bbc/cosmos/tools/types/base_type.rb, line 43
def get_parameters
  @config.resources["cloudformation"]["components"][@id][@options[:stack]]["variants"][@options[:variant]] || []
end
valid_component_and_stack() click to toggle source
# File lib/bbc/cosmos/tools/types/base_type.rb, line 38
def valid_component_and_stack
  Tools::Cloudformation::Generator.component_exists?(@id, @config) &&
    Tools::Cloudformation::Generator.stack_exists?(@id, @config, @options[:stack])
end