Class: Humidifier::Loader

Inherits:
Object
  • Object
show all
Defined in:
lib/humidifier/loader.rb

Overview

Reads the specs/CloudFormationResourceSpecification.json file and load each resource as a class

Defined Under Namespace

Classes: StructureContainer

Constant Summary collapse

SPECPATH =

The path to the specification file

File.expand_path(File.join('..', '..', '..', filename), __FILE__)

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.loadObject

convenience class method to build a new loader and call load



56
57
58
# File 'lib/humidifier/loader.rb', line 56

def self.load
  new.load
end

Instance Method Details

#loadObject

loop through the specs and register each class



44
45
46
47
48
49
50
51
52
53
# File 'lib/humidifier/loader.rb', line 44

def load
  parsed = JSON.parse(File.read(SPECPATH))
  structs = StructureContainer.new(parsed['PropertyTypes'])

  parsed['ResourceTypes'].each do |key, spec|
    match = key.match(/\A(\w+)::(\w+)::(\w+)\z/)

    register(match[1], match[2], match[3], spec, structs.search(key))
  end
end