bson 1.8.2-java → 1.8.3-java

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.

Binary file
data/LICENSE CHANGED
@@ -175,7 +175,7 @@
175
175
 
176
176
  END OF TERMS AND CONDITIONS
177
177
 
178
- Copyright 2008-2010 10gen, Inc.
178
+ Copyright (C) 2008-2013 10gen, Inc.
179
179
 
180
180
  Licensed under the Apache License, Version 2.0 (the "License");
181
181
  you may not use this file except in compliance with the License.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.8.2
1
+ 1.8.3
data/bin/b2json CHANGED
@@ -1,22 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
2
  # encoding: UTF-8
3
3
 
4
- # --
5
- # Copyright (C) 2008-2010 10gen Inc.
6
- #
7
- # Licensed under the Apache License, Version 2.0 (the "License");
8
- # you may not use this file except in compliance with the License.
9
- # You may obtain a copy of the License at
10
- #
11
- # http://www.apache.org/licenses/LICENSE-2.0
12
- #
13
- # Unless required by applicable law or agreed to in writing, software
14
- # distributed under the License is distributed on an "AS IS" BASIS,
15
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
- # See the License for the specific language governing permissions and
17
- # limitations under the License.
18
- # ++
19
-
20
4
  require 'rubygems'
21
5
  require 'bson'
22
6
 
data/bin/j2bson CHANGED
@@ -1,39 +1,17 @@
1
1
  #!/usr/bin/env ruby
2
2
  # encoding: UTF-8
3
3
 
4
- # --
5
- # Copyright (C) 2008-2010 10gen Inc.
6
- #
7
- # Licensed under the Apache License, Version 2.0 (the "License");
8
- # you may not use this file except in compliance with the License.
9
- # You may obtain a copy of the License at
10
- #
11
- # http://www.apache.org/licenses/LICENSE-2.0
12
- #
13
- # Unless required by applicable law or agreed to in writing, software
14
- # distributed under the License is distributed on an "AS IS" BASIS,
15
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
- # See the License for the specific language governing permissions and
17
- # limitations under the License.
18
- # ++
19
-
20
4
  require 'rubygems'
21
5
  require 'bson'
22
6
 
23
- # We don't use YAJL because we need to specify the class
24
- # to store the JSON object in. BSON is ordered so we need BSON::OrderedHash
25
- #
26
- # We use json/pure because json/ext is broken with BSON::OrderedHash
27
- # (probably for the same reasons that we can't use YAJL).
28
- #
29
7
  # Note that, at the moment, this will not properly round-trip
30
8
  # in all cases from the output generated by b2json.
31
9
  begin
32
10
  require 'json/pure' # broken with 'json/ext'
33
11
  rescue LoadError
34
12
  puts "This script requires json/pure. Please install one of the following:"
35
- puts " gem install json_pure"
36
- puts " gem install json"
13
+ puts " gem install json_pure"
14
+ puts " gem install json"
37
15
  Process.exit
38
16
  end
39
17
 
@@ -2,13 +2,16 @@ Gem::Specification.new do |s|
2
2
  s.name = 'bson'
3
3
 
4
4
  s.version = File.read(File.join(File.dirname(__FILE__), 'VERSION'))
5
- s.authors = ['Tyler Brock', 'Gary Murakami', 'Emily Stolfo', 'Brandon Black']
5
+ s.authors = ['Tyler Brock', 'Gary Murakami', 'Emily Stolfo', 'Brandon Black', 'Durran Jordan']
6
6
  s.email = 'mongodb-dev@googlegroups.com'
7
7
  s.homepage = 'http://www.mongodb.org'
8
8
  s.summary = 'Ruby implementation of BSON'
9
9
  s.description = 'A Ruby BSON implementation for MongoDB. For more information about Mongo, see http://www.mongodb.org. For more information on BSON, see http://www.bsonspec.org.'
10
10
  s.rubyforge_project = 'bson'
11
11
 
12
+ s.signing_key = 'gem-private_key.pem'
13
+ s.cert_chain = ['gem-public_cert.pem']
14
+
12
15
  s.files = ['bson.gemspec', 'LICENSE', 'VERSION']
13
16
  s.files += ['bin/b2json', 'bin/j2bson', 'lib/bson.rb']
14
17
  s.files += Dir['lib/bson/**/*.rb']
Binary file
@@ -1,25 +1,5 @@
1
- # --
2
- # Copyright (C) 2008-2012 10gen Inc.
3
- #
4
- # Licensed under the Apache License, Version 2.0 (the "License");
5
- # you may not use this file except in compliance with the License.
6
- # You may obtain a copy of the License at
7
- #
8
- # http://www.apache.org/licenses/LICENSE-2.0
9
- #
10
- # Unless required by applicable law or agreed to in writing, software
11
- # distributed under the License is distributed on an "AS IS" BASIS,
12
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- # See the License for the specific language governing permissions and
14
- # limitations under the License.
15
- # ++
16
-
17
1
  module BSON
18
- if defined? Mongo::DEFAULT_MAX_BSON_SIZE
19
- DEFAULT_MAX_BSON_SIZE = Mongo::DEFAULT_MAX_BSON_SIZE
20
- else
21
- DEFAULT_MAX_BSON_SIZE = 4 * 1024 * 1024
22
- end
2
+ DEFAULT_MAX_BSON_SIZE = 4 * 1024 * 1024
23
3
 
24
4
  def self.serialize(obj, check_keys=false, move_id=false)
25
5
  BSON_CODER.serialize(obj, check_keys, move_id)
@@ -1,26 +1,8 @@
1
- # encoding: UTF-8
2
-
3
- # --
4
- # Copyright (C) 2008-2012 10gen Inc.
5
- #
6
- # Licensed under the Apache License, Version 2.0 (the "License");
7
- # you may not use this file except in compliance with the License.
8
- # You may obtain a copy of the License at
9
- #
10
- # http://www.apache.org/licenses/LICENSE-2.0
11
- #
12
- # Unless required by applicable law or agreed to in writing, software
13
- # distributed under the License is distributed on an "AS IS" BASIS,
14
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
- # See the License for the specific language governing permissions and
16
- # limitations under the License.
17
- # ++
18
-
19
1
  # A thin wrapper for the CBson class
20
2
  module BSON
21
3
  class BSON_C
22
4
 
23
- def self.serialize(obj, check_keys=false, move_id=false, max_bson_size=BSON::DEFAULT_MAX_BSON_SIZE)
5
+ def self.serialize(obj, check_keys=false, move_id=false, max_bson_size=DEFAULT_MAX_BSON_SIZE)
24
6
  ByteBuffer.new(CBson.serialize(obj, check_keys, move_id, max_bson_size))
25
7
  end
26
8
 
@@ -8,7 +8,7 @@ require File.join(jar_dir, 'target/jbson.jar')
8
8
 
9
9
  module BSON
10
10
  class BSON_JAVA
11
- def self.serialize(obj, check_keys=false, move_id=false, max_bson_size=BSON::DEFAULT_MAX_BSON_SIZE)
11
+ def self.serialize(obj, check_keys=false, move_id=false, max_bson_size=DEFAULT_MAX_BSON_SIZE)
12
12
  raise InvalidDocument, "BSON_JAVA.serialize takes a Hash" unless obj.is_a?(Hash)
13
13
  enc = Java::OrgJbson::RubyBSONEncoder.new(JRuby.runtime, check_keys, move_id, max_bson_size)
14
14
  ByteBuffer.new(enc.encode(obj))
@@ -1,29 +1,8 @@
1
- # encoding: UTF-8
2
-
3
- # --
4
- # Copyright (C) 2008-2012 10gen Inc.
5
- #
6
- # Licensed under the Apache License, Version 2.0 (the "License");
7
- # you may not use this file except in compliance with the License.
8
- # You may obtain a copy of the License at
9
- #
10
- # http://www.apache.org/licenses/LICENSE-2.0
11
- #
12
- # Unless required by applicable law or agreed to in writing, software
13
- # distributed under the License is distributed on an "AS IS" BASIS,
14
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
- # See the License for the specific language governing permissions and
16
- # limitations under the License.
17
- # ++
18
-
19
1
  module BSON
20
2
  NULL_BYTE = "\x00"
21
3
 
22
4
  # A BSON seralizer/deserializer in pure Ruby.
23
5
  class BSON_RUBY
24
-
25
- DEFAULT_MAX_BSON_SIZE = 4 * 1024 * 1024
26
-
27
6
  @@max_bson_size = DEFAULT_MAX_BSON_SIZE
28
7
 
29
8
  MINKEY = -1
@@ -53,7 +32,7 @@ module BSON
53
32
  INT64_MIN = -2**64 / 2
54
33
  INT64_MAX = 2**64 / 2 - 1
55
34
 
56
- def initialize(max_bson_size=BSON::DEFAULT_MAX_BSON_SIZE)
35
+ def initialize(max_bson_size=DEFAULT_MAX_BSON_SIZE)
57
36
  @buf = ByteBuffer.new('', max_bson_size)
58
37
  @encoder = BSON_RUBY
59
38
  end
@@ -111,7 +90,7 @@ module BSON
111
90
 
112
91
  # Serializes an object.
113
92
  # Implemented to ensure an API compatible with BSON extension.
114
- def self.serialize(obj, check_keys=false, move_id=false, max_bson_size=BSON::DEFAULT_MAX_BSON_SIZE)
93
+ def self.serialize(obj, check_keys=false, move_id=false, max_bson_size=DEFAULT_MAX_BSON_SIZE)
115
94
  new(max_bson_size).serialize(obj, check_keys, move_id)
116
95
  end
117
96
 
@@ -145,7 +124,7 @@ module BSON
145
124
  serialize_eoo_element(@buf)
146
125
  if @buf.size > @buf.max_size
147
126
  raise InvalidDocument, "Document is too large (#{@buf.size}). " +
148
- "This BSON documents is limited to #{@buf.max_size} bytes."
127
+ "This BSON document is limited to #{@buf.max_size} bytes."
149
128
  end
150
129
  @buf.put_int(@buf.size, 0)
151
130
  @buf
@@ -153,7 +132,7 @@ module BSON
153
132
 
154
133
  # Returns the array stored in the buffer.
155
134
  # Implemented to ensure an API compatible with BSON extension.
156
- def unpack(arg)
135
+ def unpack
157
136
  @buf.to_a
158
137
  end
159
138
 
@@ -326,7 +305,7 @@ module BSON
326
305
  def deserialize_object_data(buf)
327
306
  size = buf.get_int
328
307
  buf.position -= 4
329
- object = @encoder.new().deserialize(buf.get(size))
308
+ object = @encoder.new.deserialize(buf.get(size))
330
309
  if object.has_key? "$ref"
331
310
  DBRef.new(object["$ref"], object["$id"])
332
311
  else
@@ -388,7 +367,7 @@ module BSON
388
367
 
389
368
  scope_size = buf.get_int
390
369
  buf.position -= 4
391
- scope = @encoder.new().deserialize(buf.get(scope_size))
370
+ scope = @encoder.new.deserialize(buf.get(scope_size))
392
371
 
393
372
  Code.new(encoded_str(code), scope)
394
373
  end
@@ -419,7 +398,7 @@ module BSON
419
398
  self.class.serialize_key(buf, key)
420
399
  end
421
400
 
422
- def serialize_dbref_element(buf, key, val)
401
+ def serialize_dbref_element(buf, key, val) # this does NOT use the BSON "\x0C" DBPointer type
423
402
  oh = BSON::OrderedHash.new
424
403
  oh['$ref'] = val.namespace
425
404
  oh['$id'] = val.object_id
@@ -1,21 +1,3 @@
1
- # encoding: UTF-8
2
-
3
- # --
4
- # Copyright (C) 2008-2012 10gen Inc.
5
- #
6
- # Licensed under the Apache License, Version 2.0 (the "License");
7
- # you may not use this file except in compliance with the License.
8
- # You may obtain a copy of the License at
9
- #
10
- # http://www.apache.org/licenses/LICENSE-2.0
11
- #
12
- # Unless required by applicable law or agreed to in writing, software
13
- # distributed under the License is distributed on an "AS IS" BASIS,
14
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
- # See the License for the specific language governing permissions and
16
- # limitations under the License.
17
- # ++
18
-
19
1
  # A byte buffer.
20
2
  module BSON
21
3
  class ByteBuffer
@@ -26,7 +8,7 @@ module BSON
26
8
  INT64_PACK = 'q<'.freeze
27
9
  DOUBLE_PACK = 'E'.freeze
28
10
 
29
- def initialize(initial_data="", max_size=BSON::DEFAULT_MAX_BSON_SIZE)
11
+ def initialize(initial_data="", max_size=DEFAULT_MAX_BSON_SIZE)
30
12
  @str = case initial_data
31
13
  when String then
32
14
  if initial_data.respond_to?(:force_encoding)
@@ -1,21 +1,3 @@
1
- # encoding: UTF-8
2
-
3
- # --
4
- # Copyright (C) 2008-2012 10gen Inc.
5
- #
6
- # Licensed under the Apache License, Version 2.0 (the "License");
7
- # you may not use this file except in compliance with the License.
8
- # You may obtain a copy of the License at
9
- #
10
- # http://www.apache.org/licenses/LICENSE-2.0
11
- #
12
- # Unless required by applicable law or agreed to in writing, software
13
- # distributed under the License is distributed on an "AS IS" BASIS,
14
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
- # See the License for the specific language governing permissions and
16
- # limitations under the License.
17
- # ++
18
-
19
1
  module BSON
20
2
  # Generic Mongo Ruby Driver exception class.
21
3
  class MongoRubyError < StandardError; end
@@ -1,21 +1,3 @@
1
- # encoding: UTF-8
2
-
3
- # --
4
- # Copyright (C) 2008-2012 10gen Inc.
5
- #
6
- # Licensed under the Apache License, Version 2.0 (the "License");
7
- # you may not use this file except in compliance with the License.
8
- # You may obtain a copy of the License at
9
- #
10
- # http://www.apache.org/licenses/LICENSE-2.0
11
- #
12
- # Unless required by applicable law or agreed to in writing, software
13
- # distributed under the License is distributed on an "AS IS" BASIS,
14
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
- # See the License for the specific language governing permissions and
16
- # limitations under the License.
17
- # ++
18
-
19
1
  # A hash in which the order of keys are preserved.
20
2
  #
21
3
  # Under Ruby 1.9 and greater, this class has no added methods because Ruby's
@@ -1,21 +1,3 @@
1
- # encoding: UTF-8
2
- #
3
- # --
4
- # Copyright (C) 2008-2012 10gen Inc.
5
- #
6
- # Licensed under the Apache License, Version 2.0 (the "License");
7
- # you may not use this file except in compliance with the License.
8
- # You may obtain a copy of the License at
9
- #
10
- # http://www.apache.org/licenses/LICENSE-2.0
11
- #
12
- # Unless required by applicable law or agreed to in writing, software
13
- # distributed under the License is distributed on an "AS IS" BASIS,
14
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
- # See the License for the specific language governing permissions and
16
- # limitations under the License.
17
- # ++
18
-
19
1
  require 'active_support'
20
2
  begin
21
3
  require 'active_support/hash_with_indifferent_access'
@@ -1,21 +1,3 @@
1
- # encoding: UTF-8
2
-
3
- # --
4
- # Copyright (C) 2008-2012 10gen Inc.
5
- #
6
- # Licensed under the Apache License, Version 2.0 (the "License");
7
- # you may not use this file except in compliance with the License.
8
- # You may obtain a copy of the License at
9
- #
10
- # http://www.apache.org/licenses/LICENSE-2.0
11
- #
12
- # Unless required by applicable law or agreed to in writing, software
13
- # distributed under the License is distributed on an "AS IS" BASIS,
14
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
- # See the License for the specific language governing permissions and
16
- # limitations under the License.
17
- # ++
18
-
19
1
  require 'bson/byte_buffer'
20
2
 
21
3
  module BSON
@@ -1,21 +1,3 @@
1
- # encoding: UTF-8
2
-
3
- # --
4
- # Copyright (C) 2008-2012 10gen Inc.
5
- #
6
- # Licensed under the Apache License, Version 2.0 (the "License");
7
- # you may not use this file except in compliance with the License.
8
- # You may obtain a copy of the License at
9
- #
10
- # http://www.apache.org/licenses/LICENSE-2.0
11
- #
12
- # Unless required by applicable law or agreed to in writing, software
13
- # distributed under the License is distributed on an "AS IS" BASIS,
14
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
- # See the License for the specific language governing permissions and
16
- # limitations under the License.
17
- # ++
18
-
19
1
  module BSON
20
2
 
21
3
  # JavaScript code to be evaluated by MongoDB.
@@ -1,21 +1,3 @@
1
- # encoding: UTF-8
2
-
3
- # --
4
- # Copyright (C) 2008-2012 10gen Inc.
5
- #
6
- # Licensed under the Apache License, Version 2.0 (the "License");
7
- # you may not use this file except in compliance with the License.
8
- # You may obtain a copy of the License at
9
- #
10
- # http://www.apache.org/licenses/LICENSE-2.0
11
- #
12
- # Unless required by applicable law or agreed to in writing, software
13
- # distributed under the License is distributed on an "AS IS" BASIS,
14
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
- # See the License for the specific language governing permissions and
16
- # limitations under the License.
17
- # ++
18
-
19
1
  module BSON
20
2
 
21
3
  # A reference to another object in a MongoDB database.
@@ -1,21 +1,3 @@
1
- # encoding: UTF-8
2
-
3
- # --
4
- # Copyright (C) 2008-2012 10gen Inc.
5
- #
6
- # Licensed under the Apache License, Version 2.0 (the "License");
7
- # you may not use this file except in compliance with the License.
8
- # You may obtain a copy of the License at
9
- #
10
- # http://www.apache.org/licenses/LICENSE-2.0
11
- #
12
- # Unless required by applicable law or agreed to in writing, software
13
- # distributed under the License is distributed on an "AS IS" BASIS,
14
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
- # See the License for the specific language governing permissions and
16
- # limitations under the License.
17
- # ++
18
-
19
1
  module BSON
20
2
 
21
3
  # A class representing the BSON MaxKey type. MaxKey will always compare greater than
@@ -1,21 +1,3 @@
1
- # encoding: UTF-8
2
-
3
- # --
4
- # Copyright (C) 2008-2012 10gen Inc.
5
- #
6
- # Licensed under the Apache License, Version 2.0 (the "License");
7
- # you may not use this file except in compliance with the License.
8
- # You may obtain a copy of the License at
9
- #
10
- # http://www.apache.org/licenses/LICENSE-2.0
11
- #
12
- # Unless required by applicable law or agreed to in writing, software
13
- # distributed under the License is distributed on an "AS IS" BASIS,
14
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
- # See the License for the specific language governing permissions and
16
- # limitations under the License.
17
- # ++
18
-
19
1
  require 'thread'
20
2
  require 'socket'
21
3
  require 'digest/md5'
@@ -1,21 +1,3 @@
1
- # encoding: UTF-8
2
-
3
- # --
4
- # Copyright (C) 2008-2012 10gen Inc.
5
- #
6
- # Licensed under the Apache License, Version 2.0 (the "License");
7
- # you may not use this file except in compliance with the License.
8
- # You may obtain a copy of the License at
9
- #
10
- # http://www.apache.org/licenses/LICENSE-2.0
11
- #
12
- # Unless required by applicable law or agreed to in writing, software
13
- # distributed under the License is distributed on an "AS IS" BASIS,
14
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
- # See the License for the specific language governing permissions and
16
- # limitations under the License.
17
- # ++
18
-
19
1
  module BSON
20
2
 
21
3
  # A class for representing BSON Timestamps. The Timestamp type is used
@@ -58,6 +58,68 @@ class BSONTest < Test::Unit::TestCase
58
58
  assert_equal doc, @encoder.deserialize(bson)
59
59
  end
60
60
 
61
+ def test_interface
62
+ doc = { 'a' => 1 }
63
+ bson = BSON.serialize(doc)
64
+ assert_equal doc, BSON.deserialize(bson)
65
+ end
66
+
67
+ def test_read_bson_document
68
+ bson_file_data_h_star = ["21000000075f6964005115883c3d75c94d3aa18b63016100000000000000f03f00"]
69
+ strio = StringIO.new(bson_file_data_h_star.pack('H*'))
70
+ bson = BSON.read_bson_document(strio)
71
+ doc = {"_id"=>BSON::ObjectId('5115883c3d75c94d3aa18b63'), "a"=>1.0}
72
+ assert_equal doc, bson
73
+ end
74
+
75
+ def test_bson_ruby_interface
76
+ doc = { 'a' => 1 }
77
+ buf = BSON_RUBY.serialize(doc)
78
+ bson = BSON::BSON_RUBY.new
79
+ bson.instance_variable_set(:@buf, buf)
80
+ assert_equal [12, 0, 0, 0, 16, 97, 0, 1, 0, 0, 0, 0], bson.to_a
81
+ assert_equal "\f\x00\x00\x00\x10a\x00\x01\x00\x00\x00\x00", bson.to_s
82
+ assert_equal [12, 0, 0, 0, 16, 97, 0, 1, 0, 0, 0, 0], bson.unpack
83
+ end
84
+
85
+ def test_bson_ruby_hex_dump
86
+ doc = { 'a' => 1 }
87
+ buf = BSON_RUBY.serialize(doc)
88
+ bson = BSON_RUBY.new
89
+ bson.instance_variable_set(:@buf, buf)
90
+ doc_hex_dump = " 0: 0C 00 00 00 10 61 00 01\n 8: 00 00 00 00"
91
+ assert_equal doc_hex_dump, bson.hex_dump
92
+ end
93
+
94
+ def test_bson_ruby_dbref_not_used
95
+ buf = BSON::ByteBuffer.new
96
+ val = ns = 'namespace'
97
+
98
+ # Make a hole for the length
99
+ len_pos = buf.position
100
+ buf.put_int(0)
101
+
102
+ # Save the string
103
+ start_pos = buf.position
104
+ BSON::BSON_RUBY.serialize_cstr(buf, val)
105
+ end_pos = buf.position
106
+
107
+ # Put the string size in front
108
+ buf.put_int(end_pos - start_pos, len_pos)
109
+
110
+ # Go back to where we were
111
+ buf.position = end_pos
112
+
113
+ oid = ObjectId.new
114
+ buf.put_array(oid.to_a)
115
+ buf.rewind
116
+
117
+ bson = BSON::BSON_RUBY.new
118
+ bson.instance_variable_set(:@buf, buf)
119
+
120
+ assert_equal DBRef.new(ns, oid).to_s, bson.deserialize_dbref_data(buf).to_s
121
+ end
122
+
61
123
  def test_require_hash
62
124
  assert_raise_error InvalidDocument, "takes a Hash" do
63
125
  BSON.serialize('foo')
@@ -191,8 +253,14 @@ class BSONTest < Test::Unit::TestCase
191
253
  end
192
254
 
193
255
  def test_code
194
- doc = {'$where' => Code.new('this.a.b < this.b')}
256
+ code = Code.new('this.a.b < this.b')
257
+ assert_equal 17, code.length
258
+ assert_match /<BSON::Code:.*@data="this.a.b < this.b".*>/, code.inspect
259
+ doc = {'$where' => code}
195
260
  assert_doc_pass(doc)
261
+ code = 'this.c.d < this.e'.to_bson_code # core_ext.rb
262
+ assert_equal BSON::Code, code.class
263
+ assert_equal code, code.to_bson_code
196
264
  end
197
265
 
198
266
  def test_code_with_symbol
@@ -343,8 +411,11 @@ class BSONTest < Test::Unit::TestCase
343
411
 
344
412
  def test_dbref
345
413
  oid = ObjectId.new
414
+ ns = 'namespace'
346
415
  doc = {}
347
- doc['dbref'] = DBRef.new('namespace', oid)
416
+ dbref = DBRef.new(ns, oid)
417
+ assert_equal({"$id"=>oid, "$ns"=>ns}, dbref.to_hash)
418
+ doc['dbref'] = dbref
348
419
  bson = @encoder.serialize(doc)
349
420
  doc2 = @encoder.deserialize(bson)
350
421
 
@@ -15,6 +15,16 @@ class ByteBufferTest < Test::Unit::TestCase
15
15
  assert_equal 0, @buf.length
16
16
  end
17
17
 
18
+ def test_initialize_with_string_and_clear
19
+ @buf = ByteBuffer.new("a")
20
+ assert_equal 1, @buf.size
21
+ assert_equal 1, @buf.position
22
+ @buf.clear
23
+ assert_equal 0, @buf.position
24
+ assert_equal "", @buf.to_s
25
+ assert_equal 0, @buf.size
26
+ end
27
+
18
28
  def test_nil_get_returns_one_byte
19
29
  @buf.put_array([1, 2, 3, 4])
20
30
  @buf.rewind
@@ -202,5 +212,4 @@ class ByteBufferTest < Test::Unit::TestCase
202
212
  assert_not_equal @buf, 123
203
213
  assert_not_equal @buf, nil
204
214
  end
205
-
206
215
  end
@@ -2,6 +2,11 @@ require 'test_helper'
2
2
 
3
3
  class TimestampTest < Test::Unit::TestCase
4
4
 
5
+ def test_timestamp_to_s
6
+ t1 = Timestamp.new(5000, 200)
7
+ assert_equal "seconds: 5000, increment: 200", t1.to_s
8
+ end
9
+
5
10
  def test_timestamp_equality
6
11
  t1 = Timestamp.new(5000, 200)
7
12
  t2 = Timestamp.new(5000, 200)
metadata CHANGED
@@ -1,18 +1,40 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bson
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.8.2
5
4
  prerelease:
5
+ version: 1.8.3
6
6
  platform: java
7
7
  authors:
8
8
  - Tyler Brock
9
9
  - Gary Murakami
10
10
  - Emily Stolfo
11
11
  - Brandon Black
12
+ - Durran Jordan
12
13
  autorequire:
13
14
  bindir: bin
14
- cert_chain: []
15
- date: 2013-01-17 00:00:00.000000000 Z
15
+ cert_chain:
16
+ - |
17
+ -----BEGIN CERTIFICATE-----
18
+ MIIDODCCAiCgAwIBAgIBADANBgkqhkiG9w0BAQUFADBCMRQwEgYDVQQDDAtkcml2
19
+ ZXItcnVieTEVMBMGCgmSJomT8ixkARkWBTEwZ2VuMRMwEQYKCZImiZPyLGQBGRYD
20
+ Y29tMB4XDTEzMDIwMTE0MTEzN1oXDTE0MDIwMTE0MTEzN1owQjEUMBIGA1UEAwwL
21
+ ZHJpdmVyLXJ1YnkxFTATBgoJkiaJk/IsZAEZFgUxMGdlbjETMBEGCgmSJomT8ixk
22
+ ARkWA2NvbTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBANFdSAa8fRm1
23
+ bAM9za6Z0fAH4g02bqM1NGnw8zJQrE/PFrFfY6IFCT2AsLfOwr1maVm7iU1+kdVI
24
+ IQ+iI/9+E+ArJ+rbGV3dDPQ+SLl3mLT+vXjfjcxMqI2IW6UuVtt2U3Rxd4QU0kdT
25
+ JxmcPYs5fDN6BgYc6XXgUjy3m+Kwha2pGctdciUOwEfOZ4RmNRlEZKCMLRHdFP8j
26
+ 4WTnJSGfXDiuoXICJb5yOPOZPuaapPSNXp93QkUdsqdKC32I+KMpKKYGBQ6yisfA
27
+ 5MyVPPCzLR1lP5qXVGJPnOqUAkvEUfCahg7EP9tI20qxiXrR6TSEraYhIFXL0EGY
28
+ u8KAcPHm5KkCAwEAAaM5MDcwCQYDVR0TBAIwADAdBgNVHQ4EFgQUW3dZsX70mlSM
29
+ CiPrZxAGA1vwfNcwCwYDVR0PBAQDAgSwMA0GCSqGSIb3DQEBBQUAA4IBAQCIa/Y6
30
+ xS7YWBxkn9WP0EMnJ3pY9vef9DTmLSi/2jz8PzwlKQ89zNTrqSUD8LoQZmBqCJBt
31
+ dKSQ/RUnaHJuxh8HWvWubP8EBYTuf+I1DFnRv648IF3MR1tCQumVL0XcYMvZcxBj
32
+ a/p+8DomWTQqUdNbNoGywwjtVBWfDdwFV8Po1XcN/AtpILOJQd9J77INIGGCHxZo
33
+ 6SOHHaNknlE9H0w6q0SVxZKZI8/+2c447V0NrHIw1Qhe0tAGJ9V1u3ky8gyxe0SM
34
+ 8v7zLF2XliYbfurYIwkcXs8yPn8ggApBIy9bX6VJxRs/l2+UvqzaHIFaFy/F8/GP
35
+ RNTuXsVG5NDACo7Q
36
+ -----END CERTIFICATE-----
37
+ date: 2013-03-04 00:00:00.000000000 Z
16
38
  dependencies: []
17
39
  description: A Ruby BSON implementation for MongoDB. For more information about Mongo, see http://www.mongodb.org. For more information on BSON, see http://www.bsonspec.org.
18
40
  email: mongodb-dev@googlegroups.com
@@ -86,4 +108,3 @@ test_files:
86
108
  - test/bson/object_id_test.rb
87
109
  - test/bson/ordered_hash_test.rb
88
110
  - test/bson/timestamp_test.rb
89
- has_rdoc: yard
@@ -0,0 +1 @@
1
+ T"3���{�E��2|ߜP���O䱭��O5�)7�0��Se��Ջ���r纥=|6&�^\a�w�� ��c��i�Ū49��T򍆨�ߴ�9K�w����b����٥�s��dk��j��3�v��R�vd ��'OIK3�����T�Eqg5����v�,���va\ʔ�y��5>_�Y������������*��`t���\��Û��w�Ì������.D7���dx���}OT{��X�ďۗY`�Q��O