Sha256: e049e336eaca793a47ba63bc0c0476a66221dbc1f3197f517d1748d938c8a3be

Contents?: true

Size: 535 Bytes

Versions: 2

Compression:

Stored size: 535 Bytes

Contents

require 'yaml'

module Docs
  class Config
    def initialize(config_file)
      @config = YAML.load(File.read(config_file))
      @environment = ENV['DOCS_ENV'] || 'production'

      begin
        env = @config.delete('environment')[@environment]
      rescue NoMethodError 
        env = {}
      end

      @config.merge!(env)
    end

    def method_missing(name, *args, &block)
      name = name.to_s
      if @config.has_key?(name)
        @config[name]
      else
        super(name, *args, &block)
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
docs-0.0.4 lib/docs/config.rb
docs-0.0.3 lib/docs/config.rb