honeybadger 5.8.1 → 5.10.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
  SHA256:
3
- metadata.gz: 970f861f7385a6b9623cab40cc53b5d12ec7466c45b977bbdaaa6bae7d79a4a3
4
- data.tar.gz: 49c3ce7f9e6b37e77806ea20ddd0372a17e432f08b31f0dd401c3cd56af2be84
3
+ metadata.gz: 6d9f929f3c5aabe854d9c6cd222a6863e751f18784077580cc8781714f0e61e6
4
+ data.tar.gz: cc4c3921b06bcf5c0fee59a5d0a33b1359da5b255db1e3709bf08cf0f84731a7
5
5
  SHA512:
6
- metadata.gz: c2446dc5c909c48c799a5fa6b7561b0e4fbf481c16f3ac36f7b0611ee09f842bebc65d39c2bb17897b4125edaead2d4f408b870c101d256f8dafe6797c95cfa6
7
- data.tar.gz: 0b5c84e1eaba9b4b7e3d40dbe0a6d784237d3d76a9354fb041ef58a305c8a4c1362e71d8026dfb9ca30b5683ce82fbfb4109727471d786f624816a43eeb3849d
6
+ metadata.gz: b786d75e0588efb1cec01e13fbb46ecd1d71d305f21b20cf41e836f88ffac2e10a938d058e0be62d41211e2c4476b210c25793919d3470a0f2aa07b2391e2fec
7
+ data.tar.gz: 68faad897df72b3ac7efa6a7321c00c5d71c97578431a39ba84d87ce8f828bea86ee754fd1216dceb2d01ac00a5b434072e2a706180da6d676777e443c28f5e4
data/CHANGELOG.md CHANGED
@@ -1,6 +1,20 @@
1
1
  # Change Log
2
2
 
3
3
 
4
+ ## [5.10.0](https://github.com/honeybadger-io/honeybadger-ruby/compare/v5.9.0...v5.10.0) (2024-05-10)
5
+
6
+
7
+ ### Features
8
+
9
+ * return block value if block was passed to Honeybadger.context ([#546](https://github.com/honeybadger-io/honeybadger-ruby/issues/546)) ([2d7c685](https://github.com/honeybadger-io/honeybadger-ruby/commit/2d7c68565a5b9013fbbad6da16a706f38a3306b0))
10
+
11
+ ## [5.9.0](https://github.com/honeybadger-io/honeybadger-ruby/compare/v5.8.1...v5.9.0) (2024-05-09)
12
+
13
+
14
+ ### Features
15
+
16
+ * implement local contexts ([#541](https://github.com/honeybadger-io/honeybadger-ruby/issues/541)) ([806718e](https://github.com/honeybadger-io/honeybadger-ruby/commit/806718e76bf8d132a632c75bea124a8b22a4cc97))
17
+
4
18
  ## [5.8.1](https://github.com/honeybadger-io/honeybadger-ruby/compare/v5.8.0...v5.8.1) (2024-05-07)
5
19
 
6
20
 
@@ -258,9 +258,11 @@ module Honeybadger
258
258
  # When present, tags will be applied to errors with this context
259
259
  # (optional).
260
260
  #
261
- # @return [self] so that method calls can be chained.
262
- def context(context = nil)
263
- context_manager.set_context(context) unless context.nil?
261
+ # @return [Object, self] value of the block if passed, otherwise self
262
+ def context(context = nil, &block)
263
+ block_result = context_manager.set_context(context, &block) unless context.nil?
264
+ return block_result if block_given?
265
+
264
266
  self
265
267
  end
266
268
 
@@ -21,15 +21,36 @@ module Honeybadger
21
21
  # Internal helpers
22
22
 
23
23
 
24
- def set_context(hash)
24
+ def set_context(hash, &block)
25
+ local = block_given?
25
26
  @mutex.synchronize do
26
- @context ||= {}
27
- @context.update(Context(hash))
27
+ @global_context ||= {}
28
+ @local_context ||= []
29
+
30
+ new_context = Context(hash)
31
+
32
+ if local
33
+ @local_context << new_context
34
+ else
35
+ @global_context.update(new_context)
36
+ end
37
+ end
38
+
39
+ if local
40
+ begin
41
+ yield
42
+ ensure
43
+ @mutex.synchronize { @local_context&.pop }
44
+ end
28
45
  end
29
46
  end
30
47
 
31
48
  def get_context
32
- @mutex.synchronize { @context }
49
+ @mutex.synchronize do
50
+ return @global_context unless @local_context
51
+
52
+ @global_context.merge(@local_context.inject({}, :merge))
53
+ end
33
54
  end
34
55
 
35
56
  def set_rack_env(env)
@@ -46,10 +67,10 @@ module Honeybadger
46
67
 
47
68
  def _initialize
48
69
  @mutex.synchronize do
49
- @context = nil
70
+ @global_context = nil
71
+ @local_context = nil
50
72
  @rack_env = nil
51
73
  end
52
74
  end
53
-
54
75
  end
55
76
  end
@@ -1,4 +1,4 @@
1
1
  module Honeybadger
2
2
  # The current String Honeybadger version.
3
- VERSION = '5.8.1'.freeze
3
+ VERSION = '5.10.0'.freeze
4
4
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: honeybadger
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.8.1
4
+ version: 5.10.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Honeybadger Industries LLC
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-05-07 00:00:00.000000000 Z
11
+ date: 2024-05-10 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Make managing application errors a more pleasant experience.
14
14
  email: