bson 1.6.1-jruby → 1.6.2-jruby

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.

@@ -59,7 +59,7 @@ module BSON
59
59
  def self.to_utf8_binary(str)
60
60
  begin
61
61
  str.unpack("U*")
62
- rescue => ex
62
+ rescue
63
63
  raise InvalidStringEncoding, "String not valid utf-8: #{str.inspect}"
64
64
  end
65
65
  str.encode(UTF8_ENCODING).force_encoding(BINARY_ENCODING)
@@ -70,7 +70,7 @@ module BSON
70
70
  def self.to_utf8_binary(str)
71
71
  begin
72
72
  str.unpack("U*")
73
- rescue => ex
73
+ rescue
74
74
  raise InvalidStringEncoding, "String not valid utf-8: #{str.inspect}"
75
75
  end
76
76
  str
@@ -57,7 +57,7 @@ module BSON
57
57
  def self.to_utf8_binary(str)
58
58
  begin
59
59
  str.unpack("U*")
60
- rescue => ex
60
+ rescue
61
61
  raise InvalidStringEncoding, "String not valid utf-8: #{str.inspect}"
62
62
  end
63
63
  str
@@ -192,33 +192,37 @@ module BSON
192
192
  @@index = 0
193
193
  @@machine_id = Digest::MD5.digest(Socket.gethostname)[0, 3]
194
194
 
195
- # This gets overwritten by the C extension if it loads.
196
- def generate(oid_time=nil)
197
- oid = ''
198
-
199
- # 4 bytes current time
200
- if oid_time
201
- t = oid_time.to_i
202
- else
203
- t = Time.new.to_i
195
+ # We need to check whether BSON_CODER is defined because it's required by
196
+ # the BSON C extensions.
197
+ if defined?(BSON::BSON_CODER) && BSON::BSON_CODER == BSON::BSON_RUBY
198
+ # This gets overwritten by the C extension if it loads.
199
+ def generate(oid_time=nil)
200
+ oid = ''
201
+
202
+ # 4 bytes current time
203
+ if oid_time
204
+ t = oid_time.to_i
205
+ else
206
+ t = Time.new.to_i
207
+ end
208
+ oid += [t].pack("N")
209
+
210
+ # 3 bytes machine
211
+ oid += @@machine_id
212
+
213
+ # 2 bytes pid
214
+ oid += [Process.pid % 0xFFFF].pack("n")
215
+
216
+ # 3 bytes inc
217
+ oid += [get_inc].pack("N")[1, 3]
218
+
219
+ oid.unpack("C12")
204
220
  end
205
- oid += [t].pack("N")
206
-
207
- # 3 bytes machine
208
- oid += @@machine_id
209
-
210
- # 2 bytes pid
211
- oid += [Process.pid % 0xFFFF].pack("n")
212
-
213
- # 3 bytes inc
214
- oid += [get_inc].pack("N")[1, 3]
215
-
216
- oid.unpack("C12")
217
- end
218
221
 
219
- def get_inc
220
- @@lock.synchronize do
221
- @@index = (@@index + 1) % 0xFFFFFF
222
+ def get_inc
223
+ @@lock.synchronize do
224
+ @@index = (@@index + 1) % 0xFFFFFF
225
+ end
222
226
  end
223
227
  end
224
228
  end
@@ -1,3 +1,3 @@
1
1
  module BSON
2
- VERSION = "1.6.1"
2
+ VERSION = "1.6.2"
3
3
  end
@@ -3,19 +3,21 @@ require './test/bson/test_helper'
3
3
  require 'set'
4
4
 
5
5
  if RUBY_VERSION < '1.9'
6
- require 'complex'
7
- require 'rational'
6
+ silently do
7
+ require 'complex'
8
+ require 'rational'
9
+ end
8
10
  end
9
11
  require 'bigdecimal'
10
12
 
11
13
  begin
12
14
  require 'date'
13
15
  require 'tzinfo'
14
- require 'active_support/core_ext'
16
+ require 'active_support/timezone'
15
17
  Time.zone = "Pacific Time (US & Canada)"
16
18
  Zone = Time.zone.now
17
19
  rescue LoadError
18
- warn 'Mocking time with zone'
20
+ #warn 'Mocking time with zone'
19
21
  module ActiveSupport
20
22
  class TimeWithZone
21
23
  def initialize(utc_time, zone)
@@ -74,23 +76,21 @@ class BSONTest < Test::Unit::TestCase
74
76
  end
75
77
 
76
78
  def test_limit_max_bson_size
77
- doc = {'name' => 'a' * BSON_CODER.max_bson_size}
79
+ doc = {'name' => 'a' * BSON::DEFAULT_MAX_BSON_SIZE}
78
80
  assert_raise InvalidDocument do
79
81
  assert @encoder.serialize(doc)
80
82
  end
81
83
  end
82
84
 
83
- def test_max_bson_size
84
- assert BSON_CODER.max_bson_size >= BSON::DEFAULT_MAX_BSON_SIZE
85
- end
86
-
87
85
  def test_update_max_bson_size
88
86
  require 'ostruct'
89
87
  mock_conn = OpenStruct.new
90
88
  size = 7 * 1024 * 1024
91
89
  mock_conn.max_bson_size = size
92
- assert_equal size, BSON_CODER.update_max_bson_size(mock_conn)
93
- assert_equal size, BSON_CODER.max_bson_size
90
+ silently do
91
+ assert_equal size, BSON_CODER.update_max_bson_size(mock_conn)
92
+ assert_equal size, BSON_CODER.max_bson_size
93
+ end
94
94
  end
95
95
 
96
96
  def test_round_trip
@@ -217,10 +217,10 @@ class BSONTest < Test::Unit::TestCase
217
217
  doc = {'doc' => {'age' => 42, 'date' => Time.now.utc, 'shoe_size' => 9.5}}
218
218
  bson = @encoder.serialize(doc)
219
219
  doc2 = @encoder.deserialize(bson)
220
- assert doc['doc']
221
- assert_equal 42, doc['doc']['age']
222
- assert_equal 9.5, doc['doc']['shoe_size']
223
- assert_in_delta Time.now, doc['doc']['date'], 1
220
+ assert doc2['doc']
221
+ assert_equal 42, doc2['doc']['age']
222
+ assert_equal 9.5, doc2['doc']['shoe_size']
223
+ assert_in_delta Time.now, doc2['doc']['date'], 1
224
224
  end
225
225
 
226
226
  def test_oid
@@ -269,6 +269,7 @@ class BSONTest < Test::Unit::TestCase
269
269
  doc = {'date' => [Time.now.utc]}
270
270
  bson = @encoder.serialize(doc)
271
271
  doc2 = @encoder.deserialize(bson)
272
+ assert doc2
272
273
  end
273
274
 
274
275
  def test_date_returns_as_utc
@@ -279,6 +280,7 @@ class BSONTest < Test::Unit::TestCase
279
280
  end
280
281
 
281
282
  def test_date_before_epoch
283
+ if RbConfig::CONFIG['host_os'] =~ /mswin|mingw|cygwin/ then return true end
282
284
  begin
283
285
  doc = {'date' => Time.utc(1600)}
284
286
  bson = @encoder.serialize(doc)
@@ -297,7 +299,7 @@ class BSONTest < Test::Unit::TestCase
297
299
  [DateTime.now, Date.today, Zone].each do |invalid_date|
298
300
  doc = {:date => invalid_date}
299
301
  begin
300
- bson = BSON::BSON_CODER.serialize(doc)
302
+ BSON::BSON_CODER.serialize(doc)
301
303
  rescue => e
302
304
  ensure
303
305
  if !invalid_date.is_a? Time
@@ -431,7 +433,7 @@ class BSONTest < Test::Unit::TestCase
431
433
 
432
434
  if !(RUBY_PLATFORM =~ /java/)
433
435
  def test_timestamp
434
- val = {"test" => [4, 20]}
436
+ # val = {"test" => [4, 20]}
435
437
  result = @encoder.deserialize([0x13, 0x00, 0x00, 0x00,
436
438
  0x11, 0x74, 0x65, 0x73,
437
439
  0x74, 0x00, 0x04, 0x00,
@@ -455,7 +457,7 @@ class BSONTest < Test::Unit::TestCase
455
457
  def test_overflow
456
458
  doc = {"x" => 2**75}
457
459
  assert_raise RangeError do
458
- bson = @encoder.serialize(doc)
460
+ @encoder.serialize(doc)
459
461
  end
460
462
 
461
463
  doc = {"x" => 9223372036854775}
@@ -466,7 +468,7 @@ class BSONTest < Test::Unit::TestCase
466
468
 
467
469
  doc["x"] = doc["x"] + 1
468
470
  assert_raise RangeError do
469
- bson = @encoder.serialize(doc)
471
+ @encoder.serialize(doc)
470
472
  end
471
473
 
472
474
  doc = {"x" => -9223372036854775}
@@ -477,7 +479,7 @@ class BSONTest < Test::Unit::TestCase
477
479
 
478
480
  doc["x"] = doc["x"] - 1
479
481
  assert_raise RangeError do
480
- bson = BSON::BSON_CODER.serialize(doc)
482
+ BSON::BSON_CODER.serialize(doc)
481
483
  end
482
484
  end
483
485
 
@@ -529,7 +531,7 @@ class BSONTest < Test::Unit::TestCase
529
531
  #one = {"_foo" => "foo"}
530
532
 
531
533
  #assert_equal @encoder.serialize(one).to_a, @encoder.serialize(dup).to_a
532
- warn "Pending test for duplicate keys"
534
+ #warn "Pending test for duplicate keys"
533
535
  end
534
536
 
535
537
  def test_no_duplicate_id_when_moving_id
@@ -7,7 +7,7 @@ class JSONTest < Test::Unit::TestCase
7
7
  # This test passes when run by itself but fails
8
8
  # when run as part of the whole test suite.
9
9
  def test_object_id_as_json
10
- warn "Pending test object id as json"
10
+ #warn "Pending test object id as json"
11
11
  #id = BSON::ObjectId.new
12
12
 
13
13
  #obj = {'_id' => id}
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: 1.6.1
4
+ version: 1.6.2
5
5
  prerelease:
6
6
  platform: jruby
7
7
  authors:
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2012-03-07 00:00:00.000000000 Z
14
+ date: 2012-04-05 00:00:00.000000000 Z
15
15
  dependencies: []
16
16
  description: A Ruby BSON implementation for MongoDB. For more information about Mongo,
17
17
  see http://www.mongodb.org. For more information on BSON, see http://www.bsonspec.org.
@@ -70,7 +70,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
70
70
  version: '0'
71
71
  requirements: []
72
72
  rubyforge_project:
73
- rubygems_version: 1.8.17
73
+ rubygems_version: 1.8.21
74
74
  signing_key:
75
75
  specification_version: 3
76
76
  summary: Ruby implementation of BSON