bson 4.6.0 → 4.7.0
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.rb +2 -2
- data/lib/bson/binary.rb +142 -9
- data/lib/bson/version.rb +1 -1
- data/spec/bson/binary_spec.rb +68 -1
- data/spec/bson/binary_uuid_spec.rb +177 -0
- metadata +53 -51
- metadata.gz.sig +1 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ac48ca5a022cc024d0ced56d11165c4a54d01610c1e805634510ad52db11cd7a
|
4
|
+
data.tar.gz: 8440d253b13a60d3af1f3e9b2179e8c376ecae89a3ea4a6cb7a3263f32d14e06
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8ffde24e9e88fd73f5e1a847c3494449ed1973348fd8407846f1a18a7671eff32ebc5df921a33fbbe0e978ed014b1bd49f93d32fb6ca213ef4bd287a2991439d
|
7
|
+
data.tar.gz: 1356bf7ffc9bdf12f96aa5efd32e5562eeabe1e13191354f2658f826c215833b3af30d65367c6316c955db98675ad8ee5c79ca0ec06793456fe2effd9a5700d2
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/lib/bson.rb
CHANGED
@@ -101,7 +101,7 @@ begin
|
|
101
101
|
else
|
102
102
|
require "bson_native"
|
103
103
|
end
|
104
|
-
rescue LoadError
|
105
|
-
$stderr.puts("Failed to load the necessary extensions.")
|
104
|
+
rescue LoadError => e
|
105
|
+
$stderr.puts("Failed to load the necessary extensions: #{e.class}: #{e}")
|
106
106
|
raise
|
107
107
|
end
|
data/lib/bson/binary.rb
CHANGED
@@ -47,13 +47,17 @@ module BSON
|
|
47
47
|
# @since 2.0.0
|
48
48
|
TYPES = SUBTYPES.invert.freeze
|
49
49
|
|
50
|
-
#
|
51
|
-
#
|
52
|
-
#
|
53
|
-
#
|
54
|
-
#
|
55
|
-
|
56
|
-
|
50
|
+
# @return [ String ] The raw binary data.
|
51
|
+
#
|
52
|
+
# The string is always stored in BINARY encoding.
|
53
|
+
#
|
54
|
+
# @since 2.0.0
|
55
|
+
attr_reader :data
|
56
|
+
|
57
|
+
# @return [ Symbol ] The binary type.
|
58
|
+
#
|
59
|
+
# @since 2.0.0
|
60
|
+
attr_reader :type
|
57
61
|
|
58
62
|
# Determine if this binary object is equal to another object.
|
59
63
|
#
|
@@ -96,15 +100,32 @@ module BSON
|
|
96
100
|
|
97
101
|
# Instantiate the new binary object.
|
98
102
|
#
|
103
|
+
# This method accepts a string in any encoding; however, if a string is
|
104
|
+
# of a non-BINARY encoding, the encoding is set to BINARY. This does not
|
105
|
+
# change the bytes of the string but it means that applications referencing
|
106
|
+
# the data of a Binary instance cannot assume it is in a non-binary
|
107
|
+
# encoding, even if the string given to the constructor was in such an
|
108
|
+
# encoding.
|
109
|
+
#
|
99
110
|
# @example Instantiate a binary.
|
100
111
|
# BSON::Binary.new(data, :md5)
|
101
112
|
#
|
102
|
-
# @param [
|
113
|
+
# @param [ String ] data The raw binary data.
|
103
114
|
# @param [ Symbol ] type The binary type.
|
104
115
|
#
|
105
116
|
# @since 2.0.0
|
106
117
|
def initialize(data = "", type = :generic)
|
107
118
|
validate_type!(type)
|
119
|
+
|
120
|
+
# The Binary class used to force encoding to BINARY when serializing to
|
121
|
+
# BSON. Instead of doing that during serialization, perform this
|
122
|
+
# operation during Binary construction to make it clear that once
|
123
|
+
# the string is given to the Binary, the data is treated as a binary
|
124
|
+
# string and not a text string in any encoding.
|
125
|
+
unless data.encoding == Encoding.find('BINARY')
|
126
|
+
data = data.dup.force_encoding('BINARY')
|
127
|
+
end
|
128
|
+
|
108
129
|
@data = data
|
109
130
|
@type = type
|
110
131
|
end
|
@@ -121,6 +142,69 @@ module BSON
|
|
121
142
|
"<BSON::Binary:0x#{object_id} type=#{type} data=0x#{data[0, 8].unpack('H*').first}...>"
|
122
143
|
end
|
123
144
|
|
145
|
+
# Returns a string representation of the UUID stored in this Binary.
|
146
|
+
#
|
147
|
+
# If the Binary is of subtype 4 (:uuid), this method returns the UUID
|
148
|
+
# in RFC 4122 format. If the representation parameter is provided, it
|
149
|
+
# must be the value :standard as a symbol or a string.
|
150
|
+
#
|
151
|
+
# If the Binary is of subtype 3 (:uuid_old), this method requires that
|
152
|
+
# the representation parameter is provided and is one of :csharp_legacy,
|
153
|
+
# :java_legacy or :python_legacy or the equivalent strings. In this case
|
154
|
+
# the method assumes the Binary stores the UUID in the specified format,
|
155
|
+
# transforms the stored bytes to the standard RFC 4122 representation
|
156
|
+
# and returns the UUID in RFC 4122 format.
|
157
|
+
#
|
158
|
+
# If the Binary is of another subtype, this method raises TypeError.
|
159
|
+
#
|
160
|
+
# @param [ Symbol ] representation How to interpret the UUID.
|
161
|
+
#
|
162
|
+
# @return [ String ] The string representation of the UUID.
|
163
|
+
#
|
164
|
+
# @raise [ TypeError ] If the subtype of Binary is not :uuid nor :uuid_old.
|
165
|
+
# @raise [ ArgumentError ] If the representation other than :standard
|
166
|
+
# is requested for Binary subtype 4 (:uuid), if :standard representation
|
167
|
+
# is requested for Binary subtype 3 (:uuid_old), or if an invalid
|
168
|
+
# representation is requested.
|
169
|
+
#
|
170
|
+
# @api experimental
|
171
|
+
def to_uuid(representation = nil)
|
172
|
+
if representation.is_a?(String)
|
173
|
+
raise ArgumentError, "Representation must be given as a symbol: #{representation}"
|
174
|
+
end
|
175
|
+
case type
|
176
|
+
when :uuid
|
177
|
+
if representation && representation != :standard
|
178
|
+
raise ArgumentError, "Binary of type :uuid can only be stringified to :standard representation, requested: #{representation.inspect}"
|
179
|
+
end
|
180
|
+
data.split('').map { |n| '%02x' % n.ord }.join.sub(/(.{8})(.{4})(.{4})(.{12})/, '\1-\2-\3-\4')
|
181
|
+
when :uuid_old
|
182
|
+
if representation.nil?
|
183
|
+
raise ArgumentError, 'Representation must be specified for BSON::Binary objects of type :uuid_old'
|
184
|
+
end
|
185
|
+
|
186
|
+
hex = data.split('').map { |n| '%02x' % n.ord }.join
|
187
|
+
|
188
|
+
case representation
|
189
|
+
when :standard
|
190
|
+
raise ArgumentError, 'BSON::Binary objects of type :uuid_old cannot be stringified to :standard representation'
|
191
|
+
when :csharp_legacy
|
192
|
+
hex.sub(/\A(..)(..)(..)(..)(..)(..)(..)(..)(.{16})\z/, '\4\3\2\1\6\5\8\7\9')
|
193
|
+
when :java_legacy
|
194
|
+
hex.sub(/\A(..)(..)(..)(..)(..)(..)(..)(..)(..)(..)(..)(..)(..)(..)(..)(..)\z/) do |m|
|
195
|
+
"#{$8}#{$7}#{$6}#{$5}#{$4}#{$3}#{$2}#{$1}" +
|
196
|
+
"#{$16}#{$15}#{$14}#{$13}#{$12}#{$11}#{$10}#{$9}"
|
197
|
+
end
|
198
|
+
when :python_legacy
|
199
|
+
hex
|
200
|
+
else
|
201
|
+
raise ArgumentError, "Invalid representation: #{representation}"
|
202
|
+
end.sub(/(.{8})(.{4})(.{4})(.{12})/, '\1-\2-\3-\4')
|
203
|
+
else
|
204
|
+
raise TypeError, "The type of Binary must be :uuid or :uuid_old, this object is: #{type.inspect}"
|
205
|
+
end
|
206
|
+
end
|
207
|
+
|
124
208
|
# Encode the binary type
|
125
209
|
#
|
126
210
|
# @example Encode the binary.
|
@@ -136,7 +220,7 @@ module BSON
|
|
136
220
|
buffer.put_int32(0)
|
137
221
|
buffer.put_byte(SUBTYPES[type])
|
138
222
|
buffer.put_int32(data.bytesize) if type == :old
|
139
|
-
buffer.put_bytes(data
|
223
|
+
buffer.put_bytes(data)
|
140
224
|
buffer.replace_int32(position, buffer.length - position - 5)
|
141
225
|
end
|
142
226
|
|
@@ -157,6 +241,55 @@ module BSON
|
|
157
241
|
new(data, type)
|
158
242
|
end
|
159
243
|
|
244
|
+
# Creates a BSON::Binary from a string representation of a UUID.
|
245
|
+
#
|
246
|
+
# The UUID may be given in either 00112233-4455-6677-8899-aabbccddeeff or
|
247
|
+
# 00112233445566778899AABBCCDDEEFF format - specifically, any dashes in
|
248
|
+
# the UUID are removed and both upper and lower case letters are acceptable.
|
249
|
+
#
|
250
|
+
# The input UUID string is always interpreted to be in the RFC 4122 format.
|
251
|
+
#
|
252
|
+
# If representation is not provided, this method creates a BSON::Binary
|
253
|
+
# of subtype 4 (:uuid). If representation is provided, it must be one of
|
254
|
+
# :standard, :csharp_legacy, :java_legacy or :python_legacy. If
|
255
|
+
# representation is :standard, this method creates a subtype 4 (:uuid)
|
256
|
+
# binary which is the same behavior as if representation was not provided.
|
257
|
+
# For other representations, this method creates a Binary of subtype 3
|
258
|
+
# (:uuid_old) with the UUID converted to the appropriate legacy MongoDB
|
259
|
+
# UUID storage format.
|
260
|
+
#
|
261
|
+
# @param [ String ] uuid The string representation of the UUID.
|
262
|
+
# @param [ Symbol ] representation How to interpret the UUID.
|
263
|
+
#
|
264
|
+
# @return [ Binary ] The binary.
|
265
|
+
#
|
266
|
+
# @raise [ ArgumentError ] If invalid representation is requested.
|
267
|
+
#
|
268
|
+
# @api experimental
|
269
|
+
def self.from_uuid(uuid, representation = nil)
|
270
|
+
if representation.is_a?(String)
|
271
|
+
raise ArgumentError, "Representation must be given as a symbol: #{representation}"
|
272
|
+
end
|
273
|
+
uuid_binary = uuid.gsub('-', '').scan(/../).map(&:hex).map(&:chr).join
|
274
|
+
case representation && representation
|
275
|
+
when nil, :standard
|
276
|
+
new(uuid_binary, :uuid)
|
277
|
+
when :csharp_legacy
|
278
|
+
uuid_binary.sub!(/\A(.)(.)(.)(.)(.)(.)(.)(.)(.{8})\z/, '\4\3\2\1\6\5\8\7\9')
|
279
|
+
new(uuid_binary, :uuid_old)
|
280
|
+
when :java_legacy
|
281
|
+
uuid_binary.sub!(/\A(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)\z/) do |m|
|
282
|
+
"#{$8}#{$7}#{$6}#{$5}#{$4}#{$3}#{$2}#{$1}" +
|
283
|
+
"#{$16}#{$15}#{$14}#{$13}#{$12}#{$11}#{$10}#{$9}"
|
284
|
+
end
|
285
|
+
new(uuid_binary, :uuid_old)
|
286
|
+
when :python_legacy
|
287
|
+
new(uuid_binary, :uuid_old)
|
288
|
+
else
|
289
|
+
raise ArgumentError, "Invalid representation: #{representation}"
|
290
|
+
end
|
291
|
+
end
|
292
|
+
|
160
293
|
# Raised when providing an invalid type to the Binary.
|
161
294
|
#
|
162
295
|
# @since 2.0.0
|
data/lib/bson/version.rb
CHANGED
data/spec/bson/binary_spec.rb
CHANGED
@@ -72,6 +72,14 @@ describe BSON::Binary do
|
|
72
72
|
|
73
73
|
describe "#initialize" do
|
74
74
|
|
75
|
+
context 'when type is not given' do
|
76
|
+
let(:obj) { described_class.new('foo') }
|
77
|
+
|
78
|
+
it 'defaults to generic type' do
|
79
|
+
expect(obj.type).to eq(:generic)
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
75
83
|
context "when he type is invalid" do
|
76
84
|
|
77
85
|
it "raises an error" do
|
@@ -105,7 +113,11 @@ describe BSON::Binary do
|
|
105
113
|
expect(object.inspect).to eq("<BSON::Binary:0x#{object.object_id} type=user data=0x1f8b08000c787055...>")
|
106
114
|
end
|
107
115
|
|
108
|
-
it 'is not
|
116
|
+
it 'is not binary' do
|
117
|
+
# As long as the default Ruby encoding is not binary, the inspected
|
118
|
+
# string should also not be in the binary encoding (it should be
|
119
|
+
# in one of the text encodings, but which one could depend on
|
120
|
+
# the Ruby runtime environment).
|
109
121
|
expect(object.inspect.encoding).not_to eq(Encoding::BINARY)
|
110
122
|
end
|
111
123
|
|
@@ -113,6 +125,15 @@ describe BSON::Binary do
|
|
113
125
|
|
114
126
|
end
|
115
127
|
|
128
|
+
describe '#from_bson' do
|
129
|
+
let(:bson) { BSON::ByteBuffer.new("#{5.to_bson}#{0.chr}hello".force_encoding('BINARY')) }
|
130
|
+
let(:obj) { described_class.from_bson(bson) }
|
131
|
+
|
132
|
+
it 'sets data encoding to binary' do
|
133
|
+
expect(obj.data.encoding).to eq(Encoding.find('BINARY'))
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
116
137
|
describe "#to_bson/#from_bson" do
|
117
138
|
|
118
139
|
let(:type) { 5.chr }
|
@@ -181,5 +202,51 @@ describe BSON::Binary do
|
|
181
202
|
it_behaves_like "a serializable bson element"
|
182
203
|
it_behaves_like "a deserializable bson element"
|
183
204
|
end
|
205
|
+
|
206
|
+
context 'when given binary string' do
|
207
|
+
let(:obj) { described_class.new("\x00\xfe\xff".force_encoding('BINARY')) }
|
208
|
+
let(:bson) { "#{3.to_bson}#{0.chr}\x00\xfe\xff".force_encoding('BINARY') }
|
209
|
+
|
210
|
+
it_behaves_like "a serializable bson element"
|
211
|
+
it_behaves_like "a deserializable bson element"
|
212
|
+
end
|
213
|
+
|
214
|
+
context 'when given a frozen string' do
|
215
|
+
let(:str) { "\x00\xfe\xff".force_encoding('BINARY').freeze }
|
216
|
+
let(:obj) { described_class.new(str) }
|
217
|
+
let(:bson) { "#{3.to_bson}#{0.chr}\x00\xfe\xff".force_encoding('BINARY') }
|
218
|
+
|
219
|
+
it_behaves_like "a serializable bson element"
|
220
|
+
it_behaves_like "a deserializable bson element"
|
221
|
+
end
|
222
|
+
end
|
223
|
+
|
224
|
+
describe '#to_uuid' do
|
225
|
+
let(:obj) { described_class.new("\x00" * 16, :uuid) }
|
226
|
+
|
227
|
+
it 'accepts symbol representation' do
|
228
|
+
expect(obj.to_uuid(:standard)).to eq('00000000-0000-0000-0000000000000000')
|
229
|
+
end
|
230
|
+
|
231
|
+
it 'rejects string representation' do
|
232
|
+
expect do
|
233
|
+
obj.to_uuid('standard')
|
234
|
+
end.to raise_error(ArgumentError, /Representation must be given as a symbol/)
|
235
|
+
end
|
236
|
+
end
|
237
|
+
|
238
|
+
describe '#from_uuid' do
|
239
|
+
let(:uuid) { '00000000-0000-0000-0000000000000000' }
|
240
|
+
|
241
|
+
it 'accepts symbol representation' do
|
242
|
+
obj = described_class.from_uuid(uuid, :standard)
|
243
|
+
expect(obj.data).to eq("\x00" * 16)
|
244
|
+
end
|
245
|
+
|
246
|
+
it 'rejects string representation' do
|
247
|
+
expect do
|
248
|
+
described_class.from_uuid(uuid, 'standard')
|
249
|
+
end.to raise_error(ArgumentError, /Representation must be given as a symbol/)
|
250
|
+
end
|
184
251
|
end
|
185
252
|
end
|
@@ -0,0 +1,177 @@
|
|
1
|
+
# Copyright (C) 2019 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
|
+
require "base64"
|
17
|
+
|
18
|
+
describe "BSON::Binary - UUID spec tests" do
|
19
|
+
def make_binary(uuid_hex_str, type)
|
20
|
+
uuid_binary_str = uuid_hex_str.scan(/../).map(&:hex).map(&:chr).join
|
21
|
+
BSON::Binary.new(uuid_binary_str, type)
|
22
|
+
end
|
23
|
+
|
24
|
+
describe 'explicit encoding' do
|
25
|
+
let(:uuid_str) { '00112233-4455-6677-8899-aabbccddeeff' }
|
26
|
+
|
27
|
+
shared_examples_for 'creates binary' do
|
28
|
+
it 'creates subtype 4 binary' do
|
29
|
+
expect(binary.type).to eq(expected_type)
|
30
|
+
end
|
31
|
+
|
32
|
+
it 'creates binary with correct value' do
|
33
|
+
expect(binary.data).to eq(expected_hex_value.scan(/../).map(&:hex).map(&:chr).join)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
context 'no representation' do
|
38
|
+
let(:binary) { BSON::Binary.from_uuid(uuid_str) }
|
39
|
+
let(:expected_type) { :uuid }
|
40
|
+
let(:expected_hex_value) { '00112233445566778899AABBCCDDEEFF' }
|
41
|
+
|
42
|
+
it_behaves_like 'creates binary'
|
43
|
+
end
|
44
|
+
|
45
|
+
context 'standard representation' do
|
46
|
+
let(:binary) { BSON::Binary.from_uuid(uuid_str, :standard) }
|
47
|
+
let(:expected_type) { :uuid }
|
48
|
+
let(:expected_hex_value) { '00112233445566778899AABBCCDDEEFF' }
|
49
|
+
|
50
|
+
it_behaves_like 'creates binary'
|
51
|
+
end
|
52
|
+
|
53
|
+
context 'csharp legacy representation' do
|
54
|
+
let(:binary) { BSON::Binary.from_uuid(uuid_str, :csharp_legacy) }
|
55
|
+
let(:expected_type) { :uuid_old }
|
56
|
+
let(:expected_hex_value) { '33221100554477668899AABBCCDDEEFF' }
|
57
|
+
|
58
|
+
it_behaves_like 'creates binary'
|
59
|
+
end
|
60
|
+
|
61
|
+
context 'java legacy representation' do
|
62
|
+
let(:binary) { BSON::Binary.from_uuid(uuid_str, :java_legacy) }
|
63
|
+
let(:expected_type) { :uuid_old }
|
64
|
+
let(:expected_hex_value) { '7766554433221100FFEEDDCCBBAA9988' }
|
65
|
+
|
66
|
+
it_behaves_like 'creates binary'
|
67
|
+
end
|
68
|
+
|
69
|
+
context 'python legacy representation' do
|
70
|
+
let(:binary) { BSON::Binary.from_uuid(uuid_str, :python_legacy) }
|
71
|
+
let(:expected_type) { :uuid_old }
|
72
|
+
let(:expected_hex_value) { '00112233445566778899AABBCCDDEEFF' }
|
73
|
+
|
74
|
+
it_behaves_like 'creates binary'
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
describe 'explicit decoding' do
|
79
|
+
context ':uuid, standard encoded' do
|
80
|
+
let(:binary) { make_binary("00112233445566778899AABBCCDDEEFF", :uuid) }
|
81
|
+
|
82
|
+
it 'decodes without arguments' do
|
83
|
+
expect(binary.to_uuid.gsub('-', '').upcase).to eq("00112233445566778899AABBCCDDEEFF")
|
84
|
+
end
|
85
|
+
|
86
|
+
it 'decodes as standard' do
|
87
|
+
expect(binary.to_uuid(:standard).gsub('-', '').upcase).to eq("00112233445566778899AABBCCDDEEFF")
|
88
|
+
end
|
89
|
+
|
90
|
+
it 'does not decode as csharp legacy' do
|
91
|
+
expect do
|
92
|
+
binary.to_uuid(:csharp_legacy)
|
93
|
+
end.to raise_error(ArgumentError, /Binary of type :uuid can only be stringified to :standard representation/)
|
94
|
+
end
|
95
|
+
|
96
|
+
it 'does not decode as java legacy' do
|
97
|
+
expect do
|
98
|
+
binary.to_uuid(:java_legacy)
|
99
|
+
end.to raise_error(ArgumentError, /Binary of type :uuid can only be stringified to :standard representation/)
|
100
|
+
end
|
101
|
+
|
102
|
+
it 'does not decode as python legacy' do
|
103
|
+
expect do
|
104
|
+
binary.to_uuid(:python_legacy)
|
105
|
+
end.to raise_error(ArgumentError, /Binary of type :uuid can only be stringified to :standard representation/)
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
shared_examples_for 'a legacy uuid' do
|
110
|
+
it 'does not decode without arguments' do
|
111
|
+
expect do
|
112
|
+
binary.to_uuid
|
113
|
+
end.to raise_error(ArgumentError, /Representation must be specified for BSON::Binary objects of type :uuid_old/)
|
114
|
+
end
|
115
|
+
|
116
|
+
it 'does not decode as standard' do
|
117
|
+
expect do
|
118
|
+
binary.to_uuid(:standard)
|
119
|
+
end.to raise_error(ArgumentError, /BSON::Binary objects of type :uuid_old cannot be stringified to :standard representation/)
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
context ':uuid_old, csharp legacy encoded' do
|
124
|
+
let(:binary) { make_binary("33221100554477668899AABBCCDDEEFF", :uuid_old) }
|
125
|
+
|
126
|
+
it_behaves_like 'a legacy uuid'
|
127
|
+
|
128
|
+
it 'decodes as csharp legacy' do
|
129
|
+
expect(binary.to_uuid(:csharp_legacy).gsub('-', '').upcase).to eq("00112233445566778899AABBCCDDEEFF")
|
130
|
+
end
|
131
|
+
|
132
|
+
it 'decodes as java legacy' do
|
133
|
+
expect(binary.to_uuid(:java_legacy).gsub('-', '').upcase).not_to eq("00112233445566778899AABBCCDDEEFF")
|
134
|
+
end
|
135
|
+
|
136
|
+
it 'decodes as python legacy' do
|
137
|
+
expect(binary.to_uuid(:python_legacy).gsub('-', '').upcase).not_to eq("00112233445566778899AABBCCDDEEFF")
|
138
|
+
end
|
139
|
+
end
|
140
|
+
|
141
|
+
context ':uuid_old, java legacy encoded' do
|
142
|
+
let(:binary) { make_binary("7766554433221100FFEEDDCCBBAA9988", :uuid_old) }
|
143
|
+
|
144
|
+
it_behaves_like 'a legacy uuid'
|
145
|
+
|
146
|
+
it 'decodes as csharp legacy' do
|
147
|
+
expect(binary.to_uuid(:csharp_legacy).gsub('-', '').upcase).not_to eq("00112233445566778899AABBCCDDEEFF")
|
148
|
+
end
|
149
|
+
|
150
|
+
it 'decodes as java legacy' do
|
151
|
+
expect(binary.to_uuid(:java_legacy).gsub('-', '').upcase).to eq("00112233445566778899AABBCCDDEEFF")
|
152
|
+
end
|
153
|
+
|
154
|
+
it 'decodes as python legacy' do
|
155
|
+
expect(binary.to_uuid(:python_legacy).gsub('-', '').upcase).not_to eq("00112233445566778899AABBCCDDEEFF")
|
156
|
+
end
|
157
|
+
end
|
158
|
+
|
159
|
+
context ':uuid_old, python legacy encoded' do
|
160
|
+
let(:binary) { make_binary("00112233445566778899AABBCCDDEEFF", :uuid_old) }
|
161
|
+
|
162
|
+
it_behaves_like 'a legacy uuid'
|
163
|
+
|
164
|
+
it 'decodes as csharp legacy' do
|
165
|
+
expect(binary.to_uuid(:csharp_legacy).gsub('-', '').upcase).not_to eq("00112233445566778899AABBCCDDEEFF")
|
166
|
+
end
|
167
|
+
|
168
|
+
it 'decodes as java legacy' do
|
169
|
+
expect(binary.to_uuid(:java_legacy).gsub('-', '').upcase).not_to eq("00112233445566778899AABBCCDDEEFF")
|
170
|
+
end
|
171
|
+
|
172
|
+
it 'decodes as python legacy' do
|
173
|
+
expect(binary.to_uuid(:python_legacy).gsub('-', '').upcase).to eq("00112233445566778899AABBCCDDEEFF")
|
174
|
+
end
|
175
|
+
end
|
176
|
+
end
|
177
|
+
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.
|
4
|
+
version: 4.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tyler Brock
|
@@ -33,7 +33,7 @@ cert_chain:
|
|
33
33
|
bMYVwXXhV8czdzgkQB/ZPWHSbEWXnmkze1mzvqWBCPOVXYrcnL9cnEl/RoxtS1hr
|
34
34
|
Db6Ac6mCUSYfYHBWpWqxjc45n70i5Xi1
|
35
35
|
-----END CERTIFICATE-----
|
36
|
-
date: 2019-
|
36
|
+
date: 2019-12-13 00:00:00.000000000 Z
|
37
37
|
dependencies: []
|
38
38
|
description: A fully featured BSON specification implementation in Ruby
|
39
39
|
email:
|
@@ -99,6 +99,7 @@ files:
|
|
99
99
|
- lib/bson/version.rb
|
100
100
|
- spec/bson/array_spec.rb
|
101
101
|
- spec/bson/binary_spec.rb
|
102
|
+
- spec/bson/binary_uuid_spec.rb
|
102
103
|
- spec/bson/boolean_spec.rb
|
103
104
|
- spec/bson/byte_buffer_read_spec.rb
|
104
105
|
- spec/bson/byte_buffer_spec.rb
|
@@ -195,81 +196,82 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
195
196
|
- !ruby/object:Gem::Version
|
196
197
|
version: 1.3.6
|
197
198
|
requirements: []
|
198
|
-
rubygems_version: 3.0.
|
199
|
+
rubygems_version: 3.0.3
|
199
200
|
signing_key:
|
200
201
|
specification_version: 4
|
201
202
|
summary: Ruby implementation of the BSON specification
|
202
203
|
test_files:
|
203
|
-
- spec/bson/
|
204
|
+
- spec/bson/date_spec.rb
|
205
|
+
- spec/bson/config_spec.rb
|
206
|
+
- spec/bson/int64_spec.rb
|
204
207
|
- spec/bson/undefined_spec.rb
|
205
|
-
- spec/bson/
|
206
|
-
- spec/bson/decimal128_spec.rb
|
208
|
+
- spec/bson/corpus_spec.rb
|
207
209
|
- spec/bson/code_spec.rb
|
208
|
-
- spec/bson/
|
210
|
+
- spec/bson/driver_bson_spec.rb
|
209
211
|
- spec/bson/object_spec.rb
|
210
|
-
- spec/bson/
|
212
|
+
- spec/bson/date_time_spec.rb
|
213
|
+
- spec/bson/raw_spec.rb
|
214
|
+
- spec/bson/min_key_spec.rb
|
215
|
+
- spec/bson/time_with_zone_spec.rb
|
216
|
+
- spec/bson/time_spec.rb
|
217
|
+
- spec/bson/hash_spec.rb
|
218
|
+
- spec/bson/timestamp_spec.rb
|
219
|
+
- spec/bson/int32_spec.rb
|
220
|
+
- spec/bson/byte_buffer_spec.rb
|
221
|
+
- spec/bson/registry_spec.rb
|
222
|
+
- spec/bson/regexp_spec.rb
|
223
|
+
- spec/bson/byte_buffer_write_spec.rb
|
224
|
+
- spec/bson/symbol_spec.rb
|
211
225
|
- spec/bson/string_spec.rb
|
212
|
-
- spec/bson/byte_buffer_read_spec.rb
|
213
|
-
- spec/bson/config_spec.rb
|
214
|
-
- spec/bson/json_spec.rb
|
215
226
|
- spec/bson/boolean_spec.rb
|
216
|
-
- spec/bson/corpus_spec.rb
|
217
|
-
- spec/bson/hash_spec.rb
|
218
227
|
- spec/bson/open_struct_spec.rb
|
219
|
-
- spec/bson/
|
228
|
+
- spec/bson/decimal128_spec.rb
|
229
|
+
- spec/bson/json_spec.rb
|
220
230
|
- spec/bson/array_spec.rb
|
221
231
|
- spec/bson/false_class_spec.rb
|
222
232
|
- spec/bson/true_class_spec.rb
|
223
|
-
- spec/bson/date_spec.rb
|
224
|
-
- spec/bson/byte_buffer_write_spec.rb
|
225
|
-
- spec/bson/int64_spec.rb
|
226
|
-
- spec/bson/timestamp_spec.rb
|
227
|
-
- spec/bson/max_key_spec.rb
|
228
|
-
- spec/bson/raw_spec.rb
|
229
|
-
- spec/bson/byte_buffer_spec.rb
|
230
|
-
- spec/bson/document_spec.rb
|
231
|
-
- spec/bson/code_with_scope_spec.rb
|
232
|
-
- spec/bson/float_spec.rb
|
233
|
-
- spec/bson/time_with_zone_spec.rb
|
234
233
|
- spec/bson/binary_spec.rb
|
235
|
-
- spec/bson/
|
236
|
-
- spec/bson/symbol_spec.rb
|
237
|
-
- spec/bson/driver_bson_spec.rb
|
238
|
-
- spec/bson/date_time_spec.rb
|
234
|
+
- spec/bson/binary_uuid_spec.rb
|
239
235
|
- spec/bson/object_id_spec.rb
|
240
|
-
- spec/bson/
|
236
|
+
- spec/bson/code_with_scope_spec.rb
|
237
|
+
- spec/bson/nil_class_spec.rb
|
238
|
+
- spec/bson/integer_spec.rb
|
239
|
+
- spec/bson/document_spec.rb
|
240
|
+
- spec/bson/max_key_spec.rb
|
241
|
+
- spec/bson/byte_buffer_read_spec.rb
|
242
|
+
- spec/bson/float_spec.rb
|
241
243
|
- spec/support/utils.rb
|
242
|
-
- spec/support/common_driver.rb
|
243
|
-
- spec/support/corpus-tests/code_w_scope.json
|
244
|
-
- spec/support/corpus-tests/code.json
|
245
|
-
- spec/support/corpus-tests/oid.json
|
246
|
-
- spec/support/corpus-tests/timestamp.json
|
247
244
|
- spec/support/corpus-tests/string.json
|
248
245
|
- spec/support/corpus-tests/null.json
|
249
246
|
- spec/support/corpus-tests/int32.json
|
250
247
|
- spec/support/corpus-tests/maxkey.json
|
251
|
-
- spec/support/corpus-tests/
|
252
|
-
- spec/support/corpus-tests/regex.json
|
253
|
-
- spec/support/corpus-tests/minkey.json
|
254
|
-
- spec/support/corpus-tests/top.json
|
255
|
-
- spec/support/corpus-tests/failures/undefined.json
|
248
|
+
- spec/support/corpus-tests/timestamp.json
|
256
249
|
- spec/support/corpus-tests/failures/binary.json
|
257
|
-
- spec/support/corpus-tests/failures/symbol.json
|
258
|
-
- spec/support/corpus-tests/failures/int64.json
|
259
250
|
- spec/support/corpus-tests/failures/dbpointer.json
|
251
|
+
- spec/support/corpus-tests/failures/symbol.json
|
252
|
+
- spec/support/corpus-tests/failures/undefined.json
|
260
253
|
- spec/support/corpus-tests/failures/datetime.json
|
261
|
-
- spec/support/corpus-tests/
|
262
|
-
- spec/support/corpus-tests/
|
254
|
+
- spec/support/corpus-tests/failures/int64.json
|
255
|
+
- spec/support/corpus-tests/code.json
|
263
256
|
- spec/support/corpus-tests/document.json
|
257
|
+
- spec/support/corpus-tests/double.json
|
258
|
+
- spec/support/corpus-tests/regex.json
|
259
|
+
- spec/support/corpus-tests/oid.json
|
260
|
+
- spec/support/corpus-tests/top.json
|
261
|
+
- spec/support/corpus-tests/boolean.json
|
262
|
+
- spec/support/corpus-tests/array.json
|
263
|
+
- spec/support/corpus-tests/code_w_scope.json
|
264
|
+
- spec/support/corpus-tests/minkey.json
|
265
|
+
- spec/support/corpus.rb
|
264
266
|
- spec/support/shared_examples.rb
|
265
|
-
- spec/support/
|
266
|
-
- spec/support/driver-spec-tests/decimal128/decimal128-
|
267
|
+
- spec/support/driver-spec-tests/decimal128/decimal128-4.json
|
268
|
+
- spec/support/driver-spec-tests/decimal128/decimal128-2.json
|
269
|
+
- spec/support/driver-spec-tests/decimal128/decimal128-5.json
|
267
270
|
- spec/support/driver-spec-tests/decimal128/decimal128-3.json
|
271
|
+
- spec/support/driver-spec-tests/decimal128/decimal128-6.json
|
268
272
|
- spec/support/driver-spec-tests/decimal128/decimal128-1.json
|
269
|
-
- spec/support/driver-spec-tests/decimal128/decimal128-4.json
|
270
273
|
- spec/support/driver-spec-tests/decimal128/decimal128-7.json
|
271
|
-
- spec/support/
|
272
|
-
- spec/support/
|
273
|
-
- spec/support/corpus.rb
|
274
|
-
- spec/bson_spec.rb
|
274
|
+
- spec/support/spec_config.rb
|
275
|
+
- spec/support/common_driver.rb
|
275
276
|
- spec/spec_helper.rb
|
277
|
+
- spec/bson_spec.rb
|
metadata.gz.sig
CHANGED
@@ -1,2 +1 @@
|
|
1
|
-
|
2
|
-
2d�D6���Е�Wɝi�67����ɴuF
|
1
|
+
���ۮ��ui�LB(�������o�8�Ջ�z�X��+�`�[��f��hZ��> ̶��o�Z��D¤V8f��H��2<T�!v�~�Lb��Ip�f�T8"vu_8�nb�����m#��������A�z���D(��n08p������$�b��g�p=s��p���rRB~4��MT.�
|