lib/rake/funnel/support/environments/loader.rb in rake-funnel-0.3.2.pre vs lib/rake/funnel/support/environments/loader.rb in rake-funnel-0.4.0.pre

- old
+ new

@@ -1,40 +1,46 @@ -require 'configatron' -require 'yaml' - -module Rake::Funnel::Support::Environments - class Loader - class << self - def load_configuration(config, store = configatron, customizer = nil) - Rake.rake_output_message("Configuring for #{config[:name]}") - store.unlock! - store.reset! - - store.env = config[:name] - - operation = 'Loading' - config.fetch(:config_files, []).each do |file| - Rake.rake_output_message("#{operation} #{file}") - operation = 'Merging' - - yaml = File.read(file) - yaml = evaluate_erb(yaml, file) - yaml = YAML.load(yaml) || {} - store.configure_from_hash(yaml) - end - - customizer.call(store) if customizer && customizer.respond_to?(:call) - - store.lock! - - Rake.rake_output_message('') - Rake.rake_output_message(store.inspect) - end - - def evaluate_erb(yaml, filename) - render = ERB.new(yaml) - render.filename = filename - render.result - end - end - end -end +require 'configatron' +require 'yaml' + +module Rake + module Funnel + module Support + module Environments + class Loader + class << self + def load_configuration(config, store = configatron, customizer = nil) + Rake.rake_output_message("Configuring for #{config[:name]}") + store.unlock! + store.reset! + + store.env = config[:name] + + operation = 'Loading' + config.fetch(:config_files, []).each do |file| + Rake.rake_output_message("#{operation} #{file}") + operation = 'Merging' + + yaml = File.read(file) + yaml = evaluate_erb(yaml, file) + yaml = YAML.load(yaml) || {} + store.configure_from_hash(yaml) + end + + customizer.call(store) if customizer && customizer.respond_to?(:call) + + store.lock! + + Rake.rake_output_message('') + Rake.rake_output_message(store.inspect) + end + + def evaluate_erb(yaml, filename) + render = ERB.new(yaml) + render.filename = filename + render.result + end + end + end + end + end + end +end