Sha256: 2cc5538d31abadfd5faacf316e5da5b4f87a093ab1da6fe6ee04f1b7f33c8a68

Contents?: true

Size: 1.23 KB

Versions: 18

Compression:

Stored size: 1.23 KB

Contents

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

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
rake-funnel-0.18.0 lib/rake/funnel/support/environments/loader.rb
rake-funnel-0.17.0 lib/rake/funnel/support/environments/loader.rb
rake-funnel-0.16.1 lib/rake/funnel/support/environments/loader.rb
rake-funnel-0.16.0 lib/rake/funnel/support/environments/loader.rb
rake-funnel-0.15.0.pre lib/rake/funnel/support/environments/loader.rb
rake-funnel-0.14.0.pre lib/rake/funnel/support/environments/loader.rb
rake-funnel-0.13.0.pre lib/rake/funnel/support/environments/loader.rb
rake-funnel-0.12.0.pre lib/rake/funnel/support/environments/loader.rb
rake-funnel-0.11.0.pre lib/rake/funnel/support/environments/loader.rb
rake-funnel-0.10.0.pre lib/rake/funnel/support/environments/loader.rb
rake-funnel-0.9.1.pre lib/rake/funnel/support/environments/loader.rb
rake-funnel-0.9.0.pre lib/rake/funnel/support/environments/loader.rb
rake-funnel-0.8.0.pre lib/rake/funnel/support/environments/loader.rb
rake-funnel-0.7.0.pre lib/rake/funnel/support/environments/loader.rb
rake-funnel-0.6.1.pre lib/rake/funnel/support/environments/loader.rb
rake-funnel-0.6.0.pre lib/rake/funnel/support/environments/loader.rb
rake-funnel-0.5.0.pre lib/rake/funnel/support/environments/loader.rb
rake-funnel-0.4.0.pre lib/rake/funnel/support/environments/loader.rb