airbrake-ruby 2.6.0 → 2.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/airbrake-ruby/truncator.rb +14 -2
- data/lib/airbrake-ruby/version.rb +1 -1
- data/spec/truncator_spec.rb +23 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 90f2e4201837aa2d9bde698e677f0821dfffde88
|
4
|
+
data.tar.gz: 26f5a5638e4dad153694a04551ac5b98f0241398
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
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) +
|
66
|
+
(fixed_str.slice(0, @max_size) + TRUNCATED).freeze
|
55
67
|
end
|
56
68
|
|
57
69
|
def stringify_object(object)
|
data/spec/truncator_spec.rb
CHANGED
@@ -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.
|
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
|
+
date: 2017-12-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|