bson 4.9.3 → 4.9.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/ext/bson/write.c +10 -3
- data/lib/bson/array.rb +3 -0
- data/lib/bson/error.rb +6 -0
- data/lib/bson/hash.rb +3 -0
- data/lib/bson/version.rb +1 -1
- data/spec/bson/array_spec.rb +17 -0
- data/spec/bson/hash_spec.rb +17 -0
- metadata +94 -93
- 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: 9d770bbf52ee70915f3f04b3831de6ef57c90ae131fcde462bb1925df609119e
|
4
|
+
data.tar.gz: ea768461024fac1dabccae70d6a2b6a6d68c74be70eb581b5849c37d535b1fb3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c85b9d81f0f849fca1f59ee23c239de332107c4758673e60ee4f160fc8c0ba4089de905bdf8024d755b005c8828043f80f6158de0e780dba02d459c17550cc34
|
7
|
+
data.tar.gz: 9663f3b950a457c1143204ef24dd7aa418be6ea350c2a615fdf752b2d14482606133649d0b2d18549d5d9676f4df37f39d23a6b027b06365b1fbc7ebba3bfc8a
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/ext/bson/write.c
CHANGED
@@ -154,8 +154,15 @@ void pvt_put_type_byte(byte_buffer_t *b, VALUE val){
|
|
154
154
|
case T_FLOAT:
|
155
155
|
type_byte = BSON_TYPE_DOUBLE;
|
156
156
|
break;
|
157
|
-
default:{
|
158
|
-
VALUE type
|
157
|
+
default: {
|
158
|
+
VALUE type;
|
159
|
+
VALUE responds = rb_funcall(val, rb_intern("respond_to?"), 1, ID2SYM(rb_intern("bson_type")));
|
160
|
+
if (!RTEST(responds)) {
|
161
|
+
VALUE klass = pvt_const_get_3("BSON", "Error", "UnserializableClass");
|
162
|
+
VALUE val_str = rb_funcall(val, rb_intern("to_s"), 0);
|
163
|
+
rb_raise(klass, "Value does not define its BSON serialized type: %s", RSTRING_PTR(val_str));
|
164
|
+
}
|
165
|
+
type = rb_funcall(val, rb_intern("bson_type"), 0);
|
159
166
|
type_byte = *RSTRING_PTR(type);
|
160
167
|
RB_GC_GUARD(type);
|
161
168
|
break;
|
@@ -627,7 +634,7 @@ VALUE rb_bson_byte_buffer_put_array(VALUE self, VALUE array, VALUE validating_ke
|
|
627
634
|
|
628
635
|
for(int32_t index=0; index < RARRAY_LEN(array); index++, array_element++){
|
629
636
|
pvt_put_type_byte(b, *array_element);
|
630
|
-
pvt_put_array_index(b,index);
|
637
|
+
pvt_put_array_index(b, index);
|
631
638
|
pvt_put_field(b, self, *array_element, validating_keys);
|
632
639
|
}
|
633
640
|
pvt_put_byte(b, 0);
|
data/lib/bson/array.rb
CHANGED
@@ -47,6 +47,9 @@ module BSON
|
|
47
47
|
position = buffer.length
|
48
48
|
buffer.put_int32(0)
|
49
49
|
each_with_index do |value, index|
|
50
|
+
unless value.respond_to?(:bson_type)
|
51
|
+
raise Error::UnserializableClass, "Array element at position #{index} does not define its BSON serialized type: #{value}"
|
52
|
+
end
|
50
53
|
buffer.put_byte(value.bson_type)
|
51
54
|
buffer.put_cstring(index.to_s)
|
52
55
|
value.to_bson(buffer, validating_keys)
|
data/lib/bson/error.rb
CHANGED
@@ -17,5 +17,11 @@ module BSON
|
|
17
17
|
# Exception raised when BSON decoding fails.
|
18
18
|
class BSONDecodeError < Error
|
19
19
|
end
|
20
|
+
|
21
|
+
# Exception raised when serializing an Array or Hash to BSON and an
|
22
|
+
# array or hash element is of a class that does not define how to serialize
|
23
|
+
# itself to BSON.
|
24
|
+
class UnserializableClass < Error
|
25
|
+
end
|
20
26
|
end
|
21
27
|
end
|
data/lib/bson/hash.rb
CHANGED
@@ -44,6 +44,9 @@ module BSON
|
|
44
44
|
position = buffer.length
|
45
45
|
buffer.put_int32(0)
|
46
46
|
each do |field, value|
|
47
|
+
unless value.respond_to?(:bson_type)
|
48
|
+
raise Error::UnserializableClass, "Hash value for key '#{field}' does not define its BSON serialized type: #{value}"
|
49
|
+
end
|
47
50
|
buffer.put_byte(value.bson_type)
|
48
51
|
key = field.to_bson_key(validating_keys)
|
49
52
|
begin
|
data/lib/bson/version.rb
CHANGED
data/spec/bson/array_spec.rb
CHANGED
@@ -132,6 +132,23 @@ describe Array do
|
|
132
132
|
end
|
133
133
|
end
|
134
134
|
end
|
135
|
+
|
136
|
+
context 'when array contains value of an unserializable class' do
|
137
|
+
class ArraySpecUnserializableClass
|
138
|
+
end
|
139
|
+
|
140
|
+
let(:obj) do
|
141
|
+
[ArraySpecUnserializableClass.new]
|
142
|
+
end
|
143
|
+
|
144
|
+
it 'raises UnserializableClass' do
|
145
|
+
lambda do
|
146
|
+
obj.to_bson
|
147
|
+
end.should raise_error(BSON::Error::UnserializableClass,
|
148
|
+
# C extension does not provide element position in the exception message.
|
149
|
+
/(Array element at position 0|Value) does not define its BSON serialized type:.*ArraySpecUnserializableClass/)
|
150
|
+
end
|
151
|
+
end
|
135
152
|
end
|
136
153
|
|
137
154
|
describe "#to_bson_normalized_value" do
|
data/spec/bson/hash_spec.rb
CHANGED
@@ -227,6 +227,23 @@ describe Hash do
|
|
227
227
|
end
|
228
228
|
end
|
229
229
|
end
|
230
|
+
|
231
|
+
context 'when hash contains value of an unserializable class' do
|
232
|
+
class HashSpecUnserializableClass
|
233
|
+
end
|
234
|
+
|
235
|
+
let(:obj) do
|
236
|
+
{foo: HashSpecUnserializableClass.new}
|
237
|
+
end
|
238
|
+
|
239
|
+
it 'raises UnserializableClass' do
|
240
|
+
lambda do
|
241
|
+
obj.to_bson
|
242
|
+
end.should raise_error(BSON::Error::UnserializableClass,
|
243
|
+
# C extension does not provide hash key in the exception message.
|
244
|
+
/(Hash value for key 'foo'|Value) does not define its BSON serialized type:.*HashSpecUnserializableClass/)
|
245
|
+
end
|
246
|
+
end
|
230
247
|
end
|
231
248
|
|
232
249
|
describe '#to_bson' do
|
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.9.
|
4
|
+
version: 4.9.4
|
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-06-
|
36
|
+
date: 2020-06-29 00:00:00.000000000 Z
|
37
37
|
dependencies: []
|
38
38
|
description: A fully featured BSON specification implementation in Ruby
|
39
39
|
email:
|
@@ -233,118 +233,119 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
233
233
|
- !ruby/object:Gem::Version
|
234
234
|
version: 1.3.6
|
235
235
|
requirements: []
|
236
|
-
|
236
|
+
rubyforge_project:
|
237
|
+
rubygems_version: 2.7.6.2
|
237
238
|
signing_key:
|
238
239
|
specification_version: 4
|
239
240
|
summary: Ruby implementation of the BSON specification
|
240
241
|
test_files:
|
241
|
-
- spec/bson/regexp_spec.rb
|
242
|
-
- spec/bson/min_key_spec.rb
|
243
|
-
- spec/bson/time_spec.rb
|
244
|
-
- spec/bson/int32_spec.rb
|
245
|
-
- spec/bson/code_spec.rb
|
246
|
-
- spec/bson/config_spec.rb
|
247
|
-
- spec/bson/undefined_spec.rb
|
248
|
-
- spec/bson/boolean_spec.rb
|
249
|
-
- spec/bson/object_spec.rb
|
250
|
-
- spec/bson/array_spec.rb
|
251
|
-
- spec/bson/hash_spec.rb
|
252
|
-
- spec/bson/date_spec.rb
|
253
|
-
- spec/bson/json_spec.rb
|
254
|
-
- spec/bson/time_with_zone_spec.rb
|
255
|
-
- spec/bson/int64_spec.rb
|
256
|
-
- spec/bson/registry_spec.rb
|
257
|
-
- spec/bson/binary_uuid_spec.rb
|
258
|
-
- spec/bson/byte_buffer_read_spec.rb
|
259
|
-
- spec/bson/raw_spec.rb
|
260
|
-
- spec/bson/binary_spec.rb
|
261
|
-
- spec/bson/max_key_spec.rb
|
262
|
-
- spec/bson/symbol_raw_spec.rb
|
263
|
-
- spec/bson/code_with_scope_spec.rb
|
264
|
-
- spec/bson/byte_buffer_write_spec.rb
|
265
|
-
- spec/bson/date_time_spec.rb
|
266
|
-
- spec/bson/false_class_spec.rb
|
267
|
-
- spec/bson/byte_buffer_spec.rb
|
268
|
-
- spec/bson/string_spec.rb
|
269
|
-
- spec/bson/open_struct_spec.rb
|
270
|
-
- spec/bson/timestamp_spec.rb
|
271
|
-
- spec/bson/ext_json_parse_spec.rb
|
272
|
-
- spec/bson/symbol_spec.rb
|
273
|
-
- spec/bson/decimal128_spec.rb
|
274
|
-
- spec/bson/integer_spec.rb
|
275
|
-
- spec/bson/document_spec.rb
|
276
|
-
- spec/bson/float_spec.rb
|
277
|
-
- spec/bson/nil_class_spec.rb
|
278
|
-
- spec/bson/true_class_spec.rb
|
279
|
-
- spec/bson/object_id_spec.rb
|
280
242
|
- spec/spec_helper.rb
|
281
|
-
- spec/bson_spec.rb
|
282
|
-
- spec/support/utils.rb
|
283
|
-
- spec/support/spec_config.rb
|
284
|
-
- spec/support/shared_examples.rb
|
285
|
-
- spec/runners/corpus.rb
|
286
|
-
- spec/runners/corpus_legacy.rb
|
287
|
-
- spec/runners/common_driver.rb
|
288
243
|
- spec/spec_tests/corpus_spec.rb
|
289
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
|
290
256
|
- spec/spec_tests/data/corpus/multi-type.json
|
291
|
-
- spec/spec_tests/data/corpus/
|
292
|
-
- spec/spec_tests/data/corpus/dbref.json
|
257
|
+
- spec/spec_tests/data/corpus/timestamp.json
|
293
258
|
- spec/spec_tests/data/corpus/multi-type-deprecated.json
|
294
|
-
- spec/spec_tests/data/corpus/
|
295
|
-
- spec/spec_tests/data/corpus/boolean.json
|
296
|
-
- spec/spec_tests/data/corpus/datetime.json
|
259
|
+
- spec/spec_tests/data/corpus/dbpointer.json
|
297
260
|
- spec/spec_tests/data/corpus/oid.json
|
298
|
-
- spec/spec_tests/data/corpus/
|
299
|
-
- spec/spec_tests/data/corpus/
|
300
|
-
- spec/spec_tests/data/corpus/decimal128-7.json
|
261
|
+
- spec/spec_tests/data/corpus/regex.json
|
262
|
+
- spec/spec_tests/data/corpus/minkey.json
|
301
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
|
302
267
|
- spec/spec_tests/data/corpus/double.json
|
303
|
-
- spec/spec_tests/data/corpus/decimal128-6.json
|
304
|
-
- spec/spec_tests/data/corpus/code_w_scope.json
|
305
|
-
- spec/spec_tests/data/corpus/int64.json
|
306
|
-
- spec/spec_tests/data/corpus/README.md
|
307
|
-
- spec/spec_tests/data/corpus/string.json
|
308
|
-
- spec/spec_tests/data/corpus/document.json
|
309
|
-
- spec/spec_tests/data/corpus/decimal128-5.json
|
310
|
-
- spec/spec_tests/data/corpus/top.json
|
311
268
|
- spec/spec_tests/data/corpus/decimal128-4.json
|
312
|
-
- spec/spec_tests/data/corpus/null.json
|
313
|
-
- spec/spec_tests/data/corpus/int32.json
|
314
|
-
- spec/spec_tests/data/corpus/dbpointer.json
|
315
|
-
- spec/spec_tests/data/corpus/undefined.json
|
316
|
-
- spec/spec_tests/data/corpus/timestamp.json
|
317
269
|
- spec/spec_tests/data/corpus/decimal128-3.json
|
318
|
-
- spec/spec_tests/data/corpus/
|
319
|
-
- spec/spec_tests/data/corpus/
|
320
|
-
- spec/spec_tests/data/corpus/
|
321
|
-
- spec/spec_tests/data/corpus/
|
322
|
-
- spec/spec_tests/data/
|
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
|
+
- spec/spec_tests/data/corpus_legacy/failures/dbpointer.json
|
323
286
|
- spec/spec_tests/data/corpus_legacy/failures/symbol.json
|
324
287
|
- spec/spec_tests/data/corpus_legacy/failures/int64.json
|
325
|
-
- spec/spec_tests/data/corpus_legacy/failures/
|
326
|
-
- spec/spec_tests/data/corpus_legacy/maxkey.json
|
327
|
-
- spec/spec_tests/data/corpus_legacy/boolean.json
|
288
|
+
- spec/spec_tests/data/corpus_legacy/failures/datetime.json
|
328
289
|
- spec/spec_tests/data/corpus_legacy/oid.json
|
329
|
-
- spec/spec_tests/data/corpus_legacy/
|
330
|
-
- spec/spec_tests/data/corpus_legacy/
|
290
|
+
- spec/spec_tests/data/corpus_legacy/regex.json
|
291
|
+
- spec/spec_tests/data/corpus_legacy/minkey.json
|
292
|
+
- spec/spec_tests/data/corpus_legacy/undefined.json
|
331
293
|
- spec/spec_tests/data/corpus_legacy/double.json
|
332
|
-
- spec/spec_tests/data/corpus_legacy/code_w_scope.json
|
333
|
-
- spec/spec_tests/data/corpus_legacy/string.json
|
334
|
-
- spec/spec_tests/data/corpus_legacy/document.json
|
335
|
-
- spec/spec_tests/data/corpus_legacy/top.json
|
336
|
-
- spec/spec_tests/data/corpus_legacy/null.json
|
337
294
|
- spec/spec_tests/data/corpus_legacy/int32.json
|
338
|
-
- spec/spec_tests/data/corpus_legacy/
|
339
|
-
- spec/spec_tests/data/corpus_legacy/
|
340
|
-
- spec/spec_tests/data/corpus_legacy/
|
341
|
-
- spec/spec_tests/data/corpus_legacy/minkey.json
|
342
|
-
- spec/spec_tests/data/corpus_legacy/regex.json
|
343
|
-
- spec/spec_tests/data/decimal128/decimal128-1.json
|
295
|
+
- spec/spec_tests/data/corpus_legacy/string.json
|
296
|
+
- spec/spec_tests/data/corpus_legacy/code.json
|
297
|
+
- spec/spec_tests/data/corpus_legacy/code_w_scope.json
|
344
298
|
- spec/spec_tests/data/decimal128/decimal128-7.json
|
299
|
+
- spec/spec_tests/data/decimal128/decimal128-2.json
|
345
300
|
- spec/spec_tests/data/decimal128/decimal128-6.json
|
346
|
-
- spec/spec_tests/data/decimal128/decimal128-
|
301
|
+
- spec/spec_tests/data/decimal128/decimal128-1.json
|
347
302
|
- spec/spec_tests/data/decimal128/decimal128-4.json
|
348
303
|
- spec/spec_tests/data/decimal128/decimal128-3.json
|
349
|
-
- spec/spec_tests/data/decimal128/decimal128-
|
304
|
+
- spec/spec_tests/data/decimal128/decimal128-5.json
|
350
305
|
- 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
|
310
|
+
- spec/runners/corpus_legacy.rb
|
311
|
+
- 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
|
351
|
+
- spec/bson_spec.rb
|
metadata.gz.sig
CHANGED
Binary file
|