bson 5.0.1 → 5.0.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
- data/ext/bson/util.c +4 -1
- data/lib/bson/array.rb +1 -1
- data/lib/bson/binary.rb +16 -1
- data/lib/bson/code.rb +1 -1
- data/lib/bson/code_with_scope.rb +1 -1
- data/lib/bson/db_pointer.rb +1 -1
- data/lib/bson/decimal128.rb +1 -1
- data/lib/bson/ext_json.rb +1 -1
- data/lib/bson/float.rb +1 -1
- data/lib/bson/hash.rb +1 -1
- data/lib/bson/int32.rb +1 -1
- data/lib/bson/int64.rb +1 -1
- data/lib/bson/integer.rb +1 -1
- data/lib/bson/max_key.rb +1 -1
- data/lib/bson/min_key.rb +1 -1
- data/lib/bson/object.rb +2 -2
- data/lib/bson/object_id.rb +1 -1
- data/lib/bson/regexp.rb +1 -1
- data/lib/bson/symbol.rb +2 -2
- data/lib/bson/time.rb +1 -1
- data/lib/bson/timestamp.rb +1 -1
- data/lib/bson/undefined.rb +1 -1
- data/lib/bson/version.rb +1 -1
- data/spec/bson/binary_spec.rb +46 -7
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 41a002d14b035c9cf01534ee489ca61c012202aac1e2729fa850960c359ba5cd
|
|
4
|
+
data.tar.gz: f63478ad673c6dfbed91eaed8477b45287a264fa6c06e29d2273c41a0951e4e1
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 67721ba06f0154a5dc37bc460602f878843243706e0194375c0350a095774beb06ba7a5b861b137d95bd0e753ed74b35d3b541283864aaec02b61dd94952d9ed
|
|
7
|
+
data.tar.gz: 525cc2a1da23ceaec40243cf7cc9ab504e81c11b56bf22e9f51f156c24294231fcd300874ae3b22c80fa473be568d84d43c627eabd4434c3895458c332364f6a
|
data/ext/bson/util.c
CHANGED
|
@@ -43,7 +43,7 @@ void rb_bson_generate_machine_id(VALUE rb_md5_class, char *rb_bson_machine_id)
|
|
|
43
43
|
* Generate the next object id.
|
|
44
44
|
*
|
|
45
45
|
* Specification:
|
|
46
|
-
* https://github.com/mongodb/specifications/blob/master/source/objectid.
|
|
46
|
+
* https://github.com/mongodb/specifications/blob/master/source/bson-objectid/objectid.md
|
|
47
47
|
*
|
|
48
48
|
* The ObjectID BSON type is a 12-byte value consisting of three different portions (fields):
|
|
49
49
|
* * a 4-byte value representing the seconds since the Unix epoch in the highest order bytes,
|
|
@@ -170,6 +170,9 @@ VALUE pvt_load_secure_random(VALUE _arg) {
|
|
|
170
170
|
pvt_SecureRandom = rb_const_get(rb_cObject, rb_intern("SecureRandom"));
|
|
171
171
|
pvt_has_random_number = rb_respond_to(pvt_SecureRandom, rb_intern("random_number"));
|
|
172
172
|
|
|
173
|
+
// mark SecureRandom so it does not get moved
|
|
174
|
+
rb_global_variable(&pvt_SecureRandom);
|
|
175
|
+
|
|
173
176
|
return Qnil;
|
|
174
177
|
}
|
|
175
178
|
|
data/lib/bson/array.rb
CHANGED
|
@@ -92,7 +92,7 @@ module BSON
|
|
|
92
92
|
end
|
|
93
93
|
|
|
94
94
|
# Converts this object to a representation directly serializable to
|
|
95
|
-
# Extended JSON (https://github.com/mongodb/specifications/blob/master/source/extended-json.
|
|
95
|
+
# Extended JSON (https://github.com/mongodb/specifications/blob/master/source/extended-json/extended-json.md).
|
|
96
96
|
#
|
|
97
97
|
# This method recursively invokes +as_extended_json+ with the provided
|
|
98
98
|
# options on each array element.
|
data/lib/bson/binary.rb
CHANGED
|
@@ -24,6 +24,7 @@ module BSON
|
|
|
24
24
|
# @since 2.0.0
|
|
25
25
|
class Binary
|
|
26
26
|
include JSON
|
|
27
|
+
include Comparable
|
|
27
28
|
|
|
28
29
|
# A binary is type 0x05 in the BSON spec.
|
|
29
30
|
#
|
|
@@ -90,6 +91,20 @@ module BSON
|
|
|
90
91
|
end
|
|
91
92
|
alias eql? ==
|
|
92
93
|
|
|
94
|
+
# Compare this binary object to another object. The two objects must have
|
|
95
|
+
# the same type for any meaningful comparison.
|
|
96
|
+
#
|
|
97
|
+
# @param [ Object ] other The object to compare against.
|
|
98
|
+
#
|
|
99
|
+
# @return [ Integer | nil ] If the objects have the same type, the result
|
|
100
|
+
# is -1 if self < other, 0 if self == other, and 1 if self > other. If
|
|
101
|
+
# other is not a Binary, or is a Binary of a different type, returns nil.
|
|
102
|
+
def <=>(other)
|
|
103
|
+
return nil unless other.is_a?(Binary) && type == other.type
|
|
104
|
+
|
|
105
|
+
data <=> other.data
|
|
106
|
+
end
|
|
107
|
+
|
|
93
108
|
# Generates a Fixnum hash value for this object.
|
|
94
109
|
#
|
|
95
110
|
# Allows using Binary as hash keys.
|
|
@@ -112,7 +127,7 @@ module BSON
|
|
|
112
127
|
end
|
|
113
128
|
|
|
114
129
|
# Converts this object to a representation directly serializable to
|
|
115
|
-
# Extended JSON (https://github.com/mongodb/specifications/blob/master/source/extended-json.
|
|
130
|
+
# Extended JSON (https://github.com/mongodb/specifications/blob/master/source/extended-json/extended-json.md).
|
|
116
131
|
#
|
|
117
132
|
# @option opts [ nil | :relaxed | :legacy ] :mode Serialization mode
|
|
118
133
|
# (default is canonical extended JSON)
|
data/lib/bson/code.rb
CHANGED
|
@@ -60,7 +60,7 @@ module BSON
|
|
|
60
60
|
end
|
|
61
61
|
|
|
62
62
|
# Converts this object to a representation directly serializable to
|
|
63
|
-
# Extended JSON (https://github.com/mongodb/specifications/blob/master/source/extended-json.
|
|
63
|
+
# Extended JSON (https://github.com/mongodb/specifications/blob/master/source/extended-json/extended-json.md).
|
|
64
64
|
#
|
|
65
65
|
# @option opts [ nil | :relaxed | :legacy ] :mode Serialization mode
|
|
66
66
|
# (default is canonical extended JSON)
|
data/lib/bson/code_with_scope.rb
CHANGED
|
@@ -64,7 +64,7 @@ module BSON
|
|
|
64
64
|
end
|
|
65
65
|
|
|
66
66
|
# Converts this object to a representation directly serializable to
|
|
67
|
-
# Extended JSON (https://github.com/mongodb/specifications/blob/master/source/extended-json.
|
|
67
|
+
# Extended JSON (https://github.com/mongodb/specifications/blob/master/source/extended-json/extended-json.md).
|
|
68
68
|
#
|
|
69
69
|
# @option opts [ nil | :relaxed | :legacy ] :mode Serialization mode
|
|
70
70
|
# (default is canonical extended JSON)
|
data/lib/bson/db_pointer.rb
CHANGED
|
@@ -66,7 +66,7 @@ module BSON
|
|
|
66
66
|
end
|
|
67
67
|
|
|
68
68
|
# Converts this object to a representation directly serializable to
|
|
69
|
-
# Extended JSON (https://github.com/mongodb/specifications/blob/master/source/extended-json.
|
|
69
|
+
# Extended JSON (https://github.com/mongodb/specifications/blob/master/source/extended-json/extended-json.md).
|
|
70
70
|
#
|
|
71
71
|
# @return [ Hash ] The extended json representation.
|
|
72
72
|
def as_extended_json(**_options)
|
data/lib/bson/decimal128.rb
CHANGED
|
@@ -73,7 +73,7 @@ module BSON
|
|
|
73
73
|
end
|
|
74
74
|
|
|
75
75
|
# Converts this object to a representation directly serializable to
|
|
76
|
-
# Extended JSON (https://github.com/mongodb/specifications/blob/master/source/extended-json.
|
|
76
|
+
# Extended JSON (https://github.com/mongodb/specifications/blob/master/source/extended-json/extended-json.md).
|
|
77
77
|
#
|
|
78
78
|
# @option opts [ nil | :relaxed | :legacy ] :mode Serialization mode
|
|
79
79
|
# (default is canonical extended JSON)
|
data/lib/bson/ext_json.rb
CHANGED
|
@@ -19,7 +19,7 @@ require 'json'
|
|
|
19
19
|
module BSON
|
|
20
20
|
|
|
21
21
|
# This module contains methods for parsing Extended JSON 2.0.
|
|
22
|
-
# https://github.com/mongodb/specifications/blob/master/source/extended-json.
|
|
22
|
+
# https://github.com/mongodb/specifications/blob/master/source/extended-json/extended-json.md
|
|
23
23
|
module ExtJSON
|
|
24
24
|
|
|
25
25
|
# Parses JSON in a string into a Ruby object tree.
|
data/lib/bson/float.rb
CHANGED
|
@@ -49,7 +49,7 @@ module BSON
|
|
|
49
49
|
end
|
|
50
50
|
|
|
51
51
|
# Converts this object to a representation directly serializable to
|
|
52
|
-
# Extended JSON (https://github.com/mongodb/specifications/blob/master/source/extended-json.
|
|
52
|
+
# Extended JSON (https://github.com/mongodb/specifications/blob/master/source/extended-json/extended-json.md).
|
|
53
53
|
#
|
|
54
54
|
# This method returns the float itself if relaxed representation is
|
|
55
55
|
# requested and the value is finite, otherwise a $numberDouble hash.
|
data/lib/bson/hash.rb
CHANGED
|
@@ -53,7 +53,7 @@ module BSON
|
|
|
53
53
|
end
|
|
54
54
|
|
|
55
55
|
# Converts this object to a representation directly serializable to
|
|
56
|
-
# Extended JSON (https://github.com/mongodb/specifications/blob/master/source/extended-json.
|
|
56
|
+
# Extended JSON (https://github.com/mongodb/specifications/blob/master/source/extended-json/extended-json.md).
|
|
57
57
|
#
|
|
58
58
|
# This method recursively invokes +as_extended_json+ with the provided
|
|
59
59
|
# options on each hash value.
|
data/lib/bson/int32.rb
CHANGED
|
@@ -131,7 +131,7 @@ module BSON
|
|
|
131
131
|
end
|
|
132
132
|
|
|
133
133
|
# Converts this object to a representation directly serializable to
|
|
134
|
-
# Extended JSON (https://github.com/mongodb/specifications/blob/master/source/extended-json.
|
|
134
|
+
# Extended JSON (https://github.com/mongodb/specifications/blob/master/source/extended-json/extended-json.md).
|
|
135
135
|
#
|
|
136
136
|
# This method returns the integer value if relaxed representation is
|
|
137
137
|
# requested, otherwise a $numberInt hash.
|
data/lib/bson/int64.rb
CHANGED
|
@@ -131,7 +131,7 @@ module BSON
|
|
|
131
131
|
end
|
|
132
132
|
|
|
133
133
|
# Converts this object to a representation directly serializable to
|
|
134
|
-
# Extended JSON (https://github.com/mongodb/specifications/blob/master/source/extended-json.
|
|
134
|
+
# Extended JSON (https://github.com/mongodb/specifications/blob/master/source/extended-json/extended-json.md).
|
|
135
135
|
#
|
|
136
136
|
# This method returns the integer value if relaxed representation is
|
|
137
137
|
# requested, otherwise a $numberLong hash.
|
data/lib/bson/integer.rb
CHANGED
|
@@ -160,7 +160,7 @@ module BSON
|
|
|
160
160
|
end
|
|
161
161
|
|
|
162
162
|
# Converts this object to a representation directly serializable to
|
|
163
|
-
# Extended JSON (https://github.com/mongodb/specifications/blob/master/source/extended-json.
|
|
163
|
+
# Extended JSON (https://github.com/mongodb/specifications/blob/master/source/extended-json/extended-json.md).
|
|
164
164
|
#
|
|
165
165
|
# This method returns the integer itself if relaxed representation is
|
|
166
166
|
# requested, otherwise a $numberInt hash if the value fits in 32 bits
|
data/lib/bson/max_key.rb
CHANGED
|
@@ -63,7 +63,7 @@ module BSON
|
|
|
63
63
|
end
|
|
64
64
|
|
|
65
65
|
# Converts this object to a representation directly serializable to
|
|
66
|
-
# Extended JSON (https://github.com/mongodb/specifications/blob/master/source/extended-json.
|
|
66
|
+
# Extended JSON (https://github.com/mongodb/specifications/blob/master/source/extended-json/extended-json.md).
|
|
67
67
|
#
|
|
68
68
|
# @option opts [ nil | :relaxed | :legacy ] :mode Serialization mode
|
|
69
69
|
# (default is canonical extended JSON)
|
data/lib/bson/min_key.rb
CHANGED
|
@@ -63,7 +63,7 @@ module BSON
|
|
|
63
63
|
end
|
|
64
64
|
|
|
65
65
|
# Converts this object to a representation directly serializable to
|
|
66
|
-
# Extended JSON (https://github.com/mongodb/specifications/blob/master/source/extended-json.
|
|
66
|
+
# Extended JSON (https://github.com/mongodb/specifications/blob/master/source/extended-json/extended-json.md).
|
|
67
67
|
#
|
|
68
68
|
# @option opts [ nil | :relaxed | :legacy ] :mode Serialization mode
|
|
69
69
|
# (default is canonical extended JSON)
|
data/lib/bson/object.rb
CHANGED
|
@@ -62,7 +62,7 @@ module BSON
|
|
|
62
62
|
end
|
|
63
63
|
|
|
64
64
|
# Serializes this object to Extended JSON
|
|
65
|
-
# (https://github.com/mongodb/specifications/blob/master/source/extended-json.
|
|
65
|
+
# (https://github.com/mongodb/specifications/blob/master/source/extended-json/extended-json.md).
|
|
66
66
|
#
|
|
67
67
|
# Subclasses should override +as_extended_json+ rather than this method.
|
|
68
68
|
#
|
|
@@ -75,7 +75,7 @@ module BSON
|
|
|
75
75
|
end
|
|
76
76
|
|
|
77
77
|
# Converts this object to a representation directly serializable to
|
|
78
|
-
# Extended JSON (https://github.com/mongodb/specifications/blob/master/source/extended-json.
|
|
78
|
+
# Extended JSON (https://github.com/mongodb/specifications/blob/master/source/extended-json/extended-json.md).
|
|
79
79
|
#
|
|
80
80
|
# Subclasses should override this method to provide custom serialization
|
|
81
81
|
# to Extended JSON.
|
data/lib/bson/object_id.rb
CHANGED
|
@@ -75,7 +75,7 @@ module BSON
|
|
|
75
75
|
end
|
|
76
76
|
|
|
77
77
|
# Converts this object to a representation directly serializable to
|
|
78
|
-
# Extended JSON (https://github.com/mongodb/specifications/blob/master/source/extended-json.
|
|
78
|
+
# Extended JSON (https://github.com/mongodb/specifications/blob/master/source/extended-json/extended-json.md).
|
|
79
79
|
#
|
|
80
80
|
# @return [ Hash ] The extended json representation.
|
|
81
81
|
def as_extended_json(**_)
|
data/lib/bson/regexp.rb
CHANGED
|
@@ -200,7 +200,7 @@ module BSON
|
|
|
200
200
|
end
|
|
201
201
|
|
|
202
202
|
# Converts this object to a representation directly serializable to
|
|
203
|
-
# Extended JSON (https://github.com/mongodb/specifications/blob/master/source/extended-json.
|
|
203
|
+
# Extended JSON (https://github.com/mongodb/specifications/blob/master/source/extended-json/extended-json.md).
|
|
204
204
|
#
|
|
205
205
|
# @option opts [ nil | :relaxed | :legacy ] :mode Serialization mode
|
|
206
206
|
# (default is canonical extended JSON)
|
data/lib/bson/symbol.rb
CHANGED
|
@@ -89,7 +89,7 @@ module BSON
|
|
|
89
89
|
end
|
|
90
90
|
|
|
91
91
|
# Converts this object to a representation directly serializable to
|
|
92
|
-
# Extended JSON (https://github.com/mongodb/specifications/blob/master/source/extended-json.
|
|
92
|
+
# Extended JSON (https://github.com/mongodb/specifications/blob/master/source/extended-json/extended-json.md).
|
|
93
93
|
#
|
|
94
94
|
# @return [ Hash ] The extended json representation.
|
|
95
95
|
def as_extended_json(**_options)
|
|
@@ -166,7 +166,7 @@ module BSON
|
|
|
166
166
|
end
|
|
167
167
|
|
|
168
168
|
# Converts this object to a representation directly serializable to
|
|
169
|
-
# Extended JSON (https://github.com/mongodb/specifications/blob/master/source/extended-json.
|
|
169
|
+
# Extended JSON (https://github.com/mongodb/specifications/blob/master/source/extended-json/extended-json.md).
|
|
170
170
|
#
|
|
171
171
|
# @return [ Hash ] The extended json representation.
|
|
172
172
|
def as_extended_json(**_options)
|
data/lib/bson/time.rb
CHANGED
|
@@ -61,7 +61,7 @@ module BSON
|
|
|
61
61
|
end
|
|
62
62
|
|
|
63
63
|
# Converts this object to a representation directly serializable to
|
|
64
|
-
# Extended JSON (https://github.com/mongodb/specifications/blob/master/source/extended-json.
|
|
64
|
+
# Extended JSON (https://github.com/mongodb/specifications/blob/master/source/extended-json/extended-json.md).
|
|
65
65
|
#
|
|
66
66
|
# @note The time is floored to the nearest millisecond.
|
|
67
67
|
#
|
data/lib/bson/timestamp.rb
CHANGED
|
@@ -92,7 +92,7 @@ module BSON
|
|
|
92
92
|
end
|
|
93
93
|
|
|
94
94
|
# Converts this object to a representation directly serializable to
|
|
95
|
-
# Extended JSON (https://github.com/mongodb/specifications/blob/master/source/extended-json.
|
|
95
|
+
# Extended JSON (https://github.com/mongodb/specifications/blob/master/source/extended-json/extended-json.md).
|
|
96
96
|
#
|
|
97
97
|
# @option opts [ nil | :relaxed | :legacy ] :mode Serialization mode
|
|
98
98
|
# (default is canonical extended JSON)
|
data/lib/bson/undefined.rb
CHANGED
|
@@ -57,7 +57,7 @@ module BSON
|
|
|
57
57
|
end
|
|
58
58
|
|
|
59
59
|
# Converts this object to a representation directly serializable to
|
|
60
|
-
# Extended JSON (https://github.com/mongodb/specifications/blob/master/source/extended-json.
|
|
60
|
+
# Extended JSON (https://github.com/mongodb/specifications/blob/master/source/extended-json/extended-json.md).
|
|
61
61
|
#
|
|
62
62
|
# @option opts [ nil | :relaxed | :legacy ] :mode Serialization mode
|
|
63
63
|
# (default is canonical extended JSON)
|
data/lib/bson/version.rb
CHANGED
data/spec/bson/binary_spec.rb
CHANGED
|
@@ -20,17 +20,56 @@ describe BSON::Binary do
|
|
|
20
20
|
let(:testing1) { described_class.new("testing") }
|
|
21
21
|
let(:testing2) { described_class.new("testing") }
|
|
22
22
|
let(:not_testing) { described_class.new("not testing") }
|
|
23
|
+
let(:testing3) { described_class.new("testing", :user) }
|
|
23
24
|
|
|
24
|
-
describe "
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
25
|
+
describe "Comparable" do
|
|
26
|
+
describe "#eql?" do
|
|
27
|
+
context "for two equal objects" do
|
|
28
|
+
it "returns true" do
|
|
29
|
+
expect(testing1).to eql(testing2)
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
context "for two different objects" do
|
|
34
|
+
it "returns false" do
|
|
35
|
+
expect(testing1).not_to eql(not_testing)
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
context 'for objects with identical data but different types' do
|
|
40
|
+
it 'returns false' do
|
|
41
|
+
expect(testing1).not_to eql(testing3)
|
|
42
|
+
end
|
|
28
43
|
end
|
|
29
44
|
end
|
|
30
45
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
46
|
+
describe '#<=>' do
|
|
47
|
+
context 'with a non-Binary object' do
|
|
48
|
+
it 'returns nil' do
|
|
49
|
+
expect(testing1 <=> 'bogus').to be_nil
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
context 'with identical type and data' do
|
|
54
|
+
it 'returns 0' do
|
|
55
|
+
expect(testing1 <=> testing2).to be == 0
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
context 'with mismatched type' do
|
|
60
|
+
it 'returns nil' do
|
|
61
|
+
expect(testing1 <=> testing3).to be_nil
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
context 'with identical type but mismatched data' do
|
|
66
|
+
it 'returns -1 when a < b' do
|
|
67
|
+
expect(not_testing <=> testing1).to be == -1
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
it 'returns 1 when a > b' do
|
|
71
|
+
expect(testing1 <=> not_testing).to be == 1
|
|
72
|
+
end
|
|
34
73
|
end
|
|
35
74
|
end
|
|
36
75
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: bson
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 5.0.
|
|
4
|
+
version: 5.0.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- The MongoDB Ruby Team
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2024-
|
|
11
|
+
date: 2024-11-19 00:00:00.000000000 Z
|
|
12
12
|
dependencies: []
|
|
13
13
|
description: A fully featured BSON specification implementation in Ruby
|
|
14
14
|
email: dbx-ruby@mongodb.com
|