Sha256: e6bcae07bcb7e11c24900978f9ce48e2d4b1975f2174c879b405c094e3ad7d5c

Contents?: true

Size: 555 Bytes

Versions: 6

Compression:

Stored size: 555 Bytes

Contents

module DeliveryBoy
  class ConfigFileLoader
    def initialize(config)
      @config = config
    end

    def load_file(path, environment)
      # First, load the ERB template from disk.
      template = ERB.new(File.new(path).read)

      # The last argument to `safe_load` allows us to use aliasing to share
      # configuration between environments.
      processed = YAML.safe_load(template.result(binding), [], [], true)

      processed.fetch(environment).each do |variable, value|
        @config.set(variable, value)
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
delivery_boy-0.1.5 lib/delivery_boy/config_file_loader.rb
delivery_boy-0.1.4 lib/delivery_boy/config_file_loader.rb
delivery_boy-0.1.3 lib/delivery_boy/config_file_loader.rb
delivery_boy-0.1.2 lib/delivery_boy/config_file_loader.rb
delivery_boy-0.1.1 lib/delivery_boy/config_file_loader.rb
delivery_boy-0.1.0 lib/delivery_boy/config_file_loader.rb