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
data/LICENSE.txt
CHANGED
|
@@ -175,18 +175,7 @@
|
|
|
175
175
|
|
|
176
176
|
END OF TERMS AND CONDITIONS
|
|
177
177
|
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
To apply the Apache License to your work, attach the following
|
|
181
|
-
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
-
replaced with your own identifying information. (Don't include
|
|
183
|
-
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
-
comment syntax for the file format. We also recommend that a
|
|
185
|
-
file or class name and description of purpose be included on the
|
|
186
|
-
same "printed page" as the copyright notice for easier
|
|
187
|
-
identification within third-party archives.
|
|
188
|
-
|
|
189
|
-
Copyright [yyyy] [name of copyright owner]
|
|
178
|
+
Copyright 2008-2010 10gen, Inc.
|
|
190
179
|
|
|
191
180
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
181
|
you may not use this file except in compliance with the License.
|
|
@@ -199,4 +188,3 @@
|
|
|
199
188
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
189
|
See the License for the specific language governing permissions and
|
|
201
190
|
limitations under the License.
|
|
202
|
-
|
data/{README.rdoc → README.md}
RENAMED
|
@@ -1,81 +1,101 @@
|
|
|
1
|
-
|
|
1
|
+
# Introduction
|
|
2
2
|
|
|
3
|
-
This is the 10gen-supported Ruby driver for MongoDB
|
|
3
|
+
This is the 10gen-supported Ruby driver for [MongoDB](http://www.mongodb.org).
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
(http://www.mongodb.org/display/DOCS/Ruby+Tutorial) for much more.
|
|
5
|
+
This documentation includes other articles of interest, include:
|
|
7
6
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
1. [A tutorial](http://api.mongodb.org/ruby/current/file.TUTORIAL.html).
|
|
8
|
+
2. [Replica Sets in Ruby](http://api.mongodb.org/ruby/current/file.REPLICA_SETS.html).
|
|
9
|
+
3. [Write Concern in Ruby](http://api.mongodb.org/ruby/current/file.WRITE_CONCERN.html).
|
|
10
|
+
4. [GridFS in Ruby](http://api.mongodb.org/ruby/current/file.GridFS.html).
|
|
11
|
+
5. [Frequently Asked Questions](http://api.mongodb.org/ruby/current/file.FAQ.html).
|
|
12
|
+
6. [History](http://api.mongodb.org/ruby/current/file.HISTORY.html).
|
|
13
|
+
7. [Credits](http://api.mongodb.org/ruby/current/file.CREDITS.html).
|
|
11
14
|
|
|
12
|
-
|
|
13
|
-
|
|
15
|
+
Here's a quick code sample. Again, see the [MongoDB Ruby Tutorial](file.TUTORIAL.html)
|
|
16
|
+
for much more:
|
|
14
17
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
require 'rubygems'
|
|
19
|
+
require 'mongo'
|
|
20
|
+
include Mongo
|
|
21
|
+
|
|
22
|
+
db = Connection.new.db('sample-db')
|
|
23
|
+
coll = db.collection('test')
|
|
24
|
+
|
|
25
|
+
coll.remove
|
|
26
|
+
3.times do |i|
|
|
27
|
+
coll.insert({'a' => i+1})
|
|
28
|
+
end
|
|
29
|
+
puts "There are #{coll.count()} records. Here they are:"
|
|
30
|
+
coll.find().each { |doc| puts doc.inspect }
|
|
31
|
+
|
|
32
|
+
# Installation
|
|
33
|
+
|
|
34
|
+
### Ruby Versions
|
|
35
|
+
|
|
36
|
+
The driver works and is consistently tested on Ruby 1.8.6, 1.8.7, and 1.9.2, and JRuby 1.5.1.
|
|
37
|
+
|
|
38
|
+
Note that if you're on 1.8.7, be sure that you're using a patchlevel >= 249. There
|
|
39
|
+
are some IO bugs in earlier versions.
|
|
21
40
|
|
|
22
|
-
|
|
41
|
+
### Gems
|
|
23
42
|
|
|
24
|
-
The driver's gems are hosted at Rubygems.org
|
|
43
|
+
The driver's gems are hosted at [Rubygems.org](http://rubygems.org). Make sure you're
|
|
25
44
|
using the latest version of rubygems:
|
|
26
45
|
|
|
27
|
-
|
|
46
|
+
$ gem update --system
|
|
28
47
|
|
|
29
48
|
Then you can install the mongo gem as follows:
|
|
30
49
|
|
|
31
|
-
|
|
50
|
+
$ gem install mongo
|
|
32
51
|
|
|
33
|
-
The driver also requires the
|
|
52
|
+
The driver also requires the bson gem:
|
|
34
53
|
|
|
35
|
-
|
|
54
|
+
$ gem install bson
|
|
36
55
|
|
|
37
56
|
And for a significant performance boost, you'll want to install the C extensions:
|
|
38
57
|
|
|
39
|
-
|
|
58
|
+
$ gem install bson_ext
|
|
40
59
|
|
|
41
|
-
|
|
60
|
+
Note that bson_ext isn't used with JRuby. Instead, some native Java extensions are bundled with the bson gem.
|
|
61
|
+
If you ever need to modify these extenions, you can recompile with the following rake task:
|
|
62
|
+
|
|
63
|
+
$ rake build:java
|
|
64
|
+
|
|
65
|
+
### From the GitHub source
|
|
42
66
|
|
|
43
67
|
The source code is available at http://github.com/mongodb/mongo-ruby-driver.
|
|
44
68
|
You can either clone the git repository or download a tarball or zip file.
|
|
45
69
|
Once you have the source, you can use it from wherever you downloaded it or
|
|
46
70
|
you can install it as a gem from the source by typing
|
|
47
71
|
|
|
48
|
-
|
|
72
|
+
$ rake gem:install
|
|
49
73
|
|
|
50
74
|
To install the C extensions from source, type this instead:
|
|
51
75
|
|
|
52
|
-
|
|
76
|
+
$ rake gem:install_extensions
|
|
53
77
|
|
|
54
78
|
That's all there is to it!
|
|
55
79
|
|
|
56
|
-
|
|
80
|
+
# Examples
|
|
57
81
|
|
|
58
|
-
For extensive examples, see the MongoDB Ruby Tutorial
|
|
59
|
-
(http://www.mongodb.org/display/DOCS/Ruby+Tutorial).
|
|
82
|
+
For extensive examples, see the [MongoDB Ruby Tutorial](http://www.mongodb.org/display/DOCS/Ruby+Tutorial).
|
|
60
83
|
|
|
61
|
-
Bundled with the driver are many examples, located in the "examples" subdirectory. Samples include using
|
|
84
|
+
Bundled with the driver are many examples, located in the "docs/examples" subdirectory. Samples include using
|
|
62
85
|
the driver and using the GridFS class GridStore. MongoDB must be running for
|
|
63
86
|
these examples to work, of course.
|
|
64
87
|
|
|
65
88
|
Here's how to start MongoDB and run the "simple.rb" example:
|
|
66
89
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
90
|
+
$ cd path/to/mongo
|
|
91
|
+
$ ./mongod run
|
|
92
|
+
... then in another window ...
|
|
93
|
+
$ cd path/to/mongo-ruby-driver
|
|
94
|
+
$ ruby docs/examples/simple.rb
|
|
72
95
|
|
|
73
96
|
See also the test code, especially test/test_db_api.rb.
|
|
74
97
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
Note: The GridStore class has been deprecated. Use either the Grid or GridFileSystem
|
|
78
|
-
classes to take advantage of GridFS.
|
|
98
|
+
# GridFS
|
|
79
99
|
|
|
80
100
|
The Ruby driver include two abstractions for storing large files: Grid and GridFileSystem.
|
|
81
101
|
The Grid class is a Ruby implementation of MongoDB's GridFS file storage
|
|
@@ -87,87 +107,56 @@ for details, and see examples/gridfs.rb for code that uses many of the Grid
|
|
|
87
107
|
features (metadata, content type, seek, tell, etc).
|
|
88
108
|
|
|
89
109
|
Examples:
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
# GridFileSystem. Store the text "Hello, world!" in the fs.
|
|
96
|
-
fs = GridFileSystem.new(db)
|
|
97
|
-
fs.open('filename', 'w') do |f|
|
|
98
|
-
f.write "Hello, world!"
|
|
99
|
-
end
|
|
100
|
-
|
|
101
|
-
# GridFileSystem. Output "Hello, world!"
|
|
102
|
-
fs = GridFileSystem.new(db)
|
|
103
|
-
fs.open('filename', 'r') do |f|
|
|
104
|
-
puts f.read
|
|
105
|
-
end
|
|
110
|
+
# Write a file on disk to the Grid
|
|
111
|
+
file = File.open('image.jpg')
|
|
112
|
+
grid = Grid.new(db)
|
|
113
|
+
id = grid.put(file)
|
|
106
114
|
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
id = grid.put(file)
|
|
115
|
+
# Retrieve the file
|
|
116
|
+
file = grid.get(id)
|
|
117
|
+
file.read
|
|
111
118
|
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
119
|
+
# Get all the file's metata
|
|
120
|
+
file.filename
|
|
121
|
+
file.content_type
|
|
122
|
+
file.metadata
|
|
115
123
|
|
|
116
|
-
|
|
117
|
-
file.filename
|
|
118
|
-
file.content_type
|
|
119
|
-
file.metadata
|
|
124
|
+
# Notes
|
|
120
125
|
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
== Thread Safety
|
|
126
|
+
## Thread Safety
|
|
124
127
|
|
|
125
128
|
The driver is thread-safe.
|
|
126
129
|
|
|
127
|
-
|
|
130
|
+
## Connection Pooling
|
|
128
131
|
|
|
129
|
-
As of
|
|
132
|
+
As of v0.18, the driver implements connection pooling. By default, only one
|
|
130
133
|
socket connection will be opened to MongoDB. However, if you're running a
|
|
131
134
|
multi-threaded application, you can specify a maximum pool size and a maximum
|
|
132
135
|
timeout for waiting for old connections to be released to the pool.
|
|
133
136
|
|
|
134
137
|
To set up a pooled connection to a single MongoDB instance:
|
|
135
138
|
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
A pooled connection to a paired instance would look like this:
|
|
139
|
-
|
|
140
|
-
@conn = Connection.new({:left => ["db1.example.com", 27017],
|
|
141
|
-
:right => ["db2.example.com", 27017]}, nil,
|
|
142
|
-
:pool_size => 20, :timeout => 5)
|
|
139
|
+
@conn = Connection.new("localhost", 27017, :pool_size => 5, :timeout => 5)
|
|
143
140
|
|
|
144
141
|
Though the pooling architecture will undoubtedly evolve, it currently owes much credit
|
|
145
142
|
to the connection pooling implementations in ActiveRecord and PyMongo.
|
|
146
143
|
|
|
147
|
-
|
|
144
|
+
## Using with Phusion Passenger and Unicorn
|
|
148
145
|
|
|
149
|
-
When
|
|
150
|
-
processes
|
|
151
|
-
activerecord-mongo-adapter handles this for you, so if you are using that
|
|
152
|
-
you shouldn't need to worry about it. Otherwise you'll either need to use
|
|
153
|
-
conservative spawning[http://www.modrails.org/documentation/Users%20guide.html#RailsSpawnMethod]
|
|
154
|
-
or handle reconnecting when passenger forks a new process:
|
|
146
|
+
When Passenger and Unicorn are in smart spawning mode you need to be sure that child
|
|
147
|
+
processes will create a new connection to the database. In Passenger, this can be handled like so:
|
|
155
148
|
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
149
|
+
if defined?(PhusionPassenger)
|
|
150
|
+
PhusionPassenger.on_event(:starting_worker_process) do |forked|
|
|
151
|
+
if forked
|
|
152
|
+
# Create new connection here
|
|
153
|
+
end
|
|
160
154
|
end
|
|
161
155
|
end
|
|
162
|
-
end
|
|
163
156
|
|
|
164
|
-
The above code should be put
|
|
165
|
-
script.
|
|
157
|
+
The above code should be put into a Rails initializer or other initialization script.
|
|
166
158
|
|
|
167
|
-
|
|
168
|
-
for more details on this issue.
|
|
169
|
-
|
|
170
|
-
== String Encoding
|
|
159
|
+
## String Encoding
|
|
171
160
|
|
|
172
161
|
The BSON ("Binary JSON") format used to communicate with Mongo requires that
|
|
173
162
|
strings be UTF-8 (http://en.wikipedia.org/wiki/UTF-8).
|
|
@@ -177,18 +166,18 @@ and received from Mongo are converted to UTF-8 when necessary, and strings
|
|
|
177
166
|
read from Mongo will have their character encodings set to UTF-8.
|
|
178
167
|
|
|
179
168
|
When used with Ruby 1.8, the bytes in each string are written to and read from
|
|
180
|
-
Mongo as
|
|
169
|
+
Mongo as is. If the string is ASCII, all is well, because ASCII is a subset of
|
|
181
170
|
UTF-8. If the string is not ASCII, it may not be a well-formed UTF-8
|
|
182
171
|
string.
|
|
183
172
|
|
|
184
|
-
|
|
173
|
+
## Primary Keys
|
|
185
174
|
|
|
186
|
-
The field
|
|
175
|
+
The `_id` field is a primary key. It is treated specially by the database, and
|
|
187
176
|
its use makes many operations more efficient. The value of an _id may be of
|
|
188
177
|
any type. The database itself inserts an _id value if none is specified when
|
|
189
178
|
a record is inserted.
|
|
190
179
|
|
|
191
|
-
|
|
180
|
+
### Primary Key Factories
|
|
192
181
|
|
|
193
182
|
A primary key factory is a class you supply to a DB object that knows how to
|
|
194
183
|
generate _id values. If you want to control _id values or even their types,
|
|
@@ -197,7 +186,7 @@ using a PK factory lets you do so.
|
|
|
197
186
|
You can tell the Ruby Mongo driver how to create primary keys by passing in
|
|
198
187
|
the :pk option to the Connection#db method.
|
|
199
188
|
|
|
200
|
-
|
|
189
|
+
db = Mongo::Connection.new.db('dbname', :pk => MyPKFactory.new)
|
|
201
190
|
|
|
202
191
|
A primary key factory object must respond to :create_pk, which should
|
|
203
192
|
take a hash and return a hash which merges the original hash with any
|
|
@@ -211,12 +200,12 @@ returned will be inserted.
|
|
|
211
200
|
|
|
212
201
|
Here is a sample primary key factory, taken from the tests:
|
|
213
202
|
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
203
|
+
class TestPKFactory
|
|
204
|
+
def create_pk(row)
|
|
205
|
+
row['_id'] ||= Mongo::ObjectID.new
|
|
206
|
+
row
|
|
207
|
+
end
|
|
218
208
|
end
|
|
219
|
-
end
|
|
220
209
|
|
|
221
210
|
Here's a slightly more sophisticated one that handles both symbol and string
|
|
222
211
|
keys. This is the PKFactory that comes with the MongoRecord code (an
|
|
@@ -238,13 +227,9 @@ changeable at all is so that libraries such as MongoRecord that use this
|
|
|
238
227
|
driver can set the PK factory after obtaining the database but before using it
|
|
239
228
|
for the first time.
|
|
240
229
|
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
=== Primary Key factories
|
|
244
|
-
|
|
245
|
-
See the section on "Primary Keys" above.
|
|
230
|
+
## The DB Class
|
|
246
231
|
|
|
247
|
-
|
|
232
|
+
### Strict mode
|
|
248
233
|
|
|
249
234
|
Each database has an optional strict mode. If strict mode is on, then asking
|
|
250
235
|
for a collection that does not exist will raise an error, as will asking to
|
|
@@ -252,90 +237,85 @@ create a collection that already exists. Note that both these operations are
|
|
|
252
237
|
completely harmless; strict mode is a programmer convenience only.
|
|
253
238
|
|
|
254
239
|
To turn on strict mode, either pass in :strict => true when obtaining a DB
|
|
255
|
-
object or call the
|
|
240
|
+
object or call the `:strict=` method:
|
|
256
241
|
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
242
|
+
db = Connection.new.db('dbname', :strict => true)
|
|
243
|
+
# I'm feeling lax
|
|
244
|
+
db.strict = false
|
|
245
|
+
# No, I'm not!
|
|
246
|
+
db.strict = true
|
|
262
247
|
|
|
263
248
|
The method DB#strict? returns the current value of that flag.
|
|
264
249
|
|
|
265
|
-
|
|
250
|
+
## Cursors
|
|
266
251
|
|
|
267
|
-
|
|
252
|
+
Notes:
|
|
268
253
|
|
|
269
|
-
|
|
254
|
+
* Cursors are enumerable (and have a #to_a method).
|
|
270
255
|
|
|
271
|
-
|
|
256
|
+
* The query doesn't get run until you actually attempt to retrieve data from a
|
|
272
257
|
cursor.
|
|
273
258
|
|
|
274
|
-
|
|
259
|
+
* Cursors will timeout on the server after 10 minutes. If you need to keep a cursor
|
|
260
|
+
open for more than 10 minutes, specify `:timeout => false` when you create the cursor.
|
|
275
261
|
|
|
276
262
|
|
|
277
|
-
|
|
263
|
+
# Testing
|
|
278
264
|
|
|
279
|
-
If you have the source code, you can run the tests.
|
|
280
|
-
the bson_ext C extension enabled.
|
|
265
|
+
If you have the source code, you can run the tests.
|
|
281
266
|
|
|
282
|
-
|
|
267
|
+
$ rake test:c
|
|
283
268
|
|
|
284
|
-
|
|
269
|
+
If you want to test the basic Ruby encoder, without the C extension, or if you're running JRuby:
|
|
285
270
|
|
|
286
|
-
|
|
271
|
+
$ rake test:ruby
|
|
287
272
|
|
|
288
273
|
These will run both unit and functional tests. To run these tests alone:
|
|
289
274
|
|
|
290
|
-
|
|
291
|
-
|
|
275
|
+
$ rake test:unit
|
|
276
|
+
$ rake test:functional
|
|
292
277
|
|
|
293
278
|
To run any individual rake tasks with the C extension enabled, just pass C_EXT=true to the task:
|
|
294
279
|
|
|
295
|
-
|
|
280
|
+
$ rake test:unit C_EXT=true
|
|
296
281
|
|
|
297
|
-
If you want to test replica
|
|
282
|
+
If you want to test replica set, you can run the following tests
|
|
298
283
|
individually:
|
|
299
284
|
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
285
|
+
$ rake test:replica_set_count
|
|
286
|
+
$ rake test:replica_set_insert
|
|
287
|
+
$ rake test:replica_set_query
|
|
303
288
|
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
$ rake test:pooled_pair_insert
|
|
307
|
-
|
|
308
|
-
===Shoulda and Mocha
|
|
289
|
+
### Shoulda and Mocha
|
|
309
290
|
|
|
310
291
|
Running the test suite requires shoulda and mocha. You can install them as follows:
|
|
311
292
|
|
|
312
|
-
|
|
313
|
-
|
|
293
|
+
$ gem install shoulda
|
|
294
|
+
$ gem install mocha
|
|
314
295
|
|
|
315
296
|
The tests assume that the Mongo database is running on the default port. You
|
|
316
297
|
can override the default host (localhost) and port (Connection::DEFAULT_PORT) by
|
|
317
298
|
using the environment variables MONGO_RUBY_DRIVER_HOST and
|
|
318
299
|
MONGO_RUBY_DRIVER_PORT.
|
|
319
300
|
|
|
320
|
-
|
|
301
|
+
# Documentation
|
|
321
302
|
|
|
322
|
-
This documentation is available online at http://api.mongodb.org/ruby. You can
|
|
303
|
+
This documentation is available online at [http://api.mongodb.org/ruby](http://api.mongodb.org/ruby). You can
|
|
323
304
|
generate the documentation if you have the source by typing
|
|
324
305
|
|
|
325
|
-
|
|
306
|
+
$ rake ydoc
|
|
326
307
|
|
|
327
308
|
Then open the file +ydoc/index.html+.
|
|
328
309
|
|
|
329
|
-
|
|
330
|
-
= Release Notes
|
|
310
|
+
# Release Notes
|
|
331
311
|
|
|
332
312
|
See HISTORY.
|
|
333
313
|
|
|
334
|
-
|
|
314
|
+
# Credits
|
|
335
315
|
|
|
336
316
|
See CREDITS.
|
|
337
317
|
|
|
338
|
-
|
|
318
|
+
# License
|
|
339
319
|
|
|
340
320
|
Copyright 2008-2010 10gen Inc.
|
|
341
321
|
|