From b3ed1486e5dddd07d0da3afb8ec087317fc24a63 Mon Sep 17 00:00:00 2001 From: Kyle Banker Date: Mon, 4 Oct 2010 13:28:26 -0400 Subject: [PATCH] minor: updates for removal deprecated DB and Connection methods and ObjectID --- ext/cbson/cbson.c | 6 +----- lib/bson.rb | 4 ++-- test/connection_test.rb | 4 ++-- test/db_test.rb | 14 -------------- 4 files changed, 5 insertions(+), 23 deletions(-) diff --git a/ext/cbson/cbson.c b/ext/cbson/cbson.c index 95f97fe..a83e78a 100644 --- a/ext/cbson/cbson.c +++ b/ext/cbson/cbson.c @@ -75,7 +75,6 @@ static ID lt_operator; static ID gt_operator; static VALUE Binary; -static VALUE ObjectID; static VALUE ObjectId; static VALUE DBRef; static VALUE Code; @@ -365,7 +364,7 @@ static int write_element(VALUE key, VALUE value, VALUE extra, int allow_id) { SAFE_WRITE(buffer, RSTRING_PTR(string_data), length); break; } - if ((strcmp(cls, "BSON::ObjectId") == 0) || (strcmp(cls, "BSON::ObjectID") == 0)) { + if (strcmp(cls, "BSON::ObjectId") == 0) { VALUE as_array = rb_funcall(value, rb_intern("to_a"), 0); int i; write_name_and_type(buffer, key, 0x07); @@ -917,8 +916,6 @@ void Init_cbson() { bson = rb_const_get(rb_cObject, rb_intern("BSON")); rb_require("bson/types/binary"); Binary = rb_const_get(bson, rb_intern("Binary")); - rb_require("bson/types/objectid"); - ObjectID = rb_const_get(bson, rb_intern("ObjectID")); rb_require("bson/types/object_id"); ObjectId = rb_const_get(bson, rb_intern("ObjectId")); rb_require("bson/types/dbref"); @@ -947,7 +944,6 @@ void Init_cbson() { Digest = rb_const_get(rb_cObject, rb_intern("Digest")); DigestMD5 = rb_const_get(Digest, rb_intern("MD5")); - rb_define_method(ObjectID, "generate", objectid_generate, 0); rb_define_method(ObjectId, "generate", objectid_generate, 0); if (gethostname(hostname, MAX_HOSTNAME_LENGTH) != 0) { diff --git a/lib/bson.rb b/lib/bson.rb index 6375270..dada0c0 100644 --- a/lib/bson.rb +++ b/lib/bson.rb @@ -55,11 +55,12 @@ else module BSON BSON_CODER = BSON_C end - rescue LoadError + rescue LoadError => e require 'bson/bson_ruby' module BSON BSON_CODER = BSON_RUBY end + p e warn "\n**Notice: C extension not loaded. This is required for optimum MongoDB Ruby driver performance." warn " You can install the extension as follows:\n gem install bson_ext\n" warn " If you continue to receive this message after installing, make sure that the" @@ -70,7 +71,6 @@ end require 'bson/types/binary' require 'bson/types/code' require 'bson/types/dbref' -require 'bson/types/objectid' require 'bson/types/object_id' require 'bson/types/min_max_keys' diff --git a/test/connection_test.rb b/test/connection_test.rb index 8df6ecf..fb2727f 100644 --- a/test/connection_test.rb +++ b/test/connection_test.rb @@ -130,7 +130,7 @@ class TestConnection < Test::Unit::TestCase end def test_nodes - db = Connection.paired([['foo', 27017], ['bar', 27018]], :connect => false) + db = Connection.multi([['foo', 27017], ['bar', 27018]], :connect => false) nodes = db.nodes assert_equal 2, nodes.length assert_equal ['foo', 27017], nodes[0] @@ -139,7 +139,7 @@ class TestConnection < Test::Unit::TestCase def test_slave_ok_with_multiple_nodes assert_raise MongoArgumentError do - Connection.paired([['foo', 27017], ['bar', 27018]], :connect => false, :slave_ok => true) + Connection.multi([['foo', 27017], ['bar', 27018]], :connect => false, :slave_ok => true) end end diff --git a/test/db_test.rb b/test/db_test.rb index c9433bc..e309715 100644 --- a/test/db_test.rb +++ b/test/db_test.rb @@ -75,20 +75,6 @@ class DBTest < Test::Unit::TestCase assert_kind_of Collection, colls[0] end - def test_pair - @@conn.close - @@users = nil - @@conn = Connection.paired([["this-should-fail", 27017], [@@host, @@port]]) - @@db = @@conn[MONGO_TEST_DB] - assert @@conn.connected? - ensure - unless @@conn.connected? - @@conn = Connection.new(@@host, @@port) - @@db = @@conn.db(MONGO_TEST_DB) - end - @@users = @@db.collection('system.users') - end - def test_pk_factory db = Connection.new(@@host, @@port).db(MONGO_TEST_DB, :pk => TestPKFactory.new) coll = db.collection('test')