2010-04-05 18:09:06 +00:00
|
|
|
$:.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
|
|
|
|
|
|
|
module BSON
|
|
|
|
VERSION = "0.20"
|
|
|
|
def self.serialize(obj, check_keys=false, move_id=false)
|
|
|
|
BSON_CODER.serialize(obj, check_keys, move_id)
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
def self.deserialize(buf=nil)
|
|
|
|
BSON_CODER.deserialize(buf)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
begin
|
|
|
|
# Need this for running test with and without c ext in Ruby 1.9.
|
|
|
|
raise LoadError if ENV['TEST_MODE'] && !ENV['C_EXT']
|
|
|
|
require 'bson_ext/cbson'
|
2010-04-05 19:30:18 +00:00
|
|
|
raise LoadError unless defined?(CBson::VERSION) && CBson::VERSION == BSON::VERSION
|
2010-04-05 18:09:06 +00:00
|
|
|
require 'bson/bson_c'
|
|
|
|
module BSON
|
|
|
|
BSON_CODER = BSON_C
|
|
|
|
end
|
|
|
|
rescue LoadError
|
|
|
|
require 'bson/bson_ruby'
|
|
|
|
module BSON
|
|
|
|
BSON_CODER = BSON_RUBY
|
|
|
|
end
|
|
|
|
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 mongo_ext\n"
|
|
|
|
warn " If you continue to receive this message after installing, make sure that the"
|
|
|
|
warn " mongo_ext gem is in your load path and that the mongo_ext and mongo gems are of the same version.\n"
|
|
|
|
end
|
|
|
|
|
|
|
|
require 'bson/types/binary'
|
|
|
|
require 'bson/types/code'
|
|
|
|
require 'bson/types/dbref'
|
|
|
|
require 'bson/types/objectid'
|
|
|
|
require 'bson/types/min_max_keys'
|
|
|
|
|
|
|
|
require 'base64'
|
|
|
|
require 'bson/ordered_hash'
|
|
|
|
require 'bson/byte_buffer'
|
|
|
|
require 'bson/bson_ruby'
|
|
|
|
require 'bson/exceptions'
|