bson 3.2.1 → 3.2.3

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
  SHA1:
3
- metadata.gz: 97406446c031dcd1d113981137d7a5f3b7cf931b
4
- data.tar.gz: 71e76d81578a58363dbb4eb254521e5b5154c9ad
3
+ metadata.gz: a83a6cb4625e37db0fafa80ce5f1fd2338d1f0d4
4
+ data.tar.gz: ea378315e221bd9c80b19038e93caaa4126fa256
5
5
  SHA512:
6
- metadata.gz: ce10bfb4026b5830ba571f98f99b4a02075223a5039262c855f9ddd7e676e562895f89db5013826d52b42bd9622580c32815b50731b41b6f4f53f0018ea20708
7
- data.tar.gz: 009a442c08996a177318e48d41fc637fde1e72354979389123cc7e829c96e9a0051ae202a0c7fae62a308c204f37c2eacf4aaa20da57d48d2fad313727f41018
6
+ metadata.gz: beec93611bb46e76ce16d45a728f13325499e5ee1713dc28adfccf6d4ca95c5ab8526911ca208ed50a7e92c4266796063dc94e483870ff5ee9aa0a2b935efc3a
7
+ data.tar.gz: 54f768da04f510ddc6cdda7ec2e0d5f7efd5b032249089f02e3cbc7694ba69a765e4dcfba6cc4171b8185ce023c58637bcb9ca316800b5099ffeac385310ac1d
Binary file
data.tar.gz.sig CHANGED
@@ -1 +1 @@
1
- ����*fc��N���Rj| ��ɘ�>'&��7d��n ���u^���<Ȁ�W��� W+�Ӝ���CT9P1��B)g�~"��X��2u��54��P��Ҩ�"���z!����1M� ��b��� X�B�Y�q�@ٵ����p��^�^8��J�vv��ݍ����6]� ��(��y�{�MC�Q�&����ƿ�=��0E�=̀�= ����]8TS���1aٍ�P�b�]N��������Y��
1
+ Gl
@@ -1,6 +1,16 @@
1
1
  BSON Changelog
2
2
  ==============
3
3
 
4
+ ## 3.2.3
5
+
6
+ ### Bug Fixes
7
+
8
+ * [#41](https://github.com/mongodb/bson-ruby/pull/41) Normalizing arrays does not mutate. (Agis Anastasopoulos)
9
+
10
+ * [#40](https://github.com/mongodb/bson-ruby/pull/40) Added big endian support. (Jeff Blight)
11
+
12
+ * [RUBY-1019](https://jira.mongodb.org/browse/RUBY-1019) Performace improvements on deserialization.
13
+
4
14
  ## 3.2.1
5
15
 
6
16
  ### Bug Fixes
@@ -89,6 +89,14 @@ static VALUE rb_utc_method;
89
89
 
90
90
  #include <ruby/encoding.h>
91
91
 
92
+ #if __BYTE_ORDER == __BIG_ENDIAN
93
+ typedef union doublebyte
94
+ {
95
+ double d;
96
+ unsigned char b[sizeof(double)];
97
+ } doublebytet;
98
+ #endif
99
+
92
100
  /**
93
101
  * Convert the binary string to a ruby utf8 string.
94
102
  *
@@ -188,7 +196,19 @@ static VALUE rb_float_to_bson(int argc, VALUE *argv, VALUE self)
188
196
  {
189
197
  const double v = NUM2DBL(self);
190
198
  VALUE encoded = rb_get_default_encoded(argc, argv);
199
+ # if __BYTE_ORDER == __LITTLE_ENDIAN
191
200
  rb_str_cat(encoded, (char*) &v, 8);
201
+ #elif __BYTE_ORDER == __BIG_ENDIAN
202
+ doublebytet swap;
203
+ unsigned char b;
204
+ swap.d = v;
205
+ for (int i=0; i < sizeof(double)/2; i++) {
206
+ b=swap.b[i];
207
+ swap.b[i] = swap.b[((sizeof(double)-1)-i)];
208
+ swap.b[((sizeof(double)-1)-i)]=b;
209
+ }
210
+ rb_str_cat(encoded, (char*)&swap.d, 8);
211
+ #endif
192
212
  return encoded;
193
213
  }
194
214
 
@@ -210,7 +230,20 @@ static VALUE rb_float_from_bson_double(VALUE self, VALUE value)
210
230
  const char * bytes;
211
231
  double v;
212
232
  bytes = StringValuePtr(value);
233
+ #if __BYTE_ORDER == __LITTLE_ENDIAN
213
234
  memcpy(&v, bytes, RSTRING_LEN(value));
235
+ #else
236
+ doublebytet swap;
237
+ unsigned char b;
238
+ memcpy(&swap.d, bytes, RSTRING_LEN(value));
239
+ for (int i=0; i < sizeof(double)/2; i++) {
240
+ b=swap.b[i];
241
+ swap.b[i] = swap.b[((sizeof(double)-1)-i)];
242
+ swap.b[((sizeof(double)-1)-i)]=b;
243
+ }
244
+ memcpy(&v, swap.b, RSTRING_LEN(value));
245
+ #endif
246
+
214
247
  return DBL2NUM(v);
215
248
  }
216
249
 
@@ -244,10 +277,17 @@ static VALUE rb_object_id_generator_next(int argc, VALUE* args, VALUE self)
244
277
  unsigned long c;
245
278
  c = htonl(rb_bson_object_id_counter << 8);
246
279
 
280
+ # if __BYTE_ORDER == __LITTLE_ENDIAN
247
281
  memcpy(&bytes, &t, 4);
248
282
  memcpy(&bytes[4], rb_bson_machine_id_hash, 3);
249
283
  memcpy(&bytes[7], &pid, 2);
250
284
  memcpy(&bytes[9], (unsigned char*) &c, 3);
285
+ #elif __BYTE_ORDER == __BIG_ENDIAN
286
+ memcpy(&bytes, ((unsigned char*) &t) + 4, 4);
287
+ memcpy(&bytes[4], rb_bson_machine_id_hash, 3);
288
+ memcpy(&bytes[7], &pid, 2);
289
+ memcpy(&bytes[9], ((unsigned char*) &c) + 4, 3);
290
+ #endif
251
291
  rb_bson_object_id_counter++;
252
292
  return rb_str_new(bytes, 12);
253
293
  }
@@ -73,11 +73,11 @@ module BSON
73
73
  # @example Convert the array to a normalized value.
74
74
  # array.to_bson_normalized_value
75
75
  #
76
- # @return [ Array ] The normazlied array.
76
+ # @return [ Array ] The normalized array.
77
77
  #
78
78
  # @since 3.0.0
79
79
  def to_bson_normalized_value
80
- map!{ |value| value.to_bson_normalized_value }
80
+ map { |value| value.to_bson_normalized_value }
81
81
  end
82
82
 
83
83
  module ClassMethods
@@ -13,5 +13,5 @@
13
13
  # limitations under the License.
14
14
 
15
15
  module BSON
16
- VERSION = "3.2.1"
16
+ VERSION = "3.2.3"
17
17
  end
@@ -29,6 +29,19 @@ describe Array do
29
29
  it_behaves_like "a deserializable bson element"
30
30
  end
31
31
 
32
+ describe "#to_bson_normalized_value" do
33
+
34
+ let(:klass) { Class.new(Hash) }
35
+ let(:obj) {[ Foo.new ]}
36
+
37
+ before(:each) { stub_const "Foo", klass }
38
+
39
+ it "does not mutate the receiver" do
40
+ obj.to_bson_normalized_value
41
+ expect(obj.first.class).to eq(Foo)
42
+ end
43
+ end
44
+
32
45
  describe "#to_bson_object_id" do
33
46
 
34
47
  context "when the array has 12 elements" do
@@ -65,7 +65,7 @@ describe BSON::Timestamp do
65
65
 
66
66
  let(:type) { 17.chr }
67
67
  let(:obj) { described_class.new(1, 10) }
68
- let(:bson) { [ 10, 1 ].pack("l2") }
68
+ let(:bson) { [ 10, 1 ].pack(BSON::Int32::PACK * 2) }
69
69
 
70
70
  it_behaves_like "a bson element"
71
71
  it_behaves_like "a serializable bson element"
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: 3.2.1
4
+ version: 3.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tyler Brock
@@ -34,7 +34,7 @@ cert_chain:
34
34
  XZOS48LlWh15EG4yZo/gRzqNAW2LUIkYA5eMS2Kp6r+KV8IBUO/LaHdrXbdilpa8
35
35
  BRsuCo7UZDbFVRns04HLyjVvkj+K/ywIcdKdS0csz5M=
36
36
  -----END CERTIFICATE-----
37
- date: 2015-07-30 00:00:00.000000000 Z
37
+ date: 2015-09-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