bson 4.11.0 → 4.11.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 06e075081379ce36a9733b97e65fe9ddedf5c02abbff44f4f80900996f978382
4
- data.tar.gz: 291dbafc79f5a81287304b17976baefa9c218ae4a9728535ac045f99f61e9a41
3
+ metadata.gz: 6f2b7b7906a18c900a2cd45e1b884f3c84cf863234e703838ee752c6b87badcb
4
+ data.tar.gz: beb2dd92cc828d7db3084ff2095a8df28dcb6a18e89c699f2a6bd7b7d1acd376
5
5
  SHA512:
6
- metadata.gz: 50915432ff0dd69ec3a2be50f718a5dfcdc5bc000d619652be55e3543493b2d5f91074018b96e17dcd4f20efcd56bde31204c4badc24a8f46a99c1effb2f1602
7
- data.tar.gz: 897db48b82f0dd8af1a1e3597cb8bcbf3d9d0679211e19407ffcf872db1615594dfce9b18baedfda3e7d299c9519cc63c047e026866f8b767e05dff10b3e7ae9
6
+ metadata.gz: 5e0359cf8b6632840e5ad9be71f5d350a53e0606d5fa5afa4706021f1083a9493a410bc8d9d5ecc24c6b3ba02f7ee482898db9dc190ff8620ad5dc9014441e90
7
+ data.tar.gz: beb107c6db4bd7f6ba32671d4d340f9593636fe490b69e6e60abc812c1698b4f203b800f2ea145af77a9c319b7c9f4dfa90bb22eea157d15828a09bc8fb388ae
Binary file
data.tar.gz.sig CHANGED
Binary file
@@ -56,6 +56,16 @@ void Init_bson_native()
56
56
 
57
57
  rb_define_alloc_func(rb_byte_buffer_class, rb_bson_byte_buffer_allocate);
58
58
  rb_define_method(rb_byte_buffer_class, "initialize", rb_bson_byte_buffer_initialize, -1);
59
+
60
+ /*
61
+ * call-seq:
62
+ * buffer.length -> Fixnum
63
+ *
64
+ * Returns the number of bytes available to be read in the buffer.
65
+ *
66
+ * When a buffer is being written to, each added byte increases its length.
67
+ * When a buffer is being read from, each read byte decreases its length.
68
+ */
59
69
  rb_define_method(rb_byte_buffer_class, "length", rb_bson_byte_buffer_length, 0);
60
70
 
61
71
  /*
@@ -266,7 +276,7 @@ void Init_bson_native()
266
276
 
267
277
  /*
268
278
  * call-seq:
269
- * buffer.put_hash(hash) -> ByteBuffer
279
+ * buffer.put_hash(hash, validating_keys) -> ByteBuffer
270
280
  *
271
281
  * Writes a Hash into the byte buffer.
272
282
  *
@@ -319,6 +329,10 @@ void Init_bson_native()
319
329
  *
320
330
  * Returns the contents of the buffer as a binary string.
321
331
  *
332
+ * If the buffer is used for reading, the returned contents is the data
333
+ * that was not yet read. If the buffer is used for writing, the returned
334
+ * contents is the complete data that has been written so far.
335
+ *
322
336
  * Note: this method copies the buffer's contents into a newly allocated
323
337
  * +String+ instance. It does not return a reference to the data stored in
324
338
  * the buffer itself.
@@ -13,5 +13,5 @@
13
13
  # limitations under the License.
14
14
 
15
15
  module BSON
16
- VERSION = "4.11.0".freeze
16
+ VERSION = "4.11.1".freeze
17
17
  end
@@ -42,7 +42,6 @@ describe BSON::ByteBuffer do
42
42
  end
43
43
  end
44
44
 
45
-
46
45
  context 'when the byte buffer is initialized with some bytes' do
47
46
 
48
47
  let(:buffer) do
@@ -53,6 +52,50 @@ describe BSON::ByteBuffer do
53
52
  expect(buffer.length).to eq(2)
54
53
  end
55
54
  end
55
+
56
+ context 'after the byte buffer was read from' do
57
+
58
+ let(:buffer) do
59
+ described_class.new({}.to_bson.to_s)
60
+ end
61
+
62
+ it 'returns the number of bytes remaining in the buffer' do
63
+ expect(buffer.length).to eq(5)
64
+ buffer.get_int32
65
+ expect(buffer.length).to eq(1)
66
+ end
67
+ end
68
+
69
+ context 'after the byte buffer was converted to string' do
70
+
71
+ shared_examples 'returns the total buffer length' do
72
+ it 'returns the total buffer length' do
73
+ expect(buffer.length).to eq(5)
74
+ buffer.to_s.length.should == 5
75
+ expect(buffer.length).to eq(5)
76
+ end
77
+ end
78
+
79
+ context 'read buffer' do
80
+
81
+ let(:buffer) do
82
+ described_class.new({}.to_bson.to_s)
83
+ end
84
+
85
+ include_examples 'returns the total buffer length'
86
+ end
87
+
88
+ context 'write buffer' do
89
+
90
+ let(:buffer) do
91
+ described_class.new.tap do |buffer|
92
+ buffer.put_bytes('hello')
93
+ end
94
+ end
95
+
96
+ include_examples 'returns the total buffer length'
97
+ end
98
+ end
56
99
  end
57
100
 
58
101
  describe '#rewind!' do
@@ -148,4 +191,40 @@ describe BSON::ByteBuffer do
148
191
  end
149
192
  end
150
193
  end
194
+
195
+ describe '#to_s' do
196
+ context 'read buffer' do
197
+ let(:buffer) do
198
+ described_class.new("\x18\x00\x00\x00*\x00\x00\x00")
199
+ end
200
+
201
+ it 'returns the data' do
202
+ buffer.to_s.should == "\x18\x00\x00\x00*\x00\x00\x00"
203
+ end
204
+
205
+ it 'returns the remaining buffer contents after a read' do
206
+ buffer.to_s.should == "\x18\x00\x00\x00*\x00\x00\x00"
207
+ buffer.get_int32.should == 24
208
+ buffer.to_s.should == "*\x00\x00\x00"
209
+ end
210
+ end
211
+
212
+ context 'write buffer' do
213
+ let(:buffer) do
214
+ described_class.new.tap do |buffer|
215
+ buffer.put_int32(24)
216
+ end
217
+ end
218
+
219
+ it 'returns the data' do
220
+ buffer.to_s.should == "\x18\x00\x00\x00".force_encoding('binary')
221
+ end
222
+
223
+ it 'returns the complete buffer contents after a write' do
224
+ buffer.to_s.should == "\x18\x00\x00\x00".force_encoding('binary')
225
+ buffer.put_int32(42)
226
+ buffer.to_s.should == "\x18\x00\x00\x00*\x00\x00\x00".force_encoding('binary')
227
+ end
228
+ end
229
+ end
151
230
  end
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.11.0
4
+ version: 4.11.1
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-10-21 00:00:00.000000000 Z
36
+ date: 2020-11-04 00:00:00.000000000 Z
37
37
  dependencies: []
38
38
  description: A fully featured BSON specification implementation in Ruby
39
39
  email:
@@ -99,7 +99,6 @@ files:
99
99
  - lib/bson/true_class.rb
100
100
  - lib/bson/undefined.rb
101
101
  - lib/bson/version.rb
102
- - lib/bson_native.bundle
103
102
  - spec/bson/array_spec.rb
104
103
  - spec/bson/binary_spec.rb
105
104
  - spec/bson/binary_uuid_spec.rb
@@ -240,113 +239,113 @@ signing_key:
240
239
  specification_version: 4
241
240
  summary: Ruby implementation of the BSON specification
242
241
  test_files:
242
+ - spec/spec_helper.rb
243
+ - spec/spec_tests/corpus_spec.rb
243
244
  - spec/spec_tests/common_driver_spec.rb
244
- - spec/spec_tests/corpus_legacy_spec.rb
245
+ - spec/spec_tests/data/corpus/decimal128-7.json
246
+ - spec/spec_tests/data/corpus/top.json
245
247
  - spec/spec_tests/data/corpus/array.json
248
+ - spec/spec_tests/data/corpus/null.json
246
249
  - spec/spec_tests/data/corpus/document.json
247
- - spec/spec_tests/data/corpus/decimal128-7.json
248
- - spec/spec_tests/data/corpus/decimal128-3.json
249
- - spec/spec_tests/data/corpus/maxkey.json
250
- - spec/spec_tests/data/corpus/code.json
251
- - spec/spec_tests/data/corpus/dbpointer.json
252
- - spec/spec_tests/data/corpus/int32.json
253
- - spec/spec_tests/data/corpus/README.md
254
- - spec/spec_tests/data/corpus/decimal128-5.json
255
- - spec/spec_tests/data/corpus/decimal128-4.json
256
250
  - spec/spec_tests/data/corpus/decimal128-2.json
257
- - spec/spec_tests/data/corpus/double.json
258
- - spec/spec_tests/data/corpus/code_w_scope.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
259
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
260
  - spec/spec_tests/data/corpus/oid.json
261
- - spec/spec_tests/data/corpus/null.json
262
- - spec/spec_tests/data/corpus/decimal128-6.json
263
- - spec/spec_tests/data/corpus/int64.json
264
- - spec/spec_tests/data/corpus/dbref.json
265
261
  - spec/spec_tests/data/corpus/regex.json
266
262
  - spec/spec_tests/data/corpus/minkey.json
267
- - spec/spec_tests/data/corpus/multi-type.json
268
- - spec/spec_tests/data/corpus/top.json
269
263
  - spec/spec_tests/data/corpus/symbol.json
270
- - spec/spec_tests/data/corpus/multi-type-deprecated.json
264
+ - spec/spec_tests/data/corpus/dbref.json
265
+ - spec/spec_tests/data/corpus/decimal128-1.json
271
266
  - spec/spec_tests/data/corpus/undefined.json
272
- - spec/spec_tests/data/corpus/datetime.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
273
272
  - spec/spec_tests/data/corpus/string.json
274
- - spec/spec_tests/data/corpus/boolean.json
275
- - spec/spec_tests/data/corpus/timestamp.json
276
- - spec/spec_tests/data/corpus/decimal128-1.json
277
- - spec/spec_tests/data/decimal128/decimal128-7.json
278
- - spec/spec_tests/data/decimal128/decimal128-3.json
279
- - spec/spec_tests/data/decimal128/decimal128-5.json
280
- - spec/spec_tests/data/decimal128/decimal128-4.json
281
- - spec/spec_tests/data/decimal128/decimal128-2.json
282
- - spec/spec_tests/data/decimal128/decimal128-6.json
283
- - spec/spec_tests/data/decimal128/decimal128-1.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
284
278
  - spec/spec_tests/data/corpus_legacy/array.json
279
+ - spec/spec_tests/data/corpus_legacy/null.json
285
280
  - spec/spec_tests/data/corpus_legacy/document.json
281
+ - spec/spec_tests/data/corpus_legacy/boolean.json
286
282
  - spec/spec_tests/data/corpus_legacy/maxkey.json
287
- - spec/spec_tests/data/corpus_legacy/code.json
288
- - spec/spec_tests/data/corpus_legacy/int32.json
289
- - spec/spec_tests/data/corpus_legacy/double.json
290
- - spec/spec_tests/data/corpus_legacy/code_w_scope.json
291
283
  - spec/spec_tests/data/corpus_legacy/binary.json
292
- - spec/spec_tests/data/corpus_legacy/oid.json
293
- - spec/spec_tests/data/corpus_legacy/null.json
294
- - spec/spec_tests/data/corpus_legacy/regex.json
295
- - spec/spec_tests/data/corpus_legacy/minkey.json
296
- - spec/spec_tests/data/corpus_legacy/top.json
284
+ - spec/spec_tests/data/corpus_legacy/timestamp.json
297
285
  - spec/spec_tests/data/corpus_legacy/failures/dbpointer.json
298
- - spec/spec_tests/data/corpus_legacy/failures/int64.json
299
286
  - spec/spec_tests/data/corpus_legacy/failures/symbol.json
287
+ - spec/spec_tests/data/corpus_legacy/failures/int64.json
300
288
  - 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
301
292
  - spec/spec_tests/data/corpus_legacy/undefined.json
293
+ - spec/spec_tests/data/corpus_legacy/double.json
294
+ - spec/spec_tests/data/corpus_legacy/int32.json
302
295
  - spec/spec_tests/data/corpus_legacy/string.json
303
- - spec/spec_tests/data/corpus_legacy/boolean.json
304
- - spec/spec_tests/data/corpus_legacy/timestamp.json
305
- - spec/spec_tests/corpus_spec.rb
306
- - spec/runners/corpus.rb
307
- - spec/runners/corpus_legacy.rb
308
- - spec/runners/common_driver.rb
309
- - spec/spec_helper.rb
310
- - spec/support/spec_config.rb
311
- - spec/support/shared_examples.rb
296
+ - spec/spec_tests/data/corpus_legacy/code.json
297
+ - 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
300
+ - spec/spec_tests/data/decimal128/decimal128-6.json
301
+ - spec/spec_tests/data/decimal128/decimal128-1.json
302
+ - spec/spec_tests/data/decimal128/decimal128-4.json
303
+ - spec/spec_tests/data/decimal128/decimal128-3.json
304
+ - spec/spec_tests/data/decimal128/decimal128-5.json
305
+ - spec/spec_tests/corpus_legacy_spec.rb
312
306
  - spec/support/utils.rb
313
- - spec/bson/ext_json_parse_spec.rb
314
- - spec/bson/object_spec.rb
315
- - spec/bson/json_spec.rb
316
- - spec/bson/true_class_spec.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
317
313
  - spec/bson/byte_buffer_read_spec.rb
318
- - spec/bson/config_spec.rb
319
314
  - spec/bson/int32_spec.rb
320
- - spec/bson/regexp_spec.rb
321
- - spec/bson/symbol_raw_spec.rb
322
- - spec/bson/open_struct_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
323
319
  - spec/bson/document_spec.rb
324
- - spec/bson/min_key_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
325
327
  - spec/bson/false_class_spec.rb
326
- - spec/bson/code_spec.rb
327
- - spec/bson/symbol_spec.rb
328
- - spec/bson/object_id_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
329
332
  - spec/bson/decimal128_spec.rb
330
- - spec/bson/registry_spec.rb
331
- - spec/bson/time_spec.rb
333
+ - spec/bson/binary_uuid_spec.rb
332
334
  - spec/bson/boolean_spec.rb
333
335
  - spec/bson/byte_buffer_spec.rb
334
- - spec/bson/hash_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
335
343
  - spec/bson/undefined_spec.rb
336
- - spec/bson/raw_spec.rb
337
- - spec/bson/string_spec.rb
344
+ - spec/bson/object_id_spec.rb
338
345
  - spec/bson/timestamp_spec.rb
339
- - spec/bson/date_time_spec.rb
340
- - spec/bson/max_key_spec.rb
346
+ - spec/bson/hash_spec.rb
347
+ - spec/bson/symbol_raw_spec.rb
348
+ - spec/bson/min_key_spec.rb
341
349
  - spec/bson/int64_spec.rb
342
- - spec/bson/byte_buffer_write_spec.rb
343
350
  - spec/bson/date_spec.rb
344
- - spec/bson/binary_spec.rb
345
- - spec/bson/code_with_scope_spec.rb
346
- - spec/bson/integer_spec.rb
347
- - spec/bson/binary_uuid_spec.rb
348
- - spec/bson/nil_class_spec.rb
349
- - spec/bson/array_spec.rb
350
- - spec/bson/time_with_zone_spec.rb
351
- - spec/bson/float_spec.rb
352
351
  - spec/bson_spec.rb
metadata.gz.sig CHANGED
@@ -1 +1,2 @@
1
- �#�׈�(x�T�&9�Mxc��v�av��S@)��]Mk�3u ��Ӭ>��"&��QK��.e��=��6��Տҿiے8謟7L������O�%�ۀ(a} �zؑ��8x!(e0�k�������xQjXf��V�U��1��0�#}_ 2���3~ՂE\��z��l����5v(��[� ���!�N@����v��]Ѫ�A�5Z?�E�x�c�/�H��~��R$�#™���vg��x!��r������z
1
+ 
2
+ ��oF\O��+��(��D�jt�oR�ީ�j1������E�7�~m�ЊNJ��.�>���/e��"1B�hk�TJ7�+���O��P������$�-[�Y
Binary file