bson 4.7.1-java → 4.8.0-java

Sign up to get free protection for your applications and to get access to all the features.
Files changed (112) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +1 -2
  3. data.tar.gz.sig +0 -0
  4. data/README.md +5 -1
  5. data/lib/bson-ruby.jar +0 -0
  6. data/lib/bson.rb +3 -0
  7. data/lib/bson/array.rb +21 -3
  8. data/lib/bson/binary.rb +41 -3
  9. data/lib/bson/boolean.rb +3 -1
  10. data/lib/bson/code.rb +15 -1
  11. data/lib/bson/code_with_scope.rb +17 -3
  12. data/lib/bson/db_pointer.rb +104 -0
  13. data/lib/bson/decimal128.rb +15 -1
  14. data/lib/bson/error.rb +17 -0
  15. data/lib/bson/ext_json.rb +374 -0
  16. data/lib/bson/float.rb +47 -1
  17. data/lib/bson/hash.rb +23 -3
  18. data/lib/bson/int32.rb +21 -1
  19. data/lib/bson/int64.rb +28 -3
  20. data/lib/bson/integer.rb +34 -0
  21. data/lib/bson/max_key.rb +12 -0
  22. data/lib/bson/min_key.rb +12 -0
  23. data/lib/bson/nil_class.rb +3 -1
  24. data/lib/bson/object.rb +27 -0
  25. data/lib/bson/object_id.rb +15 -1
  26. data/lib/bson/regexp.rb +19 -2
  27. data/lib/bson/specialized.rb +3 -1
  28. data/lib/bson/string.rb +3 -1
  29. data/lib/bson/symbol.rb +92 -3
  30. data/lib/bson/time.rb +28 -3
  31. data/lib/bson/timestamp.rb +15 -1
  32. data/lib/bson/undefined.rb +11 -0
  33. data/lib/bson/version.rb +1 -1
  34. data/spec/bson/binary_spec.rb +33 -3
  35. data/spec/bson/ext_json_parse_spec.rb +276 -0
  36. data/spec/bson/float_spec.rb +36 -0
  37. data/spec/bson/hash_spec.rb +70 -0
  38. data/spec/bson/int32_spec.rb +20 -0
  39. data/spec/bson/int64_spec.rb +38 -0
  40. data/spec/bson/integer_spec.rb +26 -0
  41. data/spec/bson/raw_spec.rb +22 -1
  42. data/spec/bson/symbol_raw_spec.rb +45 -0
  43. data/spec/bson/symbol_spec.rb +60 -0
  44. data/spec/{support → runners}/common_driver.rb +0 -0
  45. data/spec/runners/corpus.rb +182 -0
  46. data/spec/{support/corpus.rb → runners/corpus_legacy.rb} +40 -58
  47. data/spec/spec_helper.rb +9 -2
  48. data/spec/{bson/driver_bson_spec.rb → spec_tests/common_driver_spec.rb} +1 -0
  49. data/spec/{bson/corpus_spec.rb → spec_tests/corpus_legacy_spec.rb} +4 -4
  50. data/spec/spec_tests/corpus_spec.rb +124 -0
  51. data/spec/spec_tests/data/corpus/README.md +15 -0
  52. data/spec/spec_tests/data/corpus/array.json +49 -0
  53. data/spec/spec_tests/data/corpus/binary.json +85 -0
  54. data/spec/spec_tests/data/corpus/boolean.json +27 -0
  55. data/spec/spec_tests/data/corpus/code.json +67 -0
  56. data/spec/spec_tests/data/corpus/code_w_scope.json +78 -0
  57. data/spec/spec_tests/data/corpus/datetime.json +42 -0
  58. data/spec/spec_tests/data/corpus/dbpointer.json +56 -0
  59. data/spec/spec_tests/data/corpus/dbref.json +31 -0
  60. data/spec/spec_tests/data/corpus/decimal128-1.json +317 -0
  61. data/spec/spec_tests/data/corpus/decimal128-2.json +793 -0
  62. data/spec/spec_tests/data/corpus/decimal128-3.json +1771 -0
  63. data/spec/spec_tests/data/corpus/decimal128-4.json +117 -0
  64. data/spec/spec_tests/data/corpus/decimal128-5.json +402 -0
  65. data/spec/spec_tests/data/corpus/decimal128-6.json +119 -0
  66. data/spec/spec_tests/data/corpus/decimal128-7.json +323 -0
  67. data/spec/spec_tests/data/corpus/document.json +36 -0
  68. data/spec/spec_tests/data/corpus/double.json +87 -0
  69. data/spec/spec_tests/data/corpus/int32.json +43 -0
  70. data/spec/spec_tests/data/corpus/int64.json +43 -0
  71. data/spec/spec_tests/data/corpus/maxkey.json +12 -0
  72. data/spec/spec_tests/data/corpus/minkey.json +12 -0
  73. data/spec/spec_tests/data/corpus/multi-type-deprecated.json +15 -0
  74. data/spec/spec_tests/data/corpus/multi-type.json +11 -0
  75. data/spec/spec_tests/data/corpus/null.json +12 -0
  76. data/spec/spec_tests/data/corpus/oid.json +28 -0
  77. data/spec/spec_tests/data/corpus/regex.json +65 -0
  78. data/spec/spec_tests/data/corpus/string.json +72 -0
  79. data/spec/spec_tests/data/corpus/symbol.json +80 -0
  80. data/spec/spec_tests/data/corpus/timestamp.json +24 -0
  81. data/spec/spec_tests/data/corpus/top.json +240 -0
  82. data/spec/spec_tests/data/corpus/undefined.json +15 -0
  83. data/spec/{support/corpus-tests → spec_tests/data/corpus_legacy}/array.json +0 -0
  84. data/spec/{support/corpus-tests/failures → spec_tests/data/corpus_legacy}/binary.json +0 -0
  85. data/spec/{support/corpus-tests → spec_tests/data/corpus_legacy}/boolean.json +0 -0
  86. data/spec/{support/corpus-tests → spec_tests/data/corpus_legacy}/code.json +1 -1
  87. data/spec/{support/corpus-tests → spec_tests/data/corpus_legacy}/code_w_scope.json +1 -1
  88. data/spec/{support/corpus-tests → spec_tests/data/corpus_legacy}/document.json +1 -1
  89. data/spec/{support/corpus-tests → spec_tests/data/corpus_legacy}/double.json +1 -1
  90. data/spec/{support/corpus-tests → spec_tests/data/corpus_legacy}/failures/datetime.json +0 -0
  91. data/spec/{support/corpus-tests → spec_tests/data/corpus_legacy}/failures/dbpointer.json +0 -0
  92. data/spec/{support/corpus-tests → spec_tests/data/corpus_legacy}/failures/int64.json +0 -0
  93. data/spec/{support/corpus-tests → spec_tests/data/corpus_legacy}/failures/symbol.json +0 -0
  94. data/spec/{support/corpus-tests → spec_tests/data/corpus_legacy}/int32.json +1 -1
  95. data/spec/{support/corpus-tests → spec_tests/data/corpus_legacy}/maxkey.json +1 -1
  96. data/spec/{support/corpus-tests → spec_tests/data/corpus_legacy}/minkey.json +1 -1
  97. data/spec/{support/corpus-tests → spec_tests/data/corpus_legacy}/null.json +1 -1
  98. data/spec/{support/corpus-tests → spec_tests/data/corpus_legacy}/oid.json +0 -0
  99. data/spec/{support/corpus-tests → spec_tests/data/corpus_legacy}/regex.json +1 -1
  100. data/spec/{support/corpus-tests → spec_tests/data/corpus_legacy}/string.json +0 -0
  101. data/spec/{support/corpus-tests → spec_tests/data/corpus_legacy}/timestamp.json +1 -1
  102. data/spec/{support/corpus-tests → spec_tests/data/corpus_legacy}/top.json +0 -0
  103. data/spec/{support/corpus-tests/failures → spec_tests/data/corpus_legacy}/undefined.json +0 -0
  104. data/spec/{support/driver-spec-tests → spec_tests/data}/decimal128/decimal128-1.json +0 -0
  105. data/spec/{support/driver-spec-tests → spec_tests/data}/decimal128/decimal128-2.json +0 -0
  106. data/spec/{support/driver-spec-tests → spec_tests/data}/decimal128/decimal128-3.json +0 -0
  107. data/spec/{support/driver-spec-tests → spec_tests/data}/decimal128/decimal128-4.json +0 -0
  108. data/spec/{support/driver-spec-tests → spec_tests/data}/decimal128/decimal128-5.json +0 -0
  109. data/spec/{support/driver-spec-tests → spec_tests/data}/decimal128/decimal128-6.json +0 -0
  110. data/spec/{support/driver-spec-tests → spec_tests/data}/decimal128/decimal128-7.json +0 -0
  111. metadata +170 -94
  112. metadata.gz.sig +0 -0
@@ -46,18 +46,64 @@ module BSON
46
46
  buffer.put_double(self)
47
47
  end
48
48
 
49
+ # Converts this object to a representation directly serializable to
50
+ # Extended JSON (https://github.com/mongodb/specifications/blob/master/source/extended-json.rst).
51
+ #
52
+ # This method returns the float itself if relaxed representation is
53
+ # requested and the value is finite, otherwise a $numberDouble hash.
54
+ #
55
+ # @option opts [ nil | :relaxed | :legacy ] :mode Serialization mode
56
+ # (default is canonical extended JSON)
57
+ #
58
+ # @return [ Hash | Float ] The extended json representation.
59
+ def as_extended_json(**options)
60
+ case infinite?
61
+ when 1
62
+ {'$numberDouble' => 'Infinity'}
63
+ when -1
64
+ {'$numberDouble' => '-Infinity'}
65
+ else
66
+ if nan?
67
+ {'$numberDouble' => 'NaN'}
68
+ else
69
+ if options[:mode] == :relaxed || options[:mode] == :legacy
70
+ self
71
+ else
72
+ value = if BSON::Environment.jruby?
73
+ # Hack to make bson corpus spec tests pass.
74
+ # JRuby serializes -1.2345678901234568e+18 as
75
+ # -1234567890123456770.0, which is valid but differs from MRI
76
+ # serialization. Extended JSON spec does not define precise
77
+ # stringification of floats.
78
+ # https://jira.mongodb.org/browse/SPEC-1536
79
+ if abs > 1e15
80
+ '%.17g' % to_s
81
+ else
82
+ to_s
83
+ end
84
+ else
85
+ to_s
86
+ end
87
+ {'$numberDouble' => value.upcase}
88
+ end
89
+ end
90
+ end
91
+ end
92
+
49
93
  module ClassMethods
50
94
 
51
95
  # Deserialize an instance of a Float from a BSON double.
52
96
  #
53
97
  # @param [ ByteBuffer ] buffer The byte buffer.
54
98
  #
99
+ # @option options [ nil | :bson ] :mode Decoding mode to use.
100
+ #
55
101
  # @return [ Float ] The decoded Float.
56
102
  #
57
103
  # @see http://bsonspec.org/#/specification
58
104
  #
59
105
  # @since 2.0.0
60
- def from_bson(buffer)
106
+ def from_bson(buffer, **options)
61
107
  buffer.get_double
62
108
  end
63
109
  end
@@ -74,26 +74,46 @@ module BSON
74
74
  Document.new(self)
75
75
  end
76
76
 
77
+ # Converts this object to a representation directly serializable to
78
+ # Extended JSON (https://github.com/mongodb/specifications/blob/master/source/extended-json.rst).
79
+ #
80
+ # This method recursively invokes +as_extended_json+ with the provided
81
+ # options on each hash value.
82
+ #
83
+ # @option opts [ nil | :relaxed | :legacy ] :mode Serialization mode
84
+ # (default is canonical extended JSON)
85
+ #
86
+ # @return [ Hash ] This hash converted to extended json representation.
87
+ def as_extended_json(**options)
88
+ ::Hash[map do |key, value|
89
+ [key, value.as_extended_json(**options)]
90
+ end]
91
+ end
92
+
77
93
  module ClassMethods
78
94
 
79
95
  # Deserialize the hash from BSON.
80
96
  #
81
97
  # @param [ ByteBuffer ] buffer The byte buffer.
82
98
  #
99
+ # @option options [ nil | :bson ] :mode Decoding mode to use.
100
+ #
83
101
  # @return [ Array ] The decoded hash.
84
102
  #
85
103
  # @see http://bsonspec.org/#/specification
86
104
  #
87
105
  # @since 2.0.0
88
- def from_bson(buffer)
106
+ def from_bson(buffer, **options)
89
107
  if buffer.respond_to?(:get_hash)
90
- buffer.get_hash
108
+ buffer.get_hash(**options)
91
109
  else
92
110
  hash = Document.allocate
93
111
  buffer.get_int32 # Throw away the size.
94
112
  while (type = buffer.get_byte) != NULL_BYTE
95
113
  field = buffer.get_cstring
96
- hash.store(field, BSON::Registry.get(type, field).from_bson(buffer))
114
+ cls = BSON::Registry.get(type, field)
115
+ value = cls.from_bson(buffer, **options)
116
+ hash.store(field, value)
97
117
  end
98
118
  hash
99
119
  end
@@ -40,12 +40,14 @@ module BSON
40
40
  #
41
41
  # @param [ ByteBuffer ] buffer The byte buffer.
42
42
  #
43
+ # @option options [ nil | :bson ] :mode Decoding mode to use.
44
+ #
43
45
  # @return [ Integer ] The decoded Integer.
44
46
  #
45
47
  # @see http://bsonspec.org/#/specification
46
48
  #
47
49
  # @since 2.0.0
48
- def self.from_bson(buffer)
50
+ def self.from_bson(buffer, **options)
49
51
  buffer.get_int32
50
52
  end
51
53
 
@@ -115,6 +117,24 @@ module BSON
115
117
  alias :eql? :==
116
118
  alias :=== :==
117
119
 
120
+ # Converts this object to a representation directly serializable to
121
+ # Extended JSON (https://github.com/mongodb/specifications/blob/master/source/extended-json.rst).
122
+ #
123
+ # This method returns the integer value if relaxed representation is
124
+ # requested, otherwise a $numberInt hash.
125
+ #
126
+ # @option opts [ nil | :relaxed | :legacy ] :mode Serialization mode
127
+ # (default is canonical extended JSON)
128
+ #
129
+ # @return [ Hash | Integer ] The extended json representation.
130
+ def as_extended_json(**options)
131
+ if options[:mode] == :relaxed || options[:mode] == :legacy
132
+ value
133
+ else
134
+ {'$numberInt' => value.to_s}
135
+ end
136
+ end
137
+
118
138
  # Register this type when the module is loaded.
119
139
  #
120
140
  # @since 2.0.0
@@ -35,13 +35,20 @@ module BSON
35
35
  #
36
36
  # @param [ ByteBuffer ] buffer The byte buffer.
37
37
  #
38
- # @return [ Integer ] The decoded Integer.
38
+ # @option options [ nil | :bson ] :mode Decoding mode to use.
39
+ #
40
+ # @return [ Integer | BSON::Int64 ] The decoded Integer.
39
41
  #
40
42
  # @see http://bsonspec.org/#/specification
41
43
  #
42
44
  # @since 2.0.0
43
- def self.from_bson(buffer)
44
- buffer.get_int64
45
+ def self.from_bson(buffer, **options)
46
+ value = buffer.get_int64
47
+ if options[:mode] == :bson
48
+ new(value)
49
+ else
50
+ value
51
+ end
45
52
  end
46
53
 
47
54
  # Instantiate a BSON Int64.
@@ -110,6 +117,24 @@ module BSON
110
117
  alias :eql? :==
111
118
  alias :=== :==
112
119
 
120
+ # Converts this object to a representation directly serializable to
121
+ # Extended JSON (https://github.com/mongodb/specifications/blob/master/source/extended-json.rst).
122
+ #
123
+ # This method returns the integer value if relaxed representation is
124
+ # requested, otherwise a $numberLong hash.
125
+ #
126
+ # @option opts [ nil | :relaxed | :legacy ] :mode Serialization mode
127
+ # (default is canonical extended JSON)
128
+ #
129
+ # @return [ Hash | Integer ] The extended json representation.
130
+ def as_extended_json(**options)
131
+ if options[:mode] == :relaxed || options[:mode] == :legacy
132
+ value
133
+ else
134
+ {'$numberLong' => value.to_s}
135
+ end
136
+ end
137
+
113
138
  # Register this type when the module is loaded.
114
139
  #
115
140
  # @since 2.0.0
@@ -159,6 +159,40 @@ module BSON
159
159
  self
160
160
  end
161
161
 
162
+ # Converts this object to a representation directly serializable to
163
+ # Extended JSON (https://github.com/mongodb/specifications/blob/master/source/extended-json.rst).
164
+ #
165
+ # This method returns the integer itself if relaxed representation is
166
+ # requested, otherwise a $numberInt hash if the value fits in 32 bits
167
+ # and a $numberLong otherwise. Regardless of which representation is
168
+ # requested, a value that does not fit in 64 bits raises RangeError.
169
+ #
170
+ # @option opts [ nil | :relaxed | :legacy ] :mode Serialization mode
171
+ # (default is canonical extended JSON)
172
+ #
173
+ # @return [ Hash | Integer ] The extended json representation.
174
+ def as_extended_json(**options)
175
+ # The behavior of native integers' serialization to extended json is
176
+ # not specified. Following our bson serialization logic in this file,
177
+ # produce explicit $numberInt or $numberLong, choosing $numberInt if
178
+ # the integer fits in 32 bits. In Ruby integers can be arbitrarily
179
+ # big; integers that do not fit into 64 bits raise an error as we do not
180
+ # want to silently perform an effective type conversion of integer ->
181
+ # decimal.
182
+
183
+ unless bson_int64?
184
+ raise RangeError, "Integer #{self} is too big to be represented as a MongoDB integer"
185
+ end
186
+
187
+ if options[:mode] == :relaxed || options[:mode] == :legacy
188
+ self
189
+ elsif bson_int32?
190
+ {'$numberInt' => to_s}
191
+ else
192
+ {'$numberLong' => to_s}
193
+ end
194
+ end
195
+
162
196
  private
163
197
 
164
198
  def append_bson_int32(encoded)
@@ -58,7 +58,19 @@ module BSON
58
58
  # @return [ Hash ] The max key as a JSON hash.
59
59
  #
60
60
  # @since 2.0.0
61
+ # @deprecated Use as_extended_json instead.
61
62
  def as_json(*args)
63
+ as_extended_json
64
+ end
65
+
66
+ # Converts this object to a representation directly serializable to
67
+ # Extended JSON (https://github.com/mongodb/specifications/blob/master/source/extended-json.rst).
68
+ #
69
+ # @option opts [ nil | :relaxed | :legacy ] :mode Serialization mode
70
+ # (default is canonical extended JSON)
71
+ #
72
+ # @return [ Hash ] The extended json representation.
73
+ def as_extended_json(**options)
62
74
  { "$maxKey" => 1 }
63
75
  end
64
76
 
@@ -58,7 +58,19 @@ module BSON
58
58
  # @return [ Hash ] The min key as a JSON hash.
59
59
  #
60
60
  # @since 2.0.0
61
+ # @deprecated Use as_extended_json instead.
61
62
  def as_json(*args)
63
+ as_extended_json
64
+ end
65
+
66
+ # Converts this object to a representation directly serializable to
67
+ # Extended JSON (https://github.com/mongodb/specifications/blob/master/source/extended-json.rst).
68
+ #
69
+ # @option opts [ nil | :relaxed | :legacy ] :mode Serialization mode
70
+ # (default is canonical extended JSON)
71
+ #
72
+ # @return [ Hash ] The extended json representation.
73
+ def as_extended_json(**options)
62
74
  { "$minKey" => 1 }
63
75
  end
64
76
 
@@ -34,12 +34,14 @@ module BSON
34
34
  #
35
35
  # @param [ ByteBuffer ] buffer The byte buffer.
36
36
  #
37
+ # @option options [ nil | :bson ] :mode Decoding mode to use.
38
+ #
37
39
  # @return [ nil ] The decoded nil value.
38
40
  #
39
41
  # @see http://bsonspec.org/#/specification
40
42
  #
41
43
  # @since 2.0.0
42
- def from_bson(buffer)
44
+ def from_bson(buffer, **options)
43
45
  nil
44
46
  end
45
47
  end
@@ -58,6 +58,33 @@ module BSON
58
58
  def to_bson_normalized_value
59
59
  self
60
60
  end
61
+
62
+ # Serializes this object to Extended JSON
63
+ # (https://github.com/mongodb/specifications/blob/master/source/extended-json.rst).
64
+ #
65
+ # Subclasses should override +as_extended_json+ rather than this method.
66
+ #
67
+ # @option opts [ nil | :relaxed | :legacy ] :mode Serialization mode
68
+ # (default is canonical extended JSON)
69
+ #
70
+ # @return [ String ] The extended json serialization.
71
+ def to_extended_json(**options)
72
+ as_extended_json(**options).to_json
73
+ end
74
+
75
+ # Converts this object to a representation directly serializable to
76
+ # Extended JSON (https://github.com/mongodb/specifications/blob/master/source/extended-json.rst).
77
+ #
78
+ # Subclasses should override this method to provide custom serialization
79
+ # to Extended JSON.
80
+ #
81
+ # @option options [ true | false ] :relaxed Whether to produce relaxed
82
+ # extended JSON representation.
83
+ #
84
+ # @return [ Object ] The extended json representation.
85
+ def as_extended_json(**options)
86
+ self
87
+ end
61
88
  end
62
89
 
63
90
  # Raised when trying to serialize an object into a key.
@@ -71,7 +71,19 @@ module BSON
71
71
  # @return [ Hash ] The object id as a JSON hash.
72
72
  #
73
73
  # @since 2.0.0
74
+ # @deprecated Use as_extended_json instead.
74
75
  def as_json(*args)
76
+ as_extended_json
77
+ end
78
+
79
+ # Converts this object to a representation directly serializable to
80
+ # Extended JSON (https://github.com/mongodb/specifications/blob/master/source/extended-json.rst).
81
+ #
82
+ # @option opts [ nil | :relaxed | :legacy ] :mode Serialization mode
83
+ # (default is canonical extended JSON)
84
+ #
85
+ # @return [ Hash ] The extended json representation.
86
+ def as_extended_json(**options)
75
87
  { "$oid" => to_s }
76
88
  end
77
89
 
@@ -217,10 +229,12 @@ module BSON
217
229
  #
218
230
  # @param [ ByteBuffer ] buffer The byte buffer.
219
231
  #
232
+ # @option options [ nil | :bson ] :mode Decoding mode to use.
233
+ #
220
234
  # @return [ BSON::ObjectId ] The object id.
221
235
  #
222
236
  # @since 2.0.0
223
- def from_bson(buffer)
237
+ def from_bson(buffer, **options)
224
238
  from_data(buffer.get_bytes(12))
225
239
  end
226
240
 
@@ -205,7 +205,22 @@ module BSON
205
205
  #
206
206
  # @since 4.2.0
207
207
  def as_json(*args)
208
- { "$regex" => source, "$options" => options }
208
+ as_extended_json(mode: :legacy)
209
+ end
210
+
211
+ # Converts this object to a representation directly serializable to
212
+ # Extended JSON (https://github.com/mongodb/specifications/blob/master/source/extended-json.rst).
213
+ #
214
+ # @option opts [ nil | :relaxed | :legacy ] :mode Serialization mode
215
+ # (default is canonical extended JSON)
216
+ #
217
+ # @return [ Hash ] The extended json representation.
218
+ def as_extended_json(**opts)
219
+ if opts[:mode] == :legacy
220
+ { "$regex" => source, "$options" => options }
221
+ else
222
+ {"$regularExpression" => {'pattern' => source, "options" => options}}
223
+ end
209
224
  end
210
225
 
211
226
  # Check equality of the raw bson regexp against another.
@@ -248,12 +263,14 @@ module BSON
248
263
  #
249
264
  # @param [ ByteBuffer ] buffer The byte buffer.
250
265
  #
266
+ # @option opts [ nil | :bson ] :mode Decoding mode to use.
267
+ #
251
268
  # @return [ Regexp ] The decoded regular expression.
252
269
  #
253
270
  # @see http://bsonspec.org/#/specification
254
271
  #
255
272
  # @since 2.0.0
256
- def from_bson(buffer)
273
+ def from_bson(buffer, **opts)
257
274
  pattern = buffer.get_cstring
258
275
  options = buffer.get_cstring
259
276
  Raw.new(pattern, options)
@@ -61,12 +61,14 @@ module BSON
61
61
  #
62
62
  # @param [ ByteBuffer ] buffer The byte buffer.
63
63
  #
64
+ # @option options [ nil | :bson ] :mode Decoding mode to use.
65
+ #
64
66
  # @return [ Specialized ] The decoded specialized class.
65
67
  #
66
68
  # @see http://bsonspec.org/#/specification
67
69
  #
68
70
  # @since 2.0.0
69
- def from_bson(buffer)
71
+ def from_bson(buffer, **options)
70
72
  new
71
73
  end
72
74
  end
@@ -124,12 +124,14 @@ module BSON
124
124
  #
125
125
  # @param [ ByteBuffer ] buffer The byte buffer.
126
126
  #
127
+ # @option options [ nil | :bson ] :mode Decoding mode to use.
128
+ #
127
129
  # @return [ Regexp ] The decoded string.
128
130
  #
129
131
  # @see http://bsonspec.org/#/specification
130
132
  #
131
133
  # @since 2.0.0
132
- def from_bson(buffer)
134
+ def from_bson(buffer, **options)
133
135
  buffer.get_string
134
136
  end
135
137
  end