Method: Exceptional::Config.load

Defined in:
lib/exceptional/config.rb

.load(config_file = nil) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/exceptional/config.rb', line 20

def load(config_file=nil)
  if (config_file && File.file?(config_file))
    begin
      config = YAML::load_file(config_file)
      env_config = config[application_environment] || {}
      @api_key = config['api-key'] || env_config['api-key']

      @http_proxy_host = config['http-proxy-host']
      @http_proxy_port = config['http-proxy-port']
      @http_proxy_username = config['http-proxy-username']
      @http_proxy_password = config['http-proxy-password']
      @http_open_timeout = config['http-open-timeout']
      @http_read_timeout = config['http-read-timeout'] 

      @ssl = config['ssl'] || env_config['ssl']
      @enabled = env_config['enabled']
      @remote_port = config['remote-port'].to_i unless config['remote-port'].nil?
      @remote_host = config['remote-host'] unless config['remote-host'].nil?
    rescue Exception => e
      raise ConfigurationException.new("Unable to load configuration #{config_file} for environment #{application_environment} : #{e.message}")
    end
  end
end