airbrake-ruby 2.1.0 → 2.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d83d667d85784f12930d891e4a40f33ff5021d32
4
- data.tar.gz: 27abbb08a24e1f5037134d779e1cd00bb6b2c6b9
3
+ metadata.gz: 85e069b4c88a953affccceafa0e250aee3c34367
4
+ data.tar.gz: 349b91844712169716c97ba606cdebf6e200e908
5
5
  SHA512:
6
- metadata.gz: 97bde22452bbf79d34d127de8972799f482ee9476a02760de6f9089d02e548a75fa73657f02dd1a93e99ee3ae27b85f176b00d9c362b3d78c837dc49ae2ab6d6
7
- data.tar.gz: 9aa4f9c47307cf45339ebabfad298e1217498318029a5423e47a2f4f91d63b14022a41f39940bccd1b67de4f5f54fae8a2dc4dd00b97912ad2c454bfcc60d63e
6
+ metadata.gz: d4fdabb0447a4c8b0ca06a45cb8ce371d35805c191253edec1bda3fd0581f60ae5382efbf7d64b56f5845d9444fcd145c73844c6dba94abbcff5b94aad00de8f
7
+ data.tar.gz: 4662128a6ad57a91659539296229fe7c0b824a6049abb32f64f9ab883be919a4ced5af56f38a3c768016b4477844eef5db30a600dceca0daa9c9e9822af973ef
data/lib/airbrake-ruby.rb CHANGED
@@ -153,10 +153,13 @@ module Airbrake
153
153
  # @param [Hash] params The additional payload to be sent to Airbrake. Can
154
154
  # contain any values. The provided values will be displayed in the Params
155
155
  # tab in your project's dashboard
156
+ # @yield [notice] The notice to filter
157
+ # @yieldparam [Airbrake::Notice]
158
+ # @yieldreturn [void]
156
159
  # @return [Airbrake::Promise]
157
160
  # @see .notify_sync
158
- def notify(exception, params = {})
159
- @notifiers[:default].notify(exception, params)
161
+ def notify(exception, params = {}, &block)
162
+ @notifiers[:default].notify(exception, params, &block)
160
163
  end
161
164
 
162
165
  ##
@@ -166,10 +169,18 @@ module Airbrake
166
169
  # Airbrake.notify_sync('App crashed!')
167
170
  # #=> {"id"=>"123", "url"=>"https://airbrake.io/locate/321"}
168
171
  #
172
+ # @param [Exception, String, Airbrake::Notice] exception The exception to be
173
+ # sent to Airbrake
174
+ # @param [Hash] params The additional payload to be sent to Airbrake. Can
175
+ # contain any values. The provided values will be displayed in the Params
176
+ # tab in your project's dashboard
177
+ # @yield [notice] The notice to filter
178
+ # @yieldparam [Airbrake::Notice]
179
+ # @yieldreturn [void]
169
180
  # @return [Hash{String=>String}] the reponse from the server
170
181
  # @see .notify
171
- def notify_sync(exception, params = {})
172
- @notifiers[:default].notify_sync(exception, params)
182
+ def notify_sync(exception, params = {}, &block)
183
+ @notifiers[:default].notify_sync(exception, params, &block)
173
184
  end
174
185
 
175
186
  ##
@@ -56,6 +56,10 @@ module Airbrake
56
56
  # @return [String] the name of the host machine
57
57
  HOSTNAME = Socket.gethostname.freeze
58
58
 
59
+ ##
60
+ # @return [String]
61
+ DEFAULT_SEVERITY = 'error'.freeze
62
+
59
63
  ##
60
64
  # @since v1.7.0
61
65
  # @return [Hash{Symbol=>Object}] the hash with arbitrary objects to be used
@@ -158,7 +162,9 @@ module Airbrake
158
162
  environment: @config.environment,
159
163
 
160
164
  # Make sure we always send hostname.
161
- hostname: HOSTNAME
165
+ hostname: HOSTNAME,
166
+
167
+ severity: DEFAULT_SEVERITY
162
168
  }.merge(CONTEXT).delete_if { |_key, val| val.nil? || val.empty? }
163
169
  end
164
170
 
@@ -47,14 +47,14 @@ module Airbrake
47
47
 
48
48
  ##
49
49
  # @macro see_public_api_method
50
- def notify(exception, params = {})
51
- send_notice(exception, params, default_sender)
50
+ def notify(exception, params = {}, &block)
51
+ send_notice(exception, params, default_sender, &block)
52
52
  end
53
53
 
54
54
  ##
55
55
  # @macro see_public_api_method
56
- def notify_sync(exception, params = {})
57
- send_notice(exception, params, @sync_sender).value
56
+ def notify_sync(exception, params = {}, &block)
57
+ send_notice(exception, params, @sync_sender, &block).value
58
58
  end
59
59
 
60
60
  ##
@@ -119,6 +119,8 @@ module Airbrake
119
119
 
120
120
  notice = build_notice(exception, params)
121
121
  @filter_chain.refine(notice)
122
+ yield notice if block_given?
123
+
122
124
  if notice.ignored?
123
125
  return promise.reject("#{notice} was marked as ignored")
124
126
  end
@@ -4,5 +4,5 @@
4
4
  module Airbrake
5
5
  ##
6
6
  # @return [String] the library version
7
- AIRBRAKE_RUBY_VERSION = '2.1.0'.freeze
7
+ AIRBRAKE_RUBY_VERSION = '2.2.0'.freeze
8
8
  end
@@ -41,6 +41,19 @@ RSpec.describe Airbrake do
41
41
  sleep 2
42
42
  expect(a_request(:post, endpoint)).to have_been_made.once
43
43
  end
44
+
45
+ it "yields a notice" do
46
+ described_class.notify('bongo') do |notice|
47
+ notice[:params][:bingo] = :bango
48
+ end
49
+
50
+ sleep 1
51
+
52
+ expect(
53
+ a_request(:post, endpoint).
54
+ with(body: /params":{.*"bingo":"bango".*}/)
55
+ ).to have_been_made.once
56
+ end
44
57
  end
45
58
 
46
59
  describe ".notify_sync" do
@@ -51,6 +64,17 @@ RSpec.describe Airbrake do
51
64
  expect(a_request(:post, endpoint)).to have_been_made.once
52
65
  end
53
66
 
67
+ it "yields a notice" do
68
+ described_class.notify_sync('bongo') do |notice|
69
+ notice[:params][:bingo] = :bango
70
+ end
71
+
72
+ expect(
73
+ a_request(:post, endpoint).
74
+ with(body: /params":{.*"bingo":"bango".*}/)
75
+ ).to have_been_made.once
76
+ end
77
+
54
78
  describe "clean backtrace" do
55
79
  shared_examples 'backtrace building' do |msg, argument|
56
80
  it(msg) do
data/spec/notice_spec.rb CHANGED
@@ -200,6 +200,10 @@ RSpec.describe Airbrake::Notice do
200
200
  expect(notice.to_json).
201
201
  to match(/"context":{.*"hostname":".+".*}/)
202
202
  end
203
+
204
+ it "defaults to the error severity" do
205
+ expect(notice.to_json).to match(/"context":{.*"severity":"error".*}/)
206
+ end
203
207
  end
204
208
 
205
209
  describe "#[]" do
@@ -378,6 +378,13 @@ RSpec.describe Airbrake::Notifier do
378
378
  end
379
379
  end
380
380
  end
381
+
382
+ describe "block argument" do
383
+ it "yields a notice" do
384
+ @airbrake.notify_sync(ex) { |notice| notice[:params][:bingo] = :bango }
385
+ expect_a_request_with_body(/params":{.*"bingo":"bango".*}/)
386
+ end
387
+ end
381
388
  end
382
389
 
383
390
  describe "#notify" do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: airbrake-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.0
4
+ version: 2.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Airbrake Technologies, Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-04-27 00:00:00.000000000 Z
11
+ date: 2017-05-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec