Class: C3s::ConfigReader

Inherits:
Object
  • Object
show all
Defined in:
lib/configreader.rb

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ ConfigReader

Reads the configuration file



12
13
14
15
16
17
18
19
20
# File 'lib/configreader.rb', line 12

def initialize(options={})
  config_file = File.join(C3S_COMPONENT_DIR, 'component.yml')
  @config = YAML::load_file(config_file)

  SECTIONS.delete('db') if options[:no_db]
  check_config
rescue Errno::ENOENT => 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)



25
26
27
28
29
30
31
32
33
# File 'lib/configreader.rb', line 25

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