bson 4.8.1 → 4.8.2
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
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/lib/bson/array.rb +7 -1
- data/lib/bson/code_with_scope.rb +7 -1
- data/lib/bson/db_pointer.rb +7 -1
- data/lib/bson/ext_json.rb +2 -2
- data/lib/bson/version.rb +1 -1
- data/spec/bson/ext_json_parse_spec.rb +34 -2
- metadata +84 -84
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e38ba3f134f5442df04b99f97b72d5804958bd0e67a0671120c68b8e478a6bbc
|
4
|
+
data.tar.gz: aea2543db1c169057f384ee24b3823c7ecee63c50db026666e5a0ac3b657de02
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4cb39ca20cec492ae47a8ec79135dac10bc9abbd3efcbd75463af6659a37450048160a7ee72015ed5c0c1f15252b3ce2d760d1a9ecaa36135b5335e3792ec211
|
7
|
+
data.tar.gz: 981cb9b77564419678f14382ba5e63c8c55ad4ae8d500953a7b64bbc031614c1b235d76140e62573f806a0e37a680eaafd7e0699e57a41e810d028f8c74fee56
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/lib/bson/array.rb
CHANGED
@@ -122,7 +122,13 @@ module BSON
|
|
122
122
|
buffer.get_int32 # throw away the length
|
123
123
|
while (type = buffer.get_byte) != NULL_BYTE
|
124
124
|
buffer.get_cstring
|
125
|
-
|
125
|
+
cls = BSON::Registry.get(type)
|
126
|
+
value = if options.empty?
|
127
|
+
cls.from_bson(buffer)
|
128
|
+
else
|
129
|
+
cls.from_bson(buffer, **options)
|
130
|
+
end
|
131
|
+
array << value
|
126
132
|
end
|
127
133
|
array
|
128
134
|
end
|
data/lib/bson/code_with_scope.rb
CHANGED
@@ -120,7 +120,13 @@ module BSON
|
|
120
120
|
# @since 2.0.0
|
121
121
|
def self.from_bson(buffer, **options)
|
122
122
|
buffer.get_int32 # Throw away the total length.
|
123
|
-
|
123
|
+
javascript = buffer.get_string
|
124
|
+
scope = if options.empty?
|
125
|
+
::Hash.from_bson(buffer)
|
126
|
+
else
|
127
|
+
::Hash.from_bson(buffer, **options)
|
128
|
+
end
|
129
|
+
new(javascript, scope)
|
124
130
|
end
|
125
131
|
|
126
132
|
# Register this type when the module is loaded.
|
data/lib/bson/db_pointer.rb
CHANGED
@@ -95,7 +95,13 @@ module BSON
|
|
95
95
|
#
|
96
96
|
# @see http://bsonspec.org/#/specification
|
97
97
|
def self.from_bson(buffer, **options)
|
98
|
-
|
98
|
+
ref = buffer.get_string
|
99
|
+
id = if options.empty?
|
100
|
+
ObjectId.from_bson(buffer)
|
101
|
+
else
|
102
|
+
ObjectId.from_bson(buffer, **options)
|
103
|
+
end
|
104
|
+
new(ref, id)
|
99
105
|
end
|
100
106
|
|
101
107
|
# Register this type when the module is loaded.
|
data/lib/bson/ext_json.rb
CHANGED
@@ -251,13 +251,13 @@ module BSON
|
|
251
251
|
when '$date'
|
252
252
|
case value
|
253
253
|
when String
|
254
|
-
::Time.parse(value)
|
254
|
+
::Time.parse(value).utc
|
255
255
|
when Hash
|
256
256
|
unless value.keys.sort == %w($numberLong)
|
257
257
|
raise Error::ExtJSONParseError, "Invalid value for $date: #{value}"
|
258
258
|
end
|
259
259
|
sec, msec = value.values.first.to_i.divmod(1000)
|
260
|
-
::Time.at(sec, msec*1000)
|
260
|
+
::Time.at(sec, msec*1000).utc
|
261
261
|
else
|
262
262
|
raise Error::ExtJSONParseError, "Invalid value for $date: #{value}"
|
263
263
|
end
|
data/lib/bson/version.rb
CHANGED
@@ -50,14 +50,46 @@ describe "BSON::ExtJSON.parse" do
|
|
50
50
|
end
|
51
51
|
end
|
52
52
|
|
53
|
-
context 'when input is a timestamp' do
|
53
|
+
context 'when input is a BSON timestamp' do
|
54
54
|
let(:input) { {'$timestamp' => {'t' => 12345, 'i' => 42}} }
|
55
55
|
|
56
|
-
it 'returns a
|
56
|
+
it 'returns a BSON::Timestamp instance' do
|
57
57
|
parsed.should == BSON::Timestamp.new(12345, 42)
|
58
58
|
end
|
59
59
|
end
|
60
60
|
|
61
|
+
context 'when input is an ISO time' do
|
62
|
+
let(:input) { {'$date' => '1970-01-01T00:00:04Z'} }
|
63
|
+
|
64
|
+
it 'returns a Time instance ' do
|
65
|
+
parsed.should be_a(Time)
|
66
|
+
end
|
67
|
+
|
68
|
+
it 'returns a Time instance with correct value' do
|
69
|
+
parsed.should == Time.at(4)
|
70
|
+
end
|
71
|
+
|
72
|
+
it 'returns a Time instance in UTC' do
|
73
|
+
parsed.zone.should == 'UTC'
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
context 'when input is a Unix timestamp' do
|
78
|
+
let(:input) { {'$date' => {'$numberLong' => '4000'}} }
|
79
|
+
|
80
|
+
it 'returns a Time instance ' do
|
81
|
+
parsed.should be_a(Time)
|
82
|
+
end
|
83
|
+
|
84
|
+
it 'returns a Time instance with correct value' do
|
85
|
+
parsed.should == Time.at(4)
|
86
|
+
end
|
87
|
+
|
88
|
+
it 'returns a Time instance in UTC' do
|
89
|
+
parsed.zone.should == 'UTC'
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
61
93
|
context 'when input is an int32' do
|
62
94
|
let(:input) do
|
63
95
|
{'$numberInt' => '42'}
|
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.8.
|
4
|
+
version: 4.8.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tyler Brock
|
@@ -33,7 +33,7 @@ cert_chain:
|
|
33
33
|
gpvfPNWMwyBDlHaNS3GfO6cRRxBOvEG05GUCsvtTY4Bpe8yjE64wg1ymb47LMOnv
|
34
34
|
Qb1lGORmf/opg45mluKUYl7pQNZHD0d3
|
35
35
|
-----END CERTIFICATE-----
|
36
|
-
date: 2020-03-
|
36
|
+
date: 2020-03-04 00:00:00.000000000 Z
|
37
37
|
dependencies: []
|
38
38
|
description: A fully featured BSON specification implementation in Ruby
|
39
39
|
email:
|
@@ -235,118 +235,118 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
235
235
|
- !ruby/object:Gem::Version
|
236
236
|
version: 1.3.6
|
237
237
|
requirements: []
|
238
|
-
rubygems_version: 3.
|
238
|
+
rubygems_version: 3.1.2
|
239
239
|
signing_key:
|
240
240
|
specification_version: 4
|
241
241
|
summary: Ruby implementation of the BSON specification
|
242
242
|
test_files:
|
243
|
-
- spec/bson/
|
243
|
+
- spec/bson/date_spec.rb
|
244
|
+
- spec/bson/config_spec.rb
|
245
|
+
- spec/bson/int64_spec.rb
|
244
246
|
- spec/bson/undefined_spec.rb
|
245
|
-
- spec/bson/regexp_spec.rb
|
246
|
-
- spec/bson/decimal128_spec.rb
|
247
247
|
- spec/bson/code_spec.rb
|
248
|
-
- spec/bson/time_spec.rb
|
249
248
|
- spec/bson/object_spec.rb
|
250
|
-
- spec/bson/
|
249
|
+
- spec/bson/date_time_spec.rb
|
250
|
+
- spec/bson/raw_spec.rb
|
251
|
+
- spec/bson/min_key_spec.rb
|
252
|
+
- spec/bson/time_with_zone_spec.rb
|
253
|
+
- spec/bson/time_spec.rb
|
254
|
+
- spec/bson/hash_spec.rb
|
255
|
+
- spec/bson/ext_json_parse_spec.rb
|
256
|
+
- spec/bson/timestamp_spec.rb
|
257
|
+
- spec/bson/int32_spec.rb
|
258
|
+
- spec/bson/byte_buffer_spec.rb
|
259
|
+
- spec/bson/registry_spec.rb
|
260
|
+
- spec/bson/symbol_raw_spec.rb
|
261
|
+
- spec/bson/regexp_spec.rb
|
262
|
+
- spec/bson/byte_buffer_write_spec.rb
|
263
|
+
- spec/bson/symbol_spec.rb
|
251
264
|
- spec/bson/string_spec.rb
|
252
|
-
- spec/bson/byte_buffer_read_spec.rb
|
253
|
-
- spec/bson/config_spec.rb
|
254
|
-
- spec/bson/json_spec.rb
|
255
265
|
- spec/bson/boolean_spec.rb
|
256
|
-
- spec/bson/hash_spec.rb
|
257
266
|
- spec/bson/open_struct_spec.rb
|
258
|
-
- spec/bson/
|
267
|
+
- spec/bson/decimal128_spec.rb
|
268
|
+
- spec/bson/json_spec.rb
|
259
269
|
- spec/bson/array_spec.rb
|
260
270
|
- spec/bson/false_class_spec.rb
|
261
|
-
- spec/bson/symbol_raw_spec.rb
|
262
|
-
- spec/bson/binary_uuid_spec.rb
|
263
|
-
- spec/bson/ext_json_parse_spec.rb
|
264
271
|
- spec/bson/true_class_spec.rb
|
265
|
-
- spec/bson/date_spec.rb
|
266
|
-
- spec/bson/byte_buffer_write_spec.rb
|
267
|
-
- spec/bson/int64_spec.rb
|
268
|
-
- spec/bson/timestamp_spec.rb
|
269
|
-
- spec/bson/max_key_spec.rb
|
270
|
-
- spec/bson/raw_spec.rb
|
271
|
-
- spec/bson/byte_buffer_spec.rb
|
272
|
-
- spec/bson/document_spec.rb
|
273
|
-
- spec/bson/code_with_scope_spec.rb
|
274
|
-
- spec/bson/float_spec.rb
|
275
|
-
- spec/bson/time_with_zone_spec.rb
|
276
272
|
- spec/bson/binary_spec.rb
|
277
|
-
- spec/bson/
|
278
|
-
- spec/bson/symbol_spec.rb
|
279
|
-
- spec/bson/date_time_spec.rb
|
273
|
+
- spec/bson/binary_uuid_spec.rb
|
280
274
|
- spec/bson/object_id_spec.rb
|
281
|
-
- spec/bson/
|
275
|
+
- spec/bson/code_with_scope_spec.rb
|
276
|
+
- spec/bson/nil_class_spec.rb
|
277
|
+
- spec/bson/integer_spec.rb
|
278
|
+
- spec/bson/document_spec.rb
|
279
|
+
- spec/bson/max_key_spec.rb
|
280
|
+
- spec/bson/byte_buffer_read_spec.rb
|
281
|
+
- spec/bson/float_spec.rb
|
282
282
|
- spec/support/utils.rb
|
283
283
|
- spec/support/shared_examples.rb
|
284
284
|
- spec/support/spec_config.rb
|
285
|
-
- spec/
|
286
|
-
- spec/spec_tests/
|
287
|
-
- spec/spec_tests/
|
288
|
-
- spec/spec_tests/data/decimal128/decimal128-
|
285
|
+
- spec/spec_helper.rb
|
286
|
+
- spec/spec_tests/data/decimal128/decimal128-4.json
|
287
|
+
- spec/spec_tests/data/decimal128/decimal128-2.json
|
288
|
+
- spec/spec_tests/data/decimal128/decimal128-5.json
|
289
289
|
- spec/spec_tests/data/decimal128/decimal128-3.json
|
290
|
+
- spec/spec_tests/data/decimal128/decimal128-6.json
|
290
291
|
- spec/spec_tests/data/decimal128/decimal128-1.json
|
291
|
-
- spec/spec_tests/data/decimal128/decimal128-4.json
|
292
292
|
- spec/spec_tests/data/decimal128/decimal128-7.json
|
293
|
-
- spec/spec_tests/data/
|
294
|
-
- spec/spec_tests/data/decimal128/decimal128-2.json
|
295
|
-
- spec/spec_tests/data/corpus_legacy/code_w_scope.json
|
296
|
-
- spec/spec_tests/data/corpus_legacy/undefined.json
|
297
|
-
- spec/spec_tests/data/corpus_legacy/code.json
|
298
|
-
- spec/spec_tests/data/corpus_legacy/oid.json
|
299
|
-
- spec/spec_tests/data/corpus_legacy/timestamp.json
|
300
|
-
- spec/spec_tests/data/corpus_legacy/string.json
|
301
|
-
- spec/spec_tests/data/corpus_legacy/binary.json
|
302
|
-
- spec/spec_tests/data/corpus_legacy/null.json
|
303
|
-
- spec/spec_tests/data/corpus_legacy/int32.json
|
304
|
-
- spec/spec_tests/data/corpus_legacy/maxkey.json
|
305
|
-
- spec/spec_tests/data/corpus_legacy/array.json
|
306
|
-
- spec/spec_tests/data/corpus_legacy/regex.json
|
307
|
-
- spec/spec_tests/data/corpus_legacy/minkey.json
|
308
|
-
- spec/spec_tests/data/corpus_legacy/top.json
|
309
|
-
- spec/spec_tests/data/corpus_legacy/failures/symbol.json
|
310
|
-
- spec/spec_tests/data/corpus_legacy/failures/int64.json
|
311
|
-
- spec/spec_tests/data/corpus_legacy/failures/dbpointer.json
|
312
|
-
- spec/spec_tests/data/corpus_legacy/failures/datetime.json
|
313
|
-
- spec/spec_tests/data/corpus_legacy/boolean.json
|
314
|
-
- spec/spec_tests/data/corpus_legacy/double.json
|
315
|
-
- spec/spec_tests/data/corpus_legacy/document.json
|
316
|
-
- spec/spec_tests/data/corpus/code_w_scope.json
|
317
|
-
- spec/spec_tests/data/corpus/undefined.json
|
318
|
-
- spec/spec_tests/data/corpus/code.json
|
319
|
-
- spec/spec_tests/data/corpus/decimal128-6.json
|
320
|
-
- spec/spec_tests/data/corpus/oid.json
|
321
|
-
- spec/spec_tests/data/corpus/timestamp.json
|
322
|
-
- spec/spec_tests/data/corpus/decimal128-3.json
|
293
|
+
- spec/spec_tests/data/corpus/multi-type.json
|
323
294
|
- spec/spec_tests/data/corpus/string.json
|
295
|
+
- spec/spec_tests/data/corpus/decimal128-4.json
|
296
|
+
- spec/spec_tests/data/corpus/README.md
|
324
297
|
- spec/spec_tests/data/corpus/binary.json
|
298
|
+
- spec/spec_tests/data/corpus/decimal128-2.json
|
299
|
+
- spec/spec_tests/data/corpus/dbpointer.json
|
300
|
+
- spec/spec_tests/data/corpus/dbref.json
|
325
301
|
- spec/spec_tests/data/corpus/null.json
|
326
302
|
- spec/spec_tests/data/corpus/int32.json
|
327
|
-
- spec/spec_tests/data/corpus/multi-type.json
|
328
|
-
- spec/spec_tests/data/corpus/decimal128-1.json
|
329
|
-
- spec/spec_tests/data/corpus/decimal128-4.json
|
330
|
-
- spec/spec_tests/data/corpus/README.md
|
331
303
|
- spec/spec_tests/data/corpus/maxkey.json
|
332
|
-
- spec/spec_tests/data/corpus/
|
304
|
+
- spec/spec_tests/data/corpus/timestamp.json
|
305
|
+
- spec/spec_tests/data/corpus/multi-type-deprecated.json
|
306
|
+
- spec/spec_tests/data/corpus/code.json
|
307
|
+
- spec/spec_tests/data/corpus/document.json
|
308
|
+
- spec/spec_tests/data/corpus/double.json
|
309
|
+
- spec/spec_tests/data/corpus/decimal128-5.json
|
333
310
|
- spec/spec_tests/data/corpus/regex.json
|
334
|
-
- spec/spec_tests/data/corpus/dbref.json
|
335
311
|
- spec/spec_tests/data/corpus/symbol.json
|
336
|
-
- spec/spec_tests/data/corpus/
|
337
|
-
- spec/spec_tests/data/corpus/decimal128-
|
312
|
+
- spec/spec_tests/data/corpus/decimal128-3.json
|
313
|
+
- spec/spec_tests/data/corpus/decimal128-6.json
|
314
|
+
- spec/spec_tests/data/corpus/oid.json
|
338
315
|
- spec/spec_tests/data/corpus/top.json
|
339
|
-
- spec/spec_tests/data/corpus/decimal128-
|
316
|
+
- spec/spec_tests/data/corpus/decimal128-1.json
|
340
317
|
- spec/spec_tests/data/corpus/boolean.json
|
341
|
-
- spec/spec_tests/data/corpus/
|
342
|
-
- spec/spec_tests/data/corpus/
|
343
|
-
- spec/spec_tests/data/corpus/
|
344
|
-
- spec/spec_tests/data/corpus/
|
345
|
-
- spec/spec_tests/data/corpus/
|
346
|
-
- spec/spec_tests/data/corpus/document.json
|
318
|
+
- spec/spec_tests/data/corpus/decimal128-7.json
|
319
|
+
- spec/spec_tests/data/corpus/array.json
|
320
|
+
- spec/spec_tests/data/corpus/code_w_scope.json
|
321
|
+
- spec/spec_tests/data/corpus/undefined.json
|
322
|
+
- spec/spec_tests/data/corpus/minkey.json
|
347
323
|
- spec/spec_tests/data/corpus/datetime.json
|
324
|
+
- spec/spec_tests/data/corpus/int64.json
|
325
|
+
- spec/spec_tests/data/corpus_legacy/string.json
|
326
|
+
- spec/spec_tests/data/corpus_legacy/binary.json
|
327
|
+
- spec/spec_tests/data/corpus_legacy/null.json
|
328
|
+
- spec/spec_tests/data/corpus_legacy/int32.json
|
329
|
+
- spec/spec_tests/data/corpus_legacy/maxkey.json
|
330
|
+
- spec/spec_tests/data/corpus_legacy/timestamp.json
|
331
|
+
- spec/spec_tests/data/corpus_legacy/failures/dbpointer.json
|
332
|
+
- spec/spec_tests/data/corpus_legacy/failures/symbol.json
|
333
|
+
- spec/spec_tests/data/corpus_legacy/failures/datetime.json
|
334
|
+
- spec/spec_tests/data/corpus_legacy/failures/int64.json
|
335
|
+
- spec/spec_tests/data/corpus_legacy/code.json
|
336
|
+
- spec/spec_tests/data/corpus_legacy/document.json
|
337
|
+
- spec/spec_tests/data/corpus_legacy/double.json
|
338
|
+
- spec/spec_tests/data/corpus_legacy/regex.json
|
339
|
+
- spec/spec_tests/data/corpus_legacy/oid.json
|
340
|
+
- spec/spec_tests/data/corpus_legacy/top.json
|
341
|
+
- spec/spec_tests/data/corpus_legacy/boolean.json
|
342
|
+
- spec/spec_tests/data/corpus_legacy/array.json
|
343
|
+
- spec/spec_tests/data/corpus_legacy/code_w_scope.json
|
344
|
+
- spec/spec_tests/data/corpus_legacy/undefined.json
|
345
|
+
- spec/spec_tests/data/corpus_legacy/minkey.json
|
348
346
|
- spec/spec_tests/common_driver_spec.rb
|
349
|
-
- spec/
|
350
|
-
- spec/
|
351
|
-
- spec/
|
347
|
+
- spec/spec_tests/corpus_spec.rb
|
348
|
+
- spec/spec_tests/corpus_legacy_spec.rb
|
349
|
+
- spec/bson_spec.rb
|
352
350
|
- spec/runners/corpus.rb
|
351
|
+
- spec/runners/common_driver.rb
|
352
|
+
- spec/runners/corpus_legacy.rb
|
metadata.gz.sig
CHANGED
Binary file
|