bson_ext 1.8.2 → 1.8.3.rc0

Sign up to get free protection for your applications and to get access to all the features.
Binary file
data/LICENSE CHANGED
@@ -175,7 +175,7 @@
175
175
 
176
176
  END OF TERMS AND CONDITIONS
177
177
 
178
- Copyright 2008-2010 10gen, Inc.
178
+ Copyright (C) 2008-2013 10gen, Inc.
179
179
 
180
180
  Licensed under the Apache License, Version 2.0 (the "License");
181
181
  you may not use this file except in compliance with the License.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.8.2
1
+ 1.8.3.rc0
@@ -3,13 +3,16 @@ Gem::Specification.new do |s|
3
3
 
4
4
  s.version = File.read(File.join(File.dirname(__FILE__), 'VERSION'))
5
5
  s.platform = Gem::Platform::RUBY
6
- s.authors = ['Tyler Brock', 'Gary Murakami', 'Emily Stolfo', 'Brandon Black']
6
+ s.authors = ['Tyler Brock', 'Gary Murakami', 'Emily Stolfo', 'Brandon Black', 'Durran Jordan']
7
7
  s.email = 'mongodb-dev@googlegroups.com'
8
8
  s.homepage = 'http://www.mongodb.org'
9
9
  s.summary = 'C extensions for Ruby BSON.'
10
10
  s.description = 'C extensions to accelerate the Ruby BSON serialization. For more information about BSON, see http://bsonspec.org. For information about MongoDB, see http://www.mongodb.org.'
11
11
  s.rubyforge_project = 'bson_ext'
12
12
 
13
+ s.signing_key = 'gem-private_key.pem'
14
+ s.cert_chain = ['gem-public_cert.pem']
15
+
13
16
  s.files = ['bson_ext.gemspec', 'LICENSE', 'VERSION']
14
17
  s.files += Dir['ext/**/*.rb'] + Dir['ext/**/*.c'] + Dir['ext/**/*.h']
15
18
 
@@ -1,19 +1,3 @@
1
- /*
2
- * Copyright 2009-2010 10gen, Inc.
3
- *
4
- * Licensed under the Apache License, Version 2.0 (the "License");
5
- * you may not use this file except in compliance with the License.
6
- * You may obtain a copy of the License at
7
- *
8
- * http://www.apache.org/licenses/LICENSE-2.0
9
- *
10
- * Unless required by applicable law or agreed to in writing, software
11
- * distributed under the License is distributed on an "AS IS" BASIS,
12
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- * See the License for the specific language governing permissions and
14
- * limitations under the License.
15
- */
16
-
17
1
  #include <stdlib.h>
18
2
  #include <string.h>
19
3
 
@@ -1,19 +1,3 @@
1
- /*
2
- * Copyright 2009-2010 10gen, Inc.
3
- *
4
- * Licensed under the Apache License, Version 2.0 (the "License");
5
- * you may not use this file except in compliance with the License.
6
- * You may obtain a copy of the License at
7
- *
8
- * http://www.apache.org/licenses/LICENSE-2.0
9
- *
10
- * Unless required by applicable law or agreed to in writing, software
11
- * distributed under the License is distributed on an "AS IS" BASIS,
12
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- * See the License for the specific language governing permissions and
14
- * limitations under the License.
15
- */
16
-
17
1
  #ifndef _BSON_BUFFER_H
18
2
  #define _BSON_BUFFER_H
19
3
 
@@ -1,19 +1,3 @@
1
- /*
2
- * Copyright 2009-2010 10gen, Inc.
3
- *
4
- * Licensed under the Apache License, Version 2.0 (the "License");
5
- * you may not use this file except in compliance with the License.
6
- * You may obtain a copy of the License at
7
- *
8
- * http://www.apache.org/licenses/LICENSE-2.0
9
- *
10
- * Unless required by applicable law or agreed to in writing, software
11
- * distributed under the License is distributed on an "AS IS" BASIS,
12
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- * See the License for the specific language governing permissions and
14
- * limitations under the License.
15
- */
16
-
17
1
  /*
18
2
  * This file contains C implementations of some of the functions needed by the
19
3
  * bson module. If possible, these implementations should be used to speed up
@@ -93,6 +77,7 @@ static VALUE OrderedHash;
93
77
  static VALUE InvalidKeyName;
94
78
  static VALUE InvalidStringEncoding;
95
79
  static VALUE InvalidDocument;
80
+ static VALUE InvalidObjectId;
96
81
  static VALUE DigestMD5;
97
82
  static VALUE RB_HASH;
98
83
 
@@ -114,7 +99,7 @@ static int max_bson_size;
114
99
  #endif
115
100
 
116
101
  static void write_utf8(bson_buffer_t buffer, VALUE string, char check_null) {
117
- result_t status = check_string(RSTRING_PTR(string), RSTRING_LEN(string),
102
+ result_t status = check_string((unsigned char*)RSTRING_PTR(string), RSTRING_LEN(string),
118
103
  1, check_null);
119
104
  if (status == HAS_NULL) {
120
105
  bson_buffer_free(buffer);
@@ -298,7 +283,6 @@ static int write_element(VALUE key, VALUE value, VALUE extra, int allow_id) {
298
283
  {
299
284
  bson_buffer_position length_location, start_position, obj_length;
300
285
  int items, i;
301
- VALUE* values;
302
286
 
303
287
  write_name_and_type(buffer, key, 0x04);
304
288
  start_position = bson_buffer_get_position(buffer);
@@ -435,7 +419,7 @@ static int write_element(VALUE key, VALUE value, VALUE extra, int allow_id) {
435
419
  if (strcmp(cls, "BSON::Timestamp") == 0) {
436
420
  unsigned int seconds;
437
421
  unsigned int increment;
438
-
422
+
439
423
  write_name_and_type(buffer, key, 0x11);
440
424
 
441
425
  seconds = NUM2UINT(
@@ -620,7 +604,7 @@ static void write_doc(bson_buffer_t buffer, VALUE hash, VALUE check_keys, VALUE
620
604
  if (length > bson_buffer_get_max_size(buffer)) {
621
605
  bson_buffer_free(buffer);
622
606
  rb_raise(InvalidDocument,
623
- "Document too large: This BSON documents is limited to %d bytes.",
607
+ "Document too large: This BSON document is limited to %d bytes.",
624
608
  bson_buffer_get_max_size(buffer));
625
609
  return;
626
610
  }
@@ -924,6 +908,85 @@ static VALUE method_deserialize(VALUE self, VALUE bson) {
924
908
  return elements_to_hash(buffer, remaining);
925
909
  }
926
910
 
911
+ static int legal_objectid_str(VALUE str) {
912
+ int i;
913
+
914
+ if (TYPE(str) != T_STRING) {
915
+ return 0;
916
+ }
917
+
918
+ if (RSTRING_LEN(str) != 24) {
919
+ return 0;
920
+ }
921
+
922
+ for(i = 0; i < 24; i++) {
923
+ char c = RSTRING_PTR(str)[i];
924
+
925
+ if (!((c >= '0' && c <= '9') || (c >= 'A' && c <= 'F') || (c >= 'a' && c <= 'f'))) {
926
+ return 0;
927
+ }
928
+ }
929
+
930
+ return 1;
931
+ }
932
+
933
+ static VALUE objectid_legal(VALUE self, VALUE str)
934
+ {
935
+ if (legal_objectid_str(str))
936
+ return Qtrue;
937
+ return Qfalse;
938
+ }
939
+
940
+ static char hexbyte( char hex ) {
941
+ if (hex >= '0' && hex <= '9')
942
+ return (hex - '0');
943
+ else if (hex >= 'A' && hex <= 'F')
944
+ return (hex - 'A' + 10);
945
+ else if (hex >= 'a' && hex <= 'f')
946
+ return (hex - 'a' + 10);
947
+ else
948
+ return 0x0;
949
+ }
950
+
951
+ static VALUE objectid_from_string(VALUE self, VALUE str)
952
+ {
953
+ VALUE oid;
954
+ int i;
955
+
956
+ if (!legal_objectid_str(str)) {
957
+ rb_raise(InvalidObjectId, "illegal ObjectId format: %s", RSTRING_PTR(str));
958
+ }
959
+
960
+ oid = rb_ary_new2(12);
961
+
962
+ for(i = 0; i < 12; i++) {
963
+ rb_ary_store(oid, i, INT2FIX( (unsigned)(hexbyte( RSTRING_PTR(str)[2*i] ) << 4 ) | hexbyte( RSTRING_PTR(str)[2*i + 1] )));
964
+ }
965
+
966
+ return rb_class_new_instance(1, &oid, ObjectId);
967
+ }
968
+
969
+ static VALUE objectid_to_s(VALUE self)
970
+ {
971
+ VALUE data;
972
+ char cstr[25];
973
+ VALUE rstr;
974
+ VALUE *data_arr;
975
+
976
+ data = rb_iv_get(self, "@data");
977
+ data_arr = RARRAY_PTR(data);
978
+
979
+ sprintf(cstr, "%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x",
980
+ (unsigned)NUM2INT(data_arr[0]), (unsigned)NUM2INT(data_arr[1]), (unsigned)NUM2INT(data_arr[2]), (unsigned)NUM2INT(data_arr[3]),
981
+ (unsigned)NUM2INT(data_arr[4]), (unsigned)NUM2INT(data_arr[5]), (unsigned)NUM2INT(data_arr[6]), (unsigned)NUM2INT(data_arr[7]),
982
+ (unsigned)NUM2INT(data_arr[8]), (unsigned)NUM2INT(data_arr[9]), (unsigned)NUM2INT(data_arr[10]), (unsigned)NUM2INT(data_arr[11]));
983
+
984
+ rstr = rb_str_new(cstr, 24);
985
+
986
+ return rstr;
987
+ }
988
+
989
+
927
990
  static VALUE objectid_generate(int argc, VALUE* args, VALUE self)
928
991
  {
929
992
  VALUE oid;
@@ -1002,6 +1065,7 @@ void Init_cbson() {
1002
1065
  InvalidKeyName = rb_const_get(bson, rb_intern("InvalidKeyName"));
1003
1066
  InvalidStringEncoding = rb_const_get(bson, rb_intern("InvalidStringEncoding"));
1004
1067
  InvalidDocument = rb_const_get(bson, rb_intern("InvalidDocument"));
1068
+ InvalidObjectId = rb_const_get(bson, rb_intern("InvalidObjectId"));
1005
1069
  rb_require("bson/ordered_hash");
1006
1070
  OrderedHash = rb_const_get(bson, rb_intern("OrderedHash"));
1007
1071
  RB_HASH = rb_const_get(bson, rb_intern("Hash"));
@@ -1018,6 +1082,9 @@ void Init_cbson() {
1018
1082
  Digest = rb_const_get(rb_cObject, rb_intern("Digest"));
1019
1083
  DigestMD5 = rb_const_get(Digest, rb_intern("MD5"));
1020
1084
 
1085
+ rb_define_singleton_method(ObjectId, "legal?", objectid_legal, 1);
1086
+ rb_define_singleton_method(ObjectId, "from_string", objectid_from_string, 1);
1087
+ rb_define_method(ObjectId, "to_s", objectid_to_s, 0);
1021
1088
  rb_define_method(ObjectId, "generate", objectid_generate, -1);
1022
1089
 
1023
1090
  if (gethostname(hostname, MAX_HOSTNAME_LENGTH) != 0) {
@@ -1,19 +1,3 @@
1
- /*
2
- * Copyright 2009-2010 10gen, Inc.
3
- *
4
- * Licensed under the Apache License, Version 2.0 (the "License");
5
- * you may not use this file except in compliance with the License.
6
- * You may obtain a copy of the License at
7
- *
8
- * http://www.apache.org/licenses/LICENSE-2.0
9
- *
10
- * Unless required by applicable law or agreed to in writing, software
11
- * distributed under the License is distributed on an "AS IS" BASIS,
12
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- * See the License for the specific language governing permissions and
14
- * limitations under the License.
15
- */
16
-
17
1
  #include "encoding_helpers.h"
18
2
 
19
3
  /*
@@ -1,19 +1,3 @@
1
- /*
2
- * Copyright 2009-2010 10gen, Inc.
3
- *
4
- * Licensed under the Apache License, Version 2.0 (the "License");
5
- * you may not use this file except in compliance with the License.
6
- * You may obtain a copy of the License at
7
- *
8
- * http://www.apache.org/licenses/LICENSE-2.0
9
- *
10
- * Unless required by applicable law or agreed to in writing, software
11
- * distributed under the License is distributed on an "AS IS" BASIS,
12
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- * See the License for the specific language governing permissions and
14
- * limitations under the License.
15
- */
16
-
17
1
  #ifndef ENCODING_HELPERS_H
18
2
  #define ENCODING_HELPERS_H
19
3
 
@@ -1,17 +1 @@
1
- /*
2
- * Copyright 2009-2010 10gen, Inc.
3
- *
4
- * Licensed under the Apache License, Version 2.0 (the "License");
5
- * you may not use this file except in compliance with the License.
6
- * You may obtain a copy of the License at
7
- *
8
- * http://www.apache.org/licenses/LICENSE-2.0
9
- *
10
- * Unless required by applicable law or agreed to in writing, software
11
- * distributed under the License is distributed on an "AS IS" BASIS,
12
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- * See the License for the specific language governing permissions and
14
- * limitations under the License.
15
- */
16
-
17
- #define VERSION "1.8.2"
1
+ #define VERSION "1.8.3.rc0"
metadata CHANGED
@@ -1,18 +1,47 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bson_ext
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.8.2
5
- prerelease:
4
+ version: 1.8.3.rc0
5
+ prerelease: 6
6
6
  platform: ruby
7
7
  authors:
8
8
  - Tyler Brock
9
9
  - Gary Murakami
10
10
  - Emily Stolfo
11
11
  - Brandon Black
12
+ - Durran Jordan
12
13
  autorequire:
13
14
  bindir: bin
14
- cert_chain: []
15
- date: 2013-01-17 00:00:00.000000000 Z
15
+ cert_chain:
16
+ - !binary |-
17
+ LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUR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ZRFZS
34
+ MFBCQVFEQWdTd01BMEdDU3FHU0liM0RRRUJCUVVBQTRJQkFRQ0lhL1k2CnhT
35
+ N1lXQnhrbjlXUDBFTW5KM3BZOXZlZjlEVG1MU2kvMmp6OFB6d2xLUTg5ek5U
36
+ cnFTVUQ4TG9RWm1CcUNKQnQKZEtTUS9SVW5hSEp1eGg4SFd2V3ViUDhFQllU
37
+ dWYrSTFERm5SdjY0OElGM01SMXRDUXVtVkwwWGNZTXZaY3hCagphL3ArOERv
38
+ bVdUUXFVZE5iTm9HeXd3anRWQldmRGR3RlY4UG8xWGNOL0F0cElMT0pRZDlK
39
+ NzdJTklHR0NIeFpvCjZTT0hIYU5rbmxFOUgwdzZxMFNWeFpLWkk4LysyYzQ0
40
+ N1YwTnJISXcxUWhlMHRBR0o5VjF1M2t5OGd5eGUwU00KOHY3ekxGMlhsaVli
41
+ ZnVyWUl3a2NYczh5UG44Z2dBcEJJeTliWDZWSnhScy9sMitVdnF6YUhJRmFG
42
+ eS9GOC9HUApSTlR1WHNWRzVOREFDbzdRCi0tLS0tRU5EIENFUlRJRklDQVRF
43
+ LS0tLS0K
44
+ date: 2013-02-14 00:00:00.000000000 Z
16
45
  dependencies:
17
46
  - !ruby/object:Gem::Dependency
18
47
  name: bson
@@ -21,7 +50,7 @@ dependencies:
21
50
  requirements:
22
51
  - - ~>
23
52
  - !ruby/object:Gem::Version
24
- version: 1.8.2
53
+ version: 1.8.3.rc0
25
54
  type: :runtime
26
55
  prerelease: false
27
56
  version_requirements: !ruby/object:Gem::Requirement
@@ -29,7 +58,7 @@ dependencies:
29
58
  requirements:
30
59
  - - ~>
31
60
  - !ruby/object:Gem::Version
32
- version: 1.8.2
61
+ version: 1.8.3.rc0
33
62
  description: C extensions to accelerate the Ruby BSON serialization. For more information
34
63
  about BSON, see http://bsonspec.org. For information about MongoDB, see http://www.mongodb.org.
35
64
  email: mongodb-dev@googlegroups.com
@@ -60,18 +89,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
60
89
  - - ! '>='
61
90
  - !ruby/object:Gem::Version
62
91
  version: '0'
63
- segments:
64
- - 0
65
- hash: -591947596938711831
66
92
  required_rubygems_version: !ruby/object:Gem::Requirement
67
93
  none: false
68
94
  requirements:
69
- - - ! '>='
95
+ - - ! '>'
70
96
  - !ruby/object:Gem::Version
71
- version: '0'
97
+ version: 1.3.1
72
98
  requirements: []
73
99
  rubyforge_project: bson_ext
74
- rubygems_version: 1.8.24
100
+ rubygems_version: 1.8.23
75
101
  signing_key:
76
102
  specification_version: 3
77
103
  summary: C extensions for Ruby BSON.
Binary file