Class: HydraulicBrake::Configuration
- Inherits:
-
Object
- Object
- HydraulicBrake::Configuration
- Defined in:
- lib/hydraulic_brake/configuration.rb
Overview
Used to set up and modify settings for the notifier.
Constant Summary collapse
- OPTIONS =
[ :api_key, :backtrace_filters, :development_environments, :development_lookup, :environment_name, :framework, :host, :http_open_timeout, :http_read_timeout, :notifier_name, :notifier_url, :notifier_version, :params_filters, :port, :project_root, :protocol, :proxy_host, :proxy_pass, :proxy_port, :proxy_user, :rake_environment_filters, :rescue_rake_exceptions, :secure, :use_system_ssl_cert_chain, ].freeze
- DEFAULT_PARAMS_FILTERS =
%w(password password_confirmation).freeze
- DEFAULT_USER_ATTRIBUTES =
%w(id name username email).freeze
- DEFAULT_BACKTRACE_FILTERS =
[ lambda { |line| if defined?(HydraulicBrake.configuration.project_root) && HydraulicBrake.configuration.project_root.to_s != '' line.sub(/#{HydraulicBrake.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/hydraulic_brake} } ].freeze
Instance Attribute Summary collapse
-
#api_key ⇒ Object
The API key for your project, found on the project edit form.
-
#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_name ⇒ Object
The name of the environment the application is running in.
-
#framework ⇒ Object
The framework HydraulicBrake is configured to use.
-
#host ⇒ Object
The host to connect to.
-
#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).
-
#logger ⇒ Object
The logger used by HydraulicBrake.
-
#notifier_name ⇒ Object
The name of the notifier library being used to send notifications (such as “HydraulicBrake 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 Airbrake.
-
#port ⇒ Object
The port on which your Airbrake 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).
-
#rake_environment_filters ⇒ Object
readonly
A list of environment keys that will be ignored from what is sent to Airbrake server Empty by default and used only in rake handler.
-
#rescue_rake_exceptions ⇒ Object
Should HydraulicBrake catch exceptions from Rake tasks? (boolean or nil; set to nil to catch exceptions when rake isn’t running from a terminal; default is nil).
-
#secure ⇒ Object
(also: #secure?)
true
for https connections,false
for http connections. -
#use_system_ssl_cert_chain ⇒ Object
(also: #use_system_ssl_cert_chain?)
true
to use whatever CAs OpenSSL has installed on your system. -
#user_attributes ⇒ Object
User attributes that are being captured.
Instance Method Summary collapse
-
#[](option) ⇒ Object
Allows config options to be read like a hash.
- #ca_bundle_path ⇒ Object
-
#filter_backtrace(&block) {|line| ... } ⇒ Object
Takes a block and adds it to the list of backtrace filters.
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
- #local_cert_path ⇒ Object
-
#merge(hash) ⇒ Object
Returns a hash of all configurable options merged with
hash
. -
#protocol ⇒ String
Determines whether protocol should be “http” or “https”.
-
#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.
141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 |
# File 'lib/hydraulic_brake/configuration.rb', line 141 def initialize @secure = false @use_system_ssl_cert_chain= false @host = 'api.airbrake.io' @http_open_timeout = 2 @http_read_timeout = 5 @params_filters = DEFAULT_PARAMS_FILTERS.dup @backtrace_filters = DEFAULT_BACKTRACE_FILTERS.dup @development_environments = %w(development test cucumber) @development_lookup = true @notifier_name = 'HydraulicBrake Notifier' @notifier_version = VERSION @notifier_url = 'https://github.com/stevecrozz/hydraulic_brake' @framework = 'Standalone' @rescue_rake_exceptions = nil @user_attributes = DEFAULT_USER_ATTRIBUTES.dup @rake_environment_filters = [] end |
Instance Attribute Details
#api_key ⇒ Object
The API key for your project, found on the project edit form.
33 34 35 |
# File 'lib/hydraulic_brake/configuration.rb', line 33 def api_key @api_key end |
#backtrace_filters ⇒ Object (readonly)
A list of filters for cleaning and pruning the backtrace. See #filter_backtrace.
73 74 75 |
# File 'lib/hydraulic_brake/configuration.rb', line 73 def backtrace_filters @backtrace_filters end |
#development_environments ⇒ Object
A list of environments in which notifications should not be sent.
80 81 82 |
# File 'lib/hydraulic_brake/configuration.rb', line 80 def development_environments @development_environments end |
#development_lookup ⇒ Object
true
if you want to check for production errors matching development errors, false
otherwise.
83 84 85 |
# File 'lib/hydraulic_brake/configuration.rb', line 83 def development_lookup @development_lookup end |
#environment_name ⇒ Object
The name of the environment the application is running in
86 87 88 |
# File 'lib/hydraulic_brake/configuration.rb', line 86 def environment_name @environment_name end |
#framework ⇒ Object
The framework HydraulicBrake is configured to use
105 106 107 |
# File 'lib/hydraulic_brake/configuration.rb', line 105 def framework @framework end |
#host ⇒ Object
The host to connect to
36 37 38 |
# File 'lib/hydraulic_brake/configuration.rb', line 36 def host @host end |
#http_open_timeout ⇒ Object
The HTTP open timeout in seconds (defaults to 2).
51 52 53 |
# File 'lib/hydraulic_brake/configuration.rb', line 51 def http_open_timeout @http_open_timeout end |
#http_read_timeout ⇒ Object
The HTTP read timeout in seconds (defaults to 5).
54 55 56 |
# File 'lib/hydraulic_brake/configuration.rb', line 54 def http_read_timeout @http_read_timeout end |
#logger ⇒ Object
The logger used by HydraulicBrake
102 103 104 |
# File 'lib/hydraulic_brake/configuration.rb', line 102 def logger @logger end |
#notifier_name ⇒ Object
The name of the notifier library being used to send notifications (such as “HydraulicBrake Notifier”)
93 94 95 |
# File 'lib/hydraulic_brake/configuration.rb', line 93 def notifier_name @notifier_name end |
#notifier_url ⇒ Object
The url of the notifier library being used to send notifications
99 100 101 |
# File 'lib/hydraulic_brake/configuration.rb', line 99 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”)
96 97 98 |
# File 'lib/hydraulic_brake/configuration.rb', line 96 def notifier_version @notifier_version end |
#params_filters ⇒ Object (readonly)
A list of parameters that should be filtered out of what is sent to Airbrake. By default, all “password” attributes will have their contents replaced.
70 71 72 |
# File 'lib/hydraulic_brake/configuration.rb', line 70 def params_filters @params_filters end |
#port ⇒ Object
The port on which your Airbrake server runs (defaults to 443 for secure connections, 80 for insecure connections).
40 41 42 |
# File 'lib/hydraulic_brake/configuration.rb', line 40 def port @port end |
#project_root ⇒ Object
The path to the project in which the error occurred, such as the Rails.root
89 90 91 |
# File 'lib/hydraulic_brake/configuration.rb', line 89 def project_root @project_root end |
#proxy_host ⇒ Object
The hostname of your proxy server (if using a proxy)
57 58 59 |
# File 'lib/hydraulic_brake/configuration.rb', line 57 def proxy_host @proxy_host end |
#proxy_pass ⇒ Object
The password to use when logging into your proxy server (if using a proxy)
66 67 68 |
# File 'lib/hydraulic_brake/configuration.rb', line 66 def proxy_pass @proxy_pass end |
#proxy_port ⇒ Object
The port of your proxy server (if using a proxy)
60 61 62 |
# File 'lib/hydraulic_brake/configuration.rb', line 60 def proxy_port @proxy_port end |
#proxy_user ⇒ Object
The username to use when logging into your proxy server (if using a proxy)
63 64 65 |
# File 'lib/hydraulic_brake/configuration.rb', line 63 def proxy_user @proxy_user end |
#rake_environment_filters ⇒ Object (readonly)
A list of environment keys that will be ignored from what is sent to Airbrake server Empty by default and used only in rake handler
77 78 79 |
# File 'lib/hydraulic_brake/configuration.rb', line 77 def rake_environment_filters @rake_environment_filters end |
#rescue_rake_exceptions ⇒ Object
Should HydraulicBrake catch exceptions from Rake tasks? (boolean or nil; set to nil to catch exceptions when rake isn’t running from a terminal; default is nil)
109 110 111 |
# File 'lib/hydraulic_brake/configuration.rb', line 109 def rescue_rake_exceptions @rescue_rake_exceptions end |
#secure ⇒ Object Also known as: secure?
true
for https connections, false
for http connections.
43 44 45 |
# File 'lib/hydraulic_brake/configuration.rb', line 43 def secure @secure end |
#use_system_ssl_cert_chain ⇒ Object Also known as: use_system_ssl_cert_chain?
true
to use whatever CAs OpenSSL has installed on your system. false
to use the ca-bundle.crt file included in HydraulicBrake itself (reccomended and default)
48 49 50 |
# File 'lib/hydraulic_brake/configuration.rb', line 48 def use_system_ssl_cert_chain @use_system_ssl_cert_chain end |
#user_attributes ⇒ Object
User attributes that are being captured
112 113 114 |
# File 'lib/hydraulic_brake/configuration.rb', line 112 def user_attributes @user_attributes end |
Instance Method Details
#[](option) ⇒ Object
Allows config options to be read like a hash
178 179 180 |
# File 'lib/hydraulic_brake/configuration.rb', line 178 def [](option) send(option) end |
#ca_bundle_path ⇒ Object
218 219 220 221 222 223 224 |
# File 'lib/hydraulic_brake/configuration.rb', line 218 def ca_bundle_path if use_system_ssl_cert_chain? && File.exist?(OpenSSL::X509::DEFAULT_CERT_FILE) OpenSSL::X509::DEFAULT_CERT_FILE else local_cert_path # ca-bundle.crt built from source, see resources/README.md end 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.
171 172 173 |
# File 'lib/hydraulic_brake/configuration.rb', line 171 def filter_backtrace(&block) self.backtrace_filters << block end |
#local_cert_path ⇒ Object
226 227 228 |
# File 'lib/hydraulic_brake/configuration.rb', line 226 def local_cert_path File.(File.join("..", "..", "..", "resources", "ca-bundle.crt"), __FILE__) end |
#merge(hash) ⇒ Object
Returns a hash of all configurable options merged with hash
193 194 195 |
# File 'lib/hydraulic_brake/configuration.rb', line 193 def merge(hash) to_hash.merge(hash) end |
#protocol ⇒ String
Determines whether protocol should be “http” or “https”. configuration, and “https” otherwise.
210 211 212 213 214 215 216 |
# File 'lib/hydraulic_brake/configuration.rb', line 210 def protocol if secure? 'https' else 'http' end end |
#public? ⇒ Boolean
Determines if the notifier will send notices.
199 200 201 |
# File 'lib/hydraulic_brake/configuration.rb', line 199 def public? !development_environments.include?(environment_name) end |
#to_hash ⇒ Object
Returns a hash of all configurable options
183 184 185 186 187 188 |
# File 'lib/hydraulic_brake/configuration.rb', line 183 def to_hash OPTIONS.inject({}) do |hash, option| hash[option.to_sym] = self.send(option) hash end end |