bson_ext 1.8.2 → 1.8.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 287e75b64b7bd5f1fe43d1e21362cf11c881b206
4
+ data.tar.gz: 788e47f8cacf5538b7714ae905c46df65cc22f86
5
+ SHA512:
6
+ metadata.gz: 9a0b7971268eed06a75feb9362c05bcf2567dd5b4247a0d60648309f46a9b8f2118dd1305e3dacdb64d8c02bed273bb826c2ddd6dbf1de501577f05f23a22b36
7
+ data.tar.gz: e219c67b0da553e281dfe317804dbdf087bd01fd890ac67b495ff14636413ca53ac6d744f236449aa7f0ae806fb7754a12d460bc0275f0298914bebd80edc30e
checksums.yaml.gz.sig ADDED
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
data/bson_ext.gemspec CHANGED
@@ -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
 
data/ext/cbson/cbson.c CHANGED
@@ -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
 
data/ext/cbson/version.h CHANGED
@@ -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"
data.tar.gz.sig ADDED
Binary file
metadata CHANGED
@@ -1,35 +1,54 @@
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
6
5
  platform: ruby
7
6
  authors:
8
7
  - Tyler Brock
9
8
  - Gary Murakami
10
9
  - Emily Stolfo
11
10
  - Brandon Black
11
+ - Durran Jordan
12
12
  autorequire:
13
13
  bindir: bin
14
- cert_chain: []
15
- date: 2013-01-17 00:00:00.000000000 Z
14
+ cert_chain:
15
+ - |
16
+ -----BEGIN CERTIFICATE-----
17
+ MIIDODCCAiCgAwIBAgIBADANBgkqhkiG9w0BAQUFADBCMRQwEgYDVQQDDAtkcml2
18
+ ZXItcnVieTEVMBMGCgmSJomT8ixkARkWBTEwZ2VuMRMwEQYKCZImiZPyLGQBGRYD
19
+ Y29tMB4XDTEzMDIwMTE0MTEzN1oXDTE0MDIwMTE0MTEzN1owQjEUMBIGA1UEAwwL
20
+ ZHJpdmVyLXJ1YnkxFTATBgoJkiaJk/IsZAEZFgUxMGdlbjETMBEGCgmSJomT8ixk
21
+ ARkWA2NvbTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBANFdSAa8fRm1
22
+ bAM9za6Z0fAH4g02bqM1NGnw8zJQrE/PFrFfY6IFCT2AsLfOwr1maVm7iU1+kdVI
23
+ IQ+iI/9+E+ArJ+rbGV3dDPQ+SLl3mLT+vXjfjcxMqI2IW6UuVtt2U3Rxd4QU0kdT
24
+ JxmcPYs5fDN6BgYc6XXgUjy3m+Kwha2pGctdciUOwEfOZ4RmNRlEZKCMLRHdFP8j
25
+ 4WTnJSGfXDiuoXICJb5yOPOZPuaapPSNXp93QkUdsqdKC32I+KMpKKYGBQ6yisfA
26
+ 5MyVPPCzLR1lP5qXVGJPnOqUAkvEUfCahg7EP9tI20qxiXrR6TSEraYhIFXL0EGY
27
+ u8KAcPHm5KkCAwEAAaM5MDcwCQYDVR0TBAIwADAdBgNVHQ4EFgQUW3dZsX70mlSM
28
+ CiPrZxAGA1vwfNcwCwYDVR0PBAQDAgSwMA0GCSqGSIb3DQEBBQUAA4IBAQCIa/Y6
29
+ xS7YWBxkn9WP0EMnJ3pY9vef9DTmLSi/2jz8PzwlKQ89zNTrqSUD8LoQZmBqCJBt
30
+ dKSQ/RUnaHJuxh8HWvWubP8EBYTuf+I1DFnRv648IF3MR1tCQumVL0XcYMvZcxBj
31
+ a/p+8DomWTQqUdNbNoGywwjtVBWfDdwFV8Po1XcN/AtpILOJQd9J77INIGGCHxZo
32
+ 6SOHHaNknlE9H0w6q0SVxZKZI8/+2c447V0NrHIw1Qhe0tAGJ9V1u3ky8gyxe0SM
33
+ 8v7zLF2XliYbfurYIwkcXs8yPn8ggApBIy9bX6VJxRs/l2+UvqzaHIFaFy/F8/GP
34
+ RNTuXsVG5NDACo7Q
35
+ -----END CERTIFICATE-----
36
+ date: 2013-03-04 00:00:00.000000000 Z
16
37
  dependencies:
17
38
  - !ruby/object:Gem::Dependency
18
39
  name: bson
19
40
  requirement: !ruby/object:Gem::Requirement
20
- none: false
21
41
  requirements:
22
42
  - - ~>
23
43
  - !ruby/object:Gem::Version
24
- version: 1.8.2
44
+ version: 1.8.3
25
45
  type: :runtime
26
46
  prerelease: false
27
47
  version_requirements: !ruby/object:Gem::Requirement
28
- none: false
29
48
  requirements:
30
49
  - - ~>
31
50
  - !ruby/object:Gem::Version
32
- version: 1.8.2
51
+ version: 1.8.3
33
52
  description: C extensions to accelerate the Ruby BSON serialization. For more information
34
53
  about BSON, see http://bsonspec.org. For information about MongoDB, see http://www.mongodb.org.
35
54
  email: mongodb-dev@googlegroups.com
@@ -50,30 +69,25 @@ files:
50
69
  - ext/cbson/version.h
51
70
  homepage: http://www.mongodb.org
52
71
  licenses: []
72
+ metadata: {}
53
73
  post_install_message:
54
74
  rdoc_options: []
55
75
  require_paths:
56
76
  - ext/bson_ext
57
77
  required_ruby_version: !ruby/object:Gem::Requirement
58
- none: false
59
78
  requirements:
60
- - - ! '>='
79
+ - - '>='
61
80
  - !ruby/object:Gem::Version
62
81
  version: '0'
63
- segments:
64
- - 0
65
- hash: -591947596938711831
66
82
  required_rubygems_version: !ruby/object:Gem::Requirement
67
- none: false
68
83
  requirements:
69
- - - ! '>='
84
+ - - '>='
70
85
  - !ruby/object:Gem::Version
71
86
  version: '0'
72
87
  requirements: []
73
88
  rubyforge_project: bson_ext
74
- rubygems_version: 1.8.24
89
+ rubygems_version: 2.0.0
75
90
  signing_key:
76
- specification_version: 3
91
+ specification_version: 4
77
92
  summary: C extensions for Ruby BSON.
78
93
  test_files: []
79
- has_rdoc: yard
metadata.gz.sig ADDED
Binary file