bson 4.12.0 → 4.12.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
  SHA256:
3
- metadata.gz: 3662e6dcaeb6d1abeb9e550812644bcf906ecf5342ad98e5e72e556924789102
4
- data.tar.gz: b224d635c9394d2798123d33cdc34a82a9955c25bdf82864d42e24bf8f3820d1
3
+ metadata.gz: 18f69f1d0f65a2c4883500061a6637f6fb314e7758a15cda3941432a7e6fbd0a
4
+ data.tar.gz: b26789d1b2da697b6113897040ecd297d88367267fd28411609f23229ec8be2e
5
5
  SHA512:
6
- metadata.gz: b85af4ca697de6dbff5fc6acb1cbbcbd6299a5d4424e2e3e9963f9725262b8feaf3043a60e7725439c5ba26b652ff021191cc4aa093d572369ca9884bd6da89a
7
- data.tar.gz: 4515e64a7078cf06e9683bf90693b358949582986145a81d9fe180a1fad18fa4aeb20b4f8bcebc0a3f1c5e1ba2496699e3763a81a61138b53fbb4c2b4c1741ef
6
+ metadata.gz: 7f90cd2d60cb0904d80ec6a3d75ba7d88af3872b5b1fdd27f9a283026f7c27ffbe84ad5331e571ebe120c7cd8c94d06190da8f1dc9fc783c349667f0ee963de1
7
+ data.tar.gz: da4c4edb81e99a804789c3914555376db3510a65437cc7b80829ae1f38f3c0f5a45894c8b4d8b24127367d0a9d1f46c9094a7b4f0f18633dbd4c4a8890675b02
checksums.yaml.gz.sig CHANGED
Binary file
data.tar.gz.sig CHANGED
Binary file
data/lib/bson/document.rb CHANGED
@@ -315,6 +315,10 @@ module BSON
315
315
  copy
316
316
  end
317
317
 
318
+ def symbolize_keys!
319
+ raise ArgumentError, 'symbolize_keys! is not supported on BSON::Document instances. Please convert the document to hash first (using #to_h), then call #symbolize_keys! on the Hash instance'
320
+ end
321
+
318
322
  private
319
323
 
320
324
  def convert_key(key)
data/lib/bson/version.rb CHANGED
@@ -13,5 +13,5 @@
13
13
  # limitations under the License.
14
14
 
15
15
  module BSON
16
- VERSION = "4.12.0".freeze
16
+ VERSION = "4.12.1".freeze
17
17
  end
@@ -0,0 +1,46 @@
1
+ # Copyright (C) 2021 MongoDB Inc.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ require "spec_helper"
16
+
17
+ # BSON::Document ActiveSupport extensions
18
+ describe BSON::Document do
19
+ require_active_support
20
+
21
+ describe '#symbolize_keys' do
22
+ context 'string keys' do
23
+ let(:doc) do
24
+ described_class.new('foo' => 'bar')
25
+ end
26
+
27
+ it 'works correctly' do
28
+ doc.symbolize_keys.should == {foo: 'bar'}
29
+ end
30
+ end
31
+ end
32
+
33
+ describe '#symbolize_keys!' do
34
+ context 'string keys' do
35
+ let(:doc) do
36
+ described_class.new('foo' => 'bar')
37
+ end
38
+
39
+ it 'raises ArgumentError' do
40
+ lambda do
41
+ doc.symbolize_keys!
42
+ end.should raise_error(ArgumentError, /symbolize_keys! is not supported on BSON::Document instances/)
43
+ end
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,57 @@
1
+ # Copyright (C) 2021 MongoDB Inc.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ require "spec_helper"
16
+
17
+ describe 'Hash ActiveSupport extensions' do
18
+ require_active_support
19
+
20
+ describe '#symbolize_keys' do
21
+ let(:symbolized) { hash.symbolize_keys }
22
+
23
+ shared_examples 'works correctly' do
24
+ it 'returns a hash' do
25
+ symbolized.class.should be Hash
26
+ end
27
+
28
+ it 'works correctly' do
29
+ hash.symbolize_keys.should == {foo: 'bar'}
30
+ end
31
+ end
32
+
33
+ context 'string keys' do
34
+ let(:hash) do
35
+ {'foo' => 'bar'}
36
+ end
37
+
38
+ include_examples 'works correctly'
39
+ end
40
+
41
+ context 'symbol keys' do
42
+ let(:hash) do
43
+ {foo: 'bar'}
44
+ end
45
+
46
+ include_examples 'works correctly'
47
+ end
48
+
49
+ context 'both string and symbol keys' do
50
+ let(:hash) do
51
+ {'foo' => 42, foo: 'bar'}
52
+ end
53
+
54
+ include_examples 'works correctly'
55
+ end
56
+ end
57
+ end
data/spec/spec_helper.rb CHANGED
@@ -17,6 +17,7 @@ DRIVER_COMMON_BSON_TESTS = Dir.glob("#{CURRENT_PATH}/spec_tests/data/decimal128/
17
17
  BSON_CORPUS_TESTS = Dir.glob("#{CURRENT_PATH}/spec_tests/data/corpus/*.json").sort
18
18
  BSON_CORPUS_LEGACY_TESTS = Dir.glob("#{CURRENT_PATH}/spec_tests/data/corpus_legacy/*.json").sort
19
19
 
20
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), "shared", "lib"))
20
21
  $LOAD_PATH.unshift(File.dirname(__FILE__))
21
22
  $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), "..", "lib"))
22
23
 
@@ -40,6 +41,8 @@ unless ENV['CI'] || BSON::Environment.jruby?
40
41
  end
41
42
  end
42
43
 
44
+ require 'mrss/lite_constraints'
45
+
43
46
  Dir["./spec/support/**/*.rb"].each { |file| require file }
44
47
 
45
48
  # Alternate IO class that returns a String from #readbyte.
@@ -71,4 +74,6 @@ RSpec.configure do |config|
71
74
  end
72
75
  end
73
76
  end
77
+
78
+ config.extend Mrss::LiteConstraints
74
79
  end
@@ -94,8 +94,20 @@
94
94
  "string": "{\"x\" : { \"$uuid\" : { \"data\" : \"73ffd264-44b3-4c69-90e8-e7d1dfc035d4\"}}}"
95
95
  },
96
96
  {
97
- "description": "$uuid invalid value",
97
+ "description": "$uuid invalid value--too short",
98
98
  "string": "{\"x\" : { \"$uuid\" : \"73ffd264-44b3-90e8-e7d1dfc035d4\"}}"
99
+ },
100
+ {
101
+ "description": "$uuid invalid value--too long",
102
+ "string": "{\"x\" : { \"$uuid\" : \"73ffd264-44b3-4c69-90e8-e7d1dfc035d4-789e4\"}}"
103
+ },
104
+ {
105
+ "description": "$uuid invalid value--misplaced hyphens",
106
+ "string": "{\"x\" : { \"$uuid\" : \"73ff-d26444b-34c6-990e8e-7d1dfc035d4\"}}"
107
+ },
108
+ {
109
+ "description": "$uuid invalid value--too many hyphens",
110
+ "string": "{\"x\" : { \"$uuid\" : \"----d264-44b3-4--9-90e8-e7d1dfc0----\"}}"
99
111
  }
100
112
  ]
101
113
  }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bson
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.12.0
4
+ version: 4.12.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tyler Brock
@@ -33,7 +33,7 @@ cert_chain:
33
33
  YoFhlyUEi7VLlqNH0H/JFttVZK6+qmLelkVNcIYVLeWOB4Lf4VxEiYGEK1ORxsrY
34
34
  iyYKJJALWY1FAInGRIlvkN+B8o3yIhq1
35
35
  -----END CERTIFICATE-----
36
- date: 2021-02-09 00:00:00.000000000 Z
36
+ date: 2021-05-28 00:00:00.000000000 Z
37
37
  dependencies: []
38
38
  description: A fully featured BSON specification implementation in Ruby
39
39
  email:
@@ -112,10 +112,12 @@ files:
112
112
  - spec/bson/date_spec.rb
113
113
  - spec/bson/date_time_spec.rb
114
114
  - spec/bson/decimal128_spec.rb
115
+ - spec/bson/document_as_spec.rb
115
116
  - spec/bson/document_spec.rb
116
117
  - spec/bson/ext_json_parse_spec.rb
117
118
  - spec/bson/false_class_spec.rb
118
119
  - spec/bson/float_spec.rb
120
+ - spec/bson/hash_as_spec.rb
119
121
  - spec/bson/hash_spec.rb
120
122
  - spec/bson/int32_spec.rb
121
123
  - spec/bson/int64_spec.rb
@@ -239,113 +241,115 @@ signing_key:
239
241
  specification_version: 4
240
242
  summary: Ruby implementation of the BSON specification
241
243
  test_files:
244
+ - spec/bson/true_class_spec.rb
245
+ - spec/bson/false_class_spec.rb
246
+ - spec/bson/object_spec.rb
247
+ - spec/bson/json_spec.rb
248
+ - spec/bson/undefined_spec.rb
249
+ - spec/bson/time_with_zone_spec.rb
250
+ - spec/bson/max_key_spec.rb
251
+ - spec/bson/float_spec.rb
252
+ - spec/bson/int32_spec.rb
253
+ - spec/bson/boolean_spec.rb
254
+ - spec/bson/int64_spec.rb
255
+ - spec/bson/min_key_spec.rb
256
+ - spec/bson/date_time_spec.rb
257
+ - spec/bson/date_spec.rb
258
+ - spec/bson/registry_spec.rb
259
+ - spec/bson/hash_as_spec.rb
260
+ - spec/bson/regexp_spec.rb
261
+ - spec/bson/timestamp_spec.rb
262
+ - spec/bson/decimal128_spec.rb
263
+ - spec/bson/binary_uuid_spec.rb
264
+ - spec/bson/binary_spec.rb
265
+ - spec/bson/document_as_spec.rb
266
+ - spec/bson/code_spec.rb
267
+ - spec/bson/array_spec.rb
268
+ - spec/bson/time_spec.rb
269
+ - spec/bson/raw_spec.rb
270
+ - spec/bson/string_spec.rb
271
+ - spec/bson/hash_spec.rb
272
+ - spec/bson/object_id_spec.rb
273
+ - spec/bson/ext_json_parse_spec.rb
274
+ - spec/bson/document_spec.rb
275
+ - spec/bson/symbol_spec.rb
276
+ - spec/bson/open_struct_spec.rb
277
+ - spec/bson/code_with_scope_spec.rb
278
+ - spec/bson/symbol_raw_spec.rb
279
+ - spec/bson/byte_buffer_write_spec.rb
280
+ - spec/bson/byte_buffer_spec.rb
281
+ - spec/bson/nil_class_spec.rb
282
+ - spec/bson/byte_buffer_read_spec.rb
283
+ - spec/bson/config_spec.rb
284
+ - spec/bson/integer_spec.rb
285
+ - spec/support/shared_examples.rb
286
+ - spec/support/utils.rb
287
+ - spec/support/spec_config.rb
242
288
  - spec/spec_helper.rb
243
- - spec/spec_tests/corpus_spec.rb
244
- - spec/spec_tests/common_driver_spec.rb
245
- - spec/spec_tests/data/corpus/decimal128-7.json
246
- - spec/spec_tests/data/corpus/top.json
247
- - spec/spec_tests/data/corpus/array.json
248
- - spec/spec_tests/data/corpus/null.json
249
- - spec/spec_tests/data/corpus/document.json
250
- - spec/spec_tests/data/corpus/decimal128-2.json
251
- - spec/spec_tests/data/corpus/decimal128-6.json
252
- - spec/spec_tests/data/corpus/boolean.json
253
- - spec/spec_tests/data/corpus/README.md
254
- - spec/spec_tests/data/corpus/maxkey.json
255
- - spec/spec_tests/data/corpus/binary.json
256
- - spec/spec_tests/data/corpus/multi-type.json
257
- - spec/spec_tests/data/corpus/timestamp.json
258
- - spec/spec_tests/data/corpus/multi-type-deprecated.json
259
- - spec/spec_tests/data/corpus/dbpointer.json
260
- - spec/spec_tests/data/corpus/oid.json
261
- - spec/spec_tests/data/corpus/regex.json
262
- - spec/spec_tests/data/corpus/minkey.json
263
- - spec/spec_tests/data/corpus/symbol.json
264
- - spec/spec_tests/data/corpus/dbref.json
265
- - spec/spec_tests/data/corpus/decimal128-1.json
266
- - spec/spec_tests/data/corpus/undefined.json
267
- - spec/spec_tests/data/corpus/double.json
268
- - spec/spec_tests/data/corpus/decimal128-4.json
269
- - spec/spec_tests/data/corpus/decimal128-3.json
270
- - spec/spec_tests/data/corpus/decimal128-5.json
271
- - spec/spec_tests/data/corpus/int32.json
272
- - spec/spec_tests/data/corpus/string.json
273
- - spec/spec_tests/data/corpus/code.json
274
- - spec/spec_tests/data/corpus/code_w_scope.json
275
- - spec/spec_tests/data/corpus/int64.json
276
- - spec/spec_tests/data/corpus/datetime.json
277
- - spec/spec_tests/data/corpus_legacy/top.json
278
- - spec/spec_tests/data/corpus_legacy/array.json
279
- - spec/spec_tests/data/corpus_legacy/null.json
280
- - spec/spec_tests/data/corpus_legacy/document.json
281
- - spec/spec_tests/data/corpus_legacy/boolean.json
282
- - spec/spec_tests/data/corpus_legacy/maxkey.json
283
- - spec/spec_tests/data/corpus_legacy/binary.json
284
- - spec/spec_tests/data/corpus_legacy/timestamp.json
285
289
  - spec/spec_tests/data/corpus_legacy/failures/dbpointer.json
286
290
  - spec/spec_tests/data/corpus_legacy/failures/symbol.json
287
291
  - spec/spec_tests/data/corpus_legacy/failures/int64.json
288
292
  - spec/spec_tests/data/corpus_legacy/failures/datetime.json
289
- - spec/spec_tests/data/corpus_legacy/oid.json
290
- - spec/spec_tests/data/corpus_legacy/regex.json
291
- - spec/spec_tests/data/corpus_legacy/minkey.json
293
+ - spec/spec_tests/data/corpus_legacy/timestamp.json
294
+ - spec/spec_tests/data/corpus_legacy/top.json
295
+ - spec/spec_tests/data/corpus_legacy/maxkey.json
292
296
  - spec/spec_tests/data/corpus_legacy/undefined.json
293
- - spec/spec_tests/data/corpus_legacy/double.json
297
+ - spec/spec_tests/data/corpus_legacy/array.json
294
298
  - spec/spec_tests/data/corpus_legacy/int32.json
299
+ - spec/spec_tests/data/corpus_legacy/oid.json
300
+ - spec/spec_tests/data/corpus_legacy/regex.json
301
+ - spec/spec_tests/data/corpus_legacy/binary.json
302
+ - spec/spec_tests/data/corpus_legacy/null.json
295
303
  - spec/spec_tests/data/corpus_legacy/string.json
304
+ - spec/spec_tests/data/corpus_legacy/document.json
305
+ - spec/spec_tests/data/corpus_legacy/minkey.json
306
+ - spec/spec_tests/data/corpus_legacy/boolean.json
296
307
  - spec/spec_tests/data/corpus_legacy/code.json
308
+ - spec/spec_tests/data/corpus_legacy/double.json
297
309
  - spec/spec_tests/data/corpus_legacy/code_w_scope.json
298
- - spec/spec_tests/data/decimal128/decimal128-7.json
299
- - spec/spec_tests/data/decimal128/decimal128-2.json
310
+ - spec/spec_tests/data/decimal128/decimal128-4.json
300
311
  - spec/spec_tests/data/decimal128/decimal128-6.json
312
+ - spec/spec_tests/data/decimal128/decimal128-2.json
301
313
  - spec/spec_tests/data/decimal128/decimal128-1.json
302
- - spec/spec_tests/data/decimal128/decimal128-4.json
314
+ - spec/spec_tests/data/decimal128/decimal128-7.json
303
315
  - spec/spec_tests/data/decimal128/decimal128-3.json
304
316
  - spec/spec_tests/data/decimal128/decimal128-5.json
317
+ - spec/spec_tests/data/corpus/timestamp.json
318
+ - spec/spec_tests/data/corpus/top.json
319
+ - spec/spec_tests/data/corpus/maxkey.json
320
+ - spec/spec_tests/data/corpus/decimal128-4.json
321
+ - spec/spec_tests/data/corpus/dbpointer.json
322
+ - spec/spec_tests/data/corpus/undefined.json
323
+ - spec/spec_tests/data/corpus/array.json
324
+ - spec/spec_tests/data/corpus/decimal128-6.json
325
+ - spec/spec_tests/data/corpus/README.md
326
+ - spec/spec_tests/data/corpus/int32.json
327
+ - spec/spec_tests/data/corpus/oid.json
328
+ - spec/spec_tests/data/corpus/regex.json
329
+ - spec/spec_tests/data/corpus/binary.json
330
+ - spec/spec_tests/data/corpus/symbol.json
331
+ - spec/spec_tests/data/corpus/null.json
332
+ - spec/spec_tests/data/corpus/decimal128-2.json
333
+ - spec/spec_tests/data/corpus/string.json
334
+ - spec/spec_tests/data/corpus/document.json
335
+ - spec/spec_tests/data/corpus/dbref.json
336
+ - spec/spec_tests/data/corpus/decimal128-1.json
337
+ - spec/spec_tests/data/corpus/minkey.json
338
+ - spec/spec_tests/data/corpus/boolean.json
339
+ - spec/spec_tests/data/corpus/int64.json
340
+ - spec/spec_tests/data/corpus/code.json
341
+ - spec/spec_tests/data/corpus/decimal128-7.json
342
+ - spec/spec_tests/data/corpus/decimal128-3.json
343
+ - spec/spec_tests/data/corpus/decimal128-5.json
344
+ - spec/spec_tests/data/corpus/double.json
345
+ - spec/spec_tests/data/corpus/multi-type.json
346
+ - spec/spec_tests/data/corpus/multi-type-deprecated.json
347
+ - spec/spec_tests/data/corpus/datetime.json
348
+ - spec/spec_tests/data/corpus/code_w_scope.json
349
+ - spec/spec_tests/corpus_spec.rb
305
350
  - spec/spec_tests/corpus_legacy_spec.rb
306
- - spec/support/utils.rb
307
- - spec/support/shared_examples.rb
308
- - spec/support/spec_config.rb
309
- - spec/runners/common_driver.rb
351
+ - spec/spec_tests/common_driver_spec.rb
310
352
  - spec/runners/corpus_legacy.rb
311
353
  - spec/runners/corpus.rb
312
- - spec/bson/code_spec.rb
313
- - spec/bson/byte_buffer_read_spec.rb
314
- - spec/bson/int32_spec.rb
315
- - spec/bson/max_key_spec.rb
316
- - spec/bson/time_spec.rb
317
- - spec/bson/array_spec.rb
318
- - spec/bson/date_time_spec.rb
319
- - spec/bson/document_spec.rb
320
- - spec/bson/float_spec.rb
321
- - spec/bson/nil_class_spec.rb
322
- - spec/bson/time_with_zone_spec.rb
323
- - spec/bson/ext_json_parse_spec.rb
324
- - spec/bson/string_spec.rb
325
- - spec/bson/open_struct_spec.rb
326
- - spec/bson/config_spec.rb
327
- - spec/bson/false_class_spec.rb
328
- - spec/bson/raw_spec.rb
329
- - spec/bson/regexp_spec.rb
330
- - spec/bson/binary_spec.rb
331
- - spec/bson/object_spec.rb
332
- - spec/bson/decimal128_spec.rb
333
- - spec/bson/binary_uuid_spec.rb
334
- - spec/bson/boolean_spec.rb
335
- - spec/bson/byte_buffer_spec.rb
336
- - spec/bson/json_spec.rb
337
- - spec/bson/symbol_spec.rb
338
- - spec/bson/integer_spec.rb
339
- - spec/bson/byte_buffer_write_spec.rb
340
- - spec/bson/registry_spec.rb
341
- - spec/bson/code_with_scope_spec.rb
342
- - spec/bson/true_class_spec.rb
343
- - spec/bson/undefined_spec.rb
344
- - spec/bson/object_id_spec.rb
345
- - spec/bson/timestamp_spec.rb
346
- - spec/bson/hash_spec.rb
347
- - spec/bson/symbol_raw_spec.rb
348
- - spec/bson/min_key_spec.rb
349
- - spec/bson/int64_spec.rb
350
- - spec/bson/date_spec.rb
354
+ - spec/runners/common_driver.rb
351
355
  - spec/bson_spec.rb
metadata.gz.sig CHANGED
@@ -1 +1,2 @@
1
- m�{'nC{")��X��`����K�4q���*j��=�̾.��.ʩC9,h����f3�y�>�]O�e]f���ɓk ��14W��A�g\\�A���i4rpDD���m3�\Vw���eap���!w�r>'���:�u]/gn��cr��m��׬��Ń~�h�;�ORF}�9b�?���H�ԧ�� |��Oi���xp�74� ����]���P:�H�G��v[���_��X��5j�ݮ��~W���45#kkY�.��K|
1
+ E(�s���I��}�*�q: Ȃ���ģ�io���_S�O��L��#Ǡ#�����"~x,|�پ6������T���
2
+ ���s��I-�W��\�G�acM��#RQD��Ol]�]�J[��&r����JφWIs�U��c����OC�~К����puIc��b��$�j! ��w5\#��Ѿ��fp+�M/W�L���`"�N��s�4`f����B�Y2��!l�4��X~� �hZ� ��s��E��W