bson 2.2.1 → 2.2.2

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: 2045b9e4dce7563fd9bca4db925085a6e3a2383e
4
- data.tar.gz: 40f99133c083d133f9372852d814fb664815e325
3
+ metadata.gz: 3ae5b69d13047e684f5991540912ef5d979242c8
4
+ data.tar.gz: fcf64d50369ac6dcb45069092d534a1621ac5d16
5
5
  SHA512:
6
- metadata.gz: 32a51a23ebb1739fdd77cdbc49eee0129ed510db433fbb9ecd2b8e64050302382267b3ea0d86e506bddb981b088899cce59b57ff78d2ee0f5834c0b2e9ed2ec7
7
- data.tar.gz: 6f6c25e3fc1df79ad550699a8b48e77f5831c16d6c1bf1fb9f230d788ef140dcedf8a988e62d6b2eaf241e02d9a0eff42a328764d007921a834a56559f48c710
6
+ metadata.gz: 503d2ba15b6f649eef90459b92a19c09fd1b0a886a21cbc4b5452a72f566b920d3b2a52d2d70a2aad8251e44541394c3027820e5d1b5c690a52fa19c4f79d28a
7
+ data.tar.gz: 9cb98e4fd22c31cf810f0f267d7c616d520b95dd7b9636a15953b6f794c3d95c3a9111f2d9f3b9d187cbb1e4534ec788a2cefcf6a993fd9509047066f41529dc
@@ -1 +1 @@
1
- J�6��0��wY1�뉎D0�޲F3��P��c�oнK��s^d9�GC�;�x��T���k��C>�5��`� ]T���L��R6p�L���_��hCHi� cg���!�n��<i{�W�ݒ�_c9ۮ��w.�Q"��#�L��]��JgiX{��2� ��H�w6��<a���v9n&P�#��0�/S�#���hYsIo>F���K���1bB��Gk��F��,�8}pZ��_adm̀�g�*_q
1
+ ��s]"{b)�Иl�j���ℝ]��ٱ�͕C.amh��]e<��ă�u��*+�Qj�����o��T<C�F���0ޣ*z��f��(����0yA1}"��KlK��}E��+���h7qT���R�@��F�ж��M�Ɵ�IɠKFUv>Cq>�<�;׉��`5zWZ��ӯN���,$\�����یbS���[�O����O�v0�� ��5Bj]�n�~��J�E�|
data.tar.gz.sig CHANGED
Binary file
@@ -1,6 +1,18 @@
1
1
  BSON Changelog
2
2
  ==============
3
3
 
4
+ ## 2.2.2
5
+
6
+ ### Bug Fixes
7
+
8
+ * [#17](http://github.com/mongodb/bson-ruby/pull/17):
9
+ Fixed `BSON::ObjectId` counter increment on Ruby 2.1.0 since method names
10
+ can no longer override Ruby keywords.
11
+
12
+ * [#16](http://github.com/mongodb/bson-ruby/pull/16):
13
+ Fixed serialization of times when microseconds are causing `to_f` on time to
14
+ be 1 microsecond inaccurate. (Francois Bernier)
15
+
4
16
  ## 2.2.1
5
17
 
6
18
  ### Bug Fixes
@@ -492,10 +492,12 @@ static VALUE rb_integer_to_bson_int64(VALUE self, VALUE encoded)
492
492
  */
493
493
  static VALUE rb_time_to_bson(int argc, VALUE *argv, VALUE self)
494
494
  {
495
- double t = NUM2DBL(rb_funcall(self, rb_intern("to_f"), 0));
495
+ int64_t t = NUM2INT64(rb_funcall(self, rb_intern("to_i"), 0));
496
496
  int64_t milliseconds = (int64_t)(t * 1000);
497
+ int32_t micro = NUM2INT(rb_funcall(self, rb_intern("usec"), 0));
498
+ int64_t time = milliseconds + (micro / 1000);
497
499
  VALUE encoded = rb_get_default_encoded(argc, argv);
498
- return int64_t_to_bson(milliseconds, encoded);
500
+ return int64_t_to_bson(time, encoded);
499
501
  }
500
502
 
501
503
  /**
@@ -703,6 +705,6 @@ void Init_native()
703
705
  rb_define_private_method(string, "check_for_illegal_characters!", rb_string_check_for_illegal_characters, 0);
704
706
 
705
707
  // Redefine the next method on the object id generator.
706
- rb_undef_method(generator, "next");
707
- rb_define_method(generator, "next", rb_object_id_generator_next, -1);
708
+ rb_undef_method(generator, "next_object_id");
709
+ rb_define_method(generator, "next_object_id", rb_object_id_generator_next, -1);
708
710
  }
@@ -170,7 +170,7 @@ module BSON
170
170
  # @since 2.0.0
171
171
  def to_bson(encoded = ''.force_encoding(BINARY))
172
172
  repair if defined?(@data)
173
- @raw_data ||= @@generator.next
173
+ @raw_data ||= @@generator.next_object_id
174
174
  encoded << @raw_data
175
175
  end
176
176
 
@@ -268,7 +268,7 @@ module BSON
268
268
  #
269
269
  # @since 2.0.0
270
270
  def from_time(time, options = {})
271
- from_data(options[:unique] ? @@generator.next(time.to_i) : [ time.to_i ].pack("Nx8"))
271
+ from_data(options[:unique] ? @@generator.next_object_id(time.to_i) : [ time.to_i ].pack("Nx8"))
272
272
  end
273
273
 
274
274
  # Determine if the provided string is a legal object id.
@@ -337,14 +337,14 @@ module BSON
337
337
  # object id counter. Will use the provided time if not nil.
338
338
  #
339
339
  # @example Get the next object id data.
340
- # generator.next
340
+ # generator.next_object_id
341
341
  #
342
342
  # @param [ Time ] time The optional time to generate with.
343
343
  #
344
344
  # @return [ String ] The raw object id bytes.
345
345
  #
346
346
  # @since 2.0.0
347
- def next(time = nil)
347
+ def next_object_id(time = nil)
348
348
  @mutex.lock
349
349
  begin
350
350
  count = @counter = (@counter + 1) % 0xFFFFFF
@@ -38,7 +38,7 @@ module BSON
38
38
  #
39
39
  # @since 2.0.0
40
40
  def to_bson(encoded = ''.force_encoding(BINARY))
41
- encoded << [ (to_f * 1000.0).to_i ].pack(Int64::PACK)
41
+ encoded << [ (to_i * 1000) + (usec / 1000) ].pack(Int64::PACK)
42
42
  end
43
43
 
44
44
  module ClassMethods
@@ -13,5 +13,5 @@
13
13
  # limitations under the License.
14
14
 
15
15
  module BSON
16
- VERSION = "2.2.1"
16
+ VERSION = "2.2.2"
17
17
  end
@@ -24,11 +24,23 @@ describe Time do
24
24
 
25
25
  context "when the time is post epoch" do
26
26
 
27
- let(:obj) { Time.utc(2012, 1, 1, 0, 0, 0) }
28
- let(:bson) { [ (obj.to_f * 1000).to_i ].pack(BSON::Int64::PACK) }
27
+ context "when the time has no microseconds" do
29
28
 
30
- it_behaves_like "a serializable bson element"
31
- it_behaves_like "a deserializable bson element"
29
+ let(:obj) { Time.utc(2012, 1, 1, 0, 0, 0) }
30
+ let(:bson) { [ (obj.to_i * 1000) + (obj.usec / 1000) ].pack(BSON::Int64::PACK) }
31
+
32
+ it_behaves_like "a serializable bson element"
33
+ it_behaves_like "a deserializable bson element"
34
+ end
35
+
36
+ context "when the time has microseconds" do
37
+
38
+ let(:obj) { Time.at(Time.utc(2014, 03, 22, 18, 05, 05).to_i, 505000).utc }
39
+ let(:bson) { [ (obj.to_i * 1000) + (obj.usec / 1000) ].pack(BSON::Int64::PACK) }
40
+
41
+ it_behaves_like "a serializable bson element"
42
+ it_behaves_like "a deserializable bson element"
43
+ end
32
44
  end
33
45
 
34
46
  context "when the time is pre epoch" do
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.2.1
4
+ version: 2.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tyler Brock
@@ -34,7 +34,7 @@ cert_chain:
34
34
  JrZM8w8wGbIOeLtoQqa7HB/jOYbTahH7KMNh2LHAbOR93hNIJxVRa4iwxiMQ75tN
35
35
  9WUIAJ4AEtjwRg1Bz0OwDo3aucPCBpx77+/FWhv7JYY=
36
36
  -----END CERTIFICATE-----
37
- date: 2014-02-19 00:00:00.000000000 Z
37
+ date: 2014-04-03 00:00:00.000000000 Z
38
38
  dependencies: []
39
39
  description: A full featured BSON specification implementation, in Ruby
40
40
  email:
metadata.gz.sig CHANGED
Binary file