minor: version checking for cbson
This commit is contained in:
parent
02ed79d19b
commit
d39169530a
@ -36,6 +36,8 @@
|
|||||||
#include "regex.h"
|
#include "regex.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include "version.h"
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
@ -792,7 +794,7 @@ static VALUE objectid_generate(VALUE self)
|
|||||||
|
|
||||||
|
|
||||||
void Init_cbson() {
|
void Init_cbson() {
|
||||||
VALUE mongo, CBson, Digest;
|
VALUE mongo, CBson, Digest, ext_version;
|
||||||
Time = rb_const_get(rb_cObject, rb_intern("Time"));
|
Time = rb_const_get(rb_cObject, rb_intern("Time"));
|
||||||
|
|
||||||
mongo = rb_const_get(rb_cObject, rb_intern("Mongo"));
|
mongo = rb_const_get(rb_cObject, rb_intern("Mongo"));
|
||||||
@ -812,6 +814,8 @@ void Init_cbson() {
|
|||||||
OrderedHash = rb_const_get(rb_cObject, rb_intern("OrderedHash"));
|
OrderedHash = rb_const_get(rb_cObject, rb_intern("OrderedHash"));
|
||||||
|
|
||||||
CBson = rb_define_module("CBson");
|
CBson = rb_define_module("CBson");
|
||||||
|
ext_version = rb_str_new2(VERSION);
|
||||||
|
rb_define_const(CBson, "VERSION", ext_version);
|
||||||
rb_define_module_function(CBson, "serialize", method_serialize, 2);
|
rb_define_module_function(CBson, "serialize", method_serialize, 2);
|
||||||
rb_define_module_function(CBson, "deserialize", method_deserialize, 1);
|
rb_define_module_function(CBson, "deserialize", method_deserialize, 1);
|
||||||
|
|
||||||
|
17
ext/cbson/version.h
Normal file
17
ext/cbson/version.h
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2009 10gen, Inc.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define VERSION "0.18\0"
|
@ -10,8 +10,8 @@ end
|
|||||||
begin
|
begin
|
||||||
# Need this for running test with and without c ext in Ruby 1.9.
|
# Need this for running test with and without c ext in Ruby 1.9.
|
||||||
raise LoadError if ENV['TEST_MODE'] && !ENV['C_EXT']
|
raise LoadError if ENV['TEST_MODE'] && !ENV['C_EXT']
|
||||||
gem 'mongo_ext', "= #{Mongo::VERSION}"
|
|
||||||
require 'mongo_ext/cbson'
|
require 'mongo_ext/cbson'
|
||||||
|
raise LoadError if CBson::VERSION != Mongo::VERSION
|
||||||
require 'mongo/util/bson_c'
|
require 'mongo/util/bson_c'
|
||||||
BSON = BSON_C
|
BSON = BSON_C
|
||||||
BSON_SERIALIZER = CBson
|
BSON_SERIALIZER = CBson
|
||||||
|
@ -1,11 +1,12 @@
|
|||||||
require 'lib/mongo'
|
require 'lib/mongo'
|
||||||
|
VERSION_HEADER = File.open(File.join(File.dirname(__FILE__), 'ext', 'cbson', 'version.h'), "r")
|
||||||
|
VERSION = VERSION_HEADER.read.scan(/VERSION\s+"(\d+\.\d+)\\/)[0][0]
|
||||||
Gem::Specification.new do |s|
|
Gem::Specification.new do |s|
|
||||||
s.name = 'mongo_ext'
|
s.name = 'mongo_ext'
|
||||||
|
|
||||||
s.version = Mongo::VERSION
|
s.version = VERSION
|
||||||
s.platform = Gem::Platform::RUBY
|
s.platform = Gem::Platform::RUBY
|
||||||
s.summary = 'C extensions for the MongoDB Ruby driver'
|
s.summary = 'C extensions for the MongoDB Ruby driver'
|
||||||
s.description = 'C extensions to accelerate the MongoDB Ruby driver. For more information about Mongo, see http://www.mongodb.org.'
|
s.description = 'C extensions to accelerate the MongoDB Ruby driver. For more information about Mongo, see http://www.mongodb.org.'
|
||||||
|
|
||||||
s.require_paths = ['ext']
|
s.require_paths = ['ext']
|
||||||
|
Loading…
Reference in New Issue
Block a user