Class: Ribbit::Configuration
- Inherits:
-
Object
- Object
- Ribbit::Configuration
- Defined in:
- lib/ribbit/configuration.rb
Overview
Used to set up and modify settings for the notifier.
Constant Summary collapse
- OPTIONS =
[:adapter, :api_key, :automatic, :backtrace_filters, :development_environments, :development_lookup, :environment_filters, :environment_name, :host, :http_open_timeout, :http_read_timeout, :ignore, :ignore_by_filters, :ignore_user_agent, :notifier_name, :notifier_url, :notifier_version, :params_filters, :project_root, :port, :protocol, :proxy_host, :proxy_pass, :proxy_port, :proxy_user, :secure].freeze
- DEFAULT_PARAMS_FILTERS =
%w(password password_confirmation).freeze
- DEFAULT_BACKTRACE_FILTERS =
[ lambda { |line| if defined?(Ribbit.configuration.project_root) line.gsub(/#{Ribbit.configuration.project_root}/, "[PROJECT_ROOT]") else line end }, lambda { |line| line.gsub(/^\.\//, "") }, lambda { |line| if defined?(Gem) Gem.path.inject(line) do |line, path| line.gsub(/#{path}/, "[GEM_ROOT]") end end }, lambda { |line| line if line !~ %r{lib/ribbit} } ].freeze
- IGNORE_DEFAULT =
[]
Instance Attribute Summary collapse
-
#adapter ⇒ Object
The adapter to use to plug functionality into the parent application.
-
#api_key ⇒ Object
The API key for your project, found on the project edit form.
-
#automatic ⇒ Object
(also: #automatic?)
true
if errors should be caught automatically. -
#backtrace_filters ⇒ Object
readonly
A list of filters for cleaning and pruning the backtrace.
-
#development_environments ⇒ Object
A list of environments in which notifications should not be sent.
-
#development_lookup ⇒ Object
true
if you want to check for production errors matching development errors,false
otherwise. -
#environment_filters ⇒ Object
readonly
A list of environment keys that should be filtered out of what is send to Hoptoad.
-
#environment_name ⇒ Object
The name of the environment the application is running in.
-
#host ⇒ Object
The host to connect to (defaults to hoptoadapp.com).
-
#http_open_timeout ⇒ Object
The HTTP open timeout in seconds (defaults to 2).
-
#http_read_timeout ⇒ Object
The HTTP read timeout in seconds (defaults to 5).
-
#ignore ⇒ Object
readonly
A list of exception classes to ignore.
-
#ignore_by_filters ⇒ Object
readonly
A list of filters for ignoring exceptions.
-
#ignore_user_agent ⇒ Object
readonly
A list of user agents that are being ignored.
-
#notifier_name ⇒ Object
The name of the notifier library being used to send notifications (such as “Hoptoad Notifier”).
-
#notifier_url ⇒ Object
The url of the notifier library being used to send notifications.
-
#notifier_version ⇒ Object
The version of the notifier library being used to send notifications (such as “1.0.2”).
-
#params_filters ⇒ Object
readonly
A list of parameters that should be filtered out of what is sent to Hoptoad.
-
#port ⇒ Object
The port on which your Hoptoad server runs (defaults to 443 for secure connections, 80 for insecure connections).
-
#project_root ⇒ Object
The path to the project in which the error occurred, such as the RAILS_ROOT.
-
#proxy_host ⇒ Object
The hostname of your proxy server (if using a proxy).
-
#proxy_pass ⇒ Object
The password to use when logging into your proxy server (if using a proxy).
-
#proxy_port ⇒ Object
The port of your proxy server (if using a proxy).
-
#proxy_user ⇒ Object
The username to use when logging into your proxy server (if using a proxy).
-
#secure ⇒ Object
(also: #secure?)
true
for https connections,false
for http connections.
Instance Method Summary collapse
-
#[](option) ⇒ Object
Allows config options to be read like a hash.
-
#filter_backtrace(&block) {|line| ... } ⇒ Object
Takes a block and adds it to the list of backtrace filters.
-
#ignore_by_filter(&block) {|data| ... } ⇒ Object
Takes a block and adds it to the list of ignore filters.
-
#ignore_only=(names) ⇒ Object
Overrides the list of default ignored errors.
-
#ignore_user_agent_only=(names) ⇒ Object
Overrides the list of default ignored user agents.
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
-
#merge(hash) ⇒ Object
Returns a hash of all configurable options merged with
hash
. - #protocol ⇒ Object
-
#public? ⇒ Boolean
Determines if the notifier will send notices.
-
#to_hash ⇒ Object
Returns a hash of all configurable options.
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 |
# File 'lib/ribbit/configuration.rb', line 121 def initialize @secure = false @host = 'hoptoadapp.com' @http_open_timeout = 2 @http_read_timeout = 5 @params_filters = DEFAULT_PARAMS_FILTERS.dup @environment_filters = [] @backtrace_filters = DEFAULT_BACKTRACE_FILTERS.dup @ignore_by_filters = [] @ignore = IGNORE_DEFAULT.dup @ignore_user_agent = [] @development_environments = %w(development test) @automatic = true @development_lookup = true @notifier_name = CLIENT_NAME @notifier_version = VERSION @notifier_url = 'http://hoptoadapp.com' end |
Instance Attribute Details
#adapter ⇒ Object
The adapter to use to plug functionality into the parent application
78 79 80 |
# File 'lib/ribbit/configuration.rb', line 78 def adapter @adapter end |
#api_key ⇒ Object
The API key for your project, found on the project edit form.
14 15 16 |
# File 'lib/ribbit/configuration.rb', line 14 def api_key @api_key end |
#automatic ⇒ Object Also known as: automatic?
true
if errors should be caught automatically
68 69 70 |
# File 'lib/ribbit/configuration.rb', line 68 def automatic @automatic end |
#backtrace_filters ⇒ Object (readonly)
A list of filters for cleaning and pruning the backtrace. See #filter_backtrace.
53 54 55 |
# File 'lib/ribbit/configuration.rb', line 53 def backtrace_filters @backtrace_filters end |
#development_environments ⇒ Object
A list of environments in which notifications should not be sent.
65 66 67 |
# File 'lib/ribbit/configuration.rb', line 65 def development_environments @development_environments end |
#development_lookup ⇒ Object
true
if you want to check for production errors matching development errors, false
otherwise.
72 73 74 |
# File 'lib/ribbit/configuration.rb', line 72 def development_lookup @development_lookup end |
#environment_filters ⇒ Object (readonly)
A list of environment keys that should be filtered out of what is send to Hoptoad. Empty by default.
50 51 52 |
# File 'lib/ribbit/configuration.rb', line 50 def environment_filters @environment_filters end |
#environment_name ⇒ Object
The name of the environment the application is running in
75 76 77 |
# File 'lib/ribbit/configuration.rb', line 75 def environment_name @environment_name end |
#host ⇒ Object
The host to connect to (defaults to hoptoadapp.com).
17 18 19 |
# File 'lib/ribbit/configuration.rb', line 17 def host @host end |
#http_open_timeout ⇒ Object
The HTTP open timeout in seconds (defaults to 2).
27 28 29 |
# File 'lib/ribbit/configuration.rb', line 27 def http_open_timeout @http_open_timeout end |
#http_read_timeout ⇒ Object
The HTTP read timeout in seconds (defaults to 5).
30 31 32 |
# File 'lib/ribbit/configuration.rb', line 30 def http_read_timeout @http_read_timeout end |
#ignore ⇒ Object (readonly)
A list of exception classes to ignore. The array can be appended to.
59 60 61 |
# File 'lib/ribbit/configuration.rb', line 59 def ignore @ignore end |
#ignore_by_filters ⇒ Object (readonly)
A list of filters for ignoring exceptions. See #ignore_by_filter.
56 57 58 |
# File 'lib/ribbit/configuration.rb', line 56 def ignore_by_filters @ignore_by_filters end |
#ignore_user_agent ⇒ Object (readonly)
A list of user agents that are being ignored. The array can be appended to.
62 63 64 |
# File 'lib/ribbit/configuration.rb', line 62 def ignore_user_agent @ignore_user_agent end |
#notifier_name ⇒ Object
The name of the notifier library being used to send notifications (such as “Hoptoad Notifier”)
84 85 86 |
# File 'lib/ribbit/configuration.rb', line 84 def notifier_name @notifier_name end |
#notifier_url ⇒ Object
The url of the notifier library being used to send notifications
90 91 92 |
# File 'lib/ribbit/configuration.rb', line 90 def notifier_url @notifier_url end |
#notifier_version ⇒ Object
The version of the notifier library being used to send notifications (such as “1.0.2”)
87 88 89 |
# File 'lib/ribbit/configuration.rb', line 87 def notifier_version @notifier_version end |
#params_filters ⇒ Object (readonly)
A list of parameters that should be filtered out of what is sent to Hoptoad. By default, all “password” attributes will have their contents replaced.
46 47 48 |
# File 'lib/ribbit/configuration.rb', line 46 def params_filters @params_filters end |
#port ⇒ Object
The port on which your Hoptoad server runs (defaults to 443 for secure connections, 80 for insecure connections).
21 22 23 |
# File 'lib/ribbit/configuration.rb', line 21 def port @port end |
#project_root ⇒ Object
The path to the project in which the error occurred, such as the RAILS_ROOT
81 82 83 |
# File 'lib/ribbit/configuration.rb', line 81 def project_root @project_root end |
#proxy_host ⇒ Object
The hostname of your proxy server (if using a proxy)
33 34 35 |
# File 'lib/ribbit/configuration.rb', line 33 def proxy_host @proxy_host end |
#proxy_pass ⇒ Object
The password to use when logging into your proxy server (if using a proxy)
42 43 44 |
# File 'lib/ribbit/configuration.rb', line 42 def proxy_pass @proxy_pass end |
#proxy_port ⇒ Object
The port of your proxy server (if using a proxy)
36 37 38 |
# File 'lib/ribbit/configuration.rb', line 36 def proxy_port @proxy_port end |
#proxy_user ⇒ Object
The username to use when logging into your proxy server (if using a proxy)
39 40 41 |
# File 'lib/ribbit/configuration.rb', line 39 def proxy_user @proxy_user end |
#secure ⇒ Object Also known as: secure?
true
for https connections, false
for http connections.
24 25 26 |
# File 'lib/ribbit/configuration.rb', line 24 def secure @secure end |
Instance Method Details
#[](option) ⇒ Object
Allows config options to be read like a hash
186 187 188 |
# File 'lib/ribbit/configuration.rb', line 186 def [](option) send(option) end |
#filter_backtrace(&block) {|line| ... } ⇒ Object
Takes a block and adds it to the list of backtrace filters. When the filters run, the block will be handed each line of the backtrace and can modify it as necessary.
151 152 153 |
# File 'lib/ribbit/configuration.rb', line 151 def filter_backtrace(&block) self.backtrace_filters << block end |
#ignore_by_filter(&block) {|data| ... } ⇒ Object
Takes a block and adds it to the list of ignore filters. When the filters run, the block will be handed the exception.
165 166 167 |
# File 'lib/ribbit/configuration.rb', line 165 def ignore_by_filter(&block) self.ignore_by_filters << block end |
#ignore_only=(names) ⇒ Object
Overrides the list of default ignored errors.
172 173 174 |
# File 'lib/ribbit/configuration.rb', line 172 def ignore_only=(names) @ignore = [names].flatten end |
#ignore_user_agent_only=(names) ⇒ Object
Overrides the list of default ignored user agents
179 180 181 |
# File 'lib/ribbit/configuration.rb', line 179 def ignore_user_agent_only=(names) @ignore_user_agent = [names].flatten end |
#merge(hash) ⇒ Object
Returns a hash of all configurable options merged with hash
200 201 202 |
# File 'lib/ribbit/configuration.rb', line 200 def merge(hash) to_hash.merge(hash) end |
#protocol ⇒ Object
214 215 216 217 218 219 220 |
# File 'lib/ribbit/configuration.rb', line 214 def protocol if secure? 'https' else 'http' end end |
#public? ⇒ Boolean
Determines if the notifier will send notices.
206 207 208 |
# File 'lib/ribbit/configuration.rb', line 206 def public? !development_environments.include?(environment_name) end |
#to_hash ⇒ Object
Returns a hash of all configurable options
191 192 193 194 195 |
# File 'lib/ribbit/configuration.rb', line 191 def to_hash OPTIONS.inject({}) do |hash, option| hash.merge(option.to_sym => send(option)) end end |