Class: C3s::ConfigReader
- Inherits:
-
Object
- Object
- C3s::ConfigReader
- Defined in:
- lib/configreader.rb
Instance Method Summary collapse
-
#initialize(file) ⇒ ConfigReader
constructor
Reads the configuration file file:: the configuration file.
-
#section(section) ⇒ Object
Returns the client configuration for a given section section:: the section to read (client, server or db).
Constructor Details
#initialize(file) ⇒ ConfigReader
Reads the configuration file file:: the configuration file
12 13 14 15 16 17 |
# File 'lib/configreader.rb', line 12 def initialize(file) @config = YAML::load_file(File.join(file)) check_config rescue Exception => e fatal_error("Could not find the configuration file '#{file}'") end |
Instance Method Details
#section(section) ⇒ Object
Returns the client configuration for a given section section:: the section to read (client, server or db)
22 23 24 25 26 27 28 29 30 |
# File 'lib/configreader.rb', line 22 def section(section) if !SECTIONS.include?(section) fatal_error("Trying to read invalid section '#{section}'") end config_hash = {} @config[section].each do |key, val| config_hash.merge!({key.to_s => val.to_s}) end end |