class Rake::Funnel::Support::Environments::Loader

Public Class Methods

load_configuration(config, store = configatron, customizer = nil) click to toggle source
# File lib/rake/funnel/support/environments/loader.rb, line 12
def load_configuration(config, store = configatron, customizer = nil)
  $stderr.print("Configuring for #{config[:name]}\n")
  store.unlock!
  store.reset!

  store.env = config[:name]
  load(config, store)

  customizer.call(store) if customizer && customizer.respond_to?(:call)

  store.lock!

  $stderr.print("\n" + store.inspect + "\n")
end

Private Class Methods

evaluate_erb(yaml, filename) click to toggle source
# File lib/rake/funnel/support/environments/loader.rb, line 42
def evaluate_erb(yaml, filename)
  render = ERB.new(yaml)
  render.filename = filename
  render.result
end
load(config, store) click to toggle source
# File lib/rake/funnel/support/environments/loader.rb, line 29
def load(config, store)
  operation = 'Loading'
  config.fetch(:config_files, []).each do |file|
    $stderr.print("#{operation} #{file}\n")
    operation = 'Merging'

    yaml = File.read(file)
    yaml = evaluate_erb(yaml, file)
    yaml = YAML.load(yaml) || {} # rubocop:disable Security/YAMLLoad
    store.configure_from_hash(yaml)
  end
end