Class: Whoopsy::Config

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

Instance Method Summary collapse

Constructor Details

#initializeConfig

Returns a new instance of Config.



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/whoopsy/config.rb', line 28

def initialize

  @config = {}

  @file_name = 'whoopsy.yml'
  @global_config_file = "/etc/#{@file_name}"
  @local_config_file = "#{File.join(ENV['HOME'], ".#{@file_name}")}"
  @environment_file = ENV['WHOOPSY_CONFIG']

  # Load in order of priority
  load_file @global_config_file
  load_file @local_config_file
  load_file @environment_file if @environment_file

  CONFIG_OPTIONS.each do |var|
    eval("self.#{var} = \"#{@config[var]}\"")
  end

end

Instance Method Details

#config_hashObject

Return a hash of config options for the whoops_logger, making sure the “type” is correct



49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/whoopsy/config.rb', line 49

def config_hash
  h = {}

  [:host, :protocol, :proxy_host, :proxy_pass, :proxy_port, :proxy_user, :secure].each do |var|
    eval("h[:#{var}] = @#{var} unless @#{var}.empty?")
  end

  [:http_open_timeout, :http_read_timeout, :port].each do |var|
    eval("h[:#{var}] = @#{var}.to_i if @#{var}.to_i > 0")
  end

  h
end