bson 2.2.3 → 2.2.4
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 +4 -4
- data/lib/bson.rb +2 -1
- data/lib/bson/array.rb +1 -1
- data/lib/bson/binary.rb +1 -1
- data/lib/bson/boolean.rb +1 -1
- data/lib/bson/code.rb +1 -1
- data/lib/bson/code_with_scope.rb +1 -1
- data/lib/bson/date.rb +1 -1
- data/lib/bson/date_time.rb +1 -1
- data/lib/bson/document.rb +1 -1
- data/lib/bson/encodable.rb +1 -1
- data/lib/bson/environment.rb +1 -1
- data/lib/bson/false_class.rb +1 -1
- data/lib/bson/float.rb +1 -1
- data/lib/bson/hash.rb +1 -1
- 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 -1
- 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.rb +61 -0
- data/lib/bson/object_id.rb +1 -1
- 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 +1 -1
- data/lib/bson/symbol.rb +1 -1
- 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 +1 -1
- data/spec/bson/binary_spec.rb +1 -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 +1 -1
- data/spec/bson/date_spec.rb +1 -1
- data/spec/bson/date_time_spec.rb +1 -1
- 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 +18 -1
- data/spec/bson/object_spec.rb +31 -0
- data/spec/bson/regexp_spec.rb +1 -1
- data/spec/bson/registry_spec.rb +1 -1
- data/spec/bson/string_spec.rb +1 -1
- data/spec/bson/symbol_spec.rb +1 -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 +1 -1
- data/spec/support/shared_examples.rb +1 -1
- metadata +6 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 33f503f9418e54b133f0115a51c642a1413de120
|
4
|
+
data.tar.gz: e2ad2a8903b3a672328ebaad368e6d6e24b33579
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5cb2f4d67d4eed6883435e9c0411f3fb9f8169fd90db9606b61b48e69ade2d6ecda1ec6e15bcd87ec7dee7c071a34a2dff610dee4547f52adbe5ac040691366a
|
7
|
+
data.tar.gz: c8b362f0718d233c8a3cacc32c52034b8eac59c74c08b0847994f263a653715af424b1621e8e973c33325152f78265a45b66f3fd09f4354240f1e673ff6f1e29
|
data/lib/bson.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (C) 2009-
|
1
|
+
# Copyright (C) 2009-2014 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.
|
@@ -61,6 +61,7 @@ require "bson/hash"
|
|
61
61
|
require "bson/max_key"
|
62
62
|
require "bson/min_key"
|
63
63
|
require "bson/nil_class"
|
64
|
+
require "bson/object"
|
64
65
|
require "bson/object_id"
|
65
66
|
require "bson/regexp"
|
66
67
|
require "bson/string"
|
data/lib/bson/array.rb
CHANGED
data/lib/bson/binary.rb
CHANGED
data/lib/bson/boolean.rb
CHANGED
data/lib/bson/code.rb
CHANGED
data/lib/bson/code_with_scope.rb
CHANGED
data/lib/bson/date.rb
CHANGED
data/lib/bson/date_time.rb
CHANGED
data/lib/bson/document.rb
CHANGED
data/lib/bson/encodable.rb
CHANGED
data/lib/bson/environment.rb
CHANGED
data/lib/bson/false_class.rb
CHANGED
data/lib/bson/float.rb
CHANGED
data/lib/bson/hash.rb
CHANGED
data/lib/bson/int32.rb
CHANGED
data/lib/bson/int64.rb
CHANGED
data/lib/bson/integer.rb
CHANGED
data/lib/bson/json.rb
CHANGED
data/lib/bson/max_key.rb
CHANGED
data/lib/bson/min_key.rb
CHANGED
data/lib/bson/nil_class.rb
CHANGED
data/lib/bson/object.rb
ADDED
@@ -0,0 +1,61 @@
|
|
1
|
+
# Copyright (C) 2009-2014 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
|
+
module BSON
|
16
|
+
|
17
|
+
# Injects behaviour for all Ruby objects.
|
18
|
+
#
|
19
|
+
# @since 2.2.4
|
20
|
+
module Object
|
21
|
+
|
22
|
+
# Objects that don't override this method will raise an error when trying
|
23
|
+
# to use them as keys in a BSON document. This is only overridden in String
|
24
|
+
# and Symbol.
|
25
|
+
#
|
26
|
+
# @example Convert the object to a BSON key.
|
27
|
+
# object.to_bson_key
|
28
|
+
#
|
29
|
+
# @raise [ InvalidKey ] Always raises an exception.
|
30
|
+
#
|
31
|
+
# @see http://bsonspec.org/#/specification
|
32
|
+
#
|
33
|
+
# @since 2.2.4
|
34
|
+
def to_bson_key(encoded = ''.force_encoding(BINARY))
|
35
|
+
raise InvalidKey.new(self)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
# Raised when trying to serialize an object into a key.
|
40
|
+
#
|
41
|
+
# @since 2.2.4
|
42
|
+
class InvalidKey < RuntimeError
|
43
|
+
|
44
|
+
# Instantiate the exception.
|
45
|
+
#
|
46
|
+
# @example Instantiate the exception.
|
47
|
+
# BSON::Object::InvalidKey.new(object)
|
48
|
+
#
|
49
|
+
# @param [ Object ] object The object that was meant for the key.
|
50
|
+
#
|
51
|
+
# @since 2.2.4
|
52
|
+
def initialize(object)
|
53
|
+
super("#{object.class} instances are not allowed as keys in a BSON document.")
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
# Enrich the core Object class with this module.
|
58
|
+
#
|
59
|
+
# @since 2.2.4
|
60
|
+
::Object.send(:include, Object)
|
61
|
+
end
|
data/lib/bson/object_id.rb
CHANGED
data/lib/bson/regexp.rb
CHANGED
data/lib/bson/registry.rb
CHANGED
data/lib/bson/specialized.rb
CHANGED
data/lib/bson/string.rb
CHANGED
data/lib/bson/symbol.rb
CHANGED
data/lib/bson/time.rb
CHANGED
data/lib/bson/timestamp.rb
CHANGED
data/lib/bson/true_class.rb
CHANGED
data/lib/bson/undefined.rb
CHANGED
data/lib/bson/version.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (C) 2009-
|
1
|
+
# Copyright (C) 2009-2014 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.
|
@@ -13,5 +13,5 @@
|
|
13
13
|
# limitations under the License.
|
14
14
|
|
15
15
|
module BSON
|
16
|
-
VERSION = "2.2.
|
16
|
+
VERSION = "2.2.4"
|
17
17
|
end
|
data/spec/bson/array_spec.rb
CHANGED
data/spec/bson/binary_spec.rb
CHANGED
data/spec/bson/boolean_spec.rb
CHANGED
data/spec/bson/code_spec.rb
CHANGED
data/spec/bson/date_spec.rb
CHANGED
data/spec/bson/date_time_spec.rb
CHANGED
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) 2009-
|
1
|
+
# Copyright (C) 2009-2014 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.
|
@@ -521,4 +521,21 @@ describe BSON::ObjectId do
|
|
521
521
|
expect(registered).to eq(described_class)
|
522
522
|
end
|
523
523
|
end
|
524
|
+
|
525
|
+
context "when the ids are used as keys" do
|
526
|
+
|
527
|
+
let(:object_id) do
|
528
|
+
described_class.new
|
529
|
+
end
|
530
|
+
|
531
|
+
let(:hash) do
|
532
|
+
{ object_id => 1 }
|
533
|
+
end
|
534
|
+
|
535
|
+
it "raises an exception on serialization" do
|
536
|
+
expect {
|
537
|
+
hash.to_bson
|
538
|
+
}.to raise_error(BSON::InvalidKey)
|
539
|
+
end
|
540
|
+
end
|
524
541
|
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# Copyright (C) 2009-2014 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 BSON::Object do
|
18
|
+
|
19
|
+
describe "#to_bson_key" do
|
20
|
+
|
21
|
+
let(:object) do
|
22
|
+
1..3
|
23
|
+
end
|
24
|
+
|
25
|
+
it "raises an exception" do
|
26
|
+
expect {
|
27
|
+
object.to_bson_key
|
28
|
+
}.to raise_error(BSON::InvalidKey)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
data/spec/bson/regexp_spec.rb
CHANGED
data/spec/bson/registry_spec.rb
CHANGED
data/spec/bson/string_spec.rb
CHANGED
data/spec/bson/symbol_spec.rb
CHANGED
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
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bson
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.2.
|
4
|
+
version: 2.2.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tyler Brock
|
@@ -12,7 +12,7 @@ authors:
|
|
12
12
|
autorequire:
|
13
13
|
bindir: bin
|
14
14
|
cert_chain: []
|
15
|
-
date: 2014-05-
|
15
|
+
date: 2014-05-20 00:00:00.000000000 Z
|
16
16
|
dependencies: []
|
17
17
|
description: A full featured BSON specification implementation, in Ruby
|
18
18
|
email:
|
@@ -51,6 +51,7 @@ files:
|
|
51
51
|
- lib/bson/max_key.rb
|
52
52
|
- lib/bson/min_key.rb
|
53
53
|
- lib/bson/nil_class.rb
|
54
|
+
- lib/bson/object.rb
|
54
55
|
- lib/bson/object_id.rb
|
55
56
|
- lib/bson/regexp.rb
|
56
57
|
- lib/bson/registry.rb
|
@@ -81,6 +82,7 @@ files:
|
|
81
82
|
- spec/bson/min_key_spec.rb
|
82
83
|
- spec/bson/nil_class_spec.rb
|
83
84
|
- spec/bson/object_id_spec.rb
|
85
|
+
- spec/bson/object_spec.rb
|
84
86
|
- spec/bson/regexp_spec.rb
|
85
87
|
- spec/bson/registry_spec.rb
|
86
88
|
- spec/bson/string_spec.rb
|
@@ -104,7 +106,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
104
106
|
requirements:
|
105
107
|
- - ">="
|
106
108
|
- !ruby/object:Gem::Version
|
107
|
-
version: 1.
|
109
|
+
version: 1.9.3
|
108
110
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
109
111
|
requirements:
|
110
112
|
- - ">="
|
@@ -136,6 +138,7 @@ test_files:
|
|
136
138
|
- spec/bson/min_key_spec.rb
|
137
139
|
- spec/bson/nil_class_spec.rb
|
138
140
|
- spec/bson/object_id_spec.rb
|
141
|
+
- spec/bson/object_spec.rb
|
139
142
|
- spec/bson/regexp_spec.rb
|
140
143
|
- spec/bson/registry_spec.rb
|
141
144
|
- spec/bson/string_spec.rb
|