Class: ErrorappNotifier::Config

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

Constant Summary collapse

DEFAULT_IGNORE_EXCEPTIONS =
['ActiveRecord::RecordNotFound',
'ActionController::RoutingError',
'ActionController::InvalidAuthenticityToken',
'CGI::Session::CookieStore::TamperedWithCookie',
'ActionController::UnknownAction',
'AbstractController::ActionNotFound',
'ActionController::UnknownFormat',
'Mongoid::Errors::DocumentNotFound',
'Sinatra::NotFound',
"SystemExit",
"SignalException"].freeze
DEFAULT_PARAMS_FILTERS =
%w(password password_confirmation).freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfig

Returns a new instance of Config.



37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/errorapp_notifier/config.rb', line 37

def initialize
  @api_key             = ENV['ERRORAPP_API_KEY']
  @disabled_by_default = %w(development test)
  @http_open_timeout   = 2
  @http_read_timeout   = 4
  @ignore_exceptions   = DEFAULT_IGNORE_EXCEPTIONS
  @ignore_user_agents  = []
  @logger              = Logger.new(STDOUT)
  @params_filters      = DEFAULT_PARAMS_FILTERS
  @remote_host         = "errorapp.com"
  @remote_port         = nil
  @ssl                 = true
end

Instance Attribute Details

#api_keyObject

Returns the value of attribute api_key.



3
4
5
# File 'lib/errorapp_notifier/config.rb', line 3

def api_key
  @api_key
end

#disabled_by_defaultObject

Returns the value of attribute disabled_by_default.



4
5
6
# File 'lib/errorapp_notifier/config.rb', line 4

def disabled_by_default
  @disabled_by_default
end

#environment_nameObject

Returns the value of attribute environment_name.



5
6
7
# File 'lib/errorapp_notifier/config.rb', line 5

def environment_name
  @environment_name
end

#http_open_timeoutObject

Returns the value of attribute http_open_timeout.



6
7
8
# File 'lib/errorapp_notifier/config.rb', line 6

def http_open_timeout
  @http_open_timeout
end

#http_proxy_hostObject

Returns the value of attribute http_proxy_host.



7
8
9
# File 'lib/errorapp_notifier/config.rb', line 7

def http_proxy_host
  @http_proxy_host
end

#http_proxy_passwordObject

Returns the value of attribute http_proxy_password.



8
9
10
# File 'lib/errorapp_notifier/config.rb', line 8

def http_proxy_password
  @http_proxy_password
end

#http_proxy_portObject

Returns the value of attribute http_proxy_port.



9
10
11
# File 'lib/errorapp_notifier/config.rb', line 9

def http_proxy_port
  @http_proxy_port
end

#http_proxy_usernameObject

Returns the value of attribute http_proxy_username.



10
11
12
# File 'lib/errorapp_notifier/config.rb', line 10

def http_proxy_username
  @http_proxy_username
end

#http_read_timeoutObject

Returns the value of attribute http_read_timeout.



11
12
13
# File 'lib/errorapp_notifier/config.rb', line 11

def http_read_timeout
  @http_read_timeout
end

#ignore_exceptionsObject

Returns the value of attribute ignore_exceptions.



12
13
14
# File 'lib/errorapp_notifier/config.rb', line 12

def ignore_exceptions
  @ignore_exceptions
end

#ignore_user_agentsObject

Returns the value of attribute ignore_user_agents.



13
14
15
# File 'lib/errorapp_notifier/config.rb', line 13

def ignore_user_agents
  @ignore_user_agents
end

#loggerObject

Returns the value of attribute logger.



14
15
16
# File 'lib/errorapp_notifier/config.rb', line 14

def logger
  @logger
end

#params_filtersObject

Returns the value of attribute params_filters.



15
16
17
# File 'lib/errorapp_notifier/config.rb', line 15

def params_filters
  @params_filters
end

#project_rootObject

Returns the value of attribute project_root.



16
17
18
# File 'lib/errorapp_notifier/config.rb', line 16

def project_root
  @project_root
end

#remote_hostObject

Returns the value of attribute remote_host.



17
18
19
# File 'lib/errorapp_notifier/config.rb', line 17

def remote_host
  @remote_host
end

#remote_portObject

Returns the value of attribute remote_port.



18
19
20
# File 'lib/errorapp_notifier/config.rb', line 18

def remote_port
  @remote_port
end

#sslObject Also known as: ssl?

Returns the value of attribute ssl.



19
20
21
# File 'lib/errorapp_notifier/config.rb', line 19

def ssl
  @ssl
end

Instance Method Details

#application_environmentObject



63
64
65
# File 'lib/errorapp_notifier/config.rb', line 63

def application_environment
  @environment_name || ENV['RACK_ENV'] || ENV['RAILS_ENV'] || 'development'
end

#application_rootObject



55
56
57
# File 'lib/errorapp_notifier/config.rb', line 55

def application_root
  @project_root || Dir.pwd
end

#should_send_to_api?Boolean

Returns:

  • (Boolean)


51
52
53
# File 'lib/errorapp_notifier/config.rb', line 51

def should_send_to_api?
  !disabled_by_default.include?(application_environment)
end