bson_ext 1.2.4 → 1.3.0.rc0
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.
- data/Rakefile +9 -1
- data/bson_ext.gemspec +1 -1
- data/ext/cbson/cbson.c +31 -23
- data/ext/cbson/version.h +1 -1
- metadata +7 -18
data/Rakefile
CHANGED
@@ -77,41 +77,49 @@ namespace :test do
|
|
77
77
|
Rake::TestTask.new(:rs) do |t|
|
78
78
|
t.test_files = FileList['test/replica_sets/*_test.rb']
|
79
79
|
t.verbose = true
|
80
|
+
t.ruby_opts << '-w'
|
80
81
|
end
|
81
82
|
|
82
83
|
Rake::TestTask.new(:unit) do |t|
|
83
84
|
t.test_files = FileList['test/unit/*_test.rb']
|
84
85
|
t.verbose = true
|
86
|
+
t.ruby_opts << '-w'
|
85
87
|
end
|
86
88
|
|
87
89
|
Rake::TestTask.new(:functional) do |t|
|
88
90
|
t.test_files = FileList['test/*_test.rb']
|
89
91
|
t.verbose = true
|
92
|
+
t.ruby_opts << '-w'
|
90
93
|
end
|
91
94
|
|
92
95
|
Rake::TestTask.new(:pooled_threading) do |t|
|
93
96
|
t.test_files = FileList['test/threading/*_test.rb']
|
94
97
|
t.verbose = true
|
98
|
+
t.ruby_opts << '-w'
|
95
99
|
end
|
96
100
|
|
97
101
|
Rake::TestTask.new(:auto_reconnect) do |t|
|
98
102
|
t.test_files = FileList['test/auxillary/autoreconnect_test.rb']
|
99
103
|
t.verbose = true
|
104
|
+
t.ruby_opts << '-w'
|
100
105
|
end
|
101
106
|
|
102
107
|
Rake::TestTask.new(:authentication) do |t|
|
103
108
|
t.test_files = FileList['test/auxillary/authentication_test.rb']
|
104
109
|
t.verbose = true
|
110
|
+
t.ruby_opts << '-w'
|
105
111
|
end
|
106
112
|
|
107
113
|
Rake::TestTask.new(:new_features) do |t|
|
108
114
|
t.test_files = FileList['test/auxillary/1.4_features.rb']
|
109
115
|
t.verbose = true
|
116
|
+
t.ruby_opts << '-w'
|
110
117
|
end
|
111
118
|
|
112
119
|
Rake::TestTask.new(:bson) do |t|
|
113
120
|
t.test_files = FileList['test/bson/*_test.rb']
|
114
121
|
t.verbose = true
|
122
|
+
t.ruby_opts << '-w'
|
115
123
|
end
|
116
124
|
|
117
125
|
task :drop_databases do |t|
|
@@ -138,7 +146,7 @@ task :ydoc do
|
|
138
146
|
require File.join(File.dirname(__FILE__), 'lib', 'mongo')
|
139
147
|
out = File.join('ydoc', Mongo::VERSION)
|
140
148
|
FileUtils.rm_rf('ydoc')
|
141
|
-
system "yardoc lib/**/*.rb lib/mongo/**/*.rb lib/bson/**/*.rb -e yard/yard_ext.rb -p yard/templates -o #{out} --title MongoRuby-#{Mongo::VERSION} --files docs/TUTORIAL.md,docs/GridFS.md,docs/FAQ.md,docs/REPLICA_SETS.md,docs/WRITE_CONCERN.md,docs/HISTORY.md,docs/CREDITS.md,docs/1.0_UPGRADE.md"
|
149
|
+
system "yardoc lib/**/*.rb lib/mongo/**/*.rb lib/bson/**/*.rb -e yard/yard_ext.rb -p yard/templates -o #{out} --title MongoRuby-#{Mongo::VERSION} --files docs/TUTORIAL.md,docs/GridFS.md,docs/FAQ.md,docs/REPLICA_SETS.md,docs/WRITE_CONCERN.md,docs/HISTORY.md,docs/CREDITS.md,docs/1.0_UPGRADE.md,docs/RELEASES.md"
|
142
150
|
end
|
143
151
|
|
144
152
|
namespace :bamboo do
|
data/bson_ext.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
require './lib/bson'
|
2
2
|
VERSION_HEADER = File.open(File.join(File.dirname(__FILE__), 'ext', 'cbson', 'version.h'), "r")
|
3
|
-
VERSION = VERSION_HEADER.read.scan(/VERSION
|
3
|
+
VERSION = VERSION_HEADER.read.scan(/VERSION "(\d[^"]+)"/)[0][0]
|
4
4
|
Gem::Specification.new do |s|
|
5
5
|
s.name = 'bson_ext'
|
6
6
|
|
data/ext/cbson/cbson.c
CHANGED
@@ -86,6 +86,7 @@ static VALUE DBRef;
|
|
86
86
|
static VALUE Code;
|
87
87
|
static VALUE MinKey;
|
88
88
|
static VALUE MaxKey;
|
89
|
+
static VALUE Timestamp;
|
89
90
|
static VALUE Regexp;
|
90
91
|
static VALUE OrderedHash;
|
91
92
|
static VALUE InvalidKeyName;
|
@@ -107,21 +108,12 @@ static int max_bson_size;
|
|
107
108
|
} \
|
108
109
|
_str; \
|
109
110
|
})
|
110
|
-
/* MUST call TO_UTF8 before calling write_utf8. */
|
111
111
|
#define TO_UTF8(string) rb_str_export_to_enc((string), rb_utf8_encoding())
|
112
|
-
static void write_utf8(buffer_t buffer, VALUE string, char check_null) {
|
113
|
-
result_t status = check_string(RSTRING_PTR(string), RSTRING_LENINT(string),
|
114
|
-
0, check_null);
|
115
|
-
if (status == HAS_NULL) {
|
116
|
-
buffer_free(buffer);
|
117
|
-
rb_raise(InvalidDocument, "Key names / regex patterns must not contain the NULL byte");
|
118
|
-
}
|
119
|
-
SAFE_WRITE(buffer, RSTRING_PTR(string), RSTRING_LENINT(string));
|
120
|
-
}
|
121
112
|
#else
|
122
113
|
#define STR_NEW(p,n) rb_str_new((p), (n))
|
123
|
-
/* MUST call TO_UTF8 before calling write_utf8. */
|
124
114
|
#define TO_UTF8(string) (string)
|
115
|
+
#endif
|
116
|
+
|
125
117
|
static void write_utf8(buffer_t buffer, VALUE string, char check_null) {
|
126
118
|
result_t status = check_string(RSTRING_PTR(string), RSTRING_LEN(string),
|
127
119
|
1, check_null);
|
@@ -132,9 +124,9 @@ static void write_utf8(buffer_t buffer, VALUE string, char check_null) {
|
|
132
124
|
buffer_free(buffer);
|
133
125
|
rb_raise(InvalidStringEncoding, "String not valid UTF-8");
|
134
126
|
}
|
127
|
+
string = TO_UTF8(string);
|
135
128
|
SAFE_WRITE(buffer, RSTRING_PTR(string), RSTRING_LEN(string));
|
136
129
|
}
|
137
|
-
#endif
|
138
130
|
|
139
131
|
// this sucks. but for some reason these moved around between 1.8 and 1.9
|
140
132
|
#ifdef ONIGURUMA_H
|
@@ -211,7 +203,6 @@ static VALUE pack_extra(buffer_t buffer, VALUE check_keys) {
|
|
211
203
|
|
212
204
|
static void write_name_and_type(buffer_t buffer, VALUE name, char type) {
|
213
205
|
SAFE_WRITE(buffer, &type, 1);
|
214
|
-
name = TO_UTF8(name);
|
215
206
|
write_utf8(buffer, name, 1);
|
216
207
|
SAFE_WRITE(buffer, &zero, 1);
|
217
208
|
}
|
@@ -340,7 +331,6 @@ static int write_element(VALUE key, VALUE value, VALUE extra, int allow_id) {
|
|
340
331
|
{
|
341
332
|
int length;
|
342
333
|
write_name_and_type(buffer, key, 0x02);
|
343
|
-
value = TO_UTF8(value);
|
344
334
|
length = RSTRING_LENINT(value) + 1;
|
345
335
|
SAFE_WRITE(buffer, (char*)&length, 4);
|
346
336
|
write_utf8(buffer, value, 0);
|
@@ -444,6 +434,17 @@ static int write_element(VALUE key, VALUE value, VALUE extra, int allow_id) {
|
|
444
434
|
write_name_and_type(buffer, key, 0xff);
|
445
435
|
break;
|
446
436
|
}
|
437
|
+
if (strcmp(cls, "BSON::Timestamp") == 0) {
|
438
|
+
write_name_and_type(buffer, key, 0x11);
|
439
|
+
int seconds = FIX2INT(
|
440
|
+
rb_funcall(value, rb_intern("seconds"), 0));
|
441
|
+
int increment = FIX2INT(
|
442
|
+
rb_funcall(value, rb_intern("increment"), 0));
|
443
|
+
|
444
|
+
SAFE_WRITE(buffer, (const char*)&increment, 4);
|
445
|
+
SAFE_WRITE(buffer, (const char*)&seconds, 4);
|
446
|
+
break;
|
447
|
+
}
|
447
448
|
if (strcmp(cls, "DateTime") == 0 || strcmp(cls, "Date") == 0 || strcmp(cls, "ActiveSupport::TimeWithZone") == 0) {
|
448
449
|
buffer_free(buffer);
|
449
450
|
rb_raise(InvalidDocument, "%s is not currently supported; use a UTC Time instance instead.", cls);
|
@@ -485,7 +486,6 @@ static int write_element(VALUE key, VALUE value, VALUE extra, int allow_id) {
|
|
485
486
|
|
486
487
|
write_name_and_type(buffer, key, 0x0B);
|
487
488
|
|
488
|
-
pattern = TO_UTF8(pattern);
|
489
489
|
write_utf8(buffer, pattern, 1);
|
490
490
|
SAFE_WRITE(buffer, &zero, 1);
|
491
491
|
|
@@ -825,11 +825,13 @@ static VALUE get_value(const char* buffer, int* position, int type) {
|
|
825
825
|
}
|
826
826
|
case 17:
|
827
827
|
{
|
828
|
-
int
|
829
|
-
|
830
|
-
memcpy(&
|
831
|
-
memcpy(&
|
832
|
-
|
828
|
+
int sec, inc;
|
829
|
+
VALUE argv[2];
|
830
|
+
memcpy(&inc, buffer + *position, 4);
|
831
|
+
memcpy(&sec, buffer + *position + 4, 4);
|
832
|
+
argv[0] = INT2FIX(sec);
|
833
|
+
argv[1] = INT2FIX(inc);
|
834
|
+
value = rb_class_new_instance(2, argv, Timestamp);
|
833
835
|
*position += 8;
|
834
836
|
break;
|
835
837
|
}
|
@@ -881,7 +883,7 @@ static VALUE method_deserialize(VALUE self, VALUE bson) {
|
|
881
883
|
return elements_to_hash(buffer, remaining);
|
882
884
|
}
|
883
885
|
|
884
|
-
static VALUE objectid_generate(VALUE self)
|
886
|
+
static VALUE objectid_generate(int argc, VALUE* args, VALUE self)
|
885
887
|
{
|
886
888
|
VALUE oid;
|
887
889
|
unsigned char oid_bytes[12];
|
@@ -889,7 +891,11 @@ static VALUE objectid_generate(VALUE self)
|
|
889
891
|
unsigned short pid;
|
890
892
|
int i;
|
891
893
|
|
892
|
-
|
894
|
+
if(argc == 0 || (argc == 1 && *args == Qnil)) {
|
895
|
+
t = htonl((int)time(NULL));
|
896
|
+
} else {
|
897
|
+
t = htonl(FIX2INT(rb_funcall(*args, rb_intern("to_i"), 0)));
|
898
|
+
}
|
893
899
|
MEMCPY(&oid_bytes, &t, unsigned char, 4);
|
894
900
|
|
895
901
|
MEMCPY(&oid_bytes[4], hostname_digest, unsigned char, 3);
|
@@ -948,6 +954,8 @@ void Init_cbson() {
|
|
948
954
|
rb_require("bson/types/min_max_keys");
|
949
955
|
MinKey = rb_const_get(bson, rb_intern("MinKey"));
|
950
956
|
MaxKey = rb_const_get(bson, rb_intern("MaxKey"));
|
957
|
+
rb_require("bson/types/timestamp");
|
958
|
+
Timestamp = rb_const_get(bson, rb_intern("Timestamp"));
|
951
959
|
Regexp = rb_const_get(rb_cObject, rb_intern("Regexp"));
|
952
960
|
rb_require("bson/exceptions");
|
953
961
|
InvalidKeyName = rb_const_get(bson, rb_intern("InvalidKeyName"));
|
@@ -969,7 +977,7 @@ void Init_cbson() {
|
|
969
977
|
Digest = rb_const_get(rb_cObject, rb_intern("Digest"));
|
970
978
|
DigestMD5 = rb_const_get(Digest, rb_intern("MD5"));
|
971
979
|
|
972
|
-
rb_define_method(ObjectId, "generate", objectid_generate,
|
980
|
+
rb_define_method(ObjectId, "generate", objectid_generate, -1);
|
973
981
|
|
974
982
|
if (gethostname(hostname, MAX_HOSTNAME_LENGTH) != 0) {
|
975
983
|
rb_raise(rb_eRuntimeError, "failed to get hostname");
|
data/ext/cbson/version.h
CHANGED
metadata
CHANGED
@@ -1,13 +1,8 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bson_ext
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
|
6
|
-
segments:
|
7
|
-
- 1
|
8
|
-
- 2
|
9
|
-
- 4
|
10
|
-
version: 1.2.4
|
4
|
+
prerelease: 6
|
5
|
+
version: 1.3.0.rc0
|
11
6
|
platform: ruby
|
12
7
|
authors:
|
13
8
|
- Mike Dirolf
|
@@ -15,7 +10,7 @@ autorequire:
|
|
15
10
|
bindir: bin
|
16
11
|
cert_chain: []
|
17
12
|
|
18
|
-
date: 2011-
|
13
|
+
date: 2011-03-29 00:00:00 -04:00
|
19
14
|
default_executable:
|
20
15
|
dependencies: []
|
21
16
|
|
@@ -37,7 +32,7 @@ files:
|
|
37
32
|
- ext/cbson/buffer.h
|
38
33
|
- ext/cbson/encoding_helpers.h
|
39
34
|
- ext/cbson/version.h
|
40
|
-
has_rdoc:
|
35
|
+
has_rdoc: true
|
41
36
|
homepage: http://www.mongodb.org
|
42
37
|
licenses: []
|
43
38
|
|
@@ -51,23 +46,17 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
51
46
|
requirements:
|
52
47
|
- - ">="
|
53
48
|
- !ruby/object:Gem::Version
|
54
|
-
hash: 3
|
55
|
-
segments:
|
56
|
-
- 0
|
57
49
|
version: "0"
|
58
50
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
59
51
|
none: false
|
60
52
|
requirements:
|
61
|
-
- - "
|
53
|
+
- - ">"
|
62
54
|
- !ruby/object:Gem::Version
|
63
|
-
|
64
|
-
segments:
|
65
|
-
- 0
|
66
|
-
version: "0"
|
55
|
+
version: 1.3.1
|
67
56
|
requirements: []
|
68
57
|
|
69
58
|
rubyforge_project:
|
70
|
-
rubygems_version: 1.
|
59
|
+
rubygems_version: 1.5.2
|
71
60
|
signing_key:
|
72
61
|
specification_version: 3
|
73
62
|
summary: C extensions for Ruby BSON.
|