mongo 0.1.0 → 0.15

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.
Files changed (89) hide show
  1. data/README.rdoc +268 -71
  2. data/Rakefile +27 -62
  3. data/bin/bson_benchmark.rb +59 -0
  4. data/bin/mongo_console +3 -3
  5. data/bin/run_test_script +19 -0
  6. data/bin/standard_benchmark +109 -0
  7. data/examples/admin.rb +41 -0
  8. data/examples/benchmarks.rb +42 -0
  9. data/examples/blog.rb +76 -0
  10. data/examples/capped.rb +23 -0
  11. data/examples/cursor.rb +47 -0
  12. data/examples/gridfs.rb +87 -0
  13. data/examples/index_test.rb +125 -0
  14. data/examples/info.rb +30 -0
  15. data/examples/queries.rb +69 -0
  16. data/examples/simple.rb +23 -0
  17. data/examples/strict.rb +34 -0
  18. data/examples/types.rb +35 -0
  19. data/lib/mongo.rb +9 -2
  20. data/lib/mongo/admin.rb +65 -68
  21. data/lib/mongo/collection.rb +379 -117
  22. data/lib/mongo/connection.rb +151 -0
  23. data/lib/mongo/cursor.rb +271 -216
  24. data/lib/mongo/db.rb +500 -315
  25. data/lib/mongo/errors.rb +26 -0
  26. data/lib/mongo/gridfs.rb +16 -0
  27. data/lib/mongo/gridfs/chunk.rb +92 -0
  28. data/lib/mongo/gridfs/grid_store.rb +464 -0
  29. data/lib/mongo/message.rb +16 -0
  30. data/lib/mongo/message/get_more_message.rb +24 -13
  31. data/lib/mongo/message/insert_message.rb +29 -11
  32. data/lib/mongo/message/kill_cursors_message.rb +23 -12
  33. data/lib/mongo/message/message.rb +74 -62
  34. data/lib/mongo/message/message_header.rb +35 -24
  35. data/lib/mongo/message/msg_message.rb +21 -9
  36. data/lib/mongo/message/opcodes.rb +26 -15
  37. data/lib/mongo/message/query_message.rb +63 -43
  38. data/lib/mongo/message/remove_message.rb +29 -12
  39. data/lib/mongo/message/update_message.rb +30 -13
  40. data/lib/mongo/query.rb +97 -89
  41. data/lib/mongo/types/binary.rb +25 -21
  42. data/lib/mongo/types/code.rb +30 -0
  43. data/lib/mongo/types/dbref.rb +19 -23
  44. data/lib/mongo/types/objectid.rb +130 -116
  45. data/lib/mongo/types/regexp_of_holding.rb +27 -31
  46. data/lib/mongo/util/bson.rb +273 -160
  47. data/lib/mongo/util/byte_buffer.rb +32 -28
  48. data/lib/mongo/util/ordered_hash.rb +88 -42
  49. data/lib/mongo/util/xml_to_ruby.rb +18 -15
  50. data/mongo-ruby-driver.gemspec +103 -0
  51. data/test/mongo-qa/_common.rb +8 -0
  52. data/test/mongo-qa/admin +26 -0
  53. data/test/mongo-qa/capped +22 -0
  54. data/test/mongo-qa/count1 +18 -0
  55. data/test/mongo-qa/dbs +22 -0
  56. data/test/mongo-qa/find +10 -0
  57. data/test/mongo-qa/find1 +15 -0
  58. data/test/mongo-qa/gridfs_in +16 -0
  59. data/test/mongo-qa/gridfs_out +17 -0
  60. data/test/mongo-qa/indices +49 -0
  61. data/test/mongo-qa/remove +25 -0
  62. data/test/mongo-qa/stress1 +35 -0
  63. data/test/mongo-qa/test1 +11 -0
  64. data/test/mongo-qa/update +18 -0
  65. data/{tests → test}/test_admin.rb +25 -16
  66. data/test/test_bson.rb +268 -0
  67. data/{tests → test}/test_byte_buffer.rb +0 -0
  68. data/test/test_chunk.rb +84 -0
  69. data/test/test_collection.rb +282 -0
  70. data/test/test_connection.rb +101 -0
  71. data/test/test_cursor.rb +321 -0
  72. data/test/test_db.rb +196 -0
  73. data/test/test_db_api.rb +798 -0
  74. data/{tests → test}/test_db_connection.rb +4 -3
  75. data/test/test_grid_store.rb +284 -0
  76. data/{tests → test}/test_message.rb +1 -1
  77. data/test/test_objectid.rb +105 -0
  78. data/{tests → test}/test_ordered_hash.rb +55 -0
  79. data/{tests → test}/test_round_trip.rb +13 -9
  80. data/test/test_threading.rb +37 -0
  81. metadata +74 -32
  82. data/bin/validate +0 -51
  83. data/lib/mongo/mongo.rb +0 -74
  84. data/lib/mongo/types/undefined.rb +0 -31
  85. data/tests/test_bson.rb +0 -135
  86. data/tests/test_cursor.rb +0 -66
  87. data/tests/test_db.rb +0 -51
  88. data/tests/test_db_api.rb +0 -349
  89. data/tests/test_objectid.rb +0 -88
@@ -1,23 +1,15 @@
1
1
  = Introduction
2
2
 
3
- This is a Ruby driver for the 10gen Mongo DB. For more information about
4
- Mongo, see http://www.mongodb.org.
3
+ This is a Ruby driver for MongoDB[http://www.mongodb.org].
5
4
 
6
- Note: this driver is still alpha quality. The API will change, as *may* the
7
- data saved to the database (especially primary key values). Do *_not_* use
8
- this for any production data yet.
9
-
10
- Start by reading the XGen::Mongo::Driver::Mongo and XGen::Mongo::Driver::DB
11
- documentation, then move on to XGen::Mongo::Driver::Collection and
12
- XGen::Mongo::Driver::Cursor.
13
-
14
- A quick code sample:
5
+ Here is a quick code sample. See the files in the "examples" subdirectory for
6
+ many more.
15
7
 
16
8
  require 'mongo'
17
9
 
18
- include XGen::Mongo::Driver
10
+ include Mongo
19
11
 
20
- db = Mongo.new('localhost').db('sample-db')
12
+ db = Connection.new('localhost').db('sample-db')
21
13
  coll = db.collection('test')
22
14
 
23
15
  coll.clear
@@ -25,32 +17,130 @@ A quick code sample:
25
17
  puts "There are #{coll.count()} records. Here they are:"
26
18
  coll.find().each { |doc| puts doc.inspect }
27
19
 
20
+ This driver also includes an implementation of a GridStore class, a Ruby
21
+ interface to Mongo's GridFS storage.
22
+
28
23
  = Installation
29
24
 
30
- Install the "mongo" gem by typing
25
+ The driver's gems are hosted on Gemcutter[http://gemcutter.org]. If you haven't
26
+ installed a gem from Gemcutter before you'll need to set up Gemcutter first
27
+
28
+ $ gem install gemcutter
29
+ $ gem tumble
30
+
31
+ If (or once) you have Gemcutter setup, install the "mongo" gem by typing
31
32
 
32
- $ sudo gem install mongo
33
+ $ gem install mongo
33
34
 
34
- The source code is available at http://github.com/jimm/mongo-ruby-driver. You
35
- can either clone the git repository or download a tarball or zip file. Once
36
- you have the source, you can use it from wherever you downloaded it or you can
37
- install it as a gem from the source by typing
35
+ === From the GitHub source
36
+
37
+ The source code is available at http://github.com/mongodb/mongo-ruby-driver.
38
+ You can either clone the git repository or download a tarball or zip file.
39
+ Once you have the source, you can use it from wherever you downloaded it or
40
+ you can install it as a gem from the source by typing
38
41
 
39
42
  $ rake gem:install
40
43
 
44
+ === Optional C Extension
45
+
46
+ There is a separate gem containing optional C extensions that will increase the
47
+ performance of the driver. To use the optional extensions just install the gem
48
+ by typing
49
+
50
+ $ gem install mongo_ext
51
+
52
+ To install from source type this instead
53
+
54
+ $ rake gem:install_extensions
41
55
 
42
- = Demo
56
+ That's all there is to it!
43
57
 
44
- You can see and run the examples if you've downloaded the source. Mongo must
45
- be running, of course.
58
+ = Examples
46
59
 
60
+ There are many examples in the "examples" subdirectory. Samples include using
61
+ the driver and using the GridFS class GridStore. Mongo must be running for
62
+ these examples to work, of course.
63
+
64
+ Here's how to start mongo and run the "simple.rb" example:
65
+
66
+ $ cd path/to/mongo
67
+ $ ./mongod run
68
+ ... then in another window ...
69
+ $ cd path/to/mongo-ruby-driver
47
70
  $ ruby examples/simple.rb
48
71
 
49
- See also the test code, especially tests/test_db_api.rb.
72
+ See also the test code, especially test/test_db_api.rb.
73
+
74
+ = The Driver
75
+
76
+ Here is some simple example code:
77
+
78
+ require 'rubygems' # not required for Ruby 1.9
79
+ require 'mongo'
80
+
81
+ include Mongo
82
+ db = Connection.new.db('my-db-name')
83
+ things = db.collection('things')
84
+
85
+ things.clear
86
+ things.insert('a' => 42)
87
+ things.insert('a' => 99, 'b' => Time.now)
88
+ puts things.count # => 2
89
+ puts things.find('a' => 42).next_object.inspect # {"a"=>42}
90
+
91
+
92
+ = GridStore
93
+
94
+ The GridStore class is a Ruby implementation of Mongo's GridFS file storage
95
+ system. An instance of GridStore is like an IO object. See the rdocs for
96
+ details, and see examples/gridfs.rb for code that uses many of the GridStore
97
+ features like metadata, content type, rewind/seek/tell, etc.
98
+
99
+ Note that the GridStore class is not automatically required when you require
100
+ 'mongo'. You need to require 'mongo/gridfs'.
101
+
102
+ Example code:
103
+
104
+ GridStore.open(database, 'filename', 'w') { |f|
105
+ f.puts "Hello, world!"
106
+ }
107
+ GridStore.open(database, 'filename, 'r') { |f|
108
+ puts f.read # => Hello, world!\n
109
+ }
110
+ GridStore.open(database, 'filename', 'w+') { |f|
111
+ f.puts "But wait, there's more!"
112
+ }
113
+ GridStore.open(database, 'filename, 'r') { |f|
114
+ puts f.read # => Hello, world!\nBut wait, there's more!\n
115
+ }
116
+
50
117
 
51
118
 
52
119
  = Notes
53
120
 
121
+ == Using with Phusion Passenger
122
+
123
+ When passenger is in smart spawning mode you need to be sure that child
124
+ processes forked by passenger will create a new connection to the database.
125
+ activerecord-mongo-adapter handles this for you, so if you are using that
126
+ you shouldn't need to worry about it. Otherwise you'll either need to use
127
+ conservative spawning[http://www.modrails.org/documentation/Users%20guide.html#RailsSpawnMethod]
128
+ or handle reconnecting when passenger forks a new process:
129
+
130
+ if defined?(PhusionPassenger)
131
+ PhusionPassenger.on_event(:starting_worker_process) do |forked|
132
+ if forked
133
+ # Call db.connect_to_master to reconnect here
134
+ end
135
+ end
136
+ end
137
+
138
+ The above code should be put in _environment.rb_ or an initialization
139
+ script.
140
+
141
+ See this thread[http://groups.google.com/group/mongodb-user/browse_thread/thread/f31e2d23de38136a]
142
+ for more details on this issue.
143
+
54
144
  == String Encoding
55
145
 
56
146
  The BSON ("Binary JSON") format used to communicate with Mongo requires that
@@ -62,7 +152,101 @@ read from Mongo will have their character encodings set to UTF-8.
62
152
 
63
153
  When used with Ruby 1.8, the bytes in each string are written to and read from
64
154
  Mongo as-is. If the string is ASCII all is well, because ASCII is a subset of
65
- UTF-8. If the string is not ASCII then it may not be a well-formed UTF-8 string.
155
+ UTF-8. If the string is not ASCII then it may not be a well-formed UTF-8
156
+ string.
157
+
158
+ == Primary Keys
159
+
160
+ The field _id is a primary key. It is treated specially by the database, and
161
+ its use makes many operations more efficient. The value of an _id may be of
162
+ any type. The database itself inserts an _id value if none is specified when
163
+ a record is inserted.
164
+
165
+ === Primary Key Factories
166
+
167
+ A primary key factory is a class you supply to a DB object that knows how to
168
+ generate _id values. If you want to control _id values or even their types,
169
+ using a PK factory lets you do so.
170
+
171
+ You can tell the Ruby Mongo driver how to create primary keys by passing in
172
+ the :pk option to the Connection#db method.
173
+
174
+ include Mongo
175
+ db = Connection.new.db('dbname', :pk => MyPKFactory.new)
176
+
177
+ A primary key factory object must respond to :create_pk, which should take a
178
+ hash and return a hash which merges the original hash with any primary key
179
+ fields the factory wishes to inject. NOTE: if the object already has a primary
180
+ key, the factory should not inject a new key; this means that the object is
181
+ being used in a repsert but it already exists. The idea here is that whenever
182
+ a record is inserted, the :pk object's +create_pk+ method will be called and
183
+ the new hash returned will be inserted.
184
+
185
+ Here is a sample primary key factory, taken from the tests:
186
+
187
+ class TestPKFactory
188
+ def create_pk(row)
189
+ row['_id'] ||= Mongo::ObjectID.new
190
+ row
191
+ end
192
+ end
193
+
194
+ Here's a slightly more sophisticated one that handles both symbol and string
195
+ keys. This is the PKFactory that comes with the MongoRecord code (an
196
+ ActiveRecord-like framework for non-Rails apps) and the AR Mongo adapter code
197
+ (for Rails):
198
+
199
+ class PKFactory
200
+ def create_pk(row)
201
+ return row if row[:_id]
202
+ row.delete(:_id) # in case it exists but the value is nil
203
+ row['_id'] ||= Mongo::ObjectID.new
204
+ row
205
+ end
206
+ end
207
+
208
+ A database's PK factory object may be set either when a DB object is created
209
+ or immediately after you obtain it, but only once. The only reason it is
210
+ changeable at all is so that libraries such as MongoRecord that use this
211
+ driver can set the PK factory after obtaining the database but before using it
212
+ for the first time.
213
+
214
+ == The DB Class
215
+
216
+ === Primary Key factories
217
+
218
+ See the section on "Primary Keys" above.
219
+
220
+ === Strict mode
221
+
222
+ Each database has an optional strict mode. If strict mode is on, then asking
223
+ for a collection that does not exist will raise an error, as will asking to
224
+ create a collection that already exists. Note that both these operations are
225
+ completely harmless; strict mode is a programmer convenience only.
226
+
227
+ To turn on strict mode, either pass in :strict => true when obtaining a DB
228
+ object or call the :strict= method:
229
+
230
+ db = Connection.new.db('dbname', :strict => true)
231
+ # I'm feeling lax
232
+ db.strict = false
233
+ # No, I'm not!
234
+ db.strict = true
235
+
236
+ The method DB#strict? returns the current value of that flag.
237
+
238
+ == Cursors
239
+
240
+ Random cursor fun facts:
241
+
242
+ - Cursors are enumerable.
243
+
244
+ - The query doesn't get run until you actually attempt to retrieve data from a
245
+ cursor.
246
+
247
+ - Cursors have a to_a method.
248
+
249
+
66
250
 
67
251
  = Testing
68
252
 
@@ -70,21 +254,23 @@ If you have the source code, you can run the tests.
70
254
 
71
255
  $ rake test
72
256
 
73
- The tests assume that the Mongo database is running on the default port.
257
+ The tests assume that the Mongo database is running on the default port. You
258
+ can override the default host (localhost) and port (Connection::DEFAULT_PORT) by
259
+ using the environment variables MONGO_RUBY_DRIVER_HOST and
260
+ MONGO_RUBY_DRIVER_PORT.
74
261
 
75
262
  The project mongo-qa (http://github.com/mongodb/mongo-qa) contains many more
76
263
  Mongo driver tests that are language independent. To run thoses tests as part
77
- of the "rake test" task, run
264
+ of the "rake test" task, download the code "next to" this directory. So, after
265
+ installing the mongo-qa code you would have these two directories next to each
266
+ other:
78
267
 
79
- $ rake mongo_qa
268
+ $ ls
269
+ mongo-qa
270
+ mongo-ruby-driver
80
271
  $ rake test
81
272
 
82
- The mongo_qa task uses the "git clone" command to make a copy of that project
83
- in a directory named mongo-qa. If the directory already exists, then the
84
- mongo_qa task uses "git pull" to updated the code that's there. The Ruby
85
- driver tests will then use some of the data files from that project when it
86
- runs BSON tests. You can delete this directory at any time if you don't want
87
- to run those tests any more.
273
+ The tests run just fine if the mongo-qa directory is not there.
88
274
 
89
275
  Additionally, the script bin/validate is used by the mongo-qa project's
90
276
  validator script.
@@ -92,7 +278,7 @@ validator script.
92
278
 
93
279
  = Documentation
94
280
 
95
- This documentation is available online at http://mongo.rubyforge.org. You can
281
+ This documentation is available online at http://api.mongodb.org/ruby. You can
96
282
  generate the documentation if you have the source by typing
97
283
 
98
284
  $ rake rdoc
@@ -104,59 +290,70 @@ Then open the file html/index.html.
104
290
 
105
291
  See the git log comments.
106
292
 
293
+ = Credits
107
294
 
108
- = To Do
295
+ Adrian Madrid, aemadrid@gmail.com
296
+ * bin/mongo_console
297
+ * examples/benchmarks.rb
298
+ * examples/irb.rb
299
+ * Modifications to examples/simple.rb
300
+ * Found plenty of bugs and missing features.
301
+ * Ruby 1.9 support.
302
+ * Gem support.
303
+ * Many other code suggestions and improvements.
109
304
 
110
- * Add group_by. Need to figure out how we are going to send functions. The
111
- current thinking is that Mongo will allow a subset of JavaScript (which we
112
- would have to send as a string), but this is still under discussion.
305
+ Aman Gupta, aman@tmm1.net
306
+ * Collection#save
113
307
 
114
- * Tests for update and repsert.
308
+ Jon Crosby, jon@joncrosby.me
309
+ * Some code clean-up
115
310
 
116
- * Add a way to specify a collection of databases on startup (a simple array of
117
- IP address/port numbers, perhaps, or a hash or something). The driver would
118
- then find the master and, on each subsequent command, ask that machine if it
119
- is the master before proceeding.
311
+ John Nunemaker, http://railstips.org
312
+ * Collection#create_index takes symbols as well as strings
313
+ * Fix for Collection#save
120
314
 
121
- * Introduce optional per-database and per-collection PKInjector.
315
+ David James, djames@sunlightfoundation.com
316
+ * Fix dates to return as UTC
122
317
 
123
- * More tests.
318
+ Paul Dlug, paul.dlug@gmail.com
319
+ * Generate _id on the client side if not provided
320
+ * Collection#insert and Collection#save return _id
124
321
 
125
- == Optimizations
322
+ Durran Jordan and Les Hill, durran@gmail.com
323
+ * DB#collections
126
324
 
127
- * Only update message sizes once, not after every write of a value. This will
128
- require an explicit call to update_message_length in each message subclass.
325
+ Cyril Mougel, cyril.mougel@gmail.com
326
+ * Initial logging support
129
327
 
130
- * ensure_index commands should be cached to prevent excessive communication
131
- with the database. (Or, the driver user should be informed that ensure_index
132
- is not a lightweight operation for the particular driver.)
328
+ Jack Chen, chendo on github
329
+ * Test case + fix for deserializing pre-epoch Time instances
133
330
 
331
+ Kyle Banker, banker on github
332
+ * #limit and #skip methods for Cursor instances
134
333
 
135
- = Credits
334
+ Michael Bernstein, mrb on github
335
+ * #sort method for Cursor instances
136
336
 
137
- Adrian Madrid, aemadrid@gmail.com
138
- * bin/mongo_console
139
- * examples/benchmarks.rb
140
- * examples/irb.rb
141
- * Modifications to examples/simple.rb
142
- * Found plenty of bugs and missing features.
143
- * Ruby 1.9 support.
144
- * Gem support.
145
- * Many other code suggestions and improvements.
337
+ Paulo Ahahgon, pahagon on github
338
+ * removed hard limit
339
+
340
+ Les Hill, leshill on github
341
+ * OrderedHash#each returns self
146
342
 
147
343
 
148
344
  = License
149
345
 
150
- Copyright (C) 2008-2009 10gen Inc.
346
+ Copyright 2008-2009 10gen Inc.
347
+
348
+ Licensed under the Apache License, Version 2.0 (the "License");
349
+ you may not use this file except in compliance with the License.
350
+ You may obtain a copy of the License at
151
351
 
152
- This program is free software: you can redistribute it and/or modify it under
153
- the terms of the GNU Affero General Public License, version 3, as published by
154
- the Free Software Foundation.
352
+ http://www.apache.org/licenses/LICENSE-2.0
155
353
 
156
- This program is distributed in the hope that it will be useful, but WITHOUT
157
- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
158
- FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
159
- details.
354
+ Unless required by applicable law or agreed to in writing, software
355
+ distributed under the License is distributed on an "AS IS" BASIS,
356
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
357
+ See the License for the specific language governing permissions and
358
+ limitations under the License.
160
359
 
161
- See http://www.gnu.org/licenses for a copy of the GNU Affero General Public
162
- License.
data/Rakefile CHANGED
@@ -4,59 +4,27 @@ require 'fileutils'
4
4
  require 'rake'
5
5
  require 'rake/testtask'
6
6
  require 'rake/gempackagetask'
7
- require 'rake/contrib/rubyforgepublisher'
8
-
9
- GEM = "mongo"
10
- GEM_VERSION = '0.1.0'
11
- SUMMARY = 'Simple pure-Ruby driver for the 10gen Mongo DB'
12
- DESCRIPTION = 'This is a simple pure-Ruby driver for the 10gen Mongo DB. For more information about Mongo, see http://www.mongodb.org.'
13
- AUTHOR = 'Jim Menard'
14
- EMAIL = 'jimm@io.com'
15
- HOMEPAGE = 'http://www.mongodb.org'
16
- RUBYFORGE_USER = 'jimm'
17
-
18
- spec = Gem::Specification.new do |s|
19
- s.name = GEM
20
- s.version = GEM_VERSION
21
- s.platform = Gem::Platform::RUBY
22
- s.summary = SUMMARY
23
- s.description = DESCRIPTION
24
-
25
- s.require_paths = ['lib']
26
-
27
- s.files = FileList['bin/*', 'lib/**/*.rb', 'tests/**/*.rb', '[A-Z]*'].to_a
28
-
29
- s.bindir = 'bin'
30
- s.executables = %w( mongo_console )
31
- s.has_rdoc = true
32
-
33
- s.author = AUTHOR
34
- s.email = EMAIL
35
- s.homepage = HOMEPAGE
36
-
37
- s.rubyforge_project = GEM # GitHub bug, gem isn't being build when this miss
7
+ begin
8
+ require 'rake/contrib/rubyforgepublisher'
9
+ rescue LoadError
38
10
  end
11
+ require 'rbconfig'
12
+ include Config
13
+
14
+ gem_command = "gem"
15
+ gem_command = "gem1.9" if $0.match(/1\.9$/) # use gem1.9 if we used rake1.9
39
16
 
40
17
  # NOTE: some of the tests assume Mongo is running
41
18
  Rake::TestTask.new do |t|
42
- t.test_files = FileList['tests/test*.rb']
43
- end
44
-
45
- desc "Clone or pull (update) the mongo-qa project used for testing"
46
- task :mongo_qa do
47
- if File.exist?('mongo-qa')
48
- Dir.chdir('mongo-qa') do
49
- system('git pull')
50
- end
51
- else
52
- system('git clone git://github.com/mongodb/mongo-qa.git')
53
- end
19
+ t.test_files = FileList['test/test*.rb']
54
20
  end
55
21
 
56
22
  desc "Generate documentation"
57
23
  task :rdoc do
24
+ version = eval(File.read("mongo-ruby-driver.gemspec")).version
25
+ out = File.join('html', version.to_s)
58
26
  FileUtils.rm_rf('html')
59
- system "rdoc --main README.rdoc --op html --inline-source --quiet README.rdoc `find lib -name '*.rb'`"
27
+ system "rdoc --main README.rdoc --op #{out} --inline-source --quiet README.rdoc `find lib -name '*.rb'`"
60
28
  end
61
29
 
62
30
  desc "Publish documentation to mongo.rubyforge.org"
@@ -65,27 +33,24 @@ task :publish => [:rdoc] do
65
33
  Rake::RubyForgePublisher.new(GEM, RUBYFORGE_USER).upload
66
34
  end
67
35
 
68
- namespace :gem do
69
-
70
- Rake::GemPackageTask.new(spec) do |pkg|
71
- pkg.gem_spec = spec
72
- end
36
+ namespace :gem do
73
37
 
74
38
  desc "Install the gem locally"
75
- task :install => [:package] do
76
- sh %{sudo gem install pkg/#{GEM}-#{GEM_VERSION}}
39
+ task :install do
40
+ sh <<EOS
41
+ #{gem_command} build mongo-ruby-driver.gemspec &&
42
+ sudo #{gem_command} install mongo-*.gem &&
43
+ rm mongo-*.gem
44
+ EOS
77
45
  end
78
-
79
- desc "Install the gem locally with ruby 1.9"
80
- task :'install19' => [:package] do
81
- sh %{sudo gem19 install pkg/#{GEM}-#{GEM_VERSION}}
82
- end
83
-
84
- desc "Create a gemspec file"
85
- task :make_spec do
86
- File.open("#{GEM}.gemspec", "w") do |file|
87
- file.puts spec.to_ruby
88
- end
46
+
47
+ desc "Install the optional c extensions"
48
+ task :install_extensions do
49
+ sh <<EOS
50
+ #{gem_command} build mongo-extensions.gemspec &&
51
+ sudo #{gem_command} install mongo_ext-*.gem &&
52
+ rm mongo_ext-*.gem
53
+ EOS
89
54
  end
90
55
 
91
56
  end