bson 5.0.1-java → 5.0.2-java

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8abd0210ffaac5ff6d506ec5a872ad8230f9a4253be7bb26d7b5726ff5f4f0e1
4
- data.tar.gz: 2abc7512e12d5ebd109038a22e1a71d1174df6e86d82a43bd52dc5f2ae368c4b
3
+ metadata.gz: 6ed407a1b8d26fd873a143af80fa798b197603d5147df2e78c70e3608c35bb36
4
+ data.tar.gz: 404323d6b37566088e2eedce2edcdf6240cd07479b295d8f8793f4dbea505cc0
5
5
  SHA512:
6
- metadata.gz: bb55a15f35cb6700df2a3f45f13dae8525714adb796037db59cab549d21ae299c1999321e33c1e74b4f6eb1731e84972fd77e1814392f38e62ab7398ea35b7af
7
- data.tar.gz: 52af2ff9e32b7f935b3abbfc482044eb5f62b2b4b1e70a85154ea32b7f36913dabbc183831864589d56b4293458d7b9290eeed15b2e535ac5f1301b8ecd2104c
6
+ metadata.gz: f90250797cdf94c0b87bd12aaa1fb124e0102cda280409fcc19a3c3595660ef0f5833bc5e239fbfd50679061d5f319ff515afe0afad3fd8312388f9f36df54ff
7
+ data.tar.gz: 229783ad4dcc0caf556b508bbbc49b59a54285a8248d2b9c7a7b142e1138293ce90c1bc347369bf1b0f09a976bba3df44eba7775020a2482a7a67d823e1dfab8
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.rst).
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.rst).
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.rst).
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)
@@ -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.rst).
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)
@@ -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.rst).
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)
@@ -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.rst).
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.rst
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.rst).
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.rst).
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.rst).
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.rst).
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.rst).
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.rst).
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.rst).
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.rst).
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.rst).
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.
@@ -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.rst).
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.rst).
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.rst).
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.rst).
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.rst).
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
  #
@@ -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.rst).
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)
@@ -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.rst).
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
@@ -16,5 +16,5 @@
16
16
  # limitations under the License.
17
17
 
18
18
  module BSON
19
- VERSION = "5.0.1"
19
+ VERSION = "5.0.2"
20
20
  end
data/lib/bson-ruby.jar CHANGED
Binary file
@@ -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 "#eql?" do
25
- context "for two equal objects" do
26
- it "returns true" do
27
- expect(testing1).to eql(testing2)
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
- context "for two different objects" do
32
- it "returns false" do
33
- expect(testing1).not_to eql(not_testing)
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.1
4
+ version: 5.0.2
5
5
  platform: java
6
6
  authors:
7
7
  - The MongoDB Ruby Team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-07-23 00:00:00.000000000 Z
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