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 +4 -4
- checksums.yaml.gz.sig +1 -1
- data.tar.gz.sig +0 -0
- data/CHANGELOG.md +12 -0
- data/ext/bson/native.c +6 -4
- data/lib/bson/object_id.rb +4 -4
- data/lib/bson/time.rb +1 -1
- data/lib/bson/version.rb +1 -1
- data/spec/bson/time_spec.rb +16 -4
- metadata +2 -2
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3ae5b69d13047e684f5991540912ef5d979242c8
|
4
|
+
data.tar.gz: fcf64d50369ac6dcb45069092d534a1621ac5d16
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 503d2ba15b6f649eef90459b92a19c09fd1b0a886a21cbc4b5452a72f566b920d3b2a52d2d70a2aad8251e44541394c3027820e5d1b5c690a52fa19c4f79d28a
|
7
|
+
data.tar.gz: 9cb98e4fd22c31cf810f0f267d7c616d520b95dd7b9636a15953b6f794c3d95c3a9111f2d9f3b9d187cbb1e4534ec788a2cefcf6a993fd9509047066f41529dc
|
checksums.yaml.gz.sig
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
��s]�"{�b)�Иl�j���ℝ]��ٱ�͕C.amh��]e<��ă�u��*+�Q�j�����o��T<C�F���0ޣ*z��f��(����0yA1�}"��KlK��}E��+���h�7qT���R�@��F�ж��M�Ɵ�IɠKF�U�v>C�q>�<�;��`5zW�Z��ӯN���,$\�����یb�S���[�O����O�v0����5B�j�]�n�~��J�E�|
|
data.tar.gz.sig
CHANGED
Binary file
|
data/CHANGELOG.md
CHANGED
@@ -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
|
data/ext/bson/native.c
CHANGED
@@ -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
|
-
|
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(
|
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, "
|
707
|
-
rb_define_method(generator, "
|
708
|
+
rb_undef_method(generator, "next_object_id");
|
709
|
+
rb_define_method(generator, "next_object_id", rb_object_id_generator_next, -1);
|
708
710
|
}
|
data/lib/bson/object_id.rb
CHANGED
@@ -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.
|
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.
|
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.
|
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
|
347
|
+
def next_object_id(time = nil)
|
348
348
|
@mutex.lock
|
349
349
|
begin
|
350
350
|
count = @counter = (@counter + 1) % 0xFFFFFF
|
data/lib/bson/time.rb
CHANGED
data/lib/bson/version.rb
CHANGED
data/spec/bson/time_spec.rb
CHANGED
@@ -24,11 +24,23 @@ describe Time do
|
|
24
24
|
|
25
25
|
context "when the time is post epoch" do
|
26
26
|
|
27
|
-
|
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
|
-
|
31
|
-
|
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.
|
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-
|
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
|