airbrake-ruby 2.6.0 → 2.6.1

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: 10cd1c4c112ec8325d9e800128cb3598ecca5e79
4
- data.tar.gz: e06b612001f91e0a6e928250d735fc57b2d9a313
3
+ metadata.gz: 90f2e4201837aa2d9bde698e677f0821dfffde88
4
+ data.tar.gz: 26f5a5638e4dad153694a04551ac5b98f0241398
5
5
  SHA512:
6
- metadata.gz: 39edba81094187bde03fd1f5fc916255737dde0fabcd0f5c720075c22c97d914c602bdda046669db3b48680ec0bae798bf4225a4645d4a08e450171de76a34d0
7
- data.tar.gz: 3d0b4de47de97f5cc9bd425a70aa1128449df90329f33e93f843c6729571cd2ca38d371477fa98ea46d380c116dd7bf20a670f230bef59eeb34d8fd72d1b0f23
6
+ metadata.gz: 2a115026135272d066da9d827ce6d1259345881b4ee1c12287729d0fdf76c42f58485d8108cc38dff14d9eaf60ee289642ae80d740aee2c5ebb67d4e5728e1ad
7
+ data.tar.gz: 9d8d43dc5745d05e649fa290be7500015ff5f416915a8de3b0489ad518e9b307c7c4edec5f9f6cdb2d800ff569eb45175f2b5c7cb456a8ba460e59206ffc7053
@@ -12,6 +12,15 @@ module Airbrake
12
12
  # strings with +ENCODING_OPTIONS+
13
13
  TEMP_ENCODING = 'utf-16'.freeze
14
14
 
15
+ # @return [String] what to append when something is a circular reference
16
+ CIRCULAR = '[Circular]'.freeze
17
+
18
+ # @return [String] what to append when something is truncated
19
+ TRUNCATED = '[Truncated]'.freeze
20
+
21
+ # @return [Array<Class>] The types that can contain references to itself
22
+ CIRCULAR_TYPES = [Array, Hash, Set].freeze
23
+
15
24
  # @param [Integer] max_size maximum size of hashes, arrays and strings
16
25
  def initialize(max_size)
17
26
  @max_size = max_size
@@ -24,7 +33,10 @@ module Airbrake
24
33
  # @param [Set] seen The cache that helps to detect recursion
25
34
  # @return [Object] truncated object
26
35
  def truncate(object, seen = Set.new)
27
- return '[Circular]'.freeze if seen.include?(object)
36
+ if seen.include?(object)
37
+ return CIRCULAR if CIRCULAR_TYPES.any? { |t| object.is_a?(t) }
38
+ return object
39
+ end
28
40
  truncate_object(object, seen << object)
29
41
  end
30
42
 
@@ -51,7 +63,7 @@ module Airbrake
51
63
  def truncate_string(str)
52
64
  fixed_str = replace_invalid_characters(str)
53
65
  return fixed_str if fixed_str.length <= @max_size
54
- (fixed_str.slice(0, @max_size) + '[Truncated]').freeze
66
+ (fixed_str.slice(0, @max_size) + TRUNCATED).freeze
55
67
  end
56
68
 
57
69
  def stringify_object(object)
@@ -4,5 +4,5 @@
4
4
  module Airbrake
5
5
  ##
6
6
  # @return [String] the library version
7
- AIRBRAKE_RUBY_VERSION = '2.6.0'.freeze
7
+ AIRBRAKE_RUBY_VERSION = '2.6.1'.freeze
8
8
  end
@@ -211,5 +211,28 @@ RSpec.describe Airbrake::Truncator do
211
211
  expect(subject).to be_frozen
212
212
  end
213
213
  end
214
+
215
+ context "given an array with hashes and hash-like objects with identical keys" do
216
+ let(:hashie) { Class.new(Hash) }
217
+
218
+ let(:object) do
219
+ {
220
+ errors: [
221
+ { file: 'a' },
222
+ hashie.new.merge(file: 'bcde')
223
+ ]
224
+ }
225
+ end
226
+
227
+ it "truncates values" do
228
+ expect(subject).to eq(
229
+ errors: [
230
+ { file: 'a' },
231
+ hashie.new.merge(file: 'bcd[Truncated]')
232
+ ]
233
+ )
234
+ expect(subject).to be_frozen
235
+ end
236
+ end
214
237
  end
215
238
  end
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.6.0
4
+ version: 2.6.1
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-11-09 00:00:00.000000000 Z
11
+ date: 2017-12-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec