class HoptoadNotifier::Configuration
Used to set up and modify settings for the notifier.
Constants
- DEFAULT_BACKTRACE_FILTERS
- DEFAULT_PARAMS_FILTERS
- IGNORE_DEFAULT
- OPTIONS
Attributes
The API key for your project, found on the project edit form.
A list of filters for cleaning and pruning the backtrace. See filter_backtrace.
A list of environments in which notifications should not be sent.
true
if you want to check for production errors matching
development errors, false
otherwise.
The name of the environment the application is running in
The framework HoptoadNotifier is configured to use
The host to connect to (defaults to hoptoadapp.com).
The HTTP open timeout in seconds (defaults to 2).
The HTTP read timeout in seconds (defaults to 5).
A list of exception classes to ignore. The array can be appended to.
A list of filters for ignoring exceptions. See ignore_by_filter.
A list of user agents that are being ignored. The array can be appended to.
The logger used by HoptoadNotifier
The name of the notifier library being used to send notifications (such as “Hoptoad Notifier”)
The url of the notifier library being used to send notifications
The version of the notifier library being used to send notifications (such as “1.0.2”)
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.
The port on which your Hoptoad server runs (defaults to 443 for secure connections, 80 for insecure connections).
The path to the project in which the error occurred, such as the RAILS_ROOT
The hostname of your proxy server (if using a proxy)
The password to use when logging into your proxy server (if using a proxy)
The port of your proxy server (if using a proxy)
The username to use when logging into your proxy server (if using a proxy)
true
for https connections, false
for http
connections.
true
for https connections, false
for http
connections.
The text that the placeholder is replaced with. {{error_id}} is the actual error number.
Public Class Methods
# File lib/hoptoad_notifier/configuration.rb, line 120 def initialize @secure = false @host = 'hoptoadapp.com' @http_open_timeout = 2 @http_read_timeout = 5 @params_filters = DEFAULT_PARAMS_FILTERS.dup @backtrace_filters = DEFAULT_BACKTRACE_FILTERS.dup @ignore_by_filters = [] @ignore = IGNORE_DEFAULT.dup @ignore_user_agent = [] @development_environments = %w(development test cucumber) @development_lookup = true @notifier_name = 'Hoptoad Notifier' @notifier_version = VERSION @notifier_url = 'http://hoptoadapp.com' @framework = 'Standalone' @user_information = 'Hoptoad Error {{error_id}}' end
Public Instance Methods
Allows config options to be read like a hash
@param [Symbol] option Key for a given attribute
# File lib/hoptoad_notifier/configuration.rb, line 185 def [](option) send(option) end
# File lib/hoptoad_notifier/configuration.rb, line 225 def environment_filters warn 'config.environment_filters has been deprecated and has no effect.' [] end
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.
@example
config.filter_bracktrace do |line| line.gsub(/^#{Rails.root}/, "[RAILS_ROOT]") end
@param [Proc] block The new backtrace filter. @yieldparam [String] line A line in the backtrace.
# File lib/hoptoad_notifier/configuration.rb, line 150 def filter_backtrace(&block) self.backtrace_filters << block end
Takes a block and adds it to the list of ignore filters. When the filters run, the block will be handed the exception. @example
config.ignore_by_filter do |exception_data| true if exception_data[:error_class] == "RuntimeError" end
@param [Proc] block The new ignore filter @yieldparam [Hash] data The
exception data given to HoptoadNotifier.notify
@yieldreturn
[Boolean] If the block returns true the exception will be ignored,
otherwise it will be processed by hoptoad.
# File lib/hoptoad_notifier/configuration.rb, line 164 def ignore_by_filter(&block) self.ignore_by_filters << block end
Overrides the list of default ignored errors.
@param [Array<Exception>] names A list of exceptions to ignore.
# File lib/hoptoad_notifier/configuration.rb, line 171 def ignore_only=(names) @ignore = [names].flatten end
Overrides the list of default ignored user agents
@param [Array<String>] A list of user agents to ignore
# File lib/hoptoad_notifier/configuration.rb, line 178 def ignore_user_agent_only=(names) @ignore_user_agent = [names].flatten end
# File lib/hoptoad_notifier/configuration.rb, line 221 def js_notifier=(*args) warn '[HOPTOAD] config.js_notifier has been deprecated and has no effect. You should use <%= hoptoad_javascript_notifier %> directly at the top of your layouts. Be sure to place it before all other javascript.' end
Returns a hash of all configurable options merged with hash
@param [Hash] hash A set of configuration options that will take precedence over the defaults
# File lib/hoptoad_notifier/configuration.rb, line 199 def merge(hash) to_hash.merge(hash) end
# File lib/hoptoad_notifier/configuration.rb, line 213 def protocol if secure? 'https' else 'http' end end
Determines if the notifier will send notices. @return [Boolean] Returns
false
if in a development environment, true
otherwise.
# File lib/hoptoad_notifier/configuration.rb, line 205 def public? !development_environments.include?(environment_name) end
Returns a hash of all configurable options
# File lib/hoptoad_notifier/configuration.rb, line 190 def to_hash OPTIONS.inject({}) do |hash, option| hash.merge(option.to_sym => send(option)) end end
Private Instance Methods
# File lib/hoptoad_notifier/configuration.rb, line 232 def default_port if secure? 443 else 80 end end