bson 2.0.0.rc-java → 2.1.0-java
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of bson might be problematic. Click here for more details.
- checksums.yaml +7 -0
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/CHANGELOG.md +9 -0
- data/LICENSE +1 -1
- data/NOTICE +1 -1
- data/README.md +7 -1
- data/Rakefile +25 -8
- data/lib/bson-ruby.jar +0 -0
- data/lib/bson.rb +3 -1
- data/lib/bson/array.rb +18 -1
- data/lib/bson/binary.rb +56 -1
- data/lib/bson/boolean.rb +1 -1
- data/lib/bson/code.rb +1 -1
- data/lib/bson/code_with_scope.rb +7 -5
- data/lib/bson/date.rb +44 -0
- data/lib/bson/date_time.rb +65 -0
- data/lib/bson/document.rb +1 -1
- data/lib/bson/encodable.rb +1 -1
- data/lib/bson/environment.rb +13 -1
- data/lib/bson/false_class.rb +1 -1
- data/lib/bson/float.rb +1 -1
- data/lib/bson/hash.rb +3 -3
- data/lib/bson/int32.rb +1 -1
- data/lib/bson/int64.rb +1 -1
- data/lib/bson/integer.rb +1 -1
- data/lib/bson/json.rb +1 -3
- data/lib/bson/max_key.rb +1 -1
- data/lib/bson/min_key.rb +1 -1
- data/lib/bson/nil_class.rb +1 -1
- data/lib/bson/object_id.rb +79 -6
- data/lib/bson/regexp.rb +1 -1
- data/lib/bson/registry.rb +1 -1
- data/lib/bson/specialized.rb +1 -1
- data/lib/bson/string.rb +20 -3
- data/lib/bson/symbol.rb +2 -2
- data/lib/bson/time.rb +1 -1
- data/lib/bson/timestamp.rb +1 -1
- data/lib/bson/true_class.rb +1 -1
- data/lib/bson/undefined.rb +1 -1
- data/lib/bson/version.rb +2 -2
- data/spec/bson/array_spec.rb +28 -1
- data/spec/bson/binary_spec.rb +16 -1
- data/spec/bson/boolean_spec.rb +1 -1
- data/spec/bson/code_spec.rb +1 -1
- data/spec/bson/code_with_scope_spec.rb +34 -7
- data/spec/bson/date_spec.rb +39 -0
- data/spec/bson/date_time_spec.rb +37 -0
- data/spec/bson/document_spec.rb +1 -1
- data/spec/bson/false_class_spec.rb +1 -1
- data/spec/bson/float_spec.rb +1 -1
- data/spec/bson/hash_spec.rb +1 -1
- data/spec/bson/int32_spec.rb +1 -1
- data/spec/bson/int64_spec.rb +1 -1
- data/spec/bson/integer_spec.rb +1 -1
- data/spec/bson/json_spec.rb +1 -1
- data/spec/bson/max_key_spec.rb +1 -1
- data/spec/bson/min_key_spec.rb +1 -1
- data/spec/bson/nil_class_spec.rb +1 -1
- data/spec/bson/object_id_spec.rb +110 -1
- data/spec/bson/regexp_spec.rb +1 -1
- data/spec/bson/registry_spec.rb +1 -1
- data/spec/bson/string_spec.rb +29 -2
- data/spec/bson/symbol_spec.rb +11 -1
- data/spec/bson/time_spec.rb +1 -1
- data/spec/bson/timestamp_spec.rb +1 -1
- data/spec/bson/true_class_spec.rb +1 -1
- data/spec/bson/undefined_spec.rb +1 -1
- data/spec/bson_spec.rb +1 -1
- data/spec/spec_helper.rb +3 -2
- data/spec/support/shared_examples.rb +1 -1
- metadata +16 -12
- metadata.gz.sig +0 -0
@@ -0,0 +1,39 @@
|
|
1
|
+
# Copyright (C) 2009-2013 MongoDB Inc.
|
2
|
+
#
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
# you may not use this file except in compliance with the License.
|
5
|
+
# You may obtain a copy of the License at
|
6
|
+
#
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
#
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
# See the License for the specific language governing permissions and
|
13
|
+
# limitations under the License.
|
14
|
+
|
15
|
+
require "spec_helper"
|
16
|
+
|
17
|
+
describe Date do
|
18
|
+
|
19
|
+
describe "#to_bson" do
|
20
|
+
|
21
|
+
context "when the date is post epoch" do
|
22
|
+
|
23
|
+
let(:obj) { Date.new(2012, 1, 1) }
|
24
|
+
let(:time) { Time.utc(2012, 1, 1) }
|
25
|
+
let(:bson) { [ (time.to_f * 1000).to_i ].pack(BSON::Int64::PACK) }
|
26
|
+
|
27
|
+
it_behaves_like "a serializable bson element"
|
28
|
+
end
|
29
|
+
|
30
|
+
context "when the date is pre epoch" do
|
31
|
+
|
32
|
+
let(:obj) { Date.new(1969, 1, 1) }
|
33
|
+
let(:time) { Time.utc(1969, 1, 1) }
|
34
|
+
let(:bson) { [ (time.to_f * 1000).to_i ].pack(BSON::Int64::PACK) }
|
35
|
+
|
36
|
+
it_behaves_like "a serializable bson element"
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# Copyright (C) 2009-2013 MongoDB Inc.
|
2
|
+
#
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
# you may not use this file except in compliance with the License.
|
5
|
+
# You may obtain a copy of the License at
|
6
|
+
#
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
#
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
# See the License for the specific language governing permissions and
|
13
|
+
# limitations under the License.
|
14
|
+
|
15
|
+
require "spec_helper"
|
16
|
+
|
17
|
+
describe DateTime do
|
18
|
+
|
19
|
+
describe "#to_bson" do
|
20
|
+
|
21
|
+
context "when the date time is post epoch" do
|
22
|
+
|
23
|
+
let(:obj) { DateTime.new(2012, 1, 1, 0, 0, 0) }
|
24
|
+
let(:bson) { [ (obj.to_time.to_f * 1000).to_i ].pack(BSON::Int64::PACK) }
|
25
|
+
|
26
|
+
it_behaves_like "a serializable bson element"
|
27
|
+
end
|
28
|
+
|
29
|
+
context "when the date time is pre epoch" do
|
30
|
+
|
31
|
+
let(:obj) { DateTime.new(1969, 1, 1, 0, 0, 0) }
|
32
|
+
let(:bson) { [ (obj.to_time.to_f * 1000).to_i ].pack(BSON::Int64::PACK) }
|
33
|
+
|
34
|
+
it_behaves_like "a serializable bson element"
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
data/spec/bson/document_spec.rb
CHANGED
data/spec/bson/float_spec.rb
CHANGED
data/spec/bson/hash_spec.rb
CHANGED
data/spec/bson/int32_spec.rb
CHANGED
data/spec/bson/int64_spec.rb
CHANGED
data/spec/bson/integer_spec.rb
CHANGED
data/spec/bson/json_spec.rb
CHANGED
data/spec/bson/max_key_spec.rb
CHANGED
data/spec/bson/min_key_spec.rb
CHANGED
data/spec/bson/nil_class_spec.rb
CHANGED
data/spec/bson/object_id_spec.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (C) 2013
|
1
|
+
# Copyright (C) 2009-2013 MongoDB Inc.
|
2
2
|
#
|
3
3
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
4
|
# you may not use this file except in compliance with the License.
|
@@ -245,6 +245,50 @@ describe BSON::ObjectId do
|
|
245
245
|
end
|
246
246
|
end
|
247
247
|
|
248
|
+
describe "#eql" do
|
249
|
+
|
250
|
+
context "when data is identical" do
|
251
|
+
|
252
|
+
let(:time) do
|
253
|
+
Time.now
|
254
|
+
end
|
255
|
+
|
256
|
+
let(:object_id) do
|
257
|
+
described_class.from_time(time)
|
258
|
+
end
|
259
|
+
|
260
|
+
let(:other_id) do
|
261
|
+
described_class.from_time(time)
|
262
|
+
end
|
263
|
+
|
264
|
+
it "returns true" do
|
265
|
+
expect(object_id).to eql(other_id)
|
266
|
+
end
|
267
|
+
end
|
268
|
+
|
269
|
+
context "when the data is different" do
|
270
|
+
|
271
|
+
let(:time) do
|
272
|
+
Time.now
|
273
|
+
end
|
274
|
+
|
275
|
+
let(:object_id) do
|
276
|
+
described_class.from_time(time)
|
277
|
+
end
|
278
|
+
|
279
|
+
it "returns false" do
|
280
|
+
expect(object_id).to_not eql(described_class.new)
|
281
|
+
end
|
282
|
+
end
|
283
|
+
|
284
|
+
context "when other is not an object id" do
|
285
|
+
|
286
|
+
it "returns false" do
|
287
|
+
expect(described_class.new).to_not eql(nil)
|
288
|
+
end
|
289
|
+
end
|
290
|
+
end
|
291
|
+
|
248
292
|
describe ".from_string" do
|
249
293
|
|
250
294
|
context "when the string is valid" do
|
@@ -328,6 +372,28 @@ describe BSON::ObjectId do
|
|
328
372
|
end
|
329
373
|
end
|
330
374
|
|
375
|
+
describe "#hash" do
|
376
|
+
|
377
|
+
let(:object_id) do
|
378
|
+
described_class.new
|
379
|
+
end
|
380
|
+
|
381
|
+
it "returns a hash of the raw bytes" do
|
382
|
+
expect(object_id.hash).to eq(object_id.to_bson.hash)
|
383
|
+
end
|
384
|
+
end
|
385
|
+
|
386
|
+
describe "#inspect" do
|
387
|
+
|
388
|
+
let(:object_id) do
|
389
|
+
described_class.new
|
390
|
+
end
|
391
|
+
|
392
|
+
it "returns the inspection with the object id to_s" do
|
393
|
+
expect(object_id.inspect).to eq("BSON::ObjectId('#{object_id.to_s}')")
|
394
|
+
end
|
395
|
+
end
|
396
|
+
|
331
397
|
describe ".legal?" do
|
332
398
|
|
333
399
|
context "when the string is too short to be an object id" do
|
@@ -363,6 +429,49 @@ describe BSON::ObjectId do
|
|
363
429
|
end
|
364
430
|
end
|
365
431
|
|
432
|
+
describe "#marshal_dump" do
|
433
|
+
|
434
|
+
let(:object_id) do
|
435
|
+
described_class.new
|
436
|
+
end
|
437
|
+
|
438
|
+
let(:dumped) do
|
439
|
+
Marshal.dump(object_id)
|
440
|
+
end
|
441
|
+
|
442
|
+
it "dumps the raw bytes data" do
|
443
|
+
expect(Marshal.load(dumped)).to eq(object_id)
|
444
|
+
end
|
445
|
+
end
|
446
|
+
|
447
|
+
describe "#marshal_load" do
|
448
|
+
|
449
|
+
context "when the object id was dumped in the old format" do
|
450
|
+
|
451
|
+
let(:legacy) do
|
452
|
+
"\x04\bo:\x13BSON::ObjectId\x06:\n" +
|
453
|
+
"@data[\x11iUi\x01\xE2i,i\x00i\x00i\x00i\x00i\x00i\x00i\x00i\x00i\x00"
|
454
|
+
end
|
455
|
+
|
456
|
+
let(:object_id) do
|
457
|
+
Marshal.load(legacy)
|
458
|
+
end
|
459
|
+
|
460
|
+
let(:expected) do
|
461
|
+
described_class.from_time(Time.utc(2013, 1, 1))
|
462
|
+
end
|
463
|
+
|
464
|
+
it "properly loads the object id" do
|
465
|
+
expect(object_id).to eq(expected)
|
466
|
+
end
|
467
|
+
|
468
|
+
it "removes the bad legacy data" do
|
469
|
+
object_id.to_bson
|
470
|
+
expect(object_id.instance_variable_get(:@data)).to be_nil
|
471
|
+
end
|
472
|
+
end
|
473
|
+
end
|
474
|
+
|
366
475
|
describe "#to_bson/#from_bson" do
|
367
476
|
|
368
477
|
let(:time) { Time.utc(2013, 1, 1) }
|
data/spec/bson/regexp_spec.rb
CHANGED
data/spec/bson/registry_spec.rb
CHANGED
data/spec/bson/string_spec.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
|
-
# Copyright (C) 2013
|
3
|
+
# Copyright (C) 2009-2013 MongoDB Inc.
|
4
4
|
#
|
5
5
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
6
6
|
# you may not use this file except in compliance with the License.
|
@@ -65,7 +65,7 @@ describe String do
|
|
65
65
|
it "raises an error" do
|
66
66
|
expect {
|
67
67
|
string.to_bson_cstring
|
68
|
-
}.to raise_error(
|
68
|
+
}.to raise_error(ArgumentError)
|
69
69
|
end
|
70
70
|
end
|
71
71
|
|
@@ -128,6 +128,33 @@ describe String do
|
|
128
128
|
end
|
129
129
|
end
|
130
130
|
|
131
|
+
describe "#to_bson_object_id" do
|
132
|
+
|
133
|
+
context "when the string has 12 characters" do
|
134
|
+
|
135
|
+
let(:string) do
|
136
|
+
"123456789012"
|
137
|
+
end
|
138
|
+
|
139
|
+
let(:converted) do
|
140
|
+
string.to_bson_object_id
|
141
|
+
end
|
142
|
+
|
143
|
+
it "returns the array as a string" do
|
144
|
+
expect(converted).to eq(string)
|
145
|
+
end
|
146
|
+
end
|
147
|
+
|
148
|
+
context "when the array does not have 12 elements" do
|
149
|
+
|
150
|
+
it "raises an exception" do
|
151
|
+
expect {
|
152
|
+
"test".to_bson_object_id
|
153
|
+
}.to raise_error(BSON::ObjectId::Invalid)
|
154
|
+
end
|
155
|
+
end
|
156
|
+
end
|
157
|
+
|
131
158
|
describe "#to_bson_string" do
|
132
159
|
|
133
160
|
context "when the string is valid" do
|
data/spec/bson/symbol_spec.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (C) 2013
|
1
|
+
# Copyright (C) 2009-2013 MongoDB Inc.
|
2
2
|
#
|
3
3
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
4
|
# you may not use this file except in compliance with the License.
|
@@ -41,5 +41,15 @@ describe Symbol do
|
|
41
41
|
it "appends to optional previous content" do
|
42
42
|
expect(symbol.to_bson_key(previous_content)).to eq(previous_content << encoded)
|
43
43
|
end
|
44
|
+
|
45
|
+
context 'when the symbol contains a null byte' do
|
46
|
+
let(:symbol) { :"test#{BSON::NULL_BYTE}ing" }
|
47
|
+
|
48
|
+
it 'raises an error' do
|
49
|
+
expect {
|
50
|
+
symbol.to_bson_key
|
51
|
+
}.to raise_error(ArgumentError)
|
52
|
+
end
|
53
|
+
end
|
44
54
|
end
|
45
55
|
end
|
data/spec/bson/time_spec.rb
CHANGED
data/spec/bson/timestamp_spec.rb
CHANGED
data/spec/bson/undefined_spec.rb
CHANGED
data/spec/bson_spec.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (C) 2013
|
1
|
+
# Copyright (C) 2009-2013 MongoDB Inc.
|
2
2
|
#
|
3
3
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
4
|
# you may not use this file except in compliance with the License.
|
@@ -15,7 +15,7 @@
|
|
15
15
|
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
16
16
|
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), "..", "lib"))
|
17
17
|
|
18
|
-
if ENV["CI"]
|
18
|
+
if ENV["CI"] && !ENV["WITH_EXT"]
|
19
19
|
require "simplecov"
|
20
20
|
require "coveralls"
|
21
21
|
SimpleCov.formatter = Coveralls::SimpleCov::Formatter
|
@@ -25,6 +25,7 @@ if ENV["CI"]
|
|
25
25
|
end
|
26
26
|
|
27
27
|
require "bson"
|
28
|
+
require "json"
|
28
29
|
require "rspec"
|
29
30
|
require "yaml"
|
30
31
|
|
metadata
CHANGED
@@ -1,8 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bson
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
version: 2.0.0.rc
|
4
|
+
version: 2.1.0
|
6
5
|
platform: java
|
7
6
|
authors:
|
8
7
|
- Tyler Brock
|
@@ -34,7 +33,7 @@ cert_chain:
|
|
34
33
|
8v7zLF2XliYbfurYIwkcXs8yPn8ggApBIy9bX6VJxRs/l2+UvqzaHIFaFy/F8/GP
|
35
34
|
RNTuXsVG5NDACo7Q
|
36
35
|
-----END CERTIFICATE-----
|
37
|
-
date:
|
36
|
+
date: 2014-01-10 00:00:00.000000000 Z
|
38
37
|
dependencies: []
|
39
38
|
description: A full featured BSON specification implementation, in Ruby
|
40
39
|
email:
|
@@ -43,8 +42,8 @@ executables: []
|
|
43
42
|
extensions: []
|
44
43
|
extra_rdoc_files: []
|
45
44
|
files:
|
46
|
-
- CONTRIBUTING.md
|
47
45
|
- CHANGELOG.md
|
46
|
+
- CONTRIBUTING.md
|
48
47
|
- LICENSE
|
49
48
|
- NOTICE
|
50
49
|
- README.md
|
@@ -56,6 +55,8 @@ files:
|
|
56
55
|
- lib/bson/boolean.rb
|
57
56
|
- lib/bson/code.rb
|
58
57
|
- lib/bson/code_with_scope.rb
|
58
|
+
- lib/bson/date.rb
|
59
|
+
- lib/bson/date_time.rb
|
59
60
|
- lib/bson/document.rb
|
60
61
|
- lib/bson/encodable.rb
|
61
62
|
- lib/bson/environment.rb
|
@@ -80,13 +81,13 @@ files:
|
|
80
81
|
- lib/bson/true_class.rb
|
81
82
|
- lib/bson/undefined.rb
|
82
83
|
- lib/bson/version.rb
|
83
|
-
- spec/bson_spec.rb
|
84
|
-
- spec/spec_helper.rb
|
85
84
|
- spec/bson/array_spec.rb
|
86
85
|
- spec/bson/binary_spec.rb
|
87
86
|
- spec/bson/boolean_spec.rb
|
88
87
|
- spec/bson/code_spec.rb
|
89
88
|
- spec/bson/code_with_scope_spec.rb
|
89
|
+
- spec/bson/date_spec.rb
|
90
|
+
- spec/bson/date_time_spec.rb
|
90
91
|
- spec/bson/document_spec.rb
|
91
92
|
- spec/bson/false_class_spec.rb
|
92
93
|
- spec/bson/float_spec.rb
|
@@ -107,31 +108,32 @@ files:
|
|
107
108
|
- spec/bson/timestamp_spec.rb
|
108
109
|
- spec/bson/true_class_spec.rb
|
109
110
|
- spec/bson/undefined_spec.rb
|
111
|
+
- spec/bson_spec.rb
|
112
|
+
- spec/spec_helper.rb
|
110
113
|
- spec/support/shared_examples.rb
|
111
114
|
homepage: http://bsonspec.org
|
112
115
|
licenses:
|
113
116
|
- Apache License Version 2.0
|
117
|
+
metadata: {}
|
114
118
|
post_install_message:
|
115
119
|
rdoc_options: []
|
116
120
|
require_paths:
|
117
121
|
- lib
|
118
122
|
required_ruby_version: !ruby/object:Gem::Requirement
|
119
123
|
requirements:
|
120
|
-
- -
|
124
|
+
- - '>='
|
121
125
|
- !ruby/object:Gem::Version
|
122
126
|
version: 1.8.7
|
123
|
-
none: false
|
124
127
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
125
128
|
requirements:
|
126
|
-
- -
|
129
|
+
- - '>='
|
127
130
|
- !ruby/object:Gem::Version
|
128
131
|
version: 1.3.6
|
129
|
-
none: false
|
130
132
|
requirements: []
|
131
133
|
rubyforge_project: bson
|
132
|
-
rubygems_version:
|
134
|
+
rubygems_version: 2.2.1
|
133
135
|
signing_key:
|
134
|
-
specification_version:
|
136
|
+
specification_version: 4
|
135
137
|
summary: Ruby Implementation of the BSON specification
|
136
138
|
test_files:
|
137
139
|
- spec/bson_spec.rb
|
@@ -141,6 +143,8 @@ test_files:
|
|
141
143
|
- spec/bson/boolean_spec.rb
|
142
144
|
- spec/bson/code_spec.rb
|
143
145
|
- spec/bson/code_with_scope_spec.rb
|
146
|
+
- spec/bson/date_spec.rb
|
147
|
+
- spec/bson/date_time_spec.rb
|
144
148
|
- spec/bson/document_spec.rb
|
145
149
|
- spec/bson/false_class_spec.rb
|
146
150
|
- spec/bson/float_spec.rb
|