mongodb-mongo_ext 0.11.1 → 0.13

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -12,11 +12,11 @@ require 'rbconfig'
12
12
  include Config
13
13
 
14
14
  gem_command = "gem"
15
- gem_command = "gem1.9" if CONFIG["MAJOR"] == "1" && CONFIG["MINOR"] == "9"
15
+ gem_command = "gem1.9" if $0.match(/1\.9$/) # use gem1.9 if we used rake1.9
16
16
 
17
17
  # NOTE: some of the tests assume Mongo is running
18
18
  Rake::TestTask.new do |t|
19
- t.test_files = FileList['tests/test*.rb']
19
+ t.test_files = FileList['test/test*.rb']
20
20
  end
21
21
 
22
22
  desc "Generate documentation"
@@ -42,13 +42,13 @@
42
42
  #define INITIAL_BUFFER_SIZE 256
43
43
 
44
44
  static VALUE Binary;
45
- static VALUE Undefined;
46
45
  static VALUE Time;
47
46
  static VALUE ObjectID;
48
47
  static VALUE DBRef;
49
48
  static VALUE Code;
50
49
  static VALUE RegexpOfHolding;
51
50
  static VALUE OrderedHash;
51
+ static VALUE InvalidName;
52
52
 
53
53
  // this sucks. but for some reason these moved around between 1.8 and 1.9
54
54
  #ifdef ONIGURUMA_H
@@ -183,11 +183,11 @@ static int write_element_allow_id(VALUE key, VALUE value, VALUE extra, int allow
183
183
  if (check_keys == Qtrue) {
184
184
  int i;
185
185
  if (RSTRING_LEN(key) > 0 && RSTRING_PTR(key)[0] == '$') {
186
- rb_raise(rb_eRuntimeError, "key must not start with '$'");
186
+ rb_raise(InvalidName, "key must not start with '$'");
187
187
  }
188
188
  for (i = 0; i < RSTRING_LEN(key); i++) {
189
189
  if (RSTRING_PTR(key)[i] == '.') {
190
- rb_raise(rb_eRuntimeError, "key must not contain '.'");
190
+ rb_raise(InvalidName, "key must not contain '.'");
191
191
  }
192
192
  }
193
193
  }
@@ -275,7 +275,7 @@ static int write_element_allow_id(VALUE key, VALUE value, VALUE extra, int allow
275
275
  case T_STRING:
276
276
  {
277
277
  if (strcmp(rb_class2name(RBASIC(value)->klass),
278
- "XGen::Mongo::Driver::Code") == 0) {
278
+ "Mongo::Code") == 0) {
279
279
  int start_position, length_location, length, total_length;
280
280
  write_name_and_type(buffer, key, 0x0F);
281
281
 
@@ -314,7 +314,7 @@ static int write_element_allow_id(VALUE key, VALUE value, VALUE extra, int allow
314
314
  {
315
315
  // TODO there has to be a better way to do these checks...
316
316
  const char* cls = rb_class2name(RBASIC(value)->klass);
317
- if (strcmp(cls, "XGen::Mongo::Driver::Binary") == 0 ||
317
+ if (strcmp(cls, "Mongo::Binary") == 0 ||
318
318
  strcmp(cls, "ByteBuffer") == 0) {
319
319
  const char subtype = strcmp(cls, "ByteBuffer") ?
320
320
  (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
333
333
  buffer_write_bytes(buffer, RSTRING_PTR(string_data), length);
334
334
  break;
335
335
  }
336
- if (strcmp(cls, "XGen::Mongo::Driver::ObjectID") == 0) {
336
+ if (strcmp(cls, "Mongo::ObjectID") == 0) {
337
337
  VALUE as_array = rb_funcall(value, rb_intern("to_a"), 0);
338
338
  int i;
339
339
  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
343
343
  }
344
344
  break;
345
345
  }
346
- if (strcmp(cls, "XGen::Mongo::Driver::DBRef") == 0) {
346
+ if (strcmp(cls, "Mongo::DBRef") == 0) {
347
347
  int start_position, length_location, obj_length;
348
348
  VALUE ns, oid;
349
349
  write_name_and_type(buffer, key, 0x03);
@@ -364,8 +364,8 @@ static int write_element_allow_id(VALUE key, VALUE value, VALUE extra, int allow
364
364
  memcpy(buffer->buffer + length_location, &obj_length, 4);
365
365
  break;
366
366
  }
367
- if (strcmp(cls, "XGen::Mongo::Driver::Undefined") == 0) {
368
- write_name_and_type(buffer, key, 0x06);
367
+ if (strcmp(cls, "Mongo::Undefined") == 0) {
368
+ write_name_and_type(buffer, key, 0x0A); // just use nil type
369
369
  break;
370
370
  }
371
371
  }
@@ -562,7 +562,7 @@ static VALUE get_value(const char* buffer, int* position, int type) {
562
562
  }
563
563
  case 6:
564
564
  {
565
- value = rb_class_new_instance(0, NULL, Undefined);
565
+ value = Qnil;
566
566
  break;
567
567
  }
568
568
  case 7:
@@ -736,25 +736,22 @@ static VALUE method_deserialize(VALUE self, VALUE bson) {
736
736
  }
737
737
 
738
738
  void Init_cbson() {
739
- VALUE driver, CBson;
739
+ VALUE mongo, CBson;
740
740
  Time = rb_const_get(rb_cObject, rb_intern("Time"));
741
741
 
742
- driver = rb_const_get(rb_const_get(rb_const_get(rb_cObject,
743
- rb_intern("XGen")),
744
- rb_intern("Mongo")),
745
- rb_intern("Driver"));
742
+ mongo = rb_const_get(rb_cObject, rb_intern("Mongo"));
746
743
  rb_require("mongo/types/binary");
747
- Binary = rb_const_get(driver, rb_intern("Binary"));
748
- rb_require("mongo/types/undefined");
749
- Undefined = rb_const_get(driver, rb_intern("Undefined"));
744
+ Binary = rb_const_get(mongo, rb_intern("Binary"));
750
745
  rb_require("mongo/types/objectid");
751
- ObjectID = rb_const_get(driver, rb_intern("ObjectID"));
746
+ ObjectID = rb_const_get(mongo, rb_intern("ObjectID"));
752
747
  rb_require("mongo/types/dbref");
753
- DBRef = rb_const_get(driver, rb_intern("DBRef"));
748
+ DBRef = rb_const_get(mongo, rb_intern("DBRef"));
754
749
  rb_require("mongo/types/code");
755
- Code = rb_const_get(driver, rb_intern("Code"));
750
+ Code = rb_const_get(mongo, rb_intern("Code"));
756
751
  rb_require("mongo/types/regexp_of_holding");
757
- RegexpOfHolding = rb_const_get(driver, rb_intern("RegexpOfHolding"));
752
+ RegexpOfHolding = rb_const_get(mongo, rb_intern("RegexpOfHolding"));
753
+ rb_require("mongo/errors");
754
+ InvalidName = rb_const_get(mongo, rb_intern("InvalidName"));
758
755
  rb_require("mongo/util/ordered_hash");
759
756
  OrderedHash = rb_const_get(rb_cObject, rb_intern("OrderedHash"));
760
757
 
@@ -8,7 +8,7 @@ TEST_FILES = []
8
8
  Gem::Specification.new do |s|
9
9
  s.name = 'mongo_ext'
10
10
 
11
- s.version = '0.11.1'
11
+ s.version = '0.13'
12
12
  s.platform = Gem::Platform::RUBY
13
13
  s.summary = 'C extensions for the MongoDB Ruby driver'
14
14
  s.description = 'C extensions to accelerate the MondoDB Ruby driver. For more information about Mongo, see http://www.mongodb.org.'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mongodb-mongo_ext
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.11.1
4
+ version: "0.13"
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike Dirolf