airbrake 4.3.8 → 5.0.0.rc.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/airbrake.rb +16 -185
- data/lib/airbrake/capistrano/tasks.rb +64 -0
- data/lib/airbrake/delayed_job/plugin.rb +48 -0
- data/lib/airbrake/rack/middleware.rb +45 -0
- data/lib/airbrake/rack/notice_builder.rb +80 -0
- data/lib/airbrake/rack/user.rb +51 -0
- data/lib/airbrake/rails/action_controller.rb +35 -0
- data/lib/airbrake/rails/active_job.rb +23 -0
- data/lib/airbrake/rails/active_record.rb +40 -0
- data/lib/airbrake/rails/railtie.rb +61 -0
- data/lib/airbrake/rake/task_ext.rb +61 -0
- data/lib/airbrake/rake/tasks.rb +93 -0
- data/lib/airbrake/resque/failure.rb +19 -0
- data/lib/airbrake/sidekiq/error_handler.rb +35 -0
- data/lib/airbrake/version.rb +4 -1
- data/lib/generators/airbrake_generator.rb +25 -0
- data/lib/generators/airbrake_initializer.rb.erb +55 -0
- data/spec/airbrake_spec.rb +0 -0
- data/spec/apps/rack/dummy_app.rb +17 -0
- data/spec/apps/rails/dummy_app.rb +150 -0
- data/spec/apps/rails/dummy_task.rake +20 -0
- data/spec/apps/rails/logs/32.log +13358 -0
- data/spec/apps/rails/logs/40.log +6854 -0
- data/spec/apps/rails/logs/41.log +3170 -0
- data/spec/apps/rails/logs/42.log +23919 -0
- data/spec/apps/rails/logs/50.log +10976 -0
- data/spec/apps/sinatra/dummy_app.rb +12 -0
- data/spec/integration/rack/rack_spec.rb +17 -0
- data/spec/integration/rails/rails_spec.rb +135 -0
- data/spec/integration/rails/rake_spec.rb +160 -0
- data/spec/integration/shared_examples/rack_examples.rb +106 -0
- data/spec/integration/sinatra/sinatra_spec.rb +15 -0
- data/spec/spec_helper.rb +127 -0
- data/spec/unit/rack/middleware_spec.rb +80 -0
- data/spec/unit/rack/notice_builder_spec.rb +35 -0
- data/spec/unit/rack/user_spec.rb +78 -0
- data/spec/unit/rake/tasks_spec.rb +40 -0
- data/spec/unit/sidekiq/error_handler_spec.rb +29 -0
- metadata +110 -325
- data/CHANGELOG +0 -1716
- data/Gemfile +0 -3
- data/Guardfile +0 -6
- data/INSTALL +0 -20
- data/LICENSE +0 -61
- data/README.md +0 -148
- data/README_FOR_HEROKU_ADDON.md +0 -102
- data/Rakefile +0 -179
- data/TESTED_AGAINST +0 -7
- data/airbrake.gemspec +0 -41
- data/bin/airbrake +0 -12
- data/features/metal.feature +0 -34
- data/features/rack.feature +0 -60
- data/features/rails.feature +0 -324
- data/features/rake.feature +0 -33
- data/features/sinatra.feature +0 -126
- data/features/step_definitions/file_steps.rb +0 -14
- data/features/step_definitions/rack_steps.rb +0 -27
- data/features/step_definitions/rails_application_steps.rb +0 -267
- data/features/step_definitions/rake_steps.rb +0 -22
- data/features/support/airbrake_shim.rb.template +0 -11
- data/features/support/aruba.rb +0 -5
- data/features/support/env.rb +0 -39
- data/features/support/matchers.rb +0 -35
- data/features/support/rails.rb +0 -156
- data/features/support/rake/Rakefile +0 -77
- data/features/user_informer.feature +0 -57
- data/generators/airbrake/airbrake_generator.rb +0 -94
- data/generators/airbrake/lib/insert_commands.rb +0 -34
- data/generators/airbrake/lib/rake_commands.rb +0 -24
- data/generators/airbrake/templates/airbrake_tasks.rake +0 -25
- data/generators/airbrake/templates/capistrano_hook.rb +0 -6
- data/generators/airbrake/templates/initializer.rb +0 -4
- data/install.rb +0 -1
- data/lib/airbrake/backtrace.rb +0 -103
- data/lib/airbrake/capistrano.rb +0 -103
- data/lib/airbrake/capistrano3.rb +0 -3
- data/lib/airbrake/cli/client.rb +0 -76
- data/lib/airbrake/cli/options.rb +0 -45
- data/lib/airbrake/cli/printer.rb +0 -33
- data/lib/airbrake/cli/project.rb +0 -17
- data/lib/airbrake/cli/project_factory.rb +0 -33
- data/lib/airbrake/cli/runner.rb +0 -49
- data/lib/airbrake/cli/validator.rb +0 -8
- data/lib/airbrake/configuration.rb +0 -366
- data/lib/airbrake/jobs/send_job.rb +0 -7
- data/lib/airbrake/notice.rb +0 -411
- data/lib/airbrake/rack.rb +0 -64
- data/lib/airbrake/rails.rb +0 -45
- data/lib/airbrake/rails/action_controller_catcher.rb +0 -32
- data/lib/airbrake/rails/controller_methods.rb +0 -146
- data/lib/airbrake/rails/error_lookup.rb +0 -35
- data/lib/airbrake/rails/middleware.rb +0 -63
- data/lib/airbrake/rails3_tasks.rb +0 -126
- data/lib/airbrake/railtie.rb +0 -46
- data/lib/airbrake/rake_handler.rb +0 -75
- data/lib/airbrake/response.rb +0 -29
- data/lib/airbrake/sender.rb +0 -213
- data/lib/airbrake/shared_tasks.rb +0 -59
- data/lib/airbrake/sidekiq.rb +0 -8
- data/lib/airbrake/sinatra.rb +0 -40
- data/lib/airbrake/tasks.rb +0 -81
- data/lib/airbrake/tasks/airbrake.cap +0 -28
- data/lib/airbrake/user_informer.rb +0 -36
- data/lib/airbrake/utils/params_cleaner.rb +0 -141
- data/lib/airbrake/utils/rack_filters.rb +0 -45
- data/lib/airbrake_tasks.rb +0 -62
- data/lib/rails/generators/airbrake/airbrake_generator.rb +0 -155
- data/lib/templates/rescue.erb +0 -91
- data/rails/init.rb +0 -1
- data/resources/README.md +0 -34
- data/resources/airbrake_2_4.xsd +0 -89
- data/resources/airbrake_3_0.json +0 -52
- data/resources/ca-bundle.crt +0 -3376
- data/script/integration_test.rb +0 -35
- data/test/airbrake_tasks_test.rb +0 -161
- data/test/backtrace_test.rb +0 -215
- data/test/capistrano_test.rb +0 -44
- data/test/configuration_test.rb +0 -303
- data/test/controller_methods_test.rb +0 -230
- data/test/helper.rb +0 -233
- data/test/integration.rb +0 -13
- data/test/integration/catcher_test.rb +0 -371
- data/test/logger_test.rb +0 -79
- data/test/notice_test.rb +0 -494
- data/test/notifier_test.rb +0 -288
- data/test/params_cleaner_test.rb +0 -204
- data/test/rack_test.rb +0 -62
- data/test/rails_initializer_test.rb +0 -36
- data/test/recursion_test.rb +0 -10
- data/test/response_test.rb +0 -18
- data/test/sender_test.rb +0 -335
- data/test/support/response_shim.xml +0 -4
- data/test/user_informer_test.rb +0 -29
data/lib/airbrake/cli/project.rb
DELETED
@@ -1,17 +0,0 @@
|
|
1
|
-
class Project
|
2
|
-
attr_writer :name, :id, :api_key
|
3
|
-
|
4
|
-
def initialize(attributes = {})
|
5
|
-
attributes.keys.each do |key|
|
6
|
-
instance_variable_set("@#{key}",attributes[key])
|
7
|
-
end
|
8
|
-
end
|
9
|
-
|
10
|
-
def to_s
|
11
|
-
"#{@name}".rjust(20) + "(#{@id}):".rjust(10) + " #{@api_key}"
|
12
|
-
end
|
13
|
-
|
14
|
-
def valid?
|
15
|
-
@name && @id && @api_key
|
16
|
-
end
|
17
|
-
end
|
@@ -1,33 +0,0 @@
|
|
1
|
-
require File.expand_path( "../project", __FILE__)
|
2
|
-
# Responsible for creating projects when needed.
|
3
|
-
# Creates them from XML received.
|
4
|
-
class ProjectFactory
|
5
|
-
attr_reader :project, :projects
|
6
|
-
|
7
|
-
def initialize
|
8
|
-
@project = Project.new
|
9
|
-
@projects = []
|
10
|
-
end
|
11
|
-
|
12
|
-
def create_projects_from_xml(xml)
|
13
|
-
xml.split("\n").each do |line|
|
14
|
-
/<name[^>]*>(.*)<\/name>/ =~ line
|
15
|
-
name = $1
|
16
|
-
project.name = name.capitalize if name
|
17
|
-
/<id[^>]*>(.*)<\/id>/ =~ line
|
18
|
-
id = $1
|
19
|
-
project.id = id if id
|
20
|
-
/<api-key[^>]*>(.*)<\/api-key>/ =~ line
|
21
|
-
api_key = $1
|
22
|
-
project.api_key = api_key if api_key
|
23
|
-
check_project
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
def check_project
|
28
|
-
if @project.valid?
|
29
|
-
projects << @project
|
30
|
-
@project = Project.new
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
data/lib/airbrake/cli/runner.rb
DELETED
@@ -1,49 +0,0 @@
|
|
1
|
-
require File.expand_path( "../project_factory", __FILE__)
|
2
|
-
require File.expand_path( "../options", __FILE__)
|
3
|
-
require File.expand_path( "../validator", __FILE__)
|
4
|
-
require File.expand_path( "../printer", __FILE__)
|
5
|
-
require File.expand_path( "../client", __FILE__)
|
6
|
-
|
7
|
-
module Runner
|
8
|
-
extend Validator
|
9
|
-
|
10
|
-
extend self
|
11
|
-
|
12
|
-
attr_accessor :options
|
13
|
-
|
14
|
-
def run!(command, cli_options = {})
|
15
|
-
|
16
|
-
self.options = Options.new(cli_options)
|
17
|
-
|
18
|
-
case command
|
19
|
-
when 'raise'
|
20
|
-
validates :api_key
|
21
|
-
Airbrake.configure do |c|
|
22
|
-
c.api_key = options.api_key
|
23
|
-
c.host = options.host if options.host
|
24
|
-
c.port = options.port if options.port
|
25
|
-
c.secure = options.port.to_i == 443
|
26
|
-
end
|
27
|
-
exception_id = Airbrake.notify(:error_class => options.error,
|
28
|
-
:error_message => "#{options.error}: #{options.message}",
|
29
|
-
:cgi_data => ENV)
|
30
|
-
abort "Error sending exception to Airbrake server. Try again later." unless exception_id
|
31
|
-
puts "Exception sent successfully: http://airbrake.io/locate/#{exception_id}"
|
32
|
-
|
33
|
-
when "list"
|
34
|
-
validates :auth_token, :account
|
35
|
-
Client.print_projects
|
36
|
-
|
37
|
-
when "create"
|
38
|
-
validates :auth_token, :account
|
39
|
-
Client.create_project
|
40
|
-
|
41
|
-
when "deploy"
|
42
|
-
validates :api_key
|
43
|
-
Client.create_deploy
|
44
|
-
|
45
|
-
else
|
46
|
-
Printer.print_usage
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|
@@ -1,366 +0,0 @@
|
|
1
|
-
module Airbrake
|
2
|
-
# Used to set up and modify settings for the notifier.
|
3
|
-
class Configuration
|
4
|
-
|
5
|
-
OPTIONS = [:api_key, :backtrace_filters, :development_environments,
|
6
|
-
:development_lookup, :environment_name, :host,
|
7
|
-
:http_open_timeout, :http_read_timeout, :ignore, :ignore_by_filters,
|
8
|
-
:ignore_user_agent, :notifier_name, :notifier_url, :notifier_version,
|
9
|
-
:params_filters, :params_whitelist_filters, :project_root, :port, :protocol, :proxy_host,
|
10
|
-
:proxy_pass, :proxy_port, :proxy_user, :secure, :use_system_ssl_cert_chain,
|
11
|
-
:framework, :user_information, :rescue_rake_exceptions, :rake_environment_filters,
|
12
|
-
:test_mode].freeze
|
13
|
-
|
14
|
-
# The API key for your project, found on the project edit form.
|
15
|
-
attr_accessor :api_key
|
16
|
-
|
17
|
-
# The host to connect to (defaults to airbrake.io).
|
18
|
-
attr_accessor :host
|
19
|
-
|
20
|
-
# The port on which your Airbrake server runs (defaults to 443 for secure
|
21
|
-
# connections, 80 for insecure connections).
|
22
|
-
attr_writer :port
|
23
|
-
|
24
|
-
# +true+ for https connections, +false+ for http connections.
|
25
|
-
attr_accessor :secure
|
26
|
-
|
27
|
-
# +true+ to use whatever CAs OpenSSL has installed on your system. +false+ to use the ca-bundle.crt file included in Airbrake itself (reccomended and default)
|
28
|
-
attr_accessor :use_system_ssl_cert_chain
|
29
|
-
|
30
|
-
# The HTTP open timeout in seconds (defaults to 2).
|
31
|
-
attr_accessor :http_open_timeout
|
32
|
-
|
33
|
-
# The HTTP read timeout in seconds (defaults to 5).
|
34
|
-
attr_accessor :http_read_timeout
|
35
|
-
|
36
|
-
# The hostname of your proxy server (if using a proxy)
|
37
|
-
attr_accessor :proxy_host
|
38
|
-
|
39
|
-
# The port of your proxy server (if using a proxy)
|
40
|
-
attr_accessor :proxy_port
|
41
|
-
|
42
|
-
# The username to use when logging into your proxy server (if using a proxy)
|
43
|
-
attr_accessor :proxy_user
|
44
|
-
|
45
|
-
# The password to use when logging into your proxy server (if using a proxy)
|
46
|
-
attr_accessor :proxy_pass
|
47
|
-
|
48
|
-
# A list of parameters that should be filtered out of what is sent to Airbrake.
|
49
|
-
# By default, all "password" attributes will have their contents replaced.
|
50
|
-
attr_accessor :params_filters
|
51
|
-
|
52
|
-
# A list of whitelisted parameters that will be sent to Airbrake.
|
53
|
-
# All other parameters will be filtered and their content replaced.
|
54
|
-
# By default this list is empty (all parameters are whitelisted).
|
55
|
-
attr_accessor :params_whitelist_filters
|
56
|
-
|
57
|
-
# A list of filters for cleaning and pruning the backtrace. See #filter_backtrace.
|
58
|
-
attr_reader :backtrace_filters
|
59
|
-
|
60
|
-
# A list of filters for ignoring exceptions. See #ignore_by_filter.
|
61
|
-
attr_reader :ignore_by_filters
|
62
|
-
|
63
|
-
# A list of environment keys that will be ignored from what is sent to Airbrake server
|
64
|
-
# Empty by default and used only in rake handler
|
65
|
-
attr_reader :rake_environment_filters
|
66
|
-
|
67
|
-
# A list of exception classes to ignore during server requests. The array can be appended to.
|
68
|
-
attr_reader :ignore
|
69
|
-
|
70
|
-
# A list of exception classes to ignore during Rake tasks. The array can be appended to.
|
71
|
-
attr_reader :ignore_rake
|
72
|
-
|
73
|
-
# A list of user agents that are being ignored. The array can be appended to.
|
74
|
-
attr_reader :ignore_user_agent
|
75
|
-
|
76
|
-
# A list of environments in which notifications should not be sent.
|
77
|
-
attr_accessor :development_environments
|
78
|
-
|
79
|
-
# +true+ if you want to check for production errors matching development errors, +false+ otherwise.
|
80
|
-
attr_accessor :development_lookup
|
81
|
-
|
82
|
-
# The name of the environment the application is running in
|
83
|
-
attr_accessor :environment_name
|
84
|
-
|
85
|
-
# The path to the project in which the error occurred, such as the Rails.root
|
86
|
-
attr_accessor :project_root
|
87
|
-
|
88
|
-
# The name of the notifier library being used to send notifications (such as "Airbrake Notifier")
|
89
|
-
attr_accessor :notifier_name
|
90
|
-
|
91
|
-
# The version of the notifier library being used to send notifications (such as "1.0.2")
|
92
|
-
attr_accessor :notifier_version
|
93
|
-
|
94
|
-
# The url of the notifier library being used to send notifications
|
95
|
-
attr_accessor :notifier_url
|
96
|
-
|
97
|
-
# The logger used by Airbrake
|
98
|
-
attr_accessor :logger
|
99
|
-
|
100
|
-
# The text that the placeholder is replaced with. {{error_id}} is the actual error number.
|
101
|
-
attr_accessor :user_information
|
102
|
-
|
103
|
-
# The framework Airbrake is configured to use
|
104
|
-
attr_accessor :framework
|
105
|
-
|
106
|
-
# Should Airbrake catch exceptions from Rake tasks?
|
107
|
-
# (boolean or nil; set to nil to catch exceptions when rake isn't running from a terminal; default is nil)
|
108
|
-
attr_accessor :rescue_rake_exceptions
|
109
|
-
alias_method :rescue_rake_exceptions?, :rescue_rake_exceptions
|
110
|
-
|
111
|
-
# User attributes that are being captured
|
112
|
-
attr_reader :user_attributes
|
113
|
-
|
114
|
-
# Only used for JSON API
|
115
|
-
attr_reader :project_id
|
116
|
-
|
117
|
-
# Setting this to true will use the CollectingSender instead of
|
118
|
-
# the default one which will cause storing the last notice locally
|
119
|
-
attr_accessor :test_mode
|
120
|
-
alias_method :test_mode?, :test_mode
|
121
|
-
|
122
|
-
DEFAULT_PARAMS_FILTERS = %w(password password_confirmation).freeze
|
123
|
-
DEFAULT_PARAMS_WHITELIST_FILTERS = [].freeze
|
124
|
-
|
125
|
-
DEFAULT_USER_ATTRIBUTES = %w(id).freeze
|
126
|
-
|
127
|
-
VALID_USER_ATTRIBUTES = %w(id name username email).freeze
|
128
|
-
|
129
|
-
DEFAULT_BACKTRACE_FILTERS = [
|
130
|
-
lambda { |line|
|
131
|
-
if defined?(Airbrake.configuration.project_root) && Airbrake.configuration.project_root.to_s != ''
|
132
|
-
line.sub(/#{Airbrake.configuration.project_root}/, "[PROJECT_ROOT]")
|
133
|
-
else
|
134
|
-
line
|
135
|
-
end
|
136
|
-
},
|
137
|
-
lambda { |line| line.gsub(/^\.\//, "") },
|
138
|
-
lambda { |line|
|
139
|
-
Gem.path.each{ |path| line.sub!(/#{path}/, "[GEM_ROOT]") unless path.to_s.strip.empty? } if defined?(Gem)
|
140
|
-
line
|
141
|
-
},
|
142
|
-
lambda { |line| line if line !~ %r{lib/airbrake} }
|
143
|
-
].freeze
|
144
|
-
|
145
|
-
IGNORE_DEFAULT = ['ActiveRecord::RecordNotFound',
|
146
|
-
'ActionController::RoutingError',
|
147
|
-
'ActionController::InvalidAuthenticityToken',
|
148
|
-
'CGI::Session::CookieStore::TamperedWithCookie',
|
149
|
-
'ActionController::UnknownHttpMethod',
|
150
|
-
'ActionController::UnknownAction',
|
151
|
-
'AbstractController::ActionNotFound',
|
152
|
-
'Mongoid::Errors::DocumentNotFound',
|
153
|
-
'ActionController::UnknownFormat']
|
154
|
-
|
155
|
-
alias_method :secure?, :secure
|
156
|
-
alias_method :use_system_ssl_cert_chain?, :use_system_ssl_cert_chain
|
157
|
-
|
158
|
-
def initialize
|
159
|
-
@secure = false
|
160
|
-
@use_system_ssl_cert_chain= false
|
161
|
-
@host = 'api.airbrake.io'
|
162
|
-
@port = nil
|
163
|
-
@http_open_timeout = 2
|
164
|
-
@http_read_timeout = 5
|
165
|
-
@params_filters = DEFAULT_PARAMS_FILTERS.dup
|
166
|
-
@params_whitelist_filters = DEFAULT_PARAMS_WHITELIST_FILTERS.dup
|
167
|
-
@backtrace_filters = DEFAULT_BACKTRACE_FILTERS.dup
|
168
|
-
@ignore_by_filters = [] # These filters are applied to both server requests and Rake tasks
|
169
|
-
@ignore = IGNORE_DEFAULT.dup
|
170
|
-
@ignore_rake = [] # Rake tasks don't ignore any exception classes by default
|
171
|
-
@ignore_user_agent = []
|
172
|
-
@development_environments = %w(development test cucumber)
|
173
|
-
@development_lookup = true
|
174
|
-
@notifier_name = 'Airbrake Notifier'
|
175
|
-
@notifier_version = VERSION
|
176
|
-
@notifier_url = 'https://github.com/airbrake/airbrake'
|
177
|
-
@framework = 'Standalone'
|
178
|
-
@user_information = 'Airbrake Error {{error_id}}'
|
179
|
-
@rescue_rake_exceptions = nil
|
180
|
-
@user_attributes = DEFAULT_USER_ATTRIBUTES.dup
|
181
|
-
@rake_environment_filters = []
|
182
|
-
@async = nil
|
183
|
-
end
|
184
|
-
|
185
|
-
# Takes a block and adds it to the list of backtrace filters. When the filters
|
186
|
-
# run, the block will be handed each line of the backtrace and can modify
|
187
|
-
# it as necessary.
|
188
|
-
#
|
189
|
-
# @example
|
190
|
-
# config.filter_bracktrace do |line|
|
191
|
-
# line.gsub(/^#{Rails.root}/, "[Rails.root]")
|
192
|
-
# end
|
193
|
-
#
|
194
|
-
# @param [Proc] block The new backtrace filter.
|
195
|
-
# @yieldparam [String] line A line in the backtrace.
|
196
|
-
def filter_backtrace(&block)
|
197
|
-
self.backtrace_filters << block
|
198
|
-
end
|
199
|
-
|
200
|
-
# Takes a block and adds it to the list of ignore filters.
|
201
|
-
# When the filters run, the block will be handed the exception.
|
202
|
-
# @example
|
203
|
-
# config.ignore_by_filter do |exception_data|
|
204
|
-
# true if exception_data[:error_class] == "RuntimeError"
|
205
|
-
# end
|
206
|
-
#
|
207
|
-
# @param [Proc] block The new ignore filter
|
208
|
-
# @yieldparam [Hash] data The exception data given to +Airbrake.notify+
|
209
|
-
# @yieldreturn [Boolean] If the block returns true the exception will be ignored, otherwise it will be processed by airbrake.
|
210
|
-
def ignore_by_filter(&block)
|
211
|
-
self.ignore_by_filters << block
|
212
|
-
end
|
213
|
-
|
214
|
-
# Overrides the list of default ignored errors.
|
215
|
-
#
|
216
|
-
# @param [Array<Exception>] names A list of exceptions to ignore.
|
217
|
-
def ignore_only=(names)
|
218
|
-
@ignore = [names].flatten
|
219
|
-
end
|
220
|
-
|
221
|
-
# Overrides the list of default ignored errors during Rake tasks.
|
222
|
-
#
|
223
|
-
# @param [Array<Exception>] names A list of rake exceptions to ignore.
|
224
|
-
def ignore_rake_only=(names)
|
225
|
-
@ignore_rake = [names].flatten
|
226
|
-
end
|
227
|
-
|
228
|
-
# Overrides the list of default ignored user agents
|
229
|
-
#
|
230
|
-
# @param [Array<String>] A list of user agents to ignore
|
231
|
-
def ignore_user_agent_only=(names)
|
232
|
-
@ignore_user_agent = [names].flatten
|
233
|
-
end
|
234
|
-
|
235
|
-
# Allows config options to be read like a hash
|
236
|
-
#
|
237
|
-
# @param [Symbol] option Key for a given attribute
|
238
|
-
def [](option)
|
239
|
-
send(option)
|
240
|
-
end
|
241
|
-
|
242
|
-
# Returns a hash of all configurable options
|
243
|
-
def to_hash
|
244
|
-
OPTIONS.inject({}) do |hash, option|
|
245
|
-
hash[option.to_sym] = self.send(option)
|
246
|
-
hash
|
247
|
-
end
|
248
|
-
end
|
249
|
-
|
250
|
-
# Returns a hash of all configurable options merged with +hash+
|
251
|
-
#
|
252
|
-
# @param [Hash] hash A set of configuration options that will take precedence over the defaults
|
253
|
-
def merge(hash)
|
254
|
-
to_hash.merge(hash)
|
255
|
-
end
|
256
|
-
|
257
|
-
# Determines if the notifier will send notices.
|
258
|
-
# @return [Boolean] Returns +true+ if an api string exists, +false+ otherwise.
|
259
|
-
def configured?
|
260
|
-
!api_key.nil? && !api_key.empty?
|
261
|
-
end
|
262
|
-
|
263
|
-
# Determines if the notifier will send notices.
|
264
|
-
# @return [Boolean] Returns +false+ if in a development environment, +true+ otherwise.
|
265
|
-
def public?
|
266
|
-
@public ||= !development_environments.include?(environment_name)
|
267
|
-
end
|
268
|
-
|
269
|
-
def port
|
270
|
-
@port || default_port
|
271
|
-
end
|
272
|
-
|
273
|
-
# Determines whether protocol should be "http" or "https".
|
274
|
-
# @return [String] Returns +"http"+ if you've set secure to +false+ in
|
275
|
-
# configuration, and +"https"+ otherwise.
|
276
|
-
def protocol
|
277
|
-
if secure?
|
278
|
-
'https'
|
279
|
-
else
|
280
|
-
'http'
|
281
|
-
end
|
282
|
-
end
|
283
|
-
|
284
|
-
def user_attributes=(user_attributes)
|
285
|
-
@user_attributes = validate_user_attributes user_attributes
|
286
|
-
end
|
287
|
-
|
288
|
-
# Should Airbrake send notifications asynchronously
|
289
|
-
# (boolean, nil or callable; default is nil).
|
290
|
-
# Can be used as callable-setter when block provided.
|
291
|
-
def async(&block)
|
292
|
-
if block_given?
|
293
|
-
@async = block
|
294
|
-
end
|
295
|
-
@async
|
296
|
-
end
|
297
|
-
alias_method :async?, :async
|
298
|
-
|
299
|
-
def async=(use_default_or_this)
|
300
|
-
@async = use_default_or_this == true ?
|
301
|
-
default_async_processor :
|
302
|
-
use_default_or_this
|
303
|
-
end
|
304
|
-
|
305
|
-
def rescue_rake_exceptions=(val)
|
306
|
-
if val && !defined?(Airbrake::RakeHandler)
|
307
|
-
raise LoadError, "you must require 'airbrake/rake_handler' to rescue from rake exceptions"
|
308
|
-
end
|
309
|
-
@rescue_rake_exceptions = val
|
310
|
-
end
|
311
|
-
|
312
|
-
def ca_bundle_path
|
313
|
-
if use_system_ssl_cert_chain?
|
314
|
-
OpenSSL::X509::DEFAULT_CERT_FILE if File.exist?(OpenSSL::X509::DEFAULT_CERT_FILE)
|
315
|
-
else
|
316
|
-
local_cert_path # ca-bundle.crt built from source, see resources/README.md
|
317
|
-
end
|
318
|
-
end
|
319
|
-
|
320
|
-
def local_cert_path
|
321
|
-
File.expand_path(File.join("..", "..", "..", "resources", "ca-bundle.crt"), __FILE__)
|
322
|
-
end
|
323
|
-
|
324
|
-
def project_id=(project_id)
|
325
|
-
@project_id = "#{project_id}"
|
326
|
-
end
|
327
|
-
|
328
|
-
private
|
329
|
-
# Determines what port should we use for sending notices.
|
330
|
-
# @return [Fixnum] Returns 443 if you've set secure to true in your
|
331
|
-
# configuration, and 80 otherwise.
|
332
|
-
def default_port
|
333
|
-
if secure?
|
334
|
-
443
|
335
|
-
else
|
336
|
-
80
|
337
|
-
end
|
338
|
-
end
|
339
|
-
|
340
|
-
# Async notice delivery defaults to girl friday
|
341
|
-
def default_async_processor
|
342
|
-
if defined?(SuckerPunch)
|
343
|
-
lambda {|notice| SendJob.new.async.perform(notice)}
|
344
|
-
elsif defined?(GirlFriday)
|
345
|
-
queue = GirlFriday::WorkQueue.new(nil, :size => 3) do |notice|
|
346
|
-
Airbrake.sender.send_to_airbrake(notice)
|
347
|
-
end
|
348
|
-
lambda {|notice| queue << notice}
|
349
|
-
else
|
350
|
-
warn "[AIRBRAKE] You can't use the default async handler without sucker_punch or girl_friday."\
|
351
|
-
" Please make sure you have sucker_punch or girl_friday installed (sucker_punch is recommended)."
|
352
|
-
end
|
353
|
-
end
|
354
|
-
|
355
|
-
def validate_user_attributes(user_attributes)
|
356
|
-
user_attributes.reject do |attribute|
|
357
|
-
unless VALID_USER_ATTRIBUTES.include? attribute.to_s
|
358
|
-
warn "[AIRBRAKE] Unsupported user attribute: '#{attribute}'. "\
|
359
|
-
"This attribute will not be shown in the Airbrake UI. "\
|
360
|
-
"Check http://git.io/h6YRpA for more info."
|
361
|
-
true
|
362
|
-
end
|
363
|
-
end
|
364
|
-
end
|
365
|
-
end
|
366
|
-
end
|