mongodb-mongo 0.2.6 → 0.2.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -287,12 +287,17 @@ class BSON
287
287
  buf.put(BINARY)
288
288
  self.class.serialize_cstr(buf, key)
289
289
 
290
- bytes = if RUBY_VERSION >= '1.9'
291
- val.bytes.to_a
290
+ bytes = case val
291
+ when ByteBuffer
292
+ val.to_a
292
293
  else
293
- a = []
294
- val.each_byte { |byte| a << byte }
295
- a
294
+ if RUBY_VERSION >= '1.9'
295
+ val.bytes.to_a
296
+ else
297
+ a = []
298
+ val.each_byte { |byte| a << byte }
299
+ a
300
+ end
296
301
  end
297
302
 
298
303
  num_bytes = bytes.length
@@ -422,7 +427,7 @@ class BSON
422
427
  NUMBER_INT
423
428
  when Numeric
424
429
  NUMBER
425
- when XGen::Mongo::Driver::Binary # must be before String
430
+ when XGen::Mongo::Driver::Binary, ByteBuffer # must be before String
426
431
  BINARY
427
432
  when String
428
433
  # magic awful stuff - the DB requires that a where clause is sent as CODE
@@ -64,7 +64,7 @@ class OrderedHash < Hash
64
64
  end
65
65
 
66
66
  def delete(key, &block)
67
- @ordered_keys.delete(key)
67
+ @ordered_keys.delete(key) if @ordered_keys
68
68
  super
69
69
  end
70
70
 
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'mongo'
3
- s.version = '0.2.6'
3
+ s.version = '0.2.7'
4
4
  s.platform = Gem::Platform::RUBY
5
5
  s.summary = 'Simple pure-Ruby driver for the 10gen Mongo DB'
6
6
  s.description = 'A pure-Ruby driver for the 10gen Mongo DB. For more information about Mongo, see http://www.mongodb.org.'
data/tests/test_bson.rb CHANGED
@@ -125,6 +125,18 @@ class BSONTest < Test::Unit::TestCase
125
125
  assert_equal 'binstring', doc2['bin']
126
126
  end
127
127
 
128
+ # def test_binary_byte_buffer
129
+ # bb = ByteBuffer.new
130
+ # 10.times { |i| bb.put(i) }
131
+ # doc = {'bin' => bb}
132
+ # @b.serialize(doc)
133
+ # doc2 = @b.deserialize
134
+
135
+ # doc2_bytes = []
136
+ # doc2['bin'].each_byte { |b| doc2_bytes << b }
137
+ # assert_equal bb.to_a, doc2_bytes
138
+ # end
139
+
128
140
  def test_undefined
129
141
  doc = {'undef' => Undefined.new}
130
142
  @b.serialize(doc)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mongodb-mongo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.6
4
+ version: 0.2.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jim Menard