Class: ToPass::ConfigReader

Inherits:
FileReader show all
Defined in:
lib/to_pass/config_reader.rb

Overview

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

Instance Attribute Summary

Attributes inherited from FileReader

#load_path

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from FileReader

discover, extension, search_pattern, #standard_directories

Constructor Details

#initialize(fn = 'config', dir = nil) ⇒ ConfigReader

:nodoc:



10
11
12
# File 'lib/to_pass/config_reader.rb', line 10

def initialize(fn='config',dir=nil) # :nodoc:
  super
end

Class Method Details

.load(fn = 'config') ⇒ Object

as the ConfigReader is only intended to read the configuration file, the name is fixed here.



16
17
18
# File 'lib/to_pass/config_reader.rb', line 16

def self.load(fn = 'config')
  super
end

Instance Method Details

#load_from_fileObject



20
21
22
23
24
25
26
27
28
29
# File 'lib/to_pass/config_reader.rb', line 20

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