API CHANGE: moving XGen::Mongo::Driver and XGen::Mongo to Mongo and XGen::Mongo::GridFS to GridFS

This commit is contained in:
Mike Dirolf 2009-08-20 10:50:48 -04:00
parent 040ba7c9c2
commit e65dd99667
63 changed files with 2291 additions and 2423 deletions

View File

@ -7,9 +7,9 @@ many more.
require 'mongo' require 'mongo'
include XGen::Mongo::Driver include Mongo
db = Mongo.new('localhost').db('sample-db') db = Mongo::Mongo.new('localhost').db('sample-db')
coll = db.collection('test') coll = db.collection('test')
coll.clear coll.clear
@ -79,8 +79,8 @@ Here is some simple example code:
require 'rubygems' # not required for Ruby 1.9 require 'rubygems' # not required for Ruby 1.9
require 'mongo' require 'mongo'
include XGen::Mongo::Driver include Mongo
db = Mongo.new.db('my-db-name') db = Mongo::Mongo.new.db('my-db-name')
things = db.collection('things') things = db.collection('things')
things.clear things.clear
@ -149,8 +149,8 @@ using a PK factory lets you do so.
You can tell the Ruby Mongo driver how to create primary keys by passing in You can tell the Ruby Mongo driver how to create primary keys by passing in
the :pk option to the Mongo#db method. the :pk option to the Mongo#db method.
include XGen::Mongo::Driver include Mongo
db = Mongo.new.db('dbname', :pk => MyPKFactory.new) db = Mongo::Mongo.new.db('dbname', :pk => MyPKFactory.new)
A primary key factory object must respond to :create_pk, which should take a A primary key factory object must respond to :create_pk, which should take a
hash and return a hash which merges the original hash with any primary key hash and return a hash which merges the original hash with any primary key
@ -164,7 +164,7 @@ Here is a sample primary key factory, taken from the tests:
class TestPKFactory class TestPKFactory
def create_pk(row) def create_pk(row)
row['_id'] ||= XGen::Mongo::Driver::ObjectID.new row['_id'] ||= Mongo::ObjectID.new
row row
end end
end end
@ -178,7 +178,7 @@ ActiveRecord-like framework for non-Rails apps) and the AR Mongo adapter code
def create_pk(row) def create_pk(row)
return row if row[:_id] return row if row[:_id]
row.delete(:_id) # in case it exists but the value is nil row.delete(:_id) # in case it exists but the value is nil
row['_id'] ||= XGen::Mongo::Driver::ObjectID.new row['_id'] ||= Mongo::ObjectID.new
row row
end end
end end
@ -205,7 +205,7 @@ completely harmless; strict mode is a programmer convenience only.
To turn on strict mode, either pass in :strict => true when obtaining a DB To turn on strict mode, either pass in :strict => true when obtaining a DB
object or call the :strict= method: object or call the :strict= method:
db = XGen::Mongo::Driver::Mongo.new.db('dbname', :strict => true) db = Mongo::Mongo.new.db('dbname', :strict => true)
# I'm feeling lax # I'm feeling lax
db.strict = false db.strict = false
# No, I'm not! # No, I'm not!

View File

@ -3,7 +3,7 @@
$LOAD_PATH[0,0] = File.join(File.dirname(__FILE__), '..', 'lib') $LOAD_PATH[0,0] = File.join(File.dirname(__FILE__), '..', 'lib')
require 'mongo' require 'mongo'
include XGen::Mongo::Driver include Mongo
TRIALS = 100000 TRIALS = 100000

View File

@ -7,14 +7,14 @@ require 'irb'
$LOAD_PATH[0,0] = File.join(File.dirname(__FILE__), '..', 'lib') $LOAD_PATH[0,0] = File.join(File.dirname(__FILE__), '..', 'lib')
require 'mongo' require 'mongo'
include XGen::Mongo::Driver include Mongo
host = org_argv[0] || ENV['MONGO_RUBY_DRIVER_HOST'] || 'localhost' host = org_argv[0] || ENV['MONGO_RUBY_DRIVER_HOST'] || 'localhost'
port = org_argv[1] || ENV['MONGO_RUBY_DRIVER_PORT'] || XGen::Mongo::Driver::Mongo::DEFAULT_PORT port = org_argv[1] || ENV['MONGO_RUBY_DRIVER_PORT'] || Mongo::Mongo::DEFAULT_PORT
dbnm = org_argv[2] || ENV['MONGO_RUBY_DRIVER_DB'] || 'ruby-mongo-console' dbnm = org_argv[2] || ENV['MONGO_RUBY_DRIVER_DB'] || 'ruby-mongo-console'
puts "Connecting to #{host}:#{port} (CONN) on with database #{dbnm} (DB)" puts "Connecting to #{host}:#{port} (CONN) on with database #{dbnm} (DB)"
CONN = Mongo.new(host, port) CONN = Mongo::Mongo.new(host, port)
DB = CONN.db(dbnm) DB = CONN.db(dbnm)
puts "Starting IRB session..." puts "Starting IRB session..."

View File

@ -5,7 +5,7 @@
$LOAD_PATH[0,0] = File.join(File.dirname(__FILE__), '..', 'lib') $LOAD_PATH[0,0] = File.join(File.dirname(__FILE__), '..', 'lib')
require 'mongo' require 'mongo'
include XGen::Mongo::Driver include Mongo
TRIALS = 2 TRIALS = 2
PER_TRIAL = 5000 PER_TRIAL = 5000
@ -50,9 +50,9 @@ def benchmark(str, proc, n, db, coll_name, object, setup=nil)
end end
host = ENV['MONGO_RUBY_DRIVER_HOST'] || 'localhost' host = ENV['MONGO_RUBY_DRIVER_HOST'] || 'localhost'
port = ENV['MONGO_RUBY_DRIVER_PORT'] || XGen::Mongo::Driver::Mongo::DEFAULT_PORT port = ENV['MONGO_RUBY_DRIVER_PORT'] || Mongo::Mongo::DEFAULT_PORT
connection = Mongo.new(host, port) connection = Mongo::Mongo.new(host, port)
connection.drop_database("benchmark") connection.drop_database("benchmark")
db = connection.db('benchmark') db = connection.db('benchmark')

View File

@ -2,13 +2,13 @@ $LOAD_PATH[0,0] = File.join(File.dirname(__FILE__), '..', 'lib')
require 'mongo' require 'mongo'
require 'pp' require 'pp'
include XGen::Mongo::Driver include Mongo
host = ENV['MONGO_RUBY_DRIVER_HOST'] || 'localhost' host = ENV['MONGO_RUBY_DRIVER_HOST'] || 'localhost'
port = ENV['MONGO_RUBY_DRIVER_PORT'] || XGen::Mongo::Driver::Mongo::DEFAULT_PORT port = ENV['MONGO_RUBY_DRIVER_PORT'] || Mongo::Mongo::DEFAULT_PORT
puts "Connecting to #{host}:#{port}" puts "Connecting to #{host}:#{port}"
db = Mongo.new(host, port).db('ruby-mongo-examples') db = Mongo::Mongo.new(host, port).db('ruby-mongo-examples')
coll = db.create_collection('test') coll = db.create_collection('test')
# Erase all records from collection, if any # Erase all records from collection, if any

View File

@ -4,10 +4,10 @@ $LOAD_PATH[0,0] = File.join(File.dirname(__FILE__), '..', 'lib')
require 'mongo' require 'mongo'
host = ENV['MONGO_RUBY_DRIVER_HOST'] || 'localhost' host = ENV['MONGO_RUBY_DRIVER_HOST'] || 'localhost'
port = ENV['MONGO_RUBY_DRIVER_PORT'] || XGen::Mongo::Driver::Mongo::DEFAULT_PORT port = ENV['MONGO_RUBY_DRIVER_PORT'] || Mongo::Mongo::DEFAULT_PORT
puts "Connecting to #{host}:#{port}" puts "Connecting to #{host}:#{port}"
db = XGen::Mongo::Driver::Mongo.new(host, port).db('ruby-mongo-examples') db = Mongo::Mongo.new(host, port).db('ruby-mongo-examples')
coll = db.collection('test') coll = db.collection('test')
coll.clear coll.clear

View File

@ -9,13 +9,13 @@ end
$LOAD_PATH[0,0] = File.join(File.dirname(__FILE__), '..', 'lib') $LOAD_PATH[0,0] = File.join(File.dirname(__FILE__), '..', 'lib')
require 'mongo' require 'mongo'
include XGen::Mongo::Driver include Mongo
host = ENV['MONGO_RUBY_DRIVER_HOST'] || 'localhost' host = ENV['MONGO_RUBY_DRIVER_HOST'] || 'localhost'
port = ENV['MONGO_RUBY_DRIVER_PORT'] || XGen::Mongo::Driver::Mongo::DEFAULT_PORT port = ENV['MONGO_RUBY_DRIVER_PORT'] || Mongo::Mongo::DEFAULT_PORT
puts ">> Connecting to #{host}:#{port}" puts ">> Connecting to #{host}:#{port}"
DB = Mongo.new(host, port).db('ruby-mongo-blog') DB = Mongo::Mongo.new(host, port).db('ruby-mongo-blog')
LINE_SIZE = 120 LINE_SIZE = 120
puts "=" * LINE_SIZE puts "=" * LINE_SIZE

View File

@ -1,13 +1,13 @@
$LOAD_PATH[0,0] = File.join(File.dirname(__FILE__), '..', 'lib') $LOAD_PATH[0,0] = File.join(File.dirname(__FILE__), '..', 'lib')
require 'mongo' require 'mongo'
include XGen::Mongo::Driver include Mongo
host = ENV['MONGO_RUBY_DRIVER_HOST'] || 'localhost' host = ENV['MONGO_RUBY_DRIVER_HOST'] || 'localhost'
port = ENV['MONGO_RUBY_DRIVER_PORT'] || XGen::Mongo::Driver::Mongo::DEFAULT_PORT port = ENV['MONGO_RUBY_DRIVER_PORT'] || Mongo::Mongo::DEFAULT_PORT
puts "Connecting to #{host}:#{port}" puts "Connecting to #{host}:#{port}"
db = Mongo.new(host, port).db('ruby-mongo-examples') db = Mongo::Mongo.new(host, port).db('ruby-mongo-examples')
db.drop_collection('test') db.drop_collection('test')
# A capped collection has a max size and optionally a max number of records. # A capped collection has a max size and optionally a max number of records.

View File

@ -2,13 +2,13 @@ $LOAD_PATH[0,0] = File.join(File.dirname(__FILE__), '..', 'lib')
require 'mongo' require 'mongo'
require 'pp' require 'pp'
include XGen::Mongo::Driver include Mongo
host = ENV['MONGO_RUBY_DRIVER_HOST'] || 'localhost' host = ENV['MONGO_RUBY_DRIVER_HOST'] || 'localhost'
port = ENV['MONGO_RUBY_DRIVER_PORT'] || XGen::Mongo::Driver::Mongo::DEFAULT_PORT port = ENV['MONGO_RUBY_DRIVER_PORT'] || Mongo::Mongo::DEFAULT_PORT
puts "Connecting to #{host}:#{port}" puts "Connecting to #{host}:#{port}"
db = Mongo.new(host, port).db('ruby-mongo-examples') db = Mongo::Mongo.new(host, port).db('ruby-mongo-examples')
coll = db.collection('test') coll = db.collection('test')
# Erase all records from collection, if any # Erase all records from collection, if any

View File

@ -2,14 +2,14 @@ $LOAD_PATH[0,0] = File.join(File.dirname(__FILE__), '..', 'lib')
require 'mongo' require 'mongo'
require 'mongo/gridfs' require 'mongo/gridfs'
include XGen::Mongo::Driver include Mongo
include XGen::Mongo::GridFS include GridFS
host = ENV['MONGO_RUBY_DRIVER_HOST'] || 'localhost' host = ENV['MONGO_RUBY_DRIVER_HOST'] || 'localhost'
port = ENV['MONGO_RUBY_DRIVER_PORT'] || XGen::Mongo::Driver::Mongo::DEFAULT_PORT port = ENV['MONGO_RUBY_DRIVER_PORT'] || Mongo::Mongo::DEFAULT_PORT
puts "Connecting to #{host}:#{port}" puts "Connecting to #{host}:#{port}"
db = Mongo.new(host, port).db('ruby-mongo-examples') db = Mongo::Mongo.new(host, port).db('ruby-mongo-examples')
def dump(db, fname) def dump(db, fname)
GridStore.open(db, fname, 'r') { |f| puts f.read } GridStore.open(db, fname, 'r') { |f| puts f.read }

View File

@ -7,13 +7,13 @@ end
$LOAD_PATH[0,0] = File.join(File.dirname(__FILE__), '..', 'lib') $LOAD_PATH[0,0] = File.join(File.dirname(__FILE__), '..', 'lib')
require 'mongo' require 'mongo'
include XGen::Mongo::Driver include Mongo
host = ENV['MONGO_RUBY_DRIVER_HOST'] || 'localhost' host = ENV['MONGO_RUBY_DRIVER_HOST'] || 'localhost'
port = ENV['MONGO_RUBY_DRIVER_PORT'] || XGen::Mongo::Driver::Mongo::DEFAULT_PORT port = ENV['MONGO_RUBY_DRIVER_PORT'] || Mongo::Mongo::DEFAULT_PORT
puts ">> Connecting to #{host}:#{port}" puts ">> Connecting to #{host}:#{port}"
db = Mongo.new(host, port).db('ruby-mongo-index_test') db = Mongo::Mongo.new(host, port).db('ruby-mongo-index_test')
puts ">> Dropping collection test" puts ">> Dropping collection test"
begin begin
@ -76,7 +76,7 @@ end
puts ">> Dropping index" puts ">> Dropping index"
begin begin
res = coll.drop_index "all" res = coll.drop_index "all_1"
puts "dropped : #{res.inspect}" puts "dropped : #{res.inspect}"
rescue => e rescue => e
puts "Error: #{e.errmsg}" puts "Error: #{e.errmsg}"

View File

@ -1,13 +1,13 @@
$LOAD_PATH[0,0] = File.join(File.dirname(__FILE__), '..', 'lib') $LOAD_PATH[0,0] = File.join(File.dirname(__FILE__), '..', 'lib')
require 'mongo' require 'mongo'
include XGen::Mongo::Driver include Mongo
host = ENV['MONGO_RUBY_DRIVER_HOST'] || 'localhost' host = ENV['MONGO_RUBY_DRIVER_HOST'] || 'localhost'
port = ENV['MONGO_RUBY_DRIVER_PORT'] || XGen::Mongo::Driver::Mongo::DEFAULT_PORT port = ENV['MONGO_RUBY_DRIVER_PORT'] || Mongo::Mongo::DEFAULT_PORT
puts "Connecting to #{host}:#{port}" puts "Connecting to #{host}:#{port}"
db = Mongo.new(host, port).db('ruby-mongo-examples') db = Mongo::Mongo.new(host, port).db('ruby-mongo-examples')
coll = db.collection('test') coll = db.collection('test')
# Erase all records from collection, if any # Erase all records from collection, if any

View File

@ -2,13 +2,13 @@ $LOAD_PATH[0,0] = File.join(File.dirname(__FILE__), '..', 'lib')
require 'mongo' require 'mongo'
require 'pp' require 'pp'
include XGen::Mongo::Driver include Mongo
host = ENV['MONGO_RUBY_DRIVER_HOST'] || 'localhost' host = ENV['MONGO_RUBY_DRIVER_HOST'] || 'localhost'
port = ENV['MONGO_RUBY_DRIVER_PORT'] || XGen::Mongo::Driver::Mongo::DEFAULT_PORT port = ENV['MONGO_RUBY_DRIVER_PORT'] || Mongo::Mongo::DEFAULT_PORT
puts "Connecting to #{host}:#{port}" puts "Connecting to #{host}:#{port}"
db = Mongo.new(host, port).db('ruby-mongo-examples') db = Mongo::Mongo.new(host, port).db('ruby-mongo-examples')
coll = db.collection('test') coll = db.collection('test')
# Remove all records, if any # Remove all records, if any

View File

@ -1,13 +1,13 @@
$LOAD_PATH[0,0] = File.join(File.dirname(__FILE__), '..', 'lib') $LOAD_PATH[0,0] = File.join(File.dirname(__FILE__), '..', 'lib')
require 'mongo' require 'mongo'
include XGen::Mongo::Driver include Mongo
host = ENV['MONGO_RUBY_DRIVER_HOST'] || 'localhost' host = ENV['MONGO_RUBY_DRIVER_HOST'] || 'localhost'
port = ENV['MONGO_RUBY_DRIVER_PORT'] || XGen::Mongo::Driver::Mongo::DEFAULT_PORT port = ENV['MONGO_RUBY_DRIVER_PORT'] || Mongo::Mongo::DEFAULT_PORT
puts "Connecting to #{host}:#{port}" puts "Connecting to #{host}:#{port}"
db = Mongo.new(host, port).db('ruby-mongo-examples') db = Mongo::Mongo.new(host, port).db('ruby-mongo-examples')
coll = db.collection('test') coll = db.collection('test')
# Erase all records from collection, if any # Erase all records from collection, if any

View File

@ -1,13 +1,13 @@
$LOAD_PATH[0,0] = File.join(File.dirname(__FILE__), '..', 'lib') $LOAD_PATH[0,0] = File.join(File.dirname(__FILE__), '..', 'lib')
require 'mongo' require 'mongo'
include XGen::Mongo::Driver include Mongo
host = ENV['MONGO_RUBY_DRIVER_HOST'] || 'localhost' host = ENV['MONGO_RUBY_DRIVER_HOST'] || 'localhost'
port = ENV['MONGO_RUBY_DRIVER_PORT'] || XGen::Mongo::Driver::Mongo::DEFAULT_PORT port = ENV['MONGO_RUBY_DRIVER_PORT'] || Mongo::Mongo::DEFAULT_PORT
puts "Connecting to #{host}:#{port}" puts "Connecting to #{host}:#{port}"
db = Mongo.new(host, port).db('ruby-mongo-examples') db = Mongo::Mongo.new(host, port).db('ruby-mongo-examples')
db.drop_collection('does-not-exist') db.drop_collection('does-not-exist')
db.create_collection('test') db.create_collection('test')

View File

@ -2,13 +2,13 @@ $LOAD_PATH[0,0] = File.join(File.dirname(__FILE__), '..', 'lib')
require 'mongo' require 'mongo'
require 'pp' require 'pp'
include XGen::Mongo::Driver include Mongo
host = ENV['MONGO_RUBY_DRIVER_HOST'] || 'localhost' host = ENV['MONGO_RUBY_DRIVER_HOST'] || 'localhost'
port = ENV['MONGO_RUBY_DRIVER_PORT'] || XGen::Mongo::Driver::Mongo::DEFAULT_PORT port = ENV['MONGO_RUBY_DRIVER_PORT'] || Mongo::Mongo::DEFAULT_PORT
puts "Connecting to #{host}:#{port}" puts "Connecting to #{host}:#{port}"
db = Mongo.new(host, port).db('ruby-mongo-examples') db = Mongo::Mongo.new(host, port).db('ruby-mongo-examples')
coll = db.collection('test') coll = db.collection('test')
# Remove all records, if any # Remove all records, if any
@ -25,13 +25,8 @@ coll.insert('array' => [1, 2, 3],
'float' => 33.33333, 'float' => 33.33333,
'regex' => /foobar/i, 'regex' => /foobar/i,
'boolean' => true, 'boolean' => true,
'$where' => Code.new('this.x == 3'), 'where' => Code.new('this.x == 3'),
'dbref' => DBRef.new(coll.name, ObjectID.new), 'dbref' => DBRef.new(coll.name, ObjectID.new),
# NOTE: the undefined type is not saved to the database properly. This is a
# Mongo bug. However, the undefined type may go away completely.
# 'undef' => Undefined.new,
'null' => nil, 'null' => nil,
'symbol' => :zildjian) 'symbol' => :zildjian)

View File

@ -275,7 +275,7 @@ static int write_element_allow_id(VALUE key, VALUE value, VALUE extra, int allow
case T_STRING: case T_STRING:
{ {
if (strcmp(rb_class2name(RBASIC(value)->klass), if (strcmp(rb_class2name(RBASIC(value)->klass),
"XGen::Mongo::Driver::Code") == 0) { "Mongo::Code") == 0) {
int start_position, length_location, length, total_length; int start_position, length_location, length, total_length;
write_name_and_type(buffer, key, 0x0F); write_name_and_type(buffer, key, 0x0F);
@ -314,7 +314,7 @@ static int write_element_allow_id(VALUE key, VALUE value, VALUE extra, int allow
{ {
// TODO there has to be a better way to do these checks... // TODO there has to be a better way to do these checks...
const char* cls = rb_class2name(RBASIC(value)->klass); const char* cls = rb_class2name(RBASIC(value)->klass);
if (strcmp(cls, "XGen::Mongo::Driver::Binary") == 0 || if (strcmp(cls, "Mongo::Binary") == 0 ||
strcmp(cls, "ByteBuffer") == 0) { strcmp(cls, "ByteBuffer") == 0) {
const char subtype = strcmp(cls, "ByteBuffer") ? const char subtype = strcmp(cls, "ByteBuffer") ?
(const char)FIX2INT(rb_funcall(value, rb_intern("subtype"), 0)) : 2; (const char)FIX2INT(rb_funcall(value, rb_intern("subtype"), 0)) : 2;
@ -333,7 +333,7 @@ static int write_element_allow_id(VALUE key, VALUE value, VALUE extra, int allow
buffer_write_bytes(buffer, RSTRING_PTR(string_data), length); buffer_write_bytes(buffer, RSTRING_PTR(string_data), length);
break; break;
} }
if (strcmp(cls, "XGen::Mongo::Driver::ObjectID") == 0) { if (strcmp(cls, "Mongo::ObjectID") == 0) {
VALUE as_array = rb_funcall(value, rb_intern("to_a"), 0); VALUE as_array = rb_funcall(value, rb_intern("to_a"), 0);
int i; int i;
write_name_and_type(buffer, key, 0x07); write_name_and_type(buffer, key, 0x07);
@ -343,7 +343,7 @@ static int write_element_allow_id(VALUE key, VALUE value, VALUE extra, int allow
} }
break; break;
} }
if (strcmp(cls, "XGen::Mongo::Driver::DBRef") == 0) { if (strcmp(cls, "Mongo::DBRef") == 0) {
int start_position, length_location, obj_length; int start_position, length_location, obj_length;
VALUE ns, oid; VALUE ns, oid;
write_name_and_type(buffer, key, 0x03); write_name_and_type(buffer, key, 0x03);
@ -364,7 +364,7 @@ static int write_element_allow_id(VALUE key, VALUE value, VALUE extra, int allow
memcpy(buffer->buffer + length_location, &obj_length, 4); memcpy(buffer->buffer + length_location, &obj_length, 4);
break; break;
} }
if (strcmp(cls, "XGen::Mongo::Driver::Undefined") == 0) { if (strcmp(cls, "Mongo::Undefined") == 0) {
write_name_and_type(buffer, key, 0x0A); // just use nil type write_name_and_type(buffer, key, 0x0A); // just use nil type
break; break;
} }
@ -736,25 +736,22 @@ static VALUE method_deserialize(VALUE self, VALUE bson) {
} }
void Init_cbson() { void Init_cbson() {
VALUE driver, CBson; VALUE mongo, CBson;
Time = rb_const_get(rb_cObject, rb_intern("Time")); Time = rb_const_get(rb_cObject, rb_intern("Time"));
driver = rb_const_get(rb_const_get(rb_const_get(rb_cObject, mongo = rb_const_get(rb_cObject, rb_intern("Mongo"));
rb_intern("XGen")),
rb_intern("Mongo")),
rb_intern("Driver"));
rb_require("mongo/types/binary"); rb_require("mongo/types/binary");
Binary = rb_const_get(driver, rb_intern("Binary")); Binary = rb_const_get(mongo, rb_intern("Binary"));
rb_require("mongo/types/objectid"); rb_require("mongo/types/objectid");
ObjectID = rb_const_get(driver, rb_intern("ObjectID")); ObjectID = rb_const_get(mongo, rb_intern("ObjectID"));
rb_require("mongo/types/dbref"); rb_require("mongo/types/dbref");
DBRef = rb_const_get(driver, rb_intern("DBRef")); DBRef = rb_const_get(mongo, rb_intern("DBRef"));
rb_require("mongo/types/code"); rb_require("mongo/types/code");
Code = rb_const_get(driver, rb_intern("Code")); Code = rb_const_get(mongo, rb_intern("Code"));
rb_require("mongo/types/regexp_of_holding"); rb_require("mongo/types/regexp_of_holding");
RegexpOfHolding = rb_const_get(driver, rb_intern("RegexpOfHolding")); RegexpOfHolding = rb_const_get(mongo, rb_intern("RegexpOfHolding"));
rb_require("mongo/errors"); rb_require("mongo/errors");
InvalidName = rb_const_get(driver, rb_intern("InvalidName")); InvalidName = rb_const_get(mongo, rb_intern("InvalidName"));
rb_require("mongo/util/ordered_hash"); rb_require("mongo/util/ordered_hash");
OrderedHash = rb_const_get(rb_cObject, rb_intern("OrderedHash")); OrderedHash = rb_const_get(rb_cObject, rb_intern("OrderedHash"));

View File

@ -12,9 +12,7 @@ require 'mongo/cursor'
require 'mongo/collection' require 'mongo/collection'
require 'mongo/admin' require 'mongo/admin'
module XGen
module Mongo module Mongo
ASCENDING = 1 ASCENDING = 1
DESCENDING = -1 DESCENDING = -1
end end
end

View File

@ -16,9 +16,7 @@
require 'mongo/util/ordered_hash' require 'mongo/util/ordered_hash'
module XGen
module Mongo module Mongo
module Driver
# Provide administrative database methods: those having to do with # Provide administrative database methods: those having to do with
# profiling and validation. # profiling and validation.
@ -83,5 +81,3 @@ module XGen
end end
end end
end
end

View File

@ -16,9 +16,7 @@
require 'mongo/query' require 'mongo/query'
module XGen
module Mongo module Mongo
module Driver
# A named collection of records in a database. # A named collection of records in a database.
class Collection class Collection
@ -275,7 +273,7 @@ module XGen
# Create a new index. +field_or_spec+ # Create a new index. +field_or_spec+
# should be either a single field name or a Array of [field name, # should be either a single field name or a Array of [field name,
# direction] pairs. Directions should be specified as # direction] pairs. Directions should be specified as
# XGen::Mongo::ASCENDING or XGen::Mongo::DESCENDING. # Mongo::ASCENDING or Mongo::DESCENDING.
# +unique+ is an optional boolean indicating whether this index # +unique+ is an optional boolean indicating whether this index
# should enforce a uniqueness constraint. # should enforce a uniqueness constraint.
def create_index(field_or_spec, unique=false) def create_index(field_or_spec, unique=false)
@ -436,6 +434,3 @@ EOS
end end
end end
end end
end
end

View File

@ -18,9 +18,7 @@ require 'mongo/message'
require 'mongo/util/byte_buffer' require 'mongo/util/byte_buffer'
require 'mongo/util/bson' require 'mongo/util/bson'
module XGen
module Mongo module Mongo
module Driver
# A cursor over query results. Returned objects are hashes. # A cursor over query results. Returned objects are hashes.
class Cursor class Cursor
@ -245,5 +243,3 @@ module XGen
end end
end end
end end
end
end

View File

@ -23,9 +23,7 @@ require 'mongo/query'
require 'mongo/util/ordered_hash.rb' require 'mongo/util/ordered_hash.rb'
require 'mongo/admin' require 'mongo/admin'
module XGen
module Mongo module Mongo
module Driver
# A Mongo database. # A Mongo database.
class DB class DB
@ -461,7 +459,7 @@ module XGen
# Create a new index on +collection_name+. +field_or_spec+ # Create a new index on +collection_name+. +field_or_spec+
# should be either a single field name or a Array of [field name, # should be either a single field name or a Array of [field name,
# direction] pairs. Directions should be specified as # direction] pairs. Directions should be specified as
# XGen::Mongo::ASCENDING or XGen::Mongo::DESCENDING. Normally called # Mongo::ASCENDING or Mongo::DESCENDING. Normally called
# by Collection#create_index. If +unique+ is true the index will # by Collection#create_index. If +unique+ is true the index will
# enforce a uniqueness constraint. # enforce a uniqueness constraint.
def create_index(collection_name, field_or_spec, unique=false) def create_index(collection_name, field_or_spec, unique=false)
@ -560,5 +558,3 @@ module XGen
end end
end end
end end
end
end

View File

@ -14,14 +14,10 @@
# Exceptions raised by the MongoDB driver. # Exceptions raised by the MongoDB driver.
module XGen
module Mongo module Mongo
module Driver
# Raised when a database operation fails. # Raised when a database operation fails.
class OperationFailure < RuntimeError; end class OperationFailure < RuntimeError; end
# Raised when an invalid name is used. # Raised when an invalid name is used.
class InvalidName < RuntimeError; end class InvalidName < RuntimeError; end
end end
end
end

View File

@ -19,8 +19,6 @@ require 'mongo/util/byte_buffer'
require 'mongo/util/ordered_hash' require 'mongo/util/ordered_hash'
module XGen
module Mongo
module GridFS module GridFS
# A chunk stores a portion of GridStore data. # A chunk stores a portion of GridStore data.
@ -33,7 +31,7 @@ module XGen
def initialize(file, mongo_object={}) def initialize(file, mongo_object={})
@file = file @file = file
@object_id = mongo_object['_id'] || XGen::Mongo::Driver::ObjectID.new @object_id = mongo_object['_id'] || Mongo::ObjectID.new
@chunk_number = mongo_object['n'] || 0 @chunk_number = mongo_object['n'] || 0
@data = ByteBuffer.new @data = ByteBuffer.new
@ -92,5 +90,3 @@ module XGen
end end
end end
end
end

View File

@ -18,8 +18,6 @@ require 'mongo/types/objectid'
require 'mongo/util/ordered_hash' require 'mongo/util/ordered_hash'
require 'mongo/gridfs/chunk' require 'mongo/gridfs/chunk'
module XGen
module Mongo
module GridFS module GridFS
# GridStore is an IO-like object that provides input and output for # GridStore is an IO-like object that provides input and output for
@ -158,7 +156,7 @@ module XGen
@metadata = doc['metadata'] @metadata = doc['metadata']
@md5 = doc['md5'] @md5 = doc['md5']
else else
@files_id = XGen::Mongo::Driver::ObjectID.new @files_id = Mongo::ObjectID.new
@content_type = DEFAULT_CONTENT_TYPE @content_type = DEFAULT_CONTENT_TYPE
@chunk_size = Chunk::DEFAULT_CHUNK_SIZE @chunk_size = Chunk::DEFAULT_CHUNK_SIZE
@length = 0 @length = 0
@ -169,7 +167,7 @@ module XGen
@curr_chunk = nth_chunk(0) @curr_chunk = nth_chunk(0)
@position = 0 @position = 0
when 'w' when 'w'
chunk_collection.create_index([['files_id', XGen::Mongo::ASCENDING], ['n', XGen::Mongo::ASCENDING]]) chunk_collection.create_index([['files_id', Mongo::ASCENDING], ['n', Mongo::ASCENDING]])
delete_chunks delete_chunks
@curr_chunk = Chunk.new(self, 'n' => 0) @curr_chunk = Chunk.new(self, 'n' => 0)
@content_type = options[:content_type] if options[:content_type] @content_type = options[:content_type] if options[:content_type]
@ -177,7 +175,7 @@ module XGen
@metadata = options[:metadata] if options[:metadata] @metadata = options[:metadata] if options[:metadata]
@position = 0 @position = 0
when 'w+' when 'w+'
chunk_collection.create_index([['files_id', XGen::Mongo::ASCENDING], ['n', XGen::Mongo::ASCENDING]]) chunk_collection.create_index([['files_id', Mongo::ASCENDING], ['n', Mongo::ASCENDING]])
@curr_chunk = nth_chunk(last_chunk_number) || Chunk.new(self, 'n' => 0) # might be empty @curr_chunk = nth_chunk(last_chunk_number) || Chunk.new(self, 'n' => 0) # might be empty
@curr_chunk.pos = @curr_chunk.data.length if @curr_chunk @curr_chunk.pos = @curr_chunk.data.length if @curr_chunk
@metadata = options[:metadata] if options[:metadata] @metadata = options[:metadata] if options[:metadata]
@ -464,5 +462,3 @@ module XGen
end end
end end
end
end

View File

@ -17,9 +17,7 @@
require 'mongo/message/message' require 'mongo/message/message'
require 'mongo/message/opcodes' require 'mongo/message/opcodes'
module XGen
module Mongo module Mongo
module Driver
class GetMoreMessage < Message class GetMoreMessage < Message
@ -32,6 +30,3 @@ module XGen
end end
end end
end end
end
end

View File

@ -17,9 +17,7 @@
require 'mongo/message/message' require 'mongo/message/message'
require 'mongo/message/opcodes' require 'mongo/message/opcodes'
module XGen
module Mongo module Mongo
module Driver
class InsertMessage < Message class InsertMessage < Message
@ -31,5 +29,3 @@ module XGen
end end
end end
end end
end
end

View File

@ -17,9 +17,7 @@
require 'mongo/message/message' require 'mongo/message/message'
require 'mongo/message/opcodes' require 'mongo/message/opcodes'
module XGen
module Mongo module Mongo
module Driver
class KillCursorsMessage < Message class KillCursorsMessage < Message
@ -31,6 +29,3 @@ module XGen
end end
end end
end end
end
end

View File

@ -17,9 +17,7 @@
require 'mongo/util/bson' require 'mongo/util/bson'
require 'mongo/util/byte_buffer' require 'mongo/util/byte_buffer'
module XGen
module Mongo module Mongo
module Driver
class Message class Message
@ -80,5 +78,3 @@ module XGen
end end
end end
end
end

View File

@ -16,9 +16,7 @@
require 'mongo/util/byte_buffer' require 'mongo/util/byte_buffer'
module XGen
module Mongo module Mongo
module Driver
class MessageHeader class MessageHeader
@ -45,6 +43,3 @@ module XGen
end end
end end
end end
end
end

View File

@ -17,9 +17,7 @@
require 'mongo/message/message' require 'mongo/message/message'
require 'mongo/message/opcodes' require 'mongo/message/opcodes'
module XGen
module Mongo module Mongo
module Driver
class MsgMessage < Message class MsgMessage < Message
@ -29,5 +27,3 @@ module XGen
end end
end end
end end
end
end

View File

@ -14,9 +14,7 @@
# limitations under the License. # limitations under the License.
# ++ # ++
module XGen
module Mongo module Mongo
module Driver
OP_REPLY = 1 # reply. responseTo is set. OP_REPLY = 1 # reply. responseTo is set.
OP_MSG = 1000 # generic msg command followed by a string OP_MSG = 1000 # generic msg command followed by a string
OP_UPDATE = 2001 # update object OP_UPDATE = 2001 # update object
@ -27,6 +25,3 @@ module XGen
OP_DELETE = 2006 OP_DELETE = 2006
OP_KILL_CURSORS = 2007 OP_KILL_CURSORS = 2007
end end
end
end

View File

@ -18,9 +18,7 @@ require 'mongo/message/message'
require 'mongo/message/opcodes' require 'mongo/message/opcodes'
require 'mongo/util/ordered_hash' require 'mongo/util/ordered_hash'
module XGen
module Mongo module Mongo
module Driver
class QueryMessage < Message class QueryMessage < Message
@ -73,5 +71,3 @@ module XGen
end end
end end
end end
end
end

View File

@ -17,9 +17,7 @@
require 'mongo/message/message' require 'mongo/message/message'
require 'mongo/message/opcodes' require 'mongo/message/opcodes'
module XGen
module Mongo module Mongo
module Driver
class RemoveMessage < Message class RemoveMessage < Message
@ -32,5 +30,3 @@ module XGen
end end
end end
end end
end
end

View File

@ -17,9 +17,7 @@
require 'mongo/message/message' require 'mongo/message/message'
require 'mongo/message/opcodes' require 'mongo/message/opcodes'
module XGen
module Mongo module Mongo
module Driver
class UpdateMessage < Message class UpdateMessage < Message
@ -33,5 +31,3 @@ module XGen
end end
end end
end end
end
end

View File

@ -16,9 +16,7 @@
require 'mongo/db' require 'mongo/db'
module XGen
module Mongo module Mongo
module Driver
# Represents a Mongo database server. # Represents a Mongo database server.
class Mongo class Mongo
@ -87,11 +85,11 @@ module XGen
@options = options @options = options
end end
# Return the XGen::Mongo::Driver::DB named +db_name+. The slave_ok and # Return the Mongo::DB named +db_name+. The slave_ok and
# auto_reconnect options passed in via #new may be overridden here. # auto_reconnect options passed in via #new may be overridden here.
# See DB#new for other options you can pass in. # See DB#new for other options you can pass in.
def db(db_name, options={}) def db(db_name, options={})
XGen::Mongo::Driver::DB.new(db_name, @pair, @options.merge(options)) DB.new(db_name, @pair, @options.merge(options))
end end
# Returns a hash containing database names as keys and disk space for # Returns a hash containing database names as keys and disk space for
@ -159,6 +157,3 @@ module XGen
end end
end end
end
end

View File

@ -18,9 +18,7 @@ require 'mongo/collection'
require 'mongo/message' require 'mongo/message'
require 'mongo/types/code' require 'mongo/types/code'
module XGen
module Mongo module Mongo
module Driver
# A query against a collection. A query's selector is a hash. See the # A query against a collection. A query's selector is a hash. See the
# Mongo documentation for query details. # Mongo documentation for query details.
@ -115,5 +113,3 @@ module XGen
end end
end end
end end
end
end

View File

@ -16,9 +16,7 @@
require 'mongo/util/byte_buffer' require 'mongo/util/byte_buffer'
module XGen
module Mongo module Mongo
module Driver
# An array of binary bytes with a Mongo subtype value. # An array of binary bytes with a Mongo subtype value.
class Binary < ByteBuffer class Binary < ByteBuffer
@ -38,5 +36,3 @@ module XGen
end end
end end
end
end

View File

@ -14,9 +14,7 @@
# limitations under the License. # limitations under the License.
# ++ # ++
module XGen
module Mongo module Mongo
module Driver
# JavaScript code to be evaluated by MongoDB # JavaScript code to be evaluated by MongoDB
class Code < String class Code < String
@ -30,5 +28,3 @@ module XGen
end end
end end
end
end

View File

@ -14,9 +14,7 @@
# limitations under the License. # limitations under the License.
# ++ # ++
module XGen
module Mongo module Mongo
module Driver
class DBRef class DBRef
@ -33,5 +31,3 @@ module XGen
end end
end end
end
end

View File

@ -17,9 +17,7 @@
require 'mutex_m' require 'mutex_m'
require 'mongo/util/byte_buffer' require 'mongo/util/byte_buffer'
module XGen
module Mongo module Mongo
module Driver
# Implementation of the Babble OID. Object ids are not required by # Implementation of the Babble OID. Object ids are not required by
# Mongo, but they make certain operations more efficient. # Mongo, but they make certain operations more efficient.
@ -133,5 +131,3 @@ module XGen
end end
end end
end
end

View File

@ -14,9 +14,7 @@
# limitations under the License. # limitations under the License.
# ++ # ++
module XGen
module Mongo module Mongo
module Driver
# A Regexp that can hold on to extra options and ignore them. Mongo # A Regexp that can hold on to extra options and ignore them. Mongo
# regexes may contain option characters beyond 'i', 'm', and 'x'. (Note # regexes may contain option characters beyond 'i', 'm', and 'x'. (Note
@ -40,5 +38,3 @@ module XGen
end end
end end
end
end

View File

@ -14,9 +14,7 @@
# limitations under the License. # limitations under the License.
# ++ # ++
module XGen
module Mongo module Mongo
module Driver
# DEPRECATED - the ruby driver converts the BSON undefined type to nil, # DEPRECATED - the ruby driver converts the BSON undefined type to nil,
# and saves this type as nil # and saves this type as nil
@ -28,5 +26,3 @@ module XGen
end end
end end
end end
end
end

View File

@ -26,7 +26,7 @@ require 'mongo/types/undefined'
# A BSON seralizer/deserializer. # A BSON seralizer/deserializer.
class BSON class BSON
include XGen::Mongo::Driver include Mongo
MINKEY = -1 MINKEY = -1
EOO = 0 EOO = 0

View File

@ -21,7 +21,7 @@ require 'mongo'
# an OrderedHash. # an OrderedHash.
class XMLToRuby class XMLToRuby
include XGen::Mongo::Driver include Mongo
def xml_to_ruby(io) def xml_to_ruby(io)
doc = REXML::Document.new(io) doc = REXML::Document.new(io)

View File

@ -5,4 +5,4 @@ DEFAULT_HOST = '127.0.0.1'
DEFAULT_PORT = 27017 DEFAULT_PORT = 27017
DEFAULT_DB = 'driver_test_framework' DEFAULT_DB = 'driver_test_framework'
include XGen::Mongo::Driver include Mongo

View File

@ -3,9 +3,9 @@
require File.join(File.dirname(__FILE__), '_common.rb') require File.join(File.dirname(__FILE__), '_common.rb')
require 'mongo/gridfs' require 'mongo/gridfs'
include XGen::Mongo::GridFS include GridFS
db = Mongo.new(DEFAULT_HOST, DEFAULT_PORT).db(DEFAULT_DB) db = Mongo::Mongo.new(DEFAULT_HOST, DEFAULT_PORT).db(DEFAULT_DB)
input_file = ARGV[0] input_file = ARGV[0]

View File

@ -3,9 +3,9 @@
require File.join(File.dirname(__FILE__), '_common.rb') require File.join(File.dirname(__FILE__), '_common.rb')
require 'mongo/gridfs' require 'mongo/gridfs'
include XGen::Mongo::GridFS include GridFS
db = Mongo.new(DEFAULT_HOST, DEFAULT_PORT).db(DEFAULT_DB) db = Mongo::Mongo.new(DEFAULT_HOST, DEFAULT_PORT).db(DEFAULT_DB)
input_file = ARGV[0] input_file = ARGV[0]
output_file = ARGV[1] output_file = ARGV[1]

View File

@ -2,9 +2,9 @@
require File.join(File.dirname(__FILE__), '_common.rb') require File.join(File.dirname(__FILE__), '_common.rb')
include XGen::Mongo include Mongo
db = Mongo.new(DEFAULT_HOST, DEFAULT_PORT).db(DEFAULT_DB) db = Mongo::Mongo.new(DEFAULT_HOST, DEFAULT_PORT).db(DEFAULT_DB)
x = db.collection('x') x = db.collection('x')
y = db.collection('y') y = db.collection('y')

View File

@ -5,7 +5,7 @@ require 'test/unit'
# NOTE: assumes Mongo is running # NOTE: assumes Mongo is running
class AdminTest < Test::Unit::TestCase class AdminTest < Test::Unit::TestCase
include XGen::Mongo::Driver include Mongo
@@db = Mongo.new(ENV['MONGO_RUBY_DRIVER_HOST'] || 'localhost', @@db = Mongo.new(ENV['MONGO_RUBY_DRIVER_HOST'] || 'localhost',
ENV['MONGO_RUBY_DRIVER_PORT'] || Mongo::DEFAULT_PORT).db('ruby-mongo-test') ENV['MONGO_RUBY_DRIVER_PORT'] || Mongo::DEFAULT_PORT).db('ruby-mongo-test')

View File

@ -5,7 +5,7 @@ require 'test/unit'
class BSONTest < Test::Unit::TestCase class BSONTest < Test::Unit::TestCase
include XGen::Mongo::Driver include Mongo
def setup def setup
# We don't pass a DB to the constructor, even though we are about to test # We don't pass a DB to the constructor, even though we are about to test
@ -85,7 +85,7 @@ class BSONTest < Test::Unit::TestCase
assert_equal doc, doc2 assert_equal doc, doc2
r = doc2['doc'] r = doc2['doc']
assert_kind_of XGen::Mongo::Driver::RegexpOfHolding, r assert_kind_of RegexpOfHolding, r
assert_equal '', r.extra_options_str assert_equal '', r.extra_options_str
r.extra_options_str << 'zywcab' r.extra_options_str << 'zywcab'
@ -99,7 +99,7 @@ class BSONTest < Test::Unit::TestCase
assert_equal doc, doc2 assert_equal doc, doc2
r = doc2['doc'] r = doc2['doc']
assert_kind_of XGen::Mongo::Driver::RegexpOfHolding, r assert_kind_of RegexpOfHolding, r
assert_equal 'abcwyz', r.extra_options_str # must be sorted assert_equal 'abcwyz', r.extra_options_str # must be sorted
end end

View File

@ -5,8 +5,8 @@ require 'mongo/gridfs'
class ChunkTest < Test::Unit::TestCase class ChunkTest < Test::Unit::TestCase
include XGen::Mongo::Driver include Mongo
include XGen::Mongo::GridFS include GridFS
@@db = Mongo.new(ENV['MONGO_RUBY_DRIVER_HOST'] || 'localhost', @@db = Mongo.new(ENV['MONGO_RUBY_DRIVER_HOST'] || 'localhost',
ENV['MONGO_RUBY_DRIVER_PORT'] || Mongo::DEFAULT_PORT).db('ruby-mongo-utils-test') ENV['MONGO_RUBY_DRIVER_PORT'] || Mongo::DEFAULT_PORT).db('ruby-mongo-utils-test')

View File

@ -20,8 +20,7 @@ require 'test/unit'
# NOTE: assumes Mongo is running # NOTE: assumes Mongo is running
class TestCollection < Test::Unit::TestCase class TestCollection < Test::Unit::TestCase
include XGen::Mongo include Mongo
include XGen::Mongo::Driver
@@db = Mongo.new(ENV['MONGO_RUBY_DRIVER_HOST'] || 'localhost', @@db = Mongo.new(ENV['MONGO_RUBY_DRIVER_HOST'] || 'localhost',
ENV['MONGO_RUBY_DRIVER_PORT'] || Mongo::DEFAULT_PORT).db('ruby-mongo-test') ENV['MONGO_RUBY_DRIVER_PORT'] || Mongo::DEFAULT_PORT).db('ruby-mongo-test')

View File

@ -5,7 +5,7 @@ require 'test/unit'
# NOTE: assumes Mongo is running # NOTE: assumes Mongo is running
class CursorTest < Test::Unit::TestCase class CursorTest < Test::Unit::TestCase
include XGen::Mongo::Driver include Mongo
@@db = Mongo.new(ENV['MONGO_RUBY_DRIVER_HOST'] || 'localhost', @@db = Mongo.new(ENV['MONGO_RUBY_DRIVER_HOST'] || 'localhost',
ENV['MONGO_RUBY_DRIVER_PORT'] || Mongo::DEFAULT_PORT).db('ruby-mongo-test') ENV['MONGO_RUBY_DRIVER_PORT'] || Mongo::DEFAULT_PORT).db('ruby-mongo-test')

View File

@ -5,7 +5,7 @@ require 'test/unit'
class TestPKFactory class TestPKFactory
def create_pk(row) def create_pk(row)
row['_id'] ||= XGen::Mongo::Driver::ObjectID.new row['_id'] ||= Mongo::ObjectID.new
row row
end end
end end
@ -13,7 +13,7 @@ end
# NOTE: assumes Mongo is running # NOTE: assumes Mongo is running
class DBTest < Test::Unit::TestCase class DBTest < Test::Unit::TestCase
include XGen::Mongo::Driver include Mongo
@@host = ENV['MONGO_RUBY_DRIVER_HOST'] || 'localhost' @@host = ENV['MONGO_RUBY_DRIVER_HOST'] || 'localhost'
@@port = ENV['MONGO_RUBY_DRIVER_PORT'] || Mongo::DEFAULT_PORT @@port = ENV['MONGO_RUBY_DRIVER_PORT'] || Mongo::DEFAULT_PORT
@ -85,7 +85,7 @@ class DBTest < Test::Unit::TestCase
assert_not_nil oid assert_not_nil oid
assert_equal insert_id, oid assert_equal insert_id, oid
oid = XGen::Mongo::Driver::ObjectID.new oid = ObjectID.new
data = {'_id' => oid, 'name' => 'Barney', 'age' => 41} data = {'_id' => oid, 'name' => 'Barney', 'age' => 41}
coll.insert(data) coll.insert(data)
row = coll.find_one({'name' => data['name']}) row = coll.find_one({'name' => data['name']})

View File

@ -4,8 +4,7 @@ require 'test/unit'
# NOTE: assumes Mongo is running # NOTE: assumes Mongo is running
class DBAPITest < Test::Unit::TestCase class DBAPITest < Test::Unit::TestCase
include XGen::Mongo include Mongo
include XGen::Mongo::Driver
@@db = Mongo.new(ENV['MONGO_RUBY_DRIVER_HOST'] || 'localhost', @@db = Mongo.new(ENV['MONGO_RUBY_DRIVER_HOST'] || 'localhost',
ENV['MONGO_RUBY_DRIVER_PORT'] || Mongo::DEFAULT_PORT).db('ruby-mongo-test') ENV['MONGO_RUBY_DRIVER_PORT'] || Mongo::DEFAULT_PORT).db('ruby-mongo-test')
@ -817,18 +816,4 @@ class DBAPITest < Test::Unit::TestCase
@@db.collection("test").find({}, :snapshot => true, :sort => 'a').to_a @@db.collection("test").find({}, :snapshot => true, :sort => 'a').to_a
end end
end end
# TODO this test fails with error message "Undefed Before end of object"
# That is a database error. The undefined type may go away.
# def test_insert_undefined
# doc = {'undef' => Undefined.new}
# @@coll.clear
# @@coll.insert(doc)
# p @@db.error # DEBUG
# assert_equal 1, @@coll.count
# row = @@coll.find().next_object
# assert_not_nil row
# end
end end

View File

@ -5,7 +5,7 @@ require 'test/unit'
# NOTE: assumes Mongo is running # NOTE: assumes Mongo is running
class DBConnectionTest < Test::Unit::TestCase class DBConnectionTest < Test::Unit::TestCase
include XGen::Mongo::Driver include Mongo
def test_no_exceptions def test_no_exceptions
host = ENV['MONGO_RUBY_DRIVER_HOST'] || 'localhost' host = ENV['MONGO_RUBY_DRIVER_HOST'] || 'localhost'

View File

@ -5,8 +5,8 @@ require 'mongo/gridfs'
class GridStoreTest < Test::Unit::TestCase class GridStoreTest < Test::Unit::TestCase
include XGen::Mongo::Driver include Mongo
include XGen::Mongo::GridFS include GridFS
@@db = Mongo.new(ENV['MONGO_RUBY_DRIVER_HOST'] || 'localhost', @@db = Mongo.new(ENV['MONGO_RUBY_DRIVER_HOST'] || 'localhost',
ENV['MONGO_RUBY_DRIVER_PORT'] || Mongo::DEFAULT_PORT).db('ruby-mongo-test') ENV['MONGO_RUBY_DRIVER_PORT'] || Mongo::DEFAULT_PORT).db('ruby-mongo-test')

View File

@ -4,7 +4,7 @@ require 'test/unit'
class MessageTest < Test::Unit::TestCase class MessageTest < Test::Unit::TestCase
include XGen::Mongo::Driver include Mongo
def setup def setup
@msg = Message.new(42) @msg = Message.new(42)

View File

@ -5,7 +5,7 @@ require 'test/unit'
# NOTE: assumes Mongo is running # NOTE: assumes Mongo is running
class MongoTest < Test::Unit::TestCase class MongoTest < Test::Unit::TestCase
include XGen::Mongo::Driver include Mongo
def setup def setup
@host = ENV['MONGO_RUBY_DRIVER_HOST'] || 'localhost' @host = ENV['MONGO_RUBY_DRIVER_HOST'] || 'localhost'

View File

@ -4,7 +4,7 @@ require 'test/unit'
class ObjectIDTest < Test::Unit::TestCase class ObjectIDTest < Test::Unit::TestCase
include XGen::Mongo::Driver include Mongo
def setup def setup
@t = 42 @t = 42

View File

@ -13,7 +13,7 @@ require 'test/unit'
# of this project), then we find the BSON test files there and use those, too. # of this project), then we find the BSON test files there and use those, too.
class RoundTripTest < Test::Unit::TestCase class RoundTripTest < Test::Unit::TestCase
include XGen::Mongo::Driver include Mongo
@@ruby = nil @@ruby = nil

View File

@ -4,7 +4,7 @@ require 'test/unit'
class TestThreading < Test::Unit::TestCase class TestThreading < Test::Unit::TestCase
include XGen::Mongo::Driver include Mongo
@@host = ENV['MONGO_RUBY_DRIVER_HOST'] || 'localhost' @@host = ENV['MONGO_RUBY_DRIVER_HOST'] || 'localhost'
@@port = ENV['MONGO_RUBY_DRIVER_PORT'] || Mongo::DEFAULT_PORT @@port = ENV['MONGO_RUBY_DRIVER_PORT'] || Mongo::DEFAULT_PORT