Sha256: 77d4c2738a8cc23a099c2d7cb59e29e546188b39c9b5a61ed23c5c7d901d603d

Contents?: true

Size: 1.05 KB

Versions: 3

Compression:

Stored size: 1.05 KB

Contents

require "conflate/conflation"

# Scans for YAML files in the config directory and parses them for
# configuration values. For example, imagine the file below:
#
#     # foo.yml
#     thing1: "qwerty"
#     thing2: "asdf"
#
# It will add foo.thing1 and foo.thing2 to Rails.application.config with the
# values from foo.yml
module Conflate
  class Conflator
    attr_accessor :path, :config

    # Public: Initialize a new Conflator
    #
    # path - Path the directory containing YAML configs (e.g., Rails.root.join("config"))
    # config - Object to receive the config entries (e.g., Rails.application.config)
    def initialize(path, config)
      self.path = path
      self.config = config
    end

    # Public: Process the configuration
    def perform
      config_paths.each do |filename|
        Conflation.new(filename, config).apply
      end
    end

    # Private: The config files in the given path
    #
    # Returns an Array of Strings containing paths
    def config_paths
      Dir.glob(File.join path, "*.yml")
    end
    private :config_paths
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
conflate-0.0.3 lib/conflate/conflator.rb
conflate-0.0.2 lib/conflate/conflator.rb
conflate-0.0.1 lib/conflate/conflator.rb