Module: GClouder::ConfigLoader
- Defined in:
- lib/gclouder/config_loader.rb
Class Method Summary collapse
Class Method Details
.load(path) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/gclouder/config_loader.rb', line 5 def self.load(path) data = DeepMergeHash.new file = File.join(File.dirname(__FILE__), path, "**/*.yml") configs = Dir.glob(file) configs.each do |config| yaml = YAML.load_file config section_path = to_path(config, path) hash = section_path.reverse.inject(yaml) { |value, key| { key => value } } data = data.deep_merge hash end data end |
.to_path(config, path) ⇒ Object
21 22 23 |
# File 'lib/gclouder/config_loader.rb', line 21 def self.to_path(config, path) config.gsub(/.*#{path}\//, "").gsub!(/\.yml$/, "").split("/") end |