mongo 1.0 → 1.1.5
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/LICENSE.txt +1 -13
- data/{README.rdoc → README.md} +129 -149
- data/Rakefile +94 -58
- data/bin/mongo_console +21 -0
- data/docs/1.0_UPGRADE.md +21 -0
- data/docs/CREDITS.md +123 -0
- data/docs/FAQ.md +112 -0
- data/docs/GridFS.md +158 -0
- data/docs/HISTORY.md +185 -0
- data/docs/REPLICA_SETS.md +75 -0
- data/docs/TUTORIAL.md +247 -0
- data/docs/WRITE_CONCERN.md +28 -0
- data/lib/mongo/collection.rb +225 -105
- data/lib/mongo/connection.rb +374 -315
- data/lib/mongo/cursor.rb +122 -77
- data/lib/mongo/db.rb +109 -85
- data/lib/mongo/exceptions.rb +6 -0
- data/lib/mongo/gridfs/grid.rb +19 -11
- data/lib/mongo/gridfs/grid_ext.rb +36 -9
- data/lib/mongo/gridfs/grid_file_system.rb +15 -9
- data/lib/mongo/gridfs/grid_io.rb +49 -16
- data/lib/mongo/gridfs/grid_io_fix.rb +38 -0
- data/lib/mongo/repl_set_connection.rb +290 -0
- data/lib/mongo/util/conversions.rb +3 -1
- data/lib/mongo/util/core_ext.rb +17 -4
- data/lib/mongo/util/pool.rb +125 -0
- data/lib/mongo/util/server_version.rb +2 -0
- data/lib/mongo/util/support.rb +12 -0
- data/lib/mongo/util/uri_parser.rb +71 -0
- data/lib/mongo.rb +23 -7
- data/{mongo-ruby-driver.gemspec → mongo.gemspec} +9 -7
- data/test/auxillary/1.4_features.rb +2 -2
- data/test/auxillary/authentication_test.rb +1 -1
- data/test/auxillary/autoreconnect_test.rb +1 -1
- data/test/{slave_connection_test.rb → auxillary/slave_connection_test.rb} +6 -6
- data/test/bson/binary_test.rb +15 -0
- data/test/bson/bson_test.rb +537 -0
- data/test/bson/byte_buffer_test.rb +190 -0
- data/test/bson/hash_with_indifferent_access_test.rb +38 -0
- data/test/bson/json_test.rb +17 -0
- data/test/bson/object_id_test.rb +141 -0
- data/test/bson/ordered_hash_test.rb +197 -0
- data/test/collection_test.rb +195 -15
- data/test/connection_test.rb +93 -56
- data/test/conversions_test.rb +1 -1
- data/test/cursor_fail_test.rb +75 -0
- data/test/cursor_message_test.rb +43 -0
- data/test/cursor_test.rb +93 -32
- data/test/db_api_test.rb +28 -55
- data/test/db_connection_test.rb +2 -3
- data/test/db_test.rb +45 -40
- data/test/grid_file_system_test.rb +14 -6
- data/test/grid_io_test.rb +36 -7
- data/test/grid_test.rb +54 -10
- data/test/replica_sets/connect_test.rb +84 -0
- data/test/replica_sets/count_test.rb +35 -0
- data/test/{replica → replica_sets}/insert_test.rb +17 -14
- data/test/replica_sets/pooled_insert_test.rb +55 -0
- data/test/replica_sets/query_secondaries.rb +80 -0
- data/test/replica_sets/query_test.rb +41 -0
- data/test/replica_sets/replication_ack_test.rb +64 -0
- data/test/replica_sets/rs_test_helper.rb +29 -0
- data/test/safe_test.rb +68 -0
- data/test/support/hash_with_indifferent_access.rb +199 -0
- data/test/support/keys.rb +45 -0
- data/test/support_test.rb +19 -0
- data/test/test_helper.rb +53 -15
- data/test/threading/{test_threading_large_pool.rb → threading_with_large_pool_test.rb} +2 -2
- data/test/threading_test.rb +2 -2
- data/test/tools/repl_set_manager.rb +241 -0
- data/test/tools/test.rb +13 -0
- data/test/unit/collection_test.rb +70 -7
- data/test/unit/connection_test.rb +18 -39
- data/test/unit/cursor_test.rb +7 -8
- data/test/unit/db_test.rb +14 -17
- data/test/unit/grid_test.rb +49 -0
- data/test/unit/pool_test.rb +9 -0
- data/test/unit/repl_set_connection_test.rb +82 -0
- data/test/unit/safe_test.rb +125 -0
- metadata +132 -51
- data/bin/bson_benchmark.rb +0 -59
- data/bin/fail_if_no_c.rb +0 -11
- data/examples/admin.rb +0 -43
- data/examples/capped.rb +0 -22
- data/examples/cursor.rb +0 -48
- data/examples/gridfs.rb +0 -44
- data/examples/index_test.rb +0 -126
- data/examples/info.rb +0 -31
- data/examples/queries.rb +0 -70
- data/examples/simple.rb +0 -24
- data/examples/strict.rb +0 -35
- data/examples/types.rb +0 -36
- data/test/replica/count_test.rb +0 -34
- data/test/replica/pooled_insert_test.rb +0 -54
- data/test/replica/query_test.rb +0 -39
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
require './test/test_helper'
|
|
2
|
+
include Mongo
|
|
3
|
+
|
|
4
|
+
class ReplSetConnectionTest < Test::Unit::TestCase
|
|
5
|
+
context "Initialization: " do
|
|
6
|
+
setup do
|
|
7
|
+
def new_mock_socket(host='localhost', port=27017)
|
|
8
|
+
socket = Object.new
|
|
9
|
+
socket.stubs(:setsockopt).with(Socket::IPPROTO_TCP, Socket::TCP_NODELAY, 1)
|
|
10
|
+
socket.stubs(:close)
|
|
11
|
+
socket
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def new_mock_db
|
|
15
|
+
db = Object.new
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
context "connecting to a replica set" do
|
|
20
|
+
setup do
|
|
21
|
+
TCPSocket.stubs(:new).returns(new_mock_socket('localhost', 27017))
|
|
22
|
+
@conn = ReplSetConnection.new(['localhost', 27017], :connect => false, :read_secondary => true)
|
|
23
|
+
|
|
24
|
+
admin_db = new_mock_db
|
|
25
|
+
@hosts = ['localhost:27018', 'localhost:27019', 'localhost:27020']
|
|
26
|
+
|
|
27
|
+
admin_db.stubs(:command).returns({'ok' => 1, 'ismaster' => 1, 'hosts' => @hosts}).
|
|
28
|
+
then.returns({'ok' => 1, 'ismaster' => 0, 'hosts' => @hosts, 'secondary' => 1}).
|
|
29
|
+
then.returns({'ok' => 1, 'ismaster' => 0, 'hosts' => @hosts, 'secondary' => 1}).
|
|
30
|
+
then.returns({'ok' => 1, 'ismaster' => 0, 'arbiterOnly' => 1})
|
|
31
|
+
|
|
32
|
+
@conn.stubs(:[]).with('admin').returns(admin_db)
|
|
33
|
+
@conn.connect
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
should "store the hosts returned from the ismaster command" do
|
|
37
|
+
assert_equal 'localhost', @conn.primary_pool.host
|
|
38
|
+
assert_equal 27017, @conn.primary_pool.port
|
|
39
|
+
|
|
40
|
+
assert_equal 'localhost', @conn.secondary_pools[0].host
|
|
41
|
+
assert_equal 27018, @conn.secondary_pools[0].port
|
|
42
|
+
|
|
43
|
+
assert_equal 'localhost', @conn.secondary_pools[1].host
|
|
44
|
+
assert_equal 27019, @conn.secondary_pools[1].port
|
|
45
|
+
|
|
46
|
+
assert_equal 2, @conn.secondary_pools.length
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
context "connecting to a replica set and providing seed nodes" do
|
|
51
|
+
setup do
|
|
52
|
+
TCPSocket.stubs(:new).returns(new_mock_socket)
|
|
53
|
+
@conn = ReplSetConnection.new(['localhost', 27017], ['localhost', 27019], :connect => false)
|
|
54
|
+
|
|
55
|
+
admin_db = new_mock_db
|
|
56
|
+
@hosts = ['localhost:27017', 'localhost:27018', 'localhost:27019']
|
|
57
|
+
admin_db.stubs(:command).returns({'ok' => 1, 'ismaster' => 1, 'hosts' => @hosts})
|
|
58
|
+
@conn.stubs(:[]).with('admin').returns(admin_db)
|
|
59
|
+
@conn.connect
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
context "initializing with a mongodb uri" do
|
|
64
|
+
|
|
65
|
+
should "parse a uri specifying multiple nodes" do
|
|
66
|
+
@conn = Connection.from_uri("mongodb://localhost:27017,mydb.com:27018", :connect => false)
|
|
67
|
+
assert_equal ['localhost', 27017], @conn.nodes[0]
|
|
68
|
+
assert_equal ['mydb.com', 27018], @conn.nodes[1]
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
should "parse a uri specifying multiple nodes with auth" do
|
|
72
|
+
@conn = Connection.from_uri("mongodb://kyle:s3cr3t@localhost:27017/app,mickey:m0u5e@mydb.com:27018/dsny", :connect => false)
|
|
73
|
+
assert_equal ['localhost', 27017], @conn.nodes[0]
|
|
74
|
+
assert_equal ['mydb.com', 27018], @conn.nodes[1]
|
|
75
|
+
auth_hash = {'username' => 'kyle', 'password' => 's3cr3t', 'db_name' => 'app'}
|
|
76
|
+
assert_equal auth_hash, @conn.auths[0]
|
|
77
|
+
auth_hash = {'username' => 'mickey', 'password' => 'm0u5e', 'db_name' => 'dsny'}
|
|
78
|
+
assert_equal auth_hash, @conn.auths[1]
|
|
79
|
+
end
|
|
80
|
+
end
|
|
81
|
+
end
|
|
82
|
+
end
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
require File.expand_path('./test/test_helper.rb')
|
|
2
|
+
|
|
3
|
+
class SafeTest < Test::Unit::TestCase
|
|
4
|
+
|
|
5
|
+
context "Safe mode on connection: " do
|
|
6
|
+
setup do
|
|
7
|
+
@safe_value = {:w => 7}
|
|
8
|
+
@con = Mongo::Connection.new('localhost', 27017, :safe => @safe_value, :connect => false)
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
should "propogate to DB" do
|
|
12
|
+
db = @con['foo']
|
|
13
|
+
assert_equal @safe_value, db.safe
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
db = @con.db('foo')
|
|
17
|
+
assert_equal @safe_value, db.safe
|
|
18
|
+
|
|
19
|
+
db = DB.new('foo', @con)
|
|
20
|
+
assert_equal @safe_value, db.safe
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
should "allow db override" do
|
|
24
|
+
db = DB.new('foo', @con, :safe => false)
|
|
25
|
+
assert_equal false, db.safe
|
|
26
|
+
|
|
27
|
+
db = @con.db('foo', :safe => false)
|
|
28
|
+
assert_equal false, db.safe
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
context "on DB: " do
|
|
32
|
+
setup do
|
|
33
|
+
@db = @con['foo']
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
should "propogate to collection" do
|
|
37
|
+
col = @db.collection('bar')
|
|
38
|
+
assert_equal @safe_value, col.safe
|
|
39
|
+
|
|
40
|
+
col = @db['bar']
|
|
41
|
+
assert_equal @safe_value, col.safe
|
|
42
|
+
|
|
43
|
+
col = Collection.new(@db, 'bar')
|
|
44
|
+
assert_equal @safe_value, col.safe
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
should "allow override on collection" do
|
|
48
|
+
col = @db.collection('bar', :safe => false)
|
|
49
|
+
assert_equal false, col.safe
|
|
50
|
+
|
|
51
|
+
col = Collection.new(@db, 'bar', :safe => false)
|
|
52
|
+
assert_equal false, col.safe
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
context "on operations supporting safe mode" do
|
|
57
|
+
setup do
|
|
58
|
+
@col = @con['foo']['bar']
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
should "use default value on insert" do
|
|
62
|
+
@con.expects(:send_message_with_safe_check).with do |op, msg, log, n, safe|
|
|
63
|
+
safe == @safe_value
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
@col.insert({:a => 1})
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
should "allow override alternate value on insert" do
|
|
70
|
+
@con.expects(:send_message_with_safe_check).with do |op, msg, log, n, safe|
|
|
71
|
+
safe == {:w => 100}
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
@col.insert({:a => 1}, :safe => {:w => 100})
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
should "allow override to disable on insert" do
|
|
78
|
+
@con.expects(:send_message)
|
|
79
|
+
@col.insert({:a => 1}, :safe => false)
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
should "use default value on update" do
|
|
83
|
+
@con.expects(:send_message_with_safe_check).with do |op, msg, log, n, safe|
|
|
84
|
+
safe == @safe_value
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
@col.update({:a => 1}, {:a => 2})
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
should "allow override alternate value on update" do
|
|
91
|
+
@con.expects(:send_message_with_safe_check).with do |op, msg, log, n, safe|
|
|
92
|
+
safe == {:w => 100}
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
@col.update({:a => 1}, {:a => 2}, :safe => {:w => 100})
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
should "allow override to disable on update" do
|
|
99
|
+
@con.expects(:send_message)
|
|
100
|
+
@col.update({:a => 1}, {:a => 2}, :safe => false)
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
should "use default value on remove" do
|
|
104
|
+
@con.expects(:send_message_with_safe_check).with do |op, msg, log, n, safe|
|
|
105
|
+
safe == @safe_value
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
@col.remove
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
should "allow override alternate value on remove" do
|
|
112
|
+
@con.expects(:send_message_with_safe_check).with do |op, msg, log, n, safe|
|
|
113
|
+
safe == {:w => 100}
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
@col.remove({}, :safe => {:w => 100})
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
should "allow override to disable on remove" do
|
|
120
|
+
@con.expects(:send_message)
|
|
121
|
+
@col.remove({}, :safe => false)
|
|
122
|
+
end
|
|
123
|
+
end
|
|
124
|
+
end
|
|
125
|
+
end
|
metadata
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: mongo
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
+
hash: 25
|
|
4
5
|
prerelease: false
|
|
5
6
|
segments:
|
|
6
7
|
- 1
|
|
7
|
-
-
|
|
8
|
-
|
|
8
|
+
- 1
|
|
9
|
+
- 5
|
|
10
|
+
version: 1.1.5
|
|
9
11
|
platform: ruby
|
|
10
12
|
authors:
|
|
11
13
|
- Jim Menard
|
|
@@ -15,61 +17,113 @@ autorequire:
|
|
|
15
17
|
bindir: bin
|
|
16
18
|
cert_chain: []
|
|
17
19
|
|
|
18
|
-
date: 2010-
|
|
20
|
+
date: 2010-12-15 00:00:00 -05:00
|
|
19
21
|
default_executable:
|
|
20
22
|
dependencies:
|
|
21
23
|
- !ruby/object:Gem::Dependency
|
|
22
24
|
name: bson
|
|
23
25
|
prerelease: false
|
|
24
26
|
requirement: &id001 !ruby/object:Gem::Requirement
|
|
27
|
+
none: false
|
|
25
28
|
requirements:
|
|
26
|
-
- - "
|
|
29
|
+
- - ">="
|
|
27
30
|
- !ruby/object:Gem::Version
|
|
31
|
+
hash: 25
|
|
28
32
|
segments:
|
|
29
33
|
- 1
|
|
30
|
-
-
|
|
31
|
-
|
|
34
|
+
- 1
|
|
35
|
+
- 5
|
|
36
|
+
version: 1.1.5
|
|
32
37
|
type: :runtime
|
|
33
38
|
version_requirements: *id001
|
|
34
39
|
description: A Ruby driver for MongoDB. For more information about Mongo, see http://www.mongodb.org.
|
|
35
40
|
email: mongodb-dev@googlegroups.com
|
|
36
|
-
executables:
|
|
37
|
-
|
|
41
|
+
executables:
|
|
42
|
+
- mongo_console
|
|
38
43
|
extensions: []
|
|
39
44
|
|
|
40
45
|
extra_rdoc_files:
|
|
41
|
-
- README.
|
|
46
|
+
- README.md
|
|
42
47
|
files:
|
|
43
|
-
- README.
|
|
48
|
+
- README.md
|
|
44
49
|
- Rakefile
|
|
45
|
-
- mongo
|
|
50
|
+
- mongo.gemspec
|
|
46
51
|
- LICENSE.txt
|
|
47
52
|
- lib/mongo.rb
|
|
48
|
-
- lib/mongo/collection.rb
|
|
49
|
-
- lib/mongo/connection.rb
|
|
50
53
|
- lib/mongo/cursor.rb
|
|
51
|
-
- lib/mongo/
|
|
54
|
+
- lib/mongo/collection.rb
|
|
52
55
|
- lib/mongo/exceptions.rb
|
|
56
|
+
- lib/mongo/connection.rb
|
|
57
|
+
- lib/mongo/repl_set_connection.rb
|
|
58
|
+
- lib/mongo/gridfs/grid_io.rb
|
|
59
|
+
- lib/mongo/gridfs/grid_file_system.rb
|
|
53
60
|
- lib/mongo/gridfs/grid.rb
|
|
54
61
|
- lib/mongo/gridfs/grid_ext.rb
|
|
55
|
-
- lib/mongo/gridfs/
|
|
56
|
-
- lib/mongo/gridfs/grid_io.rb
|
|
62
|
+
- lib/mongo/gridfs/grid_io_fix.rb
|
|
57
63
|
- lib/mongo/util/conversions.rb
|
|
64
|
+
- lib/mongo/util/support.rb
|
|
65
|
+
- lib/mongo/util/pool.rb
|
|
58
66
|
- lib/mongo/util/core_ext.rb
|
|
59
67
|
- lib/mongo/util/server_version.rb
|
|
60
|
-
- lib/mongo/util/
|
|
61
|
-
-
|
|
62
|
-
-
|
|
63
|
-
-
|
|
64
|
-
-
|
|
65
|
-
-
|
|
66
|
-
-
|
|
67
|
-
-
|
|
68
|
-
-
|
|
69
|
-
-
|
|
70
|
-
-
|
|
71
|
-
-
|
|
72
|
-
-
|
|
68
|
+
- lib/mongo/util/uri_parser.rb
|
|
69
|
+
- lib/mongo/db.rb
|
|
70
|
+
- docs/HISTORY.md
|
|
71
|
+
- docs/TUTORIAL.md
|
|
72
|
+
- docs/CREDITS.md
|
|
73
|
+
- docs/FAQ.md
|
|
74
|
+
- docs/REPLICA_SETS.md
|
|
75
|
+
- docs/1.0_UPGRADE.md
|
|
76
|
+
- docs/GridFS.md
|
|
77
|
+
- docs/WRITE_CONCERN.md
|
|
78
|
+
- bin/mongo_console
|
|
79
|
+
- test/grid_file_system_test.rb
|
|
80
|
+
- test/unit/db_test.rb
|
|
81
|
+
- test/unit/repl_set_connection_test.rb
|
|
82
|
+
- test/unit/collection_test.rb
|
|
83
|
+
- test/unit/cursor_test.rb
|
|
84
|
+
- test/unit/grid_test.rb
|
|
85
|
+
- test/unit/connection_test.rb
|
|
86
|
+
- test/unit/pool_test.rb
|
|
87
|
+
- test/unit/safe_test.rb
|
|
88
|
+
- test/db_test.rb
|
|
89
|
+
- test/collection_test.rb
|
|
90
|
+
- test/cursor_test.rb
|
|
91
|
+
- test/grid_test.rb
|
|
92
|
+
- test/db_api_test.rb
|
|
93
|
+
- test/auxillary/slave_connection_test.rb
|
|
94
|
+
- test/auxillary/authentication_test.rb
|
|
95
|
+
- test/auxillary/autoreconnect_test.rb
|
|
96
|
+
- test/auxillary/1.4_features.rb
|
|
97
|
+
- test/conversions_test.rb
|
|
98
|
+
- test/connection_test.rb
|
|
99
|
+
- test/cursor_message_test.rb
|
|
100
|
+
- test/tools/test.rb
|
|
101
|
+
- test/tools/repl_set_manager.rb
|
|
102
|
+
- test/cursor_fail_test.rb
|
|
103
|
+
- test/threading/threading_with_large_pool_test.rb
|
|
104
|
+
- test/test_helper.rb
|
|
105
|
+
- test/grid_io_test.rb
|
|
106
|
+
- test/bson/byte_buffer_test.rb
|
|
107
|
+
- test/bson/binary_test.rb
|
|
108
|
+
- test/bson/object_id_test.rb
|
|
109
|
+
- test/bson/json_test.rb
|
|
110
|
+
- test/bson/bson_test.rb
|
|
111
|
+
- test/bson/ordered_hash_test.rb
|
|
112
|
+
- test/bson/hash_with_indifferent_access_test.rb
|
|
113
|
+
- test/support/keys.rb
|
|
114
|
+
- test/support/hash_with_indifferent_access.rb
|
|
115
|
+
- test/db_connection_test.rb
|
|
116
|
+
- test/replica_sets/rs_test_helper.rb
|
|
117
|
+
- test/replica_sets/pooled_insert_test.rb
|
|
118
|
+
- test/replica_sets/count_test.rb
|
|
119
|
+
- test/replica_sets/replication_ack_test.rb
|
|
120
|
+
- test/replica_sets/query_secondaries.rb
|
|
121
|
+
- test/replica_sets/query_test.rb
|
|
122
|
+
- test/replica_sets/insert_test.rb
|
|
123
|
+
- test/replica_sets/connect_test.rb
|
|
124
|
+
- test/safe_test.rb
|
|
125
|
+
- test/support_test.rb
|
|
126
|
+
- test/threading_test.rb
|
|
73
127
|
has_rdoc: true
|
|
74
128
|
homepage: http://www.mongodb.org
|
|
75
129
|
licenses: []
|
|
@@ -77,54 +131,81 @@ licenses: []
|
|
|
77
131
|
post_install_message:
|
|
78
132
|
rdoc_options:
|
|
79
133
|
- --main
|
|
80
|
-
- README.
|
|
134
|
+
- README.md
|
|
81
135
|
- --inline-source
|
|
82
136
|
require_paths:
|
|
83
137
|
- lib
|
|
84
138
|
required_ruby_version: !ruby/object:Gem::Requirement
|
|
139
|
+
none: false
|
|
85
140
|
requirements:
|
|
86
141
|
- - ">="
|
|
87
142
|
- !ruby/object:Gem::Version
|
|
143
|
+
hash: 3
|
|
88
144
|
segments:
|
|
89
145
|
- 0
|
|
90
146
|
version: "0"
|
|
91
147
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
148
|
+
none: false
|
|
92
149
|
requirements:
|
|
93
150
|
- - ">="
|
|
94
151
|
- !ruby/object:Gem::Version
|
|
152
|
+
hash: 3
|
|
95
153
|
segments:
|
|
96
154
|
- 0
|
|
97
155
|
version: "0"
|
|
98
156
|
requirements: []
|
|
99
157
|
|
|
100
158
|
rubyforge_project:
|
|
101
|
-
rubygems_version: 1.3.
|
|
159
|
+
rubygems_version: 1.3.7
|
|
102
160
|
signing_key:
|
|
103
161
|
specification_version: 3
|
|
104
162
|
summary: Ruby driver for the MongoDB
|
|
105
163
|
test_files:
|
|
106
|
-
- test/
|
|
107
|
-
- test/
|
|
108
|
-
- test/
|
|
164
|
+
- test/grid_file_system_test.rb
|
|
165
|
+
- test/unit/db_test.rb
|
|
166
|
+
- test/unit/repl_set_connection_test.rb
|
|
167
|
+
- test/unit/collection_test.rb
|
|
168
|
+
- test/unit/cursor_test.rb
|
|
169
|
+
- test/unit/grid_test.rb
|
|
170
|
+
- test/unit/connection_test.rb
|
|
171
|
+
- test/unit/pool_test.rb
|
|
172
|
+
- test/unit/safe_test.rb
|
|
173
|
+
- test/db_test.rb
|
|
109
174
|
- test/collection_test.rb
|
|
110
|
-
- test/connection_test.rb
|
|
111
|
-
- test/conversions_test.rb
|
|
112
175
|
- test/cursor_test.rb
|
|
113
|
-
- test/db_api_test.rb
|
|
114
|
-
- test/db_connection_test.rb
|
|
115
|
-
- test/db_test.rb
|
|
116
|
-
- test/grid_file_system_test.rb
|
|
117
|
-
- test/grid_io_test.rb
|
|
118
176
|
- test/grid_test.rb
|
|
119
|
-
- test/
|
|
120
|
-
- test/
|
|
121
|
-
- test/
|
|
122
|
-
- test/
|
|
123
|
-
- test/
|
|
177
|
+
- test/db_api_test.rb
|
|
178
|
+
- test/auxillary/slave_connection_test.rb
|
|
179
|
+
- test/auxillary/authentication_test.rb
|
|
180
|
+
- test/auxillary/autoreconnect_test.rb
|
|
181
|
+
- test/auxillary/1.4_features.rb
|
|
182
|
+
- test/conversions_test.rb
|
|
183
|
+
- test/connection_test.rb
|
|
184
|
+
- test/cursor_message_test.rb
|
|
185
|
+
- test/tools/test.rb
|
|
186
|
+
- test/tools/repl_set_manager.rb
|
|
187
|
+
- test/cursor_fail_test.rb
|
|
188
|
+
- test/threading/threading_with_large_pool_test.rb
|
|
124
189
|
- test/test_helper.rb
|
|
125
|
-
- test/
|
|
190
|
+
- test/grid_io_test.rb
|
|
191
|
+
- test/bson/byte_buffer_test.rb
|
|
192
|
+
- test/bson/binary_test.rb
|
|
193
|
+
- test/bson/object_id_test.rb
|
|
194
|
+
- test/bson/json_test.rb
|
|
195
|
+
- test/bson/bson_test.rb
|
|
196
|
+
- test/bson/ordered_hash_test.rb
|
|
197
|
+
- test/bson/hash_with_indifferent_access_test.rb
|
|
198
|
+
- test/support/keys.rb
|
|
199
|
+
- test/support/hash_with_indifferent_access.rb
|
|
200
|
+
- test/db_connection_test.rb
|
|
201
|
+
- test/replica_sets/rs_test_helper.rb
|
|
202
|
+
- test/replica_sets/pooled_insert_test.rb
|
|
203
|
+
- test/replica_sets/count_test.rb
|
|
204
|
+
- test/replica_sets/replication_ack_test.rb
|
|
205
|
+
- test/replica_sets/query_secondaries.rb
|
|
206
|
+
- test/replica_sets/query_test.rb
|
|
207
|
+
- test/replica_sets/insert_test.rb
|
|
208
|
+
- test/replica_sets/connect_test.rb
|
|
209
|
+
- test/safe_test.rb
|
|
210
|
+
- test/support_test.rb
|
|
126
211
|
- test/threading_test.rb
|
|
127
|
-
- test/unit/collection_test.rb
|
|
128
|
-
- test/unit/connection_test.rb
|
|
129
|
-
- test/unit/cursor_test.rb
|
|
130
|
-
- test/unit/db_test.rb
|
data/bin/bson_benchmark.rb
DELETED
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env ruby
|
|
2
|
-
|
|
3
|
-
$LOAD_PATH[0,0] = File.join(File.dirname(__FILE__), '..', 'lib')
|
|
4
|
-
require 'mongo'
|
|
5
|
-
|
|
6
|
-
include Mongo
|
|
7
|
-
|
|
8
|
-
TRIALS = 100000
|
|
9
|
-
|
|
10
|
-
def encode(doc)
|
|
11
|
-
t0 = Time.new
|
|
12
|
-
b = Mongo::BSON_CODER.new
|
|
13
|
-
TRIALS.times { |i|
|
|
14
|
-
b = Mongo::BSON_CODER.new
|
|
15
|
-
b.serialize doc
|
|
16
|
-
}
|
|
17
|
-
print "took: #{Time.now.to_f - t0.to_f}\n"
|
|
18
|
-
return b
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
def decode(bson)
|
|
22
|
-
t0 = Time.new
|
|
23
|
-
doc = nil
|
|
24
|
-
TRIALS.times { |i|
|
|
25
|
-
doc = bson.deserialize
|
|
26
|
-
}
|
|
27
|
-
print "took: #{Time.now.to_f - t0.to_f}\n"
|
|
28
|
-
return doc
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
TEST_CASES = [{},
|
|
32
|
-
{
|
|
33
|
-
"hello" => "world"
|
|
34
|
-
},
|
|
35
|
-
{
|
|
36
|
-
"hello" => "world",
|
|
37
|
-
"mike" => "something",
|
|
38
|
-
"here's" => "another"
|
|
39
|
-
},
|
|
40
|
-
{
|
|
41
|
-
"int" => 200,
|
|
42
|
-
"bool" => true,
|
|
43
|
-
"an int" => 20,
|
|
44
|
-
"a bool" => false
|
|
45
|
-
},
|
|
46
|
-
{
|
|
47
|
-
"this" => 5,
|
|
48
|
-
"is" => {"a" => true},
|
|
49
|
-
"big" => [true, 5.5],
|
|
50
|
-
"object" => nil
|
|
51
|
-
}]
|
|
52
|
-
|
|
53
|
-
TEST_CASES.each { |doc|
|
|
54
|
-
print "case #{doc.inspect}\n"
|
|
55
|
-
print "enc bson\n"
|
|
56
|
-
enc_bson = encode(doc)
|
|
57
|
-
print "dec bson\n"
|
|
58
|
-
raise "FAIL" unless doc == decode(enc_bson)
|
|
59
|
-
}
|
data/bin/fail_if_no_c.rb
DELETED
data/examples/admin.rb
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
$:.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
|
2
|
-
|
|
3
|
-
require 'mongo'
|
|
4
|
-
require 'pp'
|
|
5
|
-
|
|
6
|
-
include Mongo
|
|
7
|
-
|
|
8
|
-
host = ENV['MONGO_RUBY_DRIVER_HOST'] || 'localhost'
|
|
9
|
-
port = ENV['MONGO_RUBY_DRIVER_PORT'] || Connection::DEFAULT_PORT
|
|
10
|
-
|
|
11
|
-
puts "Connecting to #{host}:#{port}"
|
|
12
|
-
con = Mongo::Connection.new(host, port)
|
|
13
|
-
db = con.db('ruby-mongo-examples')
|
|
14
|
-
coll = db.create_collection('test')
|
|
15
|
-
|
|
16
|
-
# Erase all records from collection, if any
|
|
17
|
-
coll.remove
|
|
18
|
-
|
|
19
|
-
admin = con['admin']
|
|
20
|
-
|
|
21
|
-
# Profiling level set/get
|
|
22
|
-
puts "Profiling level: #{admin.profiling_level}"
|
|
23
|
-
|
|
24
|
-
# Start profiling everything
|
|
25
|
-
admin.profiling_level = :all
|
|
26
|
-
|
|
27
|
-
# Read records, creating a profiling event
|
|
28
|
-
coll.find().to_a
|
|
29
|
-
|
|
30
|
-
# Stop profiling
|
|
31
|
-
admin.profiling_level = :off
|
|
32
|
-
|
|
33
|
-
# Print all profiling info
|
|
34
|
-
pp admin.profiling_info
|
|
35
|
-
|
|
36
|
-
# Validate returns a hash if all is well and
|
|
37
|
-
# raises an exception if there is a problem.
|
|
38
|
-
info = db.validate_collection(coll.name)
|
|
39
|
-
puts "valid = #{info['ok']}"
|
|
40
|
-
puts info['result']
|
|
41
|
-
|
|
42
|
-
# Destroy the collection
|
|
43
|
-
coll.drop
|
data/examples/capped.rb
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
$:.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
|
2
|
-
require 'mongo'
|
|
3
|
-
|
|
4
|
-
include Mongo
|
|
5
|
-
|
|
6
|
-
host = ENV['MONGO_RUBY_DRIVER_HOST'] || 'localhost'
|
|
7
|
-
port = ENV['MONGO_RUBY_DRIVER_PORT'] || Connection::DEFAULT_PORT
|
|
8
|
-
|
|
9
|
-
puts "Connecting to #{host}:#{port}"
|
|
10
|
-
db = Connection.new(host, port).db('ruby-mongo-examples')
|
|
11
|
-
db.drop_collection('test')
|
|
12
|
-
|
|
13
|
-
# A capped collection has a max size and, optionally, a max number of records.
|
|
14
|
-
# Old records get pushed out by new ones once the size or max num records is reached.
|
|
15
|
-
coll = db.create_collection('test', :capped => true, :size => 1024, :max => 12)
|
|
16
|
-
|
|
17
|
-
100.times { |i| coll.insert('a' => i+1) }
|
|
18
|
-
|
|
19
|
-
# We will only see the last 12 records
|
|
20
|
-
coll.find().each { |row| p row }
|
|
21
|
-
|
|
22
|
-
coll.drop
|
data/examples/cursor.rb
DELETED
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
$:.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
|
2
|
-
|
|
3
|
-
require 'mongo'
|
|
4
|
-
require 'pp'
|
|
5
|
-
|
|
6
|
-
include Mongo
|
|
7
|
-
|
|
8
|
-
host = ENV['MONGO_RUBY_DRIVER_HOST'] || 'localhost'
|
|
9
|
-
port = ENV['MONGO_RUBY_DRIVER_PORT'] || Connection::DEFAULT_PORT
|
|
10
|
-
|
|
11
|
-
puts "Connecting to #{host}:#{port}"
|
|
12
|
-
db = Connection.new(host, port).db('ruby-mongo-examples')
|
|
13
|
-
coll = db.collection('test')
|
|
14
|
-
|
|
15
|
-
# Erase all records from collection, if any
|
|
16
|
-
coll.remove
|
|
17
|
-
|
|
18
|
-
# Insert 3 records
|
|
19
|
-
3.times { |i| coll.insert({'a' => i+1}) }
|
|
20
|
-
|
|
21
|
-
# Cursors don't run their queries until you actually attempt to retrieve data
|
|
22
|
-
# from them.
|
|
23
|
-
|
|
24
|
-
# Find returns a Cursor, which is Enumerable. You can iterate:
|
|
25
|
-
coll.find().each { |row| pp row }
|
|
26
|
-
|
|
27
|
-
# You can turn it into an array:
|
|
28
|
-
array = coll.find().to_a
|
|
29
|
-
|
|
30
|
-
# You can iterate after turning it into an array (the cursor will iterate over
|
|
31
|
-
# the copy of the array that it saves internally.)
|
|
32
|
-
cursor = coll.find()
|
|
33
|
-
array = cursor.to_a
|
|
34
|
-
cursor.each { |row| pp row }
|
|
35
|
-
|
|
36
|
-
# You can get the next object
|
|
37
|
-
first_object = coll.find().next_document
|
|
38
|
-
|
|
39
|
-
# next_document returns nil if there are no more objects that match
|
|
40
|
-
cursor = coll.find()
|
|
41
|
-
obj = cursor.next_document
|
|
42
|
-
while obj
|
|
43
|
-
pp obj
|
|
44
|
-
obj = cursor.next_document
|
|
45
|
-
end
|
|
46
|
-
|
|
47
|
-
# Destroy the collection
|
|
48
|
-
coll.drop
|