mongo 0.18 → 0.18.1
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.
- data/README.rdoc +12 -4
- data/Rakefile +25 -7
- data/lib/mongo.rb +24 -15
- data/lib/mongo/admin.rb +0 -2
- data/lib/mongo/collection.rb +9 -9
- data/lib/mongo/connection.rb +5 -5
- data/lib/mongo/cursor.rb +4 -7
- data/lib/mongo/db.rb +0 -3
- data/lib/mongo/errors.rb +3 -0
- data/lib/mongo/gridfs/chunk.rb +0 -1
- data/lib/mongo/types/objectid.rb +6 -0
- data/lib/mongo/util/bson_c.rb +18 -0
- data/lib/mongo/util/{bson.rb → bson_ruby.rb} +110 -117
- data/lib/mongo/util/byte_buffer.rb +23 -0
- data/test/test_admin.rb +1 -3
- data/test/test_bson.rb +105 -70
- data/test/test_byte_buffer.rb +1 -3
- data/test/test_chunk.rb +1 -3
- data/test/test_collection.rb +11 -17
- data/test/test_connection.rb +1 -3
- data/test/test_conversions.rb +1 -2
- data/test/test_cursor.rb +1 -3
- data/test/test_db.rb +1 -3
- data/test/test_db_api.rb +1 -3
- data/test/test_db_connection.rb +1 -3
- data/test/test_grid_store.rb +1 -3
- data/test/test_helper.rb +5 -3
- data/test/test_objectid.rb +7 -3
- data/test/test_ordered_hash.rb +1 -3
- data/test/test_round_trip.rb +8 -14
- data/test/test_slave_connection.rb +1 -3
- data/test/unit/connection_test.rb +17 -1
- metadata +6 -7
data/test/test_connection.rb
CHANGED
data/test/test_conversions.rb
CHANGED
@@ -1,8 +1,7 @@
|
|
1
|
-
|
1
|
+
require 'test/test_helper'
|
2
2
|
require 'mongo/errors'
|
3
3
|
require 'mongo/util/conversions'
|
4
4
|
require 'mongo/util/ordered_hash'
|
5
|
-
require 'test/unit'
|
6
5
|
|
7
6
|
class ConversionsTest < Test::Unit::TestCase
|
8
7
|
include Mongo::Conversions
|
data/test/test_cursor.rb
CHANGED
data/test/test_db.rb
CHANGED
data/test/test_db_api.rb
CHANGED
data/test/test_db_connection.rb
CHANGED
data/test/test_grid_store.rb
CHANGED
data/test/test_helper.rb
CHANGED
@@ -1,8 +1,10 @@
|
|
1
|
-
|
2
|
-
require 'rubygems'
|
1
|
+
$:.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
2
|
+
require 'rubygems' if ENV['C_EXT']
|
3
|
+
require 'mongo'
|
3
4
|
require 'test/unit'
|
4
5
|
|
5
6
|
begin
|
7
|
+
require 'rubygems'
|
6
8
|
require 'shoulda'
|
7
9
|
require 'mocha'
|
8
10
|
rescue LoadError
|
@@ -17,7 +19,7 @@ MSG
|
|
17
19
|
exit
|
18
20
|
end
|
19
21
|
|
20
|
-
require '
|
22
|
+
require 'mongo_ext/cbson' if ENV['C_EXT']
|
21
23
|
|
22
24
|
# NOTE: most tests assume that MongoDB is running.
|
23
25
|
class Test::Unit::TestCase
|
data/test/test_objectid.rb
CHANGED
@@ -1,6 +1,4 @@
|
|
1
|
-
|
2
|
-
require 'mongo'
|
3
|
-
require 'test/unit'
|
1
|
+
require 'test/test_helper'
|
4
2
|
|
5
3
|
class ObjectIDTest < Test::Unit::TestCase
|
6
4
|
|
@@ -123,4 +121,10 @@ class ObjectIDTest < Test::Unit::TestCase
|
|
123
121
|
assert_equal s, ObjectID.legacy_string_convert(l)
|
124
122
|
end
|
125
123
|
|
124
|
+
def test_generation_time
|
125
|
+
time = Time.now
|
126
|
+
id = ObjectID.new
|
127
|
+
|
128
|
+
assert_in_delta time.to_i, id.generation_time.to_i, 2
|
129
|
+
end
|
126
130
|
end
|
data/test/test_ordered_hash.rb
CHANGED
data/test/test_round_trip.rb
CHANGED
@@ -1,8 +1,7 @@
|
|
1
1
|
HERE = File.dirname(__FILE__)
|
2
2
|
$LOAD_PATH[0,0] = File.join(HERE, '..', 'lib')
|
3
|
-
require '
|
3
|
+
require 'test/test_helper'
|
4
4
|
require 'mongo/util/xml_to_ruby'
|
5
|
-
require 'test/unit'
|
6
5
|
|
7
6
|
# For each xml/bson file in the data subdirectory, we turn the XML into an
|
8
7
|
# OrderedHash and then test both Ruby-to-BSON and BSON-to-Ruby translations.
|
@@ -74,19 +73,14 @@ EOS
|
|
74
73
|
File.open(File.join(dir, "#{name}.bson"), 'rb') { |f|
|
75
74
|
# Read the BSON from the file
|
76
75
|
bson = f.read
|
77
|
-
bson = if RUBY_VERSION >= '1.9'
|
78
|
-
bson.bytes.to_a
|
79
|
-
else
|
80
|
-
bson.split(//).collect { |c| c[0] }
|
81
|
-
end
|
82
76
|
|
83
77
|
# Turn the Ruby object into BSON bytes and compare with the BSON bytes
|
84
78
|
# from the file.
|
85
|
-
bson_from_ruby = BSON.
|
79
|
+
bson_from_ruby = BSON.serialize(obj)
|
86
80
|
|
87
81
|
begin
|
88
|
-
assert_equal bson.length, bson_from_ruby.length
|
89
|
-
assert_equal bson, bson_from_ruby
|
82
|
+
assert_equal bson.length, bson_from_ruby.to_s.length
|
83
|
+
assert_equal bson, bson_from_ruby.to_s
|
90
84
|
rescue => ex
|
91
85
|
# File.open(File.join(dir, "#{name}_out_a.bson"), 'wb') { |f| # DEBUG
|
92
86
|
# bson_from_ruby.each { |b| f.putc(b) }
|
@@ -99,15 +93,15 @@ EOS
|
|
99
93
|
# We're passing a nil db to the contructor here, but that's OK because
|
100
94
|
# the BSON DBRef bytes don't contain the db object in any case, and we
|
101
95
|
# don't care what the database is.
|
102
|
-
obj_from_bson = BSON.
|
96
|
+
obj_from_bson = BSON.deserialize(bson_from_ruby)
|
103
97
|
assert_kind_of OrderedHash, obj_from_bson
|
104
98
|
|
105
99
|
# Turn that Ruby object into BSON and compare it to the original BSON
|
106
100
|
# bytes.
|
107
|
-
bson_from_ruby = BSON.
|
101
|
+
bson_from_ruby = BSON.serialize(obj_from_bson)
|
108
102
|
begin
|
109
|
-
assert_equal bson.length, bson_from_ruby.length
|
110
|
-
assert_equal bson, bson_from_ruby
|
103
|
+
assert_equal bson.length, bson_from_ruby.to_s.length
|
104
|
+
assert_equal bson, bson_from_ruby.to_s
|
111
105
|
rescue => ex
|
112
106
|
# File.open(File.join(dir, "#{name}_out_b.bson"), 'wb') { |f| # DEBUG
|
113
107
|
# bson_from_ruby.each { |b| f.putc(b) }
|
@@ -1,6 +1,4 @@
|
|
1
|
-
|
2
|
-
require 'mongo'
|
3
|
-
require 'test/unit'
|
1
|
+
require 'test/test_helper'
|
4
2
|
|
5
3
|
# NOTE: these tests are run only if we can connect to a single MongoDB in slave mode.
|
6
4
|
class SlaveConnectionTest < Test::Unit::TestCase
|
@@ -22,7 +22,7 @@ class ConnectionTest < Test::Unit::TestCase
|
|
22
22
|
context "given a single node" do
|
23
23
|
setup do
|
24
24
|
TCPSocket.stubs(:new).returns(new_mock_socket)
|
25
|
-
@conn = Connection.new('localhost',
|
25
|
+
@conn = Connection.new('localhost', 27017, :connect => false)
|
26
26
|
|
27
27
|
admin_db = new_mock_db
|
28
28
|
admin_db.expects(:command).returns({'ok' => 1, 'ismaster' => 1})
|
@@ -45,6 +45,22 @@ class ConnectionTest < Test::Unit::TestCase
|
|
45
45
|
end
|
46
46
|
end
|
47
47
|
|
48
|
+
context "with a nonstandard port" do
|
49
|
+
setup do
|
50
|
+
TCPSocket.stubs(:new).returns(new_mock_socket)
|
51
|
+
@conn = Connection.new('255.255.255.255', 2500, :connect => false)
|
52
|
+
admin_db = new_mock_db
|
53
|
+
admin_db.expects(:command).returns({'ok' => 1, 'ismaster' => 1})
|
54
|
+
@conn.expects(:[]).with('admin').returns(admin_db)
|
55
|
+
@conn.connect_to_master
|
56
|
+
end
|
57
|
+
|
58
|
+
should "set localhost and port correctly" do
|
59
|
+
assert_equal '255.255.255.255', @conn.host
|
60
|
+
assert_equal 2500, @conn.port
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
48
64
|
context "Connection pooling: " do
|
49
65
|
setup do
|
50
66
|
TCPSocket.stubs(:new).returns(new_mock_socket)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mongo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 0.18.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jim Menard
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2009-
|
13
|
+
date: 2009-12-05 00:00:00 -05:00
|
14
14
|
default_executable:
|
15
15
|
dependencies: []
|
16
16
|
|
@@ -42,7 +42,8 @@ files:
|
|
42
42
|
- lib/mongo/types/dbref.rb
|
43
43
|
- lib/mongo/types/objectid.rb
|
44
44
|
- lib/mongo/types/regexp_of_holding.rb
|
45
|
-
- lib/mongo/util/
|
45
|
+
- lib/mongo/util/bson_c.rb
|
46
|
+
- lib/mongo/util/bson_ruby.rb
|
46
47
|
- lib/mongo/util/byte_buffer.rb
|
47
48
|
- lib/mongo/util/conversions.rb
|
48
49
|
- lib/mongo/util/ordered_hash.rb
|
@@ -67,8 +68,6 @@ files:
|
|
67
68
|
- bin/fail_if_no_c.rb
|
68
69
|
has_rdoc: true
|
69
70
|
homepage: http://www.mongodb.org
|
70
|
-
licenses: []
|
71
|
-
|
72
71
|
post_install_message:
|
73
72
|
rdoc_options:
|
74
73
|
- --main
|
@@ -91,9 +90,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
91
90
|
requirements: []
|
92
91
|
|
93
92
|
rubyforge_project:
|
94
|
-
rubygems_version: 1.3.
|
93
|
+
rubygems_version: 1.3.1
|
95
94
|
signing_key:
|
96
|
-
specification_version:
|
95
|
+
specification_version: 2
|
97
96
|
summary: Ruby driver for the MongoDB
|
98
97
|
test_files:
|
99
98
|
- test/mongo-qa/_common.rb
|