bson 4.3.0-java → 4.4.1-java
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.
- checksums.yaml +5 -5
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/Rakefile +16 -9
- data/lib/bson-ruby.jar +0 -0
- data/lib/bson.rb +1 -1
- data/lib/bson/active_support.rb +17 -0
- 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/config.rb +1 -1
- data/lib/bson/date.rb +1 -1
- data/lib/bson/date_time.rb +1 -1
- data/lib/bson/decimal128.rb +1 -1
- data/lib/bson/decimal128/builder.rb +1 -1
- data/lib/bson/document.rb +42 -4
- 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 +17 -4
- data/lib/bson/int64.rb +17 -4
- data/lib/bson/integer.rb +2 -2
- 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 +1 -1
- data/lib/bson/object_id.rb +1 -1
- data/lib/bson/open_struct.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 +6 -3
- data/lib/bson/time.rb +1 -1
- data/lib/bson/time_with_zone.rb +54 -0
- 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/byte_buffer_spec.rb +40 -0
- 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/decimal128_spec.rb +1 -1
- data/spec/bson/document_spec.rb +60 -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 +139 -3
- data/spec/bson/int64_spec.rb +139 -3
- data/spec/bson/integer_spec.rb +3 -3
- 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 +1 -1
- data/spec/bson/object_spec.rb +1 -1
- data/spec/bson/open_struct_spec.rb +1 -1
- 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 +3 -3
- data/spec/bson/time_spec.rb +1 -1
- data/spec/bson/time_with_zone_spec.rb +68 -0
- 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 +15 -1
- data/spec/support/shared_examples.rb +1 -1
- data/spec/support/spec_config.rb +9 -0
- metadata +69 -64
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 9f504ac52d583814f30388165b6e3a07a2c59aa748b4fb39567c9561467156b4
|
4
|
+
data.tar.gz: 0137c6f9f6673bd48e74c49ced4f270bdea4a6c4e71a3152f910fb24a22bdab1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 016111afc57e5358c29ea29689305753f9a42055d72fc1de9903c5cd8ac41c17f132500503a6bedd70f6335a96a5bc32e9b97562214977ec353b9dca48ab8b8b
|
7
|
+
data.tar.gz: 899e76cd3c91479cc5c9af5a3eb258a1b6f61e4441dd61bec93a5d3174ecc738436dd3b2caab166466b101346e3f1399746a81a40385e60c66c20c891bdaedf9
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/Rakefile
CHANGED
@@ -20,6 +20,7 @@ $LOAD_PATH.unshift(File.expand_path("../lib", __FILE__))
|
|
20
20
|
require "rake"
|
21
21
|
require "rake/extensiontask"
|
22
22
|
require "rspec/core/rake_task"
|
23
|
+
require 'fileutils'
|
23
24
|
|
24
25
|
def jruby?
|
25
26
|
defined?(JRUBY_VERSION)
|
@@ -62,15 +63,9 @@ else
|
|
62
63
|
end
|
63
64
|
|
64
65
|
task :clean_all => :clean do
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
`rm bson_native.o`
|
69
|
-
`rm bson-ruby.jar`
|
70
|
-
end
|
71
|
-
rescue Exception => e
|
72
|
-
puts e.message
|
73
|
-
end
|
66
|
+
FileUtils.rm_f(File.join(File.dirname(__FILE__), 'lib', "bson_native.#{extension}"))
|
67
|
+
FileUtils.rm_f(File.join(File.dirname(__FILE__), 'lib', "bson_native.o"))
|
68
|
+
FileUtils.rm_f(File.join(File.dirname(__FILE__), 'lib', "bson-ruby.jar"))
|
74
69
|
end
|
75
70
|
|
76
71
|
task :spec => :compile do
|
@@ -126,3 +121,15 @@ namespace :benchmark do
|
|
126
121
|
end
|
127
122
|
|
128
123
|
task :default => [ :clean_all, :spec ]
|
124
|
+
|
125
|
+
desc "Generate all documentation"
|
126
|
+
task :docs => 'docs:yard'
|
127
|
+
|
128
|
+
namespace :docs do
|
129
|
+
desc "Generate yard documention"
|
130
|
+
task :yard do
|
131
|
+
out = File.join('yard-docs', BSON::VERSION)
|
132
|
+
FileUtils.rm_rf(out)
|
133
|
+
system "yardoc -o #{out} --title bson-#{BSON::VERSION}"
|
134
|
+
end
|
135
|
+
end
|
data/lib/bson-ruby.jar
CHANGED
Binary file
|
data/lib/bson.rb
CHANGED
@@ -0,0 +1,17 @@
|
|
1
|
+
# Copyright (C) 2018-2019 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 this file if using BSON with ActiveSupport.
|
16
|
+
|
17
|
+
require "bson/time_with_zone"
|
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/config.rb
CHANGED
data/lib/bson/date.rb
CHANGED
data/lib/bson/date_time.rb
CHANGED
data/lib/bson/decimal128.rb
CHANGED
data/lib/bson/document.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (C) 2009-
|
1
|
+
# Copyright (C) 2009-2019 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.
|
@@ -35,8 +35,25 @@ module BSON
|
|
35
35
|
class Document < ::Hash
|
36
36
|
|
37
37
|
# Get a value from the document for the provided key. Can use string or
|
38
|
-
# symbol access,
|
39
|
-
#
|
38
|
+
# symbol access, with string access being the faster of the two.
|
39
|
+
#
|
40
|
+
# @example Get an element for the key.
|
41
|
+
# document.fetch("field")
|
42
|
+
#
|
43
|
+
# @example Get an element for the key by symbol.
|
44
|
+
# document.fetch(:field)
|
45
|
+
#
|
46
|
+
# @param [ String, Symbol ] key The key to look up.
|
47
|
+
#
|
48
|
+
# @return [ Object ] The found value. Raises KeyError if none found.
|
49
|
+
#
|
50
|
+
# @since 4.4.0
|
51
|
+
def fetch(key)
|
52
|
+
super(convert_key(key))
|
53
|
+
end
|
54
|
+
|
55
|
+
# Get a value from the document for the provided key. Can use string or
|
56
|
+
# symbol access, with string access being the faster of the two.
|
40
57
|
#
|
41
58
|
# @example Get an element for the key.
|
42
59
|
# document["field"]
|
@@ -44,7 +61,7 @@ module BSON
|
|
44
61
|
# @example Get an element for the key by symbol.
|
45
62
|
# document[:field]
|
46
63
|
#
|
47
|
-
# @param [ String, Symbol ] key The key to
|
64
|
+
# @param [ String, Symbol ] key The key to look up.
|
48
65
|
#
|
49
66
|
# @return [ Object ] The found value, or nil if none found.
|
50
67
|
#
|
@@ -192,6 +209,27 @@ module BSON
|
|
192
209
|
end
|
193
210
|
end
|
194
211
|
|
212
|
+
if instance_methods.include?(:slice)
|
213
|
+
# Slices a document to include only the given keys.
|
214
|
+
# Will normalize symbol keys into strings.
|
215
|
+
# (this method is backported from ActiveSupport::Hash)
|
216
|
+
#
|
217
|
+
# @example Get a document/hash with only the `name` and `age` fields present
|
218
|
+
# document # => { _id: <ObjectId>, :name => 'John', :age => 30, :location => 'Earth' }
|
219
|
+
# document.slice(:name, 'age') # => { name: 'John', age: 30 }
|
220
|
+
# document.slice('name') # => { name: 'John' }
|
221
|
+
# document.slice(:foo) # => nil
|
222
|
+
#
|
223
|
+
# @param [ Array<String, Symbol> ] *keys Keys, that will be kept in the resulting document
|
224
|
+
#
|
225
|
+
# @return [ BSON::Document ] The document with only the selected keys
|
226
|
+
#
|
227
|
+
# @since 4.3.1
|
228
|
+
def slice(*keys)
|
229
|
+
super(*keys.map{|key| convert_key(key)})
|
230
|
+
end
|
231
|
+
end
|
232
|
+
|
195
233
|
private
|
196
234
|
|
197
235
|
def convert_key(key)
|
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
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (C) 2009-
|
1
|
+
# Copyright (C) 2009-2019 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.
|
@@ -14,8 +14,7 @@
|
|
14
14
|
|
15
15
|
module BSON
|
16
16
|
|
17
|
-
# Represents
|
18
|
-
# specification.
|
17
|
+
# Represents int32 type.
|
19
18
|
#
|
20
19
|
# @see http://bsonspec.org/#/specification
|
21
20
|
#
|
@@ -87,9 +86,23 @@ module BSON
|
|
87
86
|
#
|
88
87
|
# @since 4.2.0
|
89
88
|
def to_bson_key(validating_keys = Config.validating_keys?)
|
90
|
-
@integer
|
89
|
+
@integer
|
91
90
|
end
|
92
91
|
|
92
|
+
# Check equality of the int32 with another object.
|
93
|
+
#
|
94
|
+
# @param [ Object ] other The object to check against.
|
95
|
+
#
|
96
|
+
# @return [ true, false ] If the objects are equal.
|
97
|
+
#
|
98
|
+
# @since 4.4.0
|
99
|
+
def ==(other)
|
100
|
+
return false unless other.is_a?(Int32)
|
101
|
+
@integer == other.instance_variable_get('@integer')
|
102
|
+
end
|
103
|
+
alias :eql? :==
|
104
|
+
alias :=== :==
|
105
|
+
|
93
106
|
private
|
94
107
|
|
95
108
|
def out_of_range!
|
data/lib/bson/int64.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (C) 2009-
|
1
|
+
# Copyright (C) 2009-2019 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.
|
@@ -14,8 +14,7 @@
|
|
14
14
|
|
15
15
|
module BSON
|
16
16
|
|
17
|
-
# Represents
|
18
|
-
# specification.
|
17
|
+
# Represents int64 type.
|
19
18
|
#
|
20
19
|
# @see http://bsonspec.org/#/specification
|
21
20
|
#
|
@@ -82,9 +81,23 @@ module BSON
|
|
82
81
|
#
|
83
82
|
# @since 4.2.0
|
84
83
|
def to_bson_key(validating_keys = Config.validating_keys?)
|
85
|
-
@integer
|
84
|
+
@integer
|
86
85
|
end
|
87
86
|
|
87
|
+
# Check equality of the int64 with another object.
|
88
|
+
#
|
89
|
+
# @param [ Object ] other The object to check against.
|
90
|
+
#
|
91
|
+
# @return [ true, false ] If the objects are equal.
|
92
|
+
#
|
93
|
+
# @since 4.4.0
|
94
|
+
def ==(other)
|
95
|
+
return false unless other.is_a?(Int64)
|
96
|
+
@integer == other.instance_variable_get('@integer')
|
97
|
+
end
|
98
|
+
alias :eql? :==
|
99
|
+
alias :=== :==
|
100
|
+
|
88
101
|
private
|
89
102
|
|
90
103
|
def out_of_range!
|
data/lib/bson/integer.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (C) 2009-
|
1
|
+
# Copyright (C) 2009-2019 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.
|
@@ -156,7 +156,7 @@ module BSON
|
|
156
156
|
#
|
157
157
|
# @since 2.0.0
|
158
158
|
def to_bson_key(validating_keys = Config.validating_keys?)
|
159
|
-
|
159
|
+
self
|
160
160
|
end
|
161
161
|
|
162
162
|
private
|
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
CHANGED
data/lib/bson/object_id.rb
CHANGED
data/lib/bson/open_struct.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
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (C) 2009-
|
1
|
+
# Copyright (C) 2009-2019 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.
|
@@ -57,7 +57,7 @@ module BSON
|
|
57
57
|
#
|
58
58
|
# @since 2.0.0
|
59
59
|
def to_bson(buffer = ByteBuffer.new, validating_keys = Config.validating_keys?)
|
60
|
-
|
60
|
+
buffer.put_symbol(self)
|
61
61
|
end
|
62
62
|
|
63
63
|
# Get the symbol as a BSON key name encoded C symbol.
|
@@ -71,7 +71,10 @@ module BSON
|
|
71
71
|
#
|
72
72
|
# @since 2.0.0
|
73
73
|
def to_bson_key(validating_keys = Config.validating_keys?)
|
74
|
-
|
74
|
+
if validating_keys
|
75
|
+
raise BSON::String::IllegalKey.new(self) if BSON::String::ILLEGAL_KEY =~ self
|
76
|
+
end
|
77
|
+
self
|
75
78
|
end
|
76
79
|
|
77
80
|
# Converts the symbol to a normalized key in a BSON document.
|