Class: Exceptiontrap::Config

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

Constant Summary collapse

DEFAULTS =
{
  :enabled_environments => %w(production),
  :ignored_exceptions => %w(ActiveRecord::RecordNotFound ActionController::RoutingError),
  :filtered_params => %w(password s3-key),
  :ssl => false,
  :notification_url => 'exceptiontrap.com/notifier/api/v1/problems',
  :deployment_url => 'exceptiontrap.com/notifier/api/v1/deployments'
}

Class Method Summary collapse

Class Method Details

.api_keyObject



30
31
32
# File 'lib/exceptiontrap/config.rb', line 30

def api_key
  @api_key
end

.enabled_environmentsObject



38
39
40
# File 'lib/exceptiontrap/config.rb', line 38

def enabled_environments
  @enabled_environments ||= DEFAULTS[:enabled_environments]
end

.filtered_paramsObject



46
47
48
# File 'lib/exceptiontrap/config.rb', line 46

def filtered_params
  @filtered_params ||= DEFAULTS[:filtered_params]
end

.ignored_exceptionsObject



42
43
44
# File 'lib/exceptiontrap/config.rb', line 42

def ignored_exceptions
  @ignored_exceptions ||= DEFAULTS[:ignored_exceptions]
end

.load(config_file = nil) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/exceptiontrap/config.rb', line 13

def load(config_file = nil)
  if (config_file && File.file?(config_file))
    begin
      config = YAML::load(File.open(config_file))

      @api_key = ENV['EXCEPTIONTRAP_API_KEY'] || config['api-key']
      @ssl = config['ssl']
      @ignored_exceptions = config['ignoreExceptions']
      @enabled_environments = config['enabledEnvironments']
      @filtered_params = config['filterParams']
      @notification_url = config['notificationUrl']
    rescue Exception => e
      raise "Unable to load configuration #{config_file} : #{e.message}"
    end
  end
end

.notification_urlObject



34
35
36
# File 'lib/exceptiontrap/config.rb', line 34

def notification_url
  @notification_url ||= DEFAULTS[:notification_url]
end

.use_ssl?Boolean

Returns:

  • (Boolean)


50
51
52
# File 'lib/exceptiontrap/config.rb', line 50

def use_ssl?
  @ssl ||= DEFAULTS[:ssl]
end