Sha256: 8e9cf1a320f74747159f4a6c181d5a92b12a8a6d63f27cbc44f1cd3a91affe9b

Contents?: true

Size: 714 Bytes

Versions: 3

Compression:

Stored size: 714 Bytes

Contents

require 'yaml'

module ToPass
  # The ConfigReader reads the given file from a YAML-file
  # into a Hash. All Strings in the Hash are converted into
  # symbols.
  #
  # Search locations are managed in ToPass::Directories
  class ConfigReader < FileReader
    def initialize(fn='config',dir=nil) # :nodoc:
      super
    end

    # as the ConfigReader is only intended to read the configuration
    # file, the name is fixed here.
    def self.load(fn = 'config')
      super
    end

    def load_from_file
      fn = super
      config = {}

      YAML.load_file(fn).each_pair do |key, value|
        config[key.to_sym] =  value.kind_of?(String) ? value.to_sym : value
      end

      config
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
to_pass-1.0.1 lib/to_pass/config_reader.rb
to_pass-1.0.0 lib/to_pass/config_reader.rb
to_pass-0.9.0 lib/to_pass/config_reader.rb