mongo 1.1.1 → 1.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE.txt +1 -13
- data/{README.rdoc → README.md} +113 -151
- data/Rakefile +17 -4
- data/docs/1.0_UPGRADE.md +21 -0
- data/docs/CREDITS.md +119 -0
- data/docs/HISTORY.md +158 -0
- data/docs/TUTORIAL.md +247 -0
- data/lib/mongo.rb +1 -1
- data/lib/mongo/collection.rb +67 -32
- data/lib/mongo/connection.rb +39 -8
- data/lib/mongo/cursor.rb +1 -1
- data/lib/mongo/db.rb +19 -6
- data/lib/mongo/exceptions.rb +3 -0
- data/lib/mongo/gridfs/grid.rb +4 -1
- data/lib/mongo/gridfs/grid_file_system.rb +5 -2
- data/lib/mongo/util/pool.rb +115 -0
- data/mongo.gemspec +4 -5
- data/test/bson/bson_test.rb +3 -1
- data/test/collection_test.rb +30 -0
- data/test/connection_test.rb +65 -52
- data/test/cursor_test.rb +27 -0
- data/test/replica_sets/connect_test.rb +24 -1
- data/test/safe_test.rb +42 -0
- data/test/unit/db_test.rb +2 -0
- data/test/unit/grid_test.rb +49 -0
- data/test/unit/safe_test.rb +125 -0
- metadata +18 -22
- data/HISTORY +0 -215
- data/bin/bson_benchmark.rb +0 -59
- data/bin/fail_if_no_c.rb +0 -11
- data/bin/insert.rb +0 -35
- data/bin/oid.rb +0 -13
- 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/examples/simple.rb
DELETED
@@ -1,24 +0,0 @@
|
|
1
|
-
$:.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
2
|
-
|
3
|
-
require 'mongo'
|
4
|
-
|
5
|
-
include Mongo
|
6
|
-
|
7
|
-
host = ENV['MONGO_RUBY_DRIVER_HOST'] || 'localhost'
|
8
|
-
port = ENV['MONGO_RUBY_DRIVER_PORT'] || Connection::DEFAULT_PORT
|
9
|
-
|
10
|
-
puts "Connecting to #{host}:#{port}"
|
11
|
-
db = Connection.new(host, port).db('ruby-mongo-examples')
|
12
|
-
coll = db.collection('test')
|
13
|
-
|
14
|
-
# Erase all records from collection, if any
|
15
|
-
coll.remove
|
16
|
-
|
17
|
-
# Insert 3 records
|
18
|
-
3.times { |i| coll.insert({'a' => i+1}) }
|
19
|
-
|
20
|
-
puts "There are #{coll.count()} records in the test collection. Here they are:"
|
21
|
-
coll.find().each { |doc| puts doc.inspect }
|
22
|
-
|
23
|
-
# Destroy the collection
|
24
|
-
coll.drop
|
data/examples/strict.rb
DELETED
@@ -1,35 +0,0 @@
|
|
1
|
-
$:.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
2
|
-
|
3
|
-
require 'mongo'
|
4
|
-
|
5
|
-
include Mongo
|
6
|
-
|
7
|
-
host = ENV['MONGO_RUBY_DRIVER_HOST'] || 'localhost'
|
8
|
-
port = ENV['MONGO_RUBY_DRIVER_PORT'] || Connection::DEFAULT_PORT
|
9
|
-
|
10
|
-
puts "Connecting to #{host}:#{port}"
|
11
|
-
db = Connection.new(host, port).db('ruby-mongo-examples')
|
12
|
-
|
13
|
-
db.drop_collection('does-not-exist')
|
14
|
-
db.create_collection('test')
|
15
|
-
|
16
|
-
db.strict = true
|
17
|
-
|
18
|
-
begin
|
19
|
-
# Can't reference collection that does not exist
|
20
|
-
db.collection('does-not-exist')
|
21
|
-
puts "error: expected exception"
|
22
|
-
rescue => ex
|
23
|
-
puts "expected exception: #{ex}"
|
24
|
-
end
|
25
|
-
|
26
|
-
begin
|
27
|
-
# Can't create collection that already exists
|
28
|
-
db.create_collection('test')
|
29
|
-
puts "error: expected exception"
|
30
|
-
rescue => ex
|
31
|
-
puts "expected exception: #{ex}"
|
32
|
-
end
|
33
|
-
|
34
|
-
db.strict = false
|
35
|
-
db.drop_collection('test')
|
data/examples/types.rb
DELETED
@@ -1,36 +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
|
-
# Remove all records, if any
|
16
|
-
coll.remove
|
17
|
-
|
18
|
-
# Insert record with all sorts of values
|
19
|
-
coll.insert('array' => [1, 2, 3],
|
20
|
-
'string' => 'hello',
|
21
|
-
'hash' => {'a' => 1, 'b' => 2},
|
22
|
-
'date' => Time.now, # milliseconds only; microseconds are not stored
|
23
|
-
'oid' => ObjectID.new,
|
24
|
-
'binary' => Binary.new([1, 2, 3]),
|
25
|
-
'int' => 42,
|
26
|
-
'float' => 33.33333,
|
27
|
-
'regex' => /foobar/i,
|
28
|
-
'boolean' => true,
|
29
|
-
'where' => Code.new('this.x == 3'),
|
30
|
-
'dbref' => DBRef.new(coll.name, ObjectID.new),
|
31
|
-
'null' => nil,
|
32
|
-
'symbol' => :zildjian)
|
33
|
-
|
34
|
-
pp coll.find().next_document
|
35
|
-
|
36
|
-
coll.remove
|