bson 4.0.0.rc0 → 4.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/lib/bson/binary.rb +1 -1
- data/lib/bson/hash.rb +1 -1
- data/lib/bson/integer.rb +2 -3
- data/lib/bson/registry.rb +1 -1
- data/lib/bson/symbol.rb +17 -1
- data/lib/bson/version.rb +1 -1
- data/spec/bson/document_spec.rb +1 -10
- data/spec/bson/hash_spec.rb +15 -0
- data/spec/bson/integer_spec.rb +3 -3
- data/spec/bson/registry_spec.rb +2 -4
- data/spec/bson/symbol_spec.rb +8 -2
- data/spec/spec_helper.rb +0 -9
- metadata +3 -3
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1da958014f886d3397ae3f00264fc2785bd1189b
|
4
|
+
data.tar.gz: cf112e2192dbf457e3dbea275c2b154a67611aa0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1f78c538b5b3e003a880cd93780f45f389163c629b519284b77ca5304f69a682d15d7cdfdae195e65c1e41e0c5ba85798c2433d283db35b301b64cfec2f14750
|
7
|
+
data.tar.gz: 9fb5768b82318f3bc316d7e9be975441aa0163ea574111141687972d4bcbb2e4a43905674fa30216a56d914337b5414b033fa131bd2488f60519d9527bbe1bf6
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/lib/bson/binary.rb
CHANGED
@@ -132,7 +132,7 @@ module BSON
|
|
132
132
|
def to_bson(buffer = ByteBuffer.new)
|
133
133
|
position = buffer.length
|
134
134
|
buffer.put_int32(0)
|
135
|
-
buffer.put_byte(SUBTYPES
|
135
|
+
buffer.put_byte(SUBTYPES[type])
|
136
136
|
buffer.put_int32(data.bytesize) if type == :old
|
137
137
|
buffer.put_bytes(data.force_encoding(BINARY))
|
138
138
|
buffer.replace_int32(position, buffer.length - position - 5)
|
data/lib/bson/hash.rb
CHANGED
@@ -74,7 +74,7 @@ module BSON
|
|
74
74
|
# @since 2.0.0
|
75
75
|
def from_bson(buffer)
|
76
76
|
hash = Document.allocate
|
77
|
-
buffer.get_int32 # Throw away the size
|
77
|
+
buffer.get_int32 # Throw away the size.
|
78
78
|
while (type = buffer.get_byte) != NULL_BYTE
|
79
79
|
field = buffer.get_cstring
|
80
80
|
hash.store(field, BSON::Registry.get(type).from_bson(buffer))
|
data/lib/bson/integer.rb
CHANGED
@@ -145,8 +145,8 @@ module BSON
|
|
145
145
|
encoded << ((self >> 56) & 255)
|
146
146
|
end
|
147
147
|
|
148
|
-
def to_bson_key
|
149
|
-
|
148
|
+
def to_bson_key
|
149
|
+
to_s
|
150
150
|
end
|
151
151
|
|
152
152
|
private
|
@@ -161,7 +161,6 @@ module BSON
|
|
161
161
|
def out_of_range!
|
162
162
|
raise RangeError.new("#{self} is not a valid 8 byte integer value.")
|
163
163
|
end
|
164
|
-
|
165
164
|
end
|
166
165
|
|
167
166
|
# Enrich the core Integer class with this module.
|
data/lib/bson/registry.rb
CHANGED
data/lib/bson/symbol.rb
CHANGED
@@ -30,6 +30,22 @@ module BSON
|
|
30
30
|
# @since 2.0.0
|
31
31
|
BSON_TYPE = 14.chr.force_encoding(BINARY).freeze
|
32
32
|
|
33
|
+
# Symbols are serialized as strings as symbols are now removed from the
|
34
|
+
# BSON specification. Therefore the bson_type when serializing must be a
|
35
|
+
# string.
|
36
|
+
#
|
37
|
+
# @example Get the BSON type for the symbol.
|
38
|
+
# :test.bson_type
|
39
|
+
#
|
40
|
+
# @return [ String ] The single byte BSON type.
|
41
|
+
#
|
42
|
+
# @see http://bsonspec.org/#/specification
|
43
|
+
#
|
44
|
+
# @since 4.0.0
|
45
|
+
def bson_type
|
46
|
+
String::BSON_TYPE
|
47
|
+
end
|
48
|
+
|
33
49
|
# Get the symbol as encoded BSON.
|
34
50
|
#
|
35
51
|
# @example Get the symbol as encoded BSON.
|
@@ -89,7 +105,7 @@ module BSON
|
|
89
105
|
# Register this type when the module is loaded.
|
90
106
|
#
|
91
107
|
# @since 2.0.0
|
92
|
-
Registry.
|
108
|
+
Registry::MAPPINGS.store(BSON_TYPE, ::Symbol)
|
93
109
|
end
|
94
110
|
|
95
111
|
# Enrich the core Symbol class with this module.
|
data/lib/bson/version.rb
CHANGED
data/spec/bson/document_spec.rb
CHANGED
@@ -840,15 +840,6 @@ describe BSON::Document do
|
|
840
840
|
end
|
841
841
|
end
|
842
842
|
|
843
|
-
context "when the symbols are utf-8" do
|
844
|
-
|
845
|
-
let(:document) do
|
846
|
-
described_class["type", "gültig".to_sym]
|
847
|
-
end
|
848
|
-
|
849
|
-
it_behaves_like "a document able to handle utf-8"
|
850
|
-
end
|
851
|
-
|
852
843
|
context "when utf-8 string values are in an array" do
|
853
844
|
|
854
845
|
let(:document) do
|
@@ -896,7 +887,7 @@ describe BSON::Document do
|
|
896
887
|
end
|
897
888
|
end
|
898
889
|
|
899
|
-
context "when binary strings with utf-8 values exist", if: BSON::Environment.jruby? &&
|
890
|
+
context "when binary strings with utf-8 values exist", if: BSON::Environment.jruby? && (JRUBY_VERSION !~ /9.0/) do
|
900
891
|
|
901
892
|
let(:string) { "europäisch" }
|
902
893
|
let(:document) do
|
data/spec/bson/hash_spec.rb
CHANGED
@@ -37,6 +37,21 @@ describe Hash do
|
|
37
37
|
it_behaves_like "a deserializable bson element"
|
38
38
|
end
|
39
39
|
|
40
|
+
context "when the hash has non-string keys" do
|
41
|
+
|
42
|
+
let(:obj) do
|
43
|
+
{ 1 => "value" }
|
44
|
+
end
|
45
|
+
|
46
|
+
let(:expected) do
|
47
|
+
{ "1" => "value" }
|
48
|
+
end
|
49
|
+
|
50
|
+
it "properly converts to bson" do
|
51
|
+
expect(BSON::Document.from_bson(BSON::ByteBuffer.new(obj.to_bson.to_s))).to eq(expected)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
40
55
|
context "when the hash is embedded" do
|
41
56
|
|
42
57
|
let(:obj) do
|
data/spec/bson/integer_spec.rb
CHANGED
@@ -62,10 +62,10 @@ describe Integer do
|
|
62
62
|
describe "#to_bson_key" do
|
63
63
|
|
64
64
|
let(:obj) { Integer::MAX_32BIT - 1 }
|
65
|
-
let(:encoded) { obj.to_s
|
65
|
+
let(:encoded) { obj.to_s }
|
66
66
|
|
67
|
-
it "returns the
|
68
|
-
expect(obj.to_bson_key
|
67
|
+
it "returns the key as a string" do
|
68
|
+
expect(obj.to_bson_key).to eq(encoded)
|
69
69
|
end
|
70
70
|
end
|
71
71
|
end
|
data/spec/bson/registry_spec.rb
CHANGED
@@ -35,10 +35,8 @@ describe BSON::Registry do
|
|
35
35
|
|
36
36
|
context "when the type has no corresponding class" do
|
37
37
|
|
38
|
-
it "
|
39
|
-
expect
|
40
|
-
described_class.get("test")
|
41
|
-
}.to raise_error(KeyError)
|
38
|
+
it "returns nil" do
|
39
|
+
expect(described_class.get("test")).to be_nil
|
42
40
|
end
|
43
41
|
end
|
44
42
|
end
|
data/spec/bson/symbol_spec.rb
CHANGED
@@ -16,16 +16,22 @@ require "spec_helper"
|
|
16
16
|
|
17
17
|
describe Symbol do
|
18
18
|
|
19
|
+
describe "#bson_type" do
|
20
|
+
|
21
|
+
it "returns the type for a string" do
|
22
|
+
expect(:type.bson_type).to eq("type".bson_type)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
19
26
|
describe "#to_bson/#from_bson" do
|
20
27
|
|
21
|
-
let(:type) {
|
28
|
+
let(:type) { 2.chr }
|
22
29
|
let(:obj) { :test }
|
23
30
|
let(:bson) { "#{5.to_bson.to_s}test#{BSON::NULL_BYTE}" }
|
24
31
|
|
25
32
|
it_behaves_like "a bson element"
|
26
33
|
it_behaves_like "a serializable bson element"
|
27
34
|
it_behaves_like "a deserializable bson element"
|
28
|
-
|
29
35
|
end
|
30
36
|
|
31
37
|
describe "#to_bson_key" do
|
data/spec/spec_helper.rb
CHANGED
@@ -15,15 +15,6 @@
|
|
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"] && !ENV["WITH_EXT"]
|
19
|
-
require "simplecov"
|
20
|
-
require "coveralls"
|
21
|
-
SimpleCov.formatter = Coveralls::SimpleCov::Formatter
|
22
|
-
SimpleCov.start do
|
23
|
-
add_filter "spec"
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
18
|
require "bson"
|
28
19
|
require "json"
|
29
20
|
require "rspec"
|
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: 4.0.0
|
4
|
+
version: 4.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tyler Brock
|
@@ -34,7 +34,7 @@ cert_chain:
|
|
34
34
|
XZOS48LlWh15EG4yZo/gRzqNAW2LUIkYA5eMS2Kp6r+KV8IBUO/LaHdrXbdilpa8
|
35
35
|
BRsuCo7UZDbFVRns04HLyjVvkj+K/ywIcdKdS0csz5M=
|
36
36
|
-----END CERTIFICATE-----
|
37
|
-
date: 2015-
|
37
|
+
date: 2015-12-07 00:00:00.000000000 Z
|
38
38
|
dependencies: []
|
39
39
|
description: A full featured BSON specification implementation, in Ruby
|
40
40
|
email:
|
@@ -137,7 +137,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
137
137
|
version: 1.3.6
|
138
138
|
requirements: []
|
139
139
|
rubyforge_project: bson
|
140
|
-
rubygems_version: 2.4.
|
140
|
+
rubygems_version: 2.4.8
|
141
141
|
signing_key:
|
142
142
|
specification_version: 4
|
143
143
|
summary: Ruby Implementation of the BSON specification
|
metadata.gz.sig
CHANGED
Binary file
|