bson 2.1.2 → 2.2.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of bson might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 837b4c981b42baf614c8b3646e7bc16950ac3503
4
- data.tar.gz: 45fb449e8d53fe4e59dfae6ea6f71c7e487ebc8d
3
+ metadata.gz: 078980f1ea9268424707f8092a03d37e994e4b57
4
+ data.tar.gz: 0237ad595808006e2e6f676b52bdf03bc29d1623
5
5
  SHA512:
6
- metadata.gz: fb199ddc9ce95e038389e1520aa382b1cba0401555074c0819f36cce56a42dab1545e5b05afa7fc055a0d40add0b55f154af8c05c24f31c99f6ee6a8339c14c6
7
- data.tar.gz: 98e62a31c66e43f68903df0cebe2a065d0c8be86ffeee72a600b6274bc6446eab5e00ed82a44b94b348d4639d7efb470a8899011ac60dd94e690fe5196b072e7
6
+ metadata.gz: 29d9e1e82351f9abcca34eeb70faf469a07cbbf68ca9b1b8c55da8e629997247adb301adbcfda3fe866b74dbf44a184afcf719695c1a990a13fa82c5d8501546
7
+ data.tar.gz: d5502ef3149262d3459558dc47e7082759f1caec153bf9b548e2c7ec1f365848a1c889169f8d4f40c9902e146f44a587fb0a36fb59e8a79bf487f18f3766c771
Binary file
data.tar.gz.sig CHANGED
Binary file
@@ -1,6 +1,12 @@
1
1
  BSON Changelog
2
2
  ==============
3
3
 
4
+ ## 2.2.0
5
+
6
+ ### Dependency Changes
7
+
8
+ * Ruby 1.8 interpreters are no longer supported.
9
+
4
10
  ## 2.1.2
5
11
 
6
12
  ### Bug Fixes
data/README.md CHANGED
@@ -6,7 +6,7 @@ An implementation of the BSON specification in Ruby.
6
6
  Compatibility
7
7
  -------------
8
8
 
9
- BSON is tested against MRI (1.8.7+), JRuby (1.5.0+), Rubinius (2.0.0+), and REE.
9
+ BSON is tested against MRI (1.9.2+), JRuby (1.7.0+) and Rubinius (2.0.0+).
10
10
 
11
11
  Installation
12
12
  ------------
@@ -15,7 +15,7 @@ With bundler, add the `bson` gem to your `Gemfile`. As of 2.0.0 native extension
15
15
  are bundled with the `bson` gem and `bson_ext` is no longer needed.
16
16
 
17
17
  ```ruby
18
- gem "bson", "~> 2.0"
18
+ gem "bson", "~> 2.2"
19
19
  ```
20
20
 
21
21
  Require the `bson` gem in your application.
@@ -87,12 +87,6 @@ static VALUE rb_bson_utf8_string;
87
87
  */
88
88
  static VALUE rb_utc_method;
89
89
 
90
- /**
91
- * Define encoding macros to be able to support 1.8.
92
- *
93
- * @since 2.0.0
94
- */
95
- #ifdef HAVE_RUBY_ENCODING_H
96
90
  #include <ruby/encoding.h>
97
91
 
98
92
  /**
@@ -144,57 +138,6 @@ static VALUE rb_str_new_encoded_binary(void)
144
138
  {
145
139
  return rb_enc_str_new("", 0, rb_ascii8bit_encoding());
146
140
  }
147
- #else
148
-
149
- /**
150
- * convert a ruby string into a utf-8 compatible binary string.
151
- *
152
- * @example convert the string to utf-8 binary.
153
- * rb_bson_to_utf8_binary("test");
154
- *
155
- * @param [ string ] string the ruby string.
156
- *
157
- * @return [ string ] the encoded string.
158
- *
159
- * @since 2.0.0
160
- */
161
- static VALUE rb_bson_to_utf8_binary(VALUE string)
162
- {
163
- return string;
164
- }
165
-
166
- /**
167
- * Convert the binary string to a ruby utf8 string.
168
- *
169
- * @example Convert the string to binary.
170
- * rb_bson_from_bson_string("test");
171
- *
172
- * @param [ String ] string The ruby string.
173
- *
174
- * @return [ String ] The encoded string.
175
- *
176
- * @since 2.0.0
177
- */
178
- static VALUE rb_bson_from_bson_string(VALUE string)
179
- {
180
- return string;
181
- }
182
-
183
- /**
184
- * Provide default new string with binary encoding.
185
- *
186
- * @example Check encoded and provide default new binary encoded string.
187
- * if (NIL_P(encoded)) encoded = rb_str_new_encoded_binary();
188
- *
189
- * @return [ String ] The new string with binary encoding.
190
- *
191
- * @since 2.0.0
192
- */
193
- static VALUE rb_str_new_encoded_binary(void)
194
- {
195
- return rb_str_new("", 0);
196
- }
197
- #endif
198
141
 
199
142
  /**
200
143
  * Constant for a null byte.
@@ -37,27 +37,6 @@ module BSON
37
37
  def to_bson(encoded = ''.force_encoding(BINARY))
38
38
  to_time.to_bson(encoded)
39
39
  end
40
-
41
- if Environment.ruby_18?
42
-
43
- # Constant to multiple the seconds fraction my for millis in REE.
44
- #
45
- # @since 2.1.0
46
- FACTOR = 86400000000
47
-
48
- # REE does not define a to_time on DateTime, so if we are using REE we
49
- # define it ourselves.
50
- #
51
- # @example Conver the DateTime to a time.
52
- # date_time.to_time
53
- #
54
- # @return [ Time ] The converted time.
55
- #
56
- # @since 2.1.0
57
- def to_time
58
- ::Time.utc(year, mon, mday, hour, min, sec, (sec_fraction * FACTOR).to_i).getlocal
59
- end
60
- end
61
40
  end
62
41
 
63
42
  # Enrich the core DateTime class with this module.
@@ -52,498 +52,5 @@ module BSON
52
52
  def [](key)
53
53
  super(key) || super(key.to_s)
54
54
  end
55
-
56
- # If we have ordered hashes, the a BSON::Document is simply a hash. If we do
57
- # not, then we need to import our custom BSON::Document implementation.
58
- #
59
- # @since 2.0.0
60
- unless Environment.retaining_hash_order?
61
-
62
- # Message for argument error when providing bad arguments to [].
63
- #
64
- # @since 2.0.0
65
- ARG_ERROR = "An even number of arguments must be passed to BSON::Document[]."
66
-
67
- # Sets a value for the provided key.
68
- #
69
- # @example Set the value in the document.
70
- # document[:name] = "Sid"
71
- #
72
- # @param [ Object ] key The name of the key.
73
- # @param [ Object ] value The value for the key.
74
- #
75
- # @return [ Object ] The passed in value.
76
- #
77
- # @since 2.0.0
78
- def []=(key, value)
79
- order.push(key) unless has_key?(key)
80
- super
81
- end
82
-
83
- # Clear out all elements in the document.
84
- #
85
- # @example Clear out all elements.
86
- # document.clear
87
- #
88
- # @return [ BSON::Document ] The empty document.
89
- #
90
- # @since 2.0.0
91
- def clear
92
- super
93
- order.clear
94
- self
95
- end
96
-
97
- # Delete a value from the document for the provided key.
98
- #
99
- # @example Delete a value from the document.
100
- # document.delete(:name)
101
- #
102
- # @param [ Object ] key The key to delete for.
103
- #
104
- # @return [ Object ] The deleted value.
105
- #
106
- # @since 2.0.0
107
- def delete(key)
108
- if has_key?(key)
109
- order.delete_at(order.index(key))
110
- end
111
- super
112
- end
113
-
114
- # Delete each key/value pair in the document for which the provided block
115
- # returns true.
116
- #
117
- # @example Delete each for when the block is true.
118
- # document.delete_if do |key, value|
119
- # value == 1
120
- # end
121
- #
122
- # @return [ BSON::Document ] The document.
123
- #
124
- # @since 2.0.0
125
- def delete_if
126
- super
127
- synchronize!
128
- self
129
- end
130
- alias :reject! :delete_if
131
-
132
- # Iterate over each element of the document in insertion order and yield
133
- # the key and value.
134
- #
135
- # @example Iterate over the document.
136
- # document.each do |key, value|
137
- # #...
138
- # end
139
- #
140
- # @return [ BSON::Document ] The document if a block was given, otherwise
141
- # an enumerator.
142
- #
143
- # @since 2.0.0
144
- def each
145
- if block_given?
146
- order.each{ |key| yield([ key, self[key]]) }
147
- self
148
- else
149
- to_enum(:each)
150
- end
151
- end
152
-
153
- # Iterate over each key in the document in insertion order and yield the
154
- # key.
155
- #
156
- # @example Iterate over the keys.
157
- # document.each_key do |key|
158
- # #...
159
- # end
160
- #
161
- # @return [ BSON::Document ] The document if a block was given, otherwise
162
- # an enumerator.
163
- #
164
- # @since 2.0.0
165
- def each_key
166
- if block_given?
167
- order.each{ |key| yield(key) }
168
- self
169
- else
170
- to_enum(:each_key)
171
- end
172
- end
173
-
174
- # Iterate over each value in the document in insertion order and yield the
175
- # value.
176
- #
177
- # @example Iterate over the values.
178
- # document.each_value do |value|
179
- # #...
180
- # end
181
- #
182
- # @return [ BSON::Document ] The document if a block was given, otherwise
183
- # an enumerator.
184
- #
185
- # @since 2.0.0
186
- def each_value
187
- if block_given?
188
- order.each{ |key| yield(self[key]) }
189
- self
190
- else
191
- to_enum(:each_value)
192
- end
193
- end
194
-
195
- # Iterate over each element of the document in insertion order and yield
196
- # the key and value.
197
- #
198
- # @example Iterate over the document.
199
- # document.each_pair do |key, value|
200
- # #...
201
- # end
202
- #
203
- # @return [ BSON::Document ] The document if a block was given, otherwise
204
- # an enumerator.
205
- #
206
- # @since 2.0.0
207
- def each_pair
208
- if block_given?
209
- order.each{ |key| yield([ key, self[key]]) }
210
- self
211
- else
212
- to_enum(:each_pair)
213
- end
214
- end
215
-
216
- # Encode the document with the provided coder.
217
- #
218
- # @example Encode the document with the coder.
219
- # document.encode_with(coder)
220
- #
221
- # @param [ Object ] coder The coder.
222
- #
223
- # @return [ String ] The encoded document.
224
- #
225
- # @since 2.0.0
226
- def encode_with(coder)
227
- coder.represent_seq("!bsondoc", map{ |key, value| { key => value }})
228
- end
229
-
230
- # Get all the keys in the document, in order.
231
- #
232
- # @example Get all the keys in the document.
233
- # document.keys
234
- #
235
- # @return [ Array<Object> ] The ordered keys.
236
- #
237
- # @since 2.0.0
238
- def keys
239
- order.dup
240
- end
241
-
242
- # Instantiate a new Document.
243
- #
244
- # @example Instantiate an empty new document.
245
- # BSON::Document.new
246
- #
247
- # @since 2.0.0
248
- def initialize(*args, &block)
249
- super
250
- @order = []
251
- end
252
-
253
- # Inspect the contents of the document.
254
- #
255
- # @example Inspect the document.
256
- # document.inspect
257
- #
258
- # @return [ String ] The inspection string.
259
- #
260
- # @since 2.0.0
261
- def inspect
262
- "#<BSON::Document #{super}>"
263
- end
264
-
265
- # Invert the document - reverses the order of all key/value pairs and
266
- # returns a new document.
267
- #
268
- # @example Invert the document.
269
- # document.invert
270
- #
271
- # @return [ BSON::Document ] The inverted document.
272
- #
273
- # @since 2.0.0
274
- def invert
275
- Document[to_a.map!{ |pair| pair.reverse }]
276
- end
277
-
278
- # Merge a document into this document. Will overwrite any existing keys and
279
- # add potential new ones. This returns a new document instead of merging in
280
- # place.
281
- #
282
- # @example Merge the document into this document.
283
- # document.merge(other_document)
284
- #
285
- # @param [ BSON::Document ] other The document to merge in.
286
- #
287
- # @return [ BSON::Document ] A newly merged document.
288
- #
289
- # @since 2.0.0
290
- def merge(other, &block)
291
- dup.merge!(other, &block)
292
- end
293
-
294
- # Merge a document into this document. Will overwrite any existing keys and
295
- # add potential new ones.
296
- #
297
- # @example Merge the document into this document.
298
- # document.merge!(other_document)
299
- #
300
- # @param [ BSON::Document ] other The document to merge in.
301
- #
302
- # @return [ BSON::Document ] The document.
303
- #
304
- # @since 2.0.0
305
- def merge!(other)
306
- if block_given?
307
- other.each do |key, value|
308
- self[key] = key?(key) ? yield(key, self[key], value) : value
309
- end
310
- else
311
- other.each{ |key, value| self[key] = value }
312
- end
313
- self
314
- end
315
- alias :update :merge!
316
-
317
- # Delete each key/value pair in the document for which the provided block
318
- # returns true. This returns a new document instead of modifying in place.
319
- #
320
- # @example Delete each for when the block is true.
321
- # document.reject do |key, value|
322
- # value == 1
323
- # end
324
- #
325
- # @return [ BSON::Document ] The new document.
326
- #
327
- # @since 2.0.0
328
- def reject(&block)
329
- dup.reject!(&block)
330
- end
331
-
332
- # Replace this document with the other document.
333
- #
334
- # @example Replace the contents of this document with the other.
335
- # document.replace(other_document)
336
- #
337
- # @param [ BSON::Document ] other The other document.
338
- #
339
- # @return [ BSON::Document ] The document replaced.
340
- #
341
- # @since 2.0.0
342
- def replace(other)
343
- super
344
- @order = other.keys
345
- self
346
- end
347
-
348
- # Shift the document by popping off the first key/value pair in the
349
- # document.
350
- #
351
- # @example Shift the document.
352
- # document.shift
353
- #
354
- # @return [ Array<Object, Object> ] The first key/value pair.
355
- #
356
- # @since 2.0.0
357
- def shift
358
- key = order.first
359
- value = delete(key)
360
- [ key, value ]
361
- end
362
-
363
- alias :select :find_all
364
-
365
- # Get the document as an array. This returns a multi-dimensional array
366
- # where each element is a [ key, value ] pair in the insertion order.
367
- #
368
- # @example Get the document as an array.
369
- # document.to_a
370
- #
371
- # @return [ Array<Array<Object, Object>> ] The pairs in insertion order.
372
- #
373
- # @since 2.0.0
374
- def to_a
375
- order.map{ |key| [ key, self[key] ]}
376
- end
377
-
378
- # Convert this document to a hash. Since a document is simply an ordered
379
- # hash we return self.
380
- #
381
- # @example Get the document as a hash.
382
- # document.to_hash
383
- #
384
- # @return [ BSON::Document ] The document.
385
- #
386
- # @since 2.0.0
387
- def to_hash
388
- self
389
- end
390
-
391
- # Convert the document to yaml.
392
- #
393
- # @example Convert the document to yaml.
394
- # document.to_yaml
395
- #
396
- # @param [ Hash ] options The yaml options.
397
- #
398
- # @return [ String ] The document as yaml.
399
- #
400
- # @since 2.0.0
401
- def to_yaml(options = {})
402
- if YAML.const_defined?(:ENGINE) && !YAML::ENGINE.syck?
403
- return super
404
- end
405
- YAML.quick_emit(self, options) do |out|
406
- out.seq(taguri) do |seq|
407
- each{ |key, value| seq.add(key => value) }
408
- end
409
- end
410
- end
411
-
412
- # Get the custom yaml type for the document.
413
- #
414
- # @example Get the yaml type.
415
- # document.to_yaml_type
416
- #
417
- # @return [ String ] "!bsondoc".
418
- #
419
- # @since 2.0.0
420
- def to_yaml_type
421
- "!bsondoc"
422
- end
423
-
424
- # Get all the values in the document, by order of insertion.
425
- #
426
- # @example Get all the values in the document.
427
- # document.values
428
- #
429
- # @return [ Array<Object> ] The ordered values.
430
- #
431
- # @since 2.0.0
432
- def values
433
- order.map{ |key| self[key] }
434
- end
435
-
436
- class << self
437
-
438
- # Create a new document given the provided arguments. The args can either
439
- # be empty in order to instantiate an empty document, or an array of
440
- # key/value pairs in the order that they should remain in.
441
- #
442
- # @example Create a new empty document.
443
- # BSON::Document[]
444
- #
445
- # @example Create a new document with the provided elements.
446
- # BSON::Document[1, 2, 3, 4]
447
- #
448
- # @example Create a new document with key/value array pairs.
449
- # BSON::Document[[ 1, 2 ], [ 3, 4 ]]
450
- #
451
- # @param [ Array<Object> ] args The key/value pairs.
452
- #
453
- # @return [ BSON::Document ] The new document.
454
- #
455
- # @since 2.0.0
456
- def [](*args)
457
- if (args.length == 1 && args.first.is_a?(Array))
458
- return document_from_pairs(args)
459
- end
460
- raise ArgumentError.new(ARG_ERROR) unless (args.size % 2 == 0)
461
- document_from_args(args)
462
- end
463
-
464
- private
465
-
466
- # Returns a document that will be generated from an array of [ key, value ]
467
- # array pairs.
468
- #
469
- # @api private
470
- #
471
- # @example Initialize a document from array pairs.
472
- # BSON::Document[[ 1, 2 ], [ 3, 4 ]]
473
- #
474
- # @param [ Array ] pairs The key/value pairs.
475
- #
476
- # @since 2.0.0
477
- #
478
- # @return [ BSON::Document ] The document.
479
- def document_from_pairs(pairs)
480
- document = new
481
- pairs.first.each do |pair|
482
- next unless (pair.is_a?(Array))
483
- document[pair[0]] = pair[1]
484
- end
485
- return document
486
- end
487
-
488
- # Returns a document that will be generated from an even number of
489
- # individual arguments.
490
- #
491
- # @api private
492
- #
493
- # @example Initialize a document from args.
494
- # BSON::Document[1, 2, 3, 4]
495
- #
496
- # @param [ Array ] args The arguments.
497
- #
498
- # @return [ BSON::Document ] The document.
499
- #
500
- # @since 2.0.0
501
- def document_from_args(args)
502
- document = new
503
- args.each_with_index do |val, ind|
504
- next if (ind % 2 != 0)
505
- document[val] = args[ind + 1]
506
- end
507
- document
508
- end
509
- end
510
-
511
- private
512
-
513
- # @!attribute order
514
- # @api private
515
- # @return [ Array<String> ] The document keys in order.
516
- # @since 2.0.0
517
- attr_reader :order
518
-
519
- # Initialize a copy of the document for use with clone or dup.
520
- #
521
- # @api private
522
- #
523
- # @example Clone the document.
524
- # document.clone
525
- #
526
- # @param [ Object ] other The original copy.
527
- #
528
- # @since 2.0.0
529
- def initialize_copy(other)
530
- super
531
- @order = other.keys
532
- end
533
-
534
- # Ensure that the ordered keys are the same entries as the internal keys.
535
- #
536
- # @api private
537
- #
538
- # @example Synchronize the keys.
539
- # document.synchronize!
540
- #
541
- # @return [ Array<Object> ] The keys.
542
- #
543
- # @since 2.0.0
544
- def synchronize!
545
- order.reject!{ |key| !has_key?(key) }
546
- end
547
- end
548
55
  end
549
56
  end
@@ -32,80 +32,5 @@ module BSON
32
32
  def jruby?
33
33
  defined?(JRUBY_VERSION)
34
34
  end
35
-
36
- # Determine if we are using REE or not.
37
- #
38
- # @example Are we running with REE?
39
- # Environment.ree?
40
- #
41
- # @return [ true, false ] If our vm is REE.
42
- #
43
- # @since 2.1.0
44
- def ree?
45
- return false unless defined?(RUBY_ENGINE)
46
- RUBY_ENGINE == "ruby" && RUBY_DESCRIPTION =~ /Enterprise/
47
- end
48
-
49
- # Does the Ruby runtime we are using support ordered hashes?
50
- #
51
- # @example Does the runtime support ordered hashes?
52
- # Environment.retaining_hash_order?
53
- #
54
- # @return [ true, false ] If the runtime has ordered hashes.
55
- #
56
- # @since 2.0.0
57
- def retaining_hash_order?
58
- jruby? || RUBY_VERSION > "1.9.1"
59
- end
60
-
61
- # Are we running in a ruby runtime that is version 1.8.x?
62
- #
63
- # @example Is the ruby runtime in 1.8 mode?
64
- # Environment.ruby_18?
65
- #
66
- # @return [ true, false ] If we are running in 1.8.
67
- #
68
- # @since 2.0.0
69
- def ruby_18?
70
- RUBY_VERSION < "1.9"
71
- end
72
35
  end
73
36
  end
74
-
75
- # In the case where we don't have encoding, we need to monkey
76
- # patch string to ignore the encoding directives.
77
- #
78
- # @since 2.0.0
79
- if BSON::Environment.ruby_18?
80
-
81
- # Making string in 1.8 respond like a 1.9 string, without any modifications.
82
- #
83
- # @since 2.0.0
84
- class String
85
-
86
- # Simply return the string when asking for it's character.
87
- #
88
- # @since 2.0.0
89
- def chr; self; end
90
-
91
- # Force the string to the provided encoding. NOOP.
92
- #
93
- # @since 2.0.0
94
- def force_encoding(*); self; end
95
-
96
- # Encode the string as the provided type. NOOP.
97
- #
98
- # @since 2.0.0
99
- def encode(*); self; end
100
-
101
- # Encode the string in place. NOOP.
102
- #
103
- # @since 2.0.0
104
- def encode!(*); self; end
105
- end
106
-
107
- # No encoding error is defined in 1.8.
108
- #
109
- # @since 2.0.0
110
- class EncodingError < RuntimeError; end
111
- end
@@ -30,7 +30,7 @@ module BSON
30
30
  # Constant for the int 32 pack directive.
31
31
  #
32
32
  # @since 2.0.0
33
- PACK = Environment.ruby_18? ? "l".freeze : "l<".freeze
33
+ PACK = "l<".freeze
34
34
 
35
35
  # Deserialize an Integer from BSON.
36
36
  #
@@ -30,7 +30,7 @@ module BSON
30
30
  # Constant for the int 64 pack directive.
31
31
  #
32
32
  # @since 2.0.0
33
- PACK = Environment.ruby_18? ? "q".freeze : "q<".freeze
33
+ PACK = "q<".freeze
34
34
 
35
35
  # Deserialize an Integer from BSON.
36
36
  #
@@ -13,5 +13,5 @@
13
13
  # limitations under the License.
14
14
 
15
15
  module BSON
16
- VERSION = "2.1.2"
16
+ VERSION = "2.2.0"
17
17
  end
@@ -25,7 +25,7 @@ describe BSON::Document do
25
25
  {}
26
26
  end
27
27
  let(:enum_class) do
28
- BSON::Environment.ruby_18? ? Enumerable::Enumerator : Enumerator
28
+ Enumerator
29
29
  end
30
30
 
31
31
  before do
@@ -559,21 +559,18 @@ describe BSON::Document do
559
559
  end
560
560
  end
561
561
 
562
- if BSON::Environment.retaining_hash_order?
562
+ context "when provided hashes" do
563
563
 
564
- context "when provided hashes" do
565
-
566
- let(:alternate) do
567
- described_class[1 => 2, 3 => 4]
568
- end
564
+ let(:alternate) do
565
+ described_class[1 => 2, 3 => 4]
566
+ end
569
567
 
570
- it "sets the keys" do
571
- expect(alternate.keys).to eq([ 1, 3 ])
572
- end
568
+ it "sets the keys" do
569
+ expect(alternate.keys).to eq([ 1, 3 ])
570
+ end
573
571
 
574
- it "sets the values" do
575
- expect(alternate.values).to eq([ 2, 4 ])
576
- end
572
+ it "sets the values" do
573
+ expect(alternate.values).to eq([ 2, 4 ])
577
574
  end
578
575
  end
579
576
  end
@@ -738,7 +735,7 @@ describe BSON::Document do
738
735
  it_behaves_like "a document able to handle utf-8"
739
736
  end
740
737
 
741
- pending "when utf-8 code with scope values are present" do
738
+ context "when utf-8 code with scope values are present" do
742
739
 
743
740
  let(:document) do
744
741
  described_class["code", BSON::CodeWithScope.new("// gültig", {})]
@@ -502,11 +502,8 @@ describe BSON::ObjectId do
502
502
  expect(object_id.to_s).to eq(expected)
503
503
  end
504
504
 
505
- unless BSON::Environment.ruby_18?
506
-
507
- it "returns the string in UTF-8" do
508
- expect(object_id.to_s.encoding).to eq(Encoding.find(BSON::UTF8))
509
- end
505
+ it "returns the string in UTF-8" do
506
+ expect(object_id.to_s.encoding).to eq(Encoding.find(BSON::UTF8))
510
507
  end
511
508
 
512
509
  it "converts to a readable yaml string" do
@@ -35,20 +35,10 @@ describe BSON::Registry do
35
35
 
36
36
  context "when the type has no corresponding class" do
37
37
 
38
- unless BSON::Environment.ruby_18?
39
-
40
- it "raises an error" do
41
- expect {
42
- described_class.get("test")
43
- }.to raise_error(KeyError)
44
- end
45
- else
46
-
47
- it "raises an error" do
48
- expect {
49
- described_class.get("test")
50
- }.to raise_error(IndexError)
51
- end
38
+ it "raises an error" do
39
+ expect {
40
+ described_class.get("test")
41
+ }.to raise_error(KeyError)
52
42
  end
53
43
  end
54
44
  end
@@ -111,19 +111,16 @@ describe String do
111
111
  it_behaves_like "a binary encoded string"
112
112
  end
113
113
 
114
- unless BSON::Environment.ruby_18?
114
+ context "when the string contains non utf-8 characters" do
115
115
 
116
- context "when the string contains non utf-8 characters" do
117
-
118
- let(:string) do
119
- 255.chr
120
- end
116
+ let(:string) do
117
+ 255.chr
118
+ end
121
119
 
122
- it "raises an error" do
123
- expect {
124
- string.to_bson_cstring
125
- }.to raise_error(EncodingError)
126
- end
120
+ it "raises an error" do
121
+ expect {
122
+ string.to_bson_cstring
123
+ }.to raise_error(EncodingError)
127
124
  end
128
125
  end
129
126
  end
@@ -242,19 +239,16 @@ describe String do
242
239
  it_behaves_like "a binary encoded string"
243
240
  end
244
241
 
245
- unless BSON::Environment.ruby_18?
242
+ context "when the string contains non utf-8 characters" do
246
243
 
247
- context "when the string contains non utf-8 characters" do
248
-
249
- let(:string) do
250
- 255.chr
251
- end
244
+ let(:string) do
245
+ 255.chr
246
+ end
252
247
 
253
- it "raises an error" do
254
- expect {
255
- string.to_bson_string
256
- }.to raise_error(EncodingError)
257
- end
248
+ it "raises an error" do
249
+ expect {
250
+ string.to_bson_string
251
+ }.to raise_error(EncodingError)
258
252
  end
259
253
  end
260
254
  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: 2.1.2
4
+ version: 2.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tyler Brock
@@ -33,7 +33,7 @@ cert_chain:
33
33
  8v7zLF2XliYbfurYIwkcXs8yPn8ggApBIy9bX6VJxRs/l2+UvqzaHIFaFy/F8/GP
34
34
  RNTuXsVG5NDACo7Q
35
35
  -----END CERTIFICATE-----
36
- date: 2014-01-16 00:00:00.000000000 Z
36
+ date: 2014-01-24 00:00:00.000000000 Z
37
37
  dependencies: []
38
38
  description: A full featured BSON specification implementation, in Ruby
39
39
  email:
@@ -123,12 +123,12 @@ require_paths:
123
123
  - lib
124
124
  required_ruby_version: !ruby/object:Gem::Requirement
125
125
  requirements:
126
- - - '>='
126
+ - - ">="
127
127
  - !ruby/object:Gem::Version
128
128
  version: 1.8.7
129
129
  required_rubygems_version: !ruby/object:Gem::Requirement
130
130
  requirements:
131
- - - '>='
131
+ - - ">="
132
132
  - !ruby/object:Gem::Version
133
133
  version: 1.3.6
134
134
  requirements: []
metadata.gz.sig CHANGED
Binary file