bson 3.2.7-java → 4.0.0.beta-java
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 +1 -3
- data/Rakefile +2 -10
- data/lib/bson-ruby.jar +0 -0
- data/lib/bson.rb +0 -1
- data/lib/bson/array.rb +15 -14
- data/lib/bson/binary.rb +13 -13
- data/lib/bson/boolean.rb +3 -3
- data/lib/bson/code.rb +5 -8
- data/lib/bson/code_with_scope.rb +10 -13
- data/lib/bson/date.rb +2 -2
- data/lib/bson/date_time.rb +2 -2
- data/lib/bson/document.rb +33 -0
- data/lib/bson/false_class.rb +2 -2
- data/lib/bson/float.rb +5 -11
- data/lib/bson/hash.rb +15 -14
- data/lib/bson/int32.rb +8 -9
- data/lib/bson/int64.rb +3 -9
- data/lib/bson/integer.rb +6 -20
- data/lib/bson/nil_class.rb +4 -16
- data/lib/bson/object.rb +1 -1
- data/lib/bson/object_id.rb +14 -16
- data/lib/bson/regexp.rb +7 -7
- data/lib/bson/specialized.rb +6 -6
- data/lib/bson/string.rb +7 -91
- data/lib/bson/symbol.rb +8 -7
- data/lib/bson/time.rb +5 -5
- data/lib/bson/timestamp.rb +8 -6
- data/lib/bson/true_class.rb +2 -2
- data/lib/bson/undefined.rb +1 -26
- data/lib/bson/version.rb +1 -1
- data/spec/bson/array_spec.rb +1 -1
- data/spec/bson/byte_buffer_spec.rb +445 -0
- data/spec/bson/code_with_scope_spec.rb +3 -7
- data/spec/bson/document_spec.rb +66 -10
- data/spec/bson/hash_spec.rb +5 -5
- data/spec/bson/int32_spec.rb +7 -5
- data/spec/bson/integer_spec.rb +1 -6
- data/spec/bson/object_id_spec.rb +2 -39
- data/spec/bson/regexp_spec.rb +1 -1
- data/spec/bson/string_spec.rb +2 -204
- data/spec/bson/symbol_spec.rb +2 -17
- data/spec/support/shared_examples.rb +3 -26
- metadata +14 -13
- metadata.gz.sig +0 -0
- data/lib/bson/encodable.rb +0 -86
data/spec/bson/symbol_spec.rb
CHANGED
@@ -20,7 +20,7 @@ describe Symbol do
|
|
20
20
|
|
21
21
|
let(:type) { 14.chr }
|
22
22
|
let(:obj) { :test }
|
23
|
-
let(:bson) { "#{5.to_bson}test#{BSON::NULL_BYTE}" }
|
23
|
+
let(:bson) { "#{5.to_bson.to_s}test#{BSON::NULL_BYTE}" }
|
24
24
|
|
25
25
|
it_behaves_like "a bson element"
|
26
26
|
it_behaves_like "a serializable bson element"
|
@@ -31,25 +31,10 @@ describe Symbol do
|
|
31
31
|
describe "#to_bson_key" do
|
32
32
|
|
33
33
|
let(:symbol) { :test }
|
34
|
-
let(:encoded) { symbol.to_s
|
35
|
-
let(:previous_content) { 'previous_content'.force_encoding(BSON::BINARY) }
|
34
|
+
let(:encoded) { symbol.to_s }
|
36
35
|
|
37
36
|
it "returns the encoded string" do
|
38
37
|
expect(symbol.to_bson_key).to eq(encoded)
|
39
38
|
end
|
40
|
-
|
41
|
-
it "appends to optional previous content" do
|
42
|
-
expect(symbol.to_bson_key(previous_content)).to eq(previous_content << encoded)
|
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
|
54
39
|
end
|
55
40
|
end
|
@@ -38,23 +38,15 @@ end
|
|
38
38
|
|
39
39
|
shared_examples_for "a serializable bson element" do
|
40
40
|
|
41
|
-
let(:previous_content) do
|
42
|
-
'previous_content'.force_encoding(BSON::BINARY)
|
43
|
-
end
|
44
|
-
|
45
41
|
it "serializes to bson" do
|
46
|
-
expect(obj.to_bson).to eq(bson)
|
47
|
-
end
|
48
|
-
|
49
|
-
it "serializes to bson by appending" do
|
50
|
-
expect(obj.to_bson(previous_content)).to eq(previous_content << bson)
|
42
|
+
expect(obj.to_bson.to_s).to eq(bson)
|
51
43
|
end
|
52
44
|
end
|
53
45
|
|
54
46
|
shared_examples_for "a deserializable bson element" do
|
55
47
|
|
56
48
|
let(:io) do
|
57
|
-
|
49
|
+
BSON::ByteBuffer.new(bson)
|
58
50
|
end
|
59
51
|
|
60
52
|
let(:result) do
|
@@ -64,21 +56,6 @@ shared_examples_for "a deserializable bson element" do
|
|
64
56
|
it "deserializes from bson" do
|
65
57
|
expect(result).to eq(obj)
|
66
58
|
end
|
67
|
-
|
68
|
-
context 'when io#readbyte returns a String' do
|
69
|
-
|
70
|
-
let(:io) do
|
71
|
-
AlternateIO.new(bson)
|
72
|
-
end
|
73
|
-
|
74
|
-
let(:result) do
|
75
|
-
described_class.from_bson(io)
|
76
|
-
end
|
77
|
-
|
78
|
-
it "deserializes from bson" do
|
79
|
-
expect(result).to eq(obj)
|
80
|
-
end
|
81
|
-
end
|
82
59
|
end
|
83
60
|
|
84
61
|
shared_examples_for "a JSON serializable object" do
|
@@ -108,7 +85,7 @@ shared_examples_for "a document able to handle utf-8" do
|
|
108
85
|
|
109
86
|
it "serializes and deserializes properly" do
|
110
87
|
expect(
|
111
|
-
BSON::Document.from_bson(
|
88
|
+
BSON::Document.from_bson(BSON::ByteBuffer.new(document.to_bson.to_s))
|
112
89
|
).to eq(document)
|
113
90
|
end
|
114
91
|
end
|
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
|
+
version: 4.0.0.beta
|
5
5
|
platform: java
|
6
6
|
authors:
|
7
7
|
- Tyler Brock
|
@@ -16,7 +16,7 @@ cert_chain:
|
|
16
16
|
-----BEGIN CERTIFICATE-----
|
17
17
|
MIIDfDCCAmSgAwIBAgIBATANBgkqhkiG9w0BAQUFADBCMRQwEgYDVQQDDAtkcml2
|
18
18
|
ZXItcnVieTEVMBMGCgmSJomT8ixkARkWBTEwZ2VuMRMwEQYKCZImiZP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
|
+
date: 2015-10-28 00:00:00.000000000 Z
|
38
38
|
dependencies: []
|
39
39
|
description: A full featured BSON specification implementation, in Ruby
|
40
40
|
email:
|
@@ -59,7 +59,6 @@ files:
|
|
59
59
|
- lib/bson/date.rb
|
60
60
|
- lib/bson/date_time.rb
|
61
61
|
- lib/bson/document.rb
|
62
|
-
- lib/bson/encodable.rb
|
63
62
|
- lib/bson/environment.rb
|
64
63
|
- lib/bson/false_class.rb
|
65
64
|
- lib/bson/float.rb
|
@@ -86,6 +85,7 @@ files:
|
|
86
85
|
- spec/bson/array_spec.rb
|
87
86
|
- spec/bson/binary_spec.rb
|
88
87
|
- spec/bson/boolean_spec.rb
|
88
|
+
- spec/bson/byte_buffer_spec.rb
|
89
89
|
- spec/bson/code_spec.rb
|
90
90
|
- spec/bson/code_with_scope_spec.rb
|
91
91
|
- spec/bson/date_spec.rb
|
@@ -124,17 +124,17 @@ require_paths:
|
|
124
124
|
- lib
|
125
125
|
required_ruby_version: !ruby/object:Gem::Requirement
|
126
126
|
requirements:
|
127
|
-
- -
|
127
|
+
- - '>='
|
128
128
|
- !ruby/object:Gem::Version
|
129
129
|
version: 1.9.3
|
130
130
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
131
131
|
requirements:
|
132
|
-
- -
|
132
|
+
- - '>='
|
133
133
|
- !ruby/object:Gem::Version
|
134
134
|
version: 1.3.6
|
135
135
|
requirements: []
|
136
136
|
rubyforge_project: bson
|
137
|
-
rubygems_version: 2.
|
137
|
+
rubygems_version: 2.4.5
|
138
138
|
signing_key:
|
139
139
|
specification_version: 4
|
140
140
|
summary: Ruby Implementation of the BSON specification
|
@@ -144,6 +144,7 @@ test_files:
|
|
144
144
|
- spec/bson/array_spec.rb
|
145
145
|
- spec/bson/binary_spec.rb
|
146
146
|
- spec/bson/boolean_spec.rb
|
147
|
+
- spec/bson/byte_buffer_spec.rb
|
147
148
|
- spec/bson/code_spec.rb
|
148
149
|
- spec/bson/code_with_scope_spec.rb
|
149
150
|
- spec/bson/date_spec.rb
|
metadata.gz.sig
CHANGED
Binary file
|
data/lib/bson/encodable.rb
DELETED
@@ -1,86 +0,0 @@
|
|
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
|
-
# Defines behaviour around objects that can be encoded.
|
18
|
-
#
|
19
|
-
# @since 2.0.0
|
20
|
-
module Encodable
|
21
|
-
|
22
|
-
# A 4 byte placeholder that would be replaced by a length at a later point.
|
23
|
-
#
|
24
|
-
# @since 2.0.0
|
25
|
-
PLACEHOLDER = 0.to_bson.freeze
|
26
|
-
|
27
|
-
# Adjustment value for total number of document bytes.
|
28
|
-
#
|
29
|
-
# @since 2.0.0
|
30
|
-
BSON_ADJUST = 0.freeze
|
31
|
-
|
32
|
-
# Adjustment value for total number of string bytes.
|
33
|
-
#
|
34
|
-
# @since 2.0.0
|
35
|
-
STRING_ADJUST = -4.freeze
|
36
|
-
|
37
|
-
# Encodes BSON to raw bytes, for types that require the length of the
|
38
|
-
# entire bytes to be present as the first word of the encoded string. This
|
39
|
-
# includes Hash, CodeWithScope.
|
40
|
-
#
|
41
|
-
# @example Encode the BSON with placeholder bytes.
|
42
|
-
# hash.encode_with_placeholder_and_null(BSON_ADJUST, encoded) do |encoded|
|
43
|
-
# each do |field, value|
|
44
|
-
# value.to_bson(encoded)
|
45
|
-
# end
|
46
|
-
# end
|
47
|
-
#
|
48
|
-
# @param [ Integer ] adjust The number of bytes to adjust with.
|
49
|
-
# @param [ String ] encoded The string to encode.
|
50
|
-
#
|
51
|
-
# @return [ String ] The encoded string.
|
52
|
-
#
|
53
|
-
# @since 2.0.0
|
54
|
-
def encode_with_placeholder_and_null(adjust, encoded = ''.force_encoding(BINARY))
|
55
|
-
pos = encoded.bytesize
|
56
|
-
encoded << PLACEHOLDER
|
57
|
-
yield(encoded)
|
58
|
-
encoded << NULL_BYTE
|
59
|
-
encoded.set_int32(pos, encoded.bytesize - pos + adjust)
|
60
|
-
encoded
|
61
|
-
end
|
62
|
-
|
63
|
-
# Encodes binary data with a generic placeholder value to be written later
|
64
|
-
# once all bytes have been written.
|
65
|
-
#
|
66
|
-
# @example Encode the BSON with placeholder bytes.
|
67
|
-
# string.encode_binary_data_with_placeholder(encoded) do |encoded|
|
68
|
-
# each do |field, value|
|
69
|
-
# value.to_bson(encoded)
|
70
|
-
# end
|
71
|
-
# end
|
72
|
-
#
|
73
|
-
# @param [ String ] encoded The string to encode.
|
74
|
-
#
|
75
|
-
# @return [ String ] The encoded string.
|
76
|
-
#
|
77
|
-
# @since 2.0.0
|
78
|
-
def encode_binary_data_with_placeholder(encoded = ''.force_encoding(BINARY))
|
79
|
-
pos = encoded.bytesize
|
80
|
-
encoded << PLACEHOLDER
|
81
|
-
yield(encoded)
|
82
|
-
encoded.set_int32(pos, encoded.bytesize - pos - 5)
|
83
|
-
encoded
|
84
|
-
end
|
85
|
-
end
|
86
|
-
end
|