Class: ATS::Configuration
- Inherits:
-
Object
- Object
- ATS::Configuration
- Defined in:
- lib/ats/configuration.rb
Instance Attribute Summary collapse
-
#config_files ⇒ Object
Returns the value of attribute config_files.
-
#configuration ⇒ Object
Returns the value of attribute configuration.
-
#logger ⇒ Object
Returns the value of attribute logger.
Instance Method Summary collapse
- #[](key) ⇒ Object
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
- #load_configuration(files = config_files) ⇒ Object
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/ats/configuration.rb', line 5 def initialize @logger = Logger.new(STDOUT) @logger.level = Logger::DEBUG @config_files = [ File.join(Dir.home, ".atsrc"), File.('.atsrc'), ENV['ATSRC'] ].compact @configuration = load_configuration end |
Instance Attribute Details
#config_files ⇒ Object
Returns the value of attribute config_files.
3 4 5 |
# File 'lib/ats/configuration.rb', line 3 def config_files @config_files end |
#configuration ⇒ Object
Returns the value of attribute configuration.
3 4 5 |
# File 'lib/ats/configuration.rb', line 3 def configuration @configuration end |
#logger ⇒ Object
Returns the value of attribute logger.
3 4 5 |
# File 'lib/ats/configuration.rb', line 3 def logger @logger end |
Instance Method Details
#[](key) ⇒ Object
17 18 19 |
# File 'lib/ats/configuration.rb', line 17 def [](key) @configuration[key.to_sym] end |
#load_configuration(files = config_files) ⇒ Object
21 22 23 24 25 26 27 |
# File 'lib/ats/configuration.rb', line 21 def load_configuration(files = config_files) files.inject({}) do |memo, file| logger.debug("Loading... #{file}") memo.merge!(YAML.load(IO.read(file))) if File.exist?(file) memo end end |