bson 4.4.1-java → 4.4.2-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 +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/README.md +1 -1
- data/lib/bson-ruby.jar +0 -0
- data/lib/bson/document.rb +22 -4
- data/lib/bson/version.rb +1 -1
- data/spec/bson/document_spec.rb +32 -0
- data/spec/support/common_driver.rb +1 -1
- data/spec/support/corpus.rb +1 -1
- metadata +3 -3
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a193ca9ff338694aeab7171f3a3c920fb94261deafe530f3696bf5a462419fbd
|
4
|
+
data.tar.gz: 695be898e4b6dde3146147eea7c506de2d30150b4455410a385d03a8eaecda68
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d2bfb46db770c6ba27bb349b38b115b0d62ea3593bdaf1a584469038a690f84b8ca3261a81a510dd294d096d9d82fadac10af0eb201379cdd796148c27d2bdbf
|
7
|
+
data.tar.gz: e38182cb056c75d83de991d57da743745605ec4e6f469375bccfdb48461525276b5641a838be080430c2a283385ef1a328893a23d3a9bb975fc9f6c43c4b2cad
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/README.md
CHANGED
@@ -32,7 +32,7 @@ As of 2.0.0, this project adheres to the [Semantic Versioning Specification](htt
|
|
32
32
|
License
|
33
33
|
-------
|
34
34
|
|
35
|
-
Copyright (C) 2009-
|
35
|
+
Copyright (C) 2009-2019 MongoDB Inc.
|
36
36
|
|
37
37
|
Licensed under the Apache License, Version 2.0 (the "License");
|
38
38
|
you may not use this file except in compliance with the License.
|
data/lib/bson-ruby.jar
CHANGED
Binary file
|
data/lib/bson/document.rb
CHANGED
@@ -37,19 +37,37 @@ module BSON
|
|
37
37
|
# Get a value from the document for the provided key. Can use string or
|
38
38
|
# symbol access, with string access being the faster of the two.
|
39
39
|
#
|
40
|
+
# @overload fetch(key)
|
41
|
+
# Returns a value from the hash for the given key. If the key does
|
42
|
+
# not exist, raises KeyError exception.
|
43
|
+
#
|
44
|
+
# @overload fetch(key, default)
|
45
|
+
# Returns a value from the hash for the given key. If the key does not
|
46
|
+
# exist, returns *default*.
|
47
|
+
#
|
48
|
+
# @overload fetch(key, &block)
|
49
|
+
# Returns a value from the hash for the given key. If the key does not
|
50
|
+
# exist, returns the value of the block called with the key.
|
51
|
+
#
|
40
52
|
# @example Get an element for the key.
|
41
53
|
# document.fetch("field")
|
42
54
|
#
|
43
|
-
# @example Get an element for the key by symbol.
|
44
|
-
# document.fetch(:field)
|
55
|
+
# @example Get an element for the key by symbol with a default.
|
56
|
+
# document.fetch(:field, 'foo')
|
57
|
+
#
|
58
|
+
# @example Get an element for the key by symbol with a block default.
|
59
|
+
# document.fetch(:field) { |key| key.upcase }
|
45
60
|
#
|
46
61
|
# @param [ String, Symbol ] key The key to look up.
|
62
|
+
# @param [ Object ] default Returned value if key does not exist.
|
63
|
+
# @yield [key] Block returning default value for the given key.
|
47
64
|
#
|
48
65
|
# @return [ Object ] The found value. Raises KeyError if none found.
|
49
66
|
#
|
50
67
|
# @since 4.4.0
|
51
|
-
def fetch(key)
|
52
|
-
|
68
|
+
def fetch(key, *args, &block)
|
69
|
+
key = convert_key(key)
|
70
|
+
super(key, *args, &block)
|
53
71
|
end
|
54
72
|
|
55
73
|
# Get a value from the document for the provided key. Can use string or
|
data/lib/bson/version.rb
CHANGED
data/spec/bson/document_spec.rb
CHANGED
@@ -76,6 +76,38 @@ describe BSON::Document do
|
|
76
76
|
document.fetch(:non_existent_key)
|
77
77
|
end.to raise_exception(KeyError)
|
78
78
|
end
|
79
|
+
|
80
|
+
context "and default value is provided" do
|
81
|
+
|
82
|
+
it "returns default value" do
|
83
|
+
expect(document.fetch(:non_existent_key, false)).to eq(false)
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
context "and block is passed" do
|
88
|
+
|
89
|
+
it "returns result of the block" do
|
90
|
+
expect(document.fetch(:non_existent_key, &:to_s))
|
91
|
+
.to eq("non_existent_key")
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
context "when key exists" do
|
97
|
+
|
98
|
+
context "and default value is provided" do
|
99
|
+
|
100
|
+
it "returns the value" do
|
101
|
+
expect(document.fetch(:key, "other")).to eq("value")
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
context "and block is passed" do
|
106
|
+
|
107
|
+
it "returns the value" do
|
108
|
+
expect(document.fetch(:key, &:to_s)).to eq("value")
|
109
|
+
end
|
110
|
+
end
|
79
111
|
end
|
80
112
|
end
|
81
113
|
|
data/spec/support/corpus.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: 4.4.
|
4
|
+
version: 4.4.2
|
5
5
|
platform: java
|
6
6
|
authors:
|
7
7
|
- Tyler Brock
|
@@ -33,7 +33,7 @@ cert_chain:
|
|
33
33
|
bMYVwXXhV8czdzgkQB/ZPWHSbEWXnmkze1mzvqWBCPOVXYrcnL9cnEl/RoxtS1hr
|
34
34
|
Db6Ac6mCUSYfYHBWpWqxjc45n70i5Xi1
|
35
35
|
-----END CERTIFICATE-----
|
36
|
-
date: 2019-01-
|
36
|
+
date: 2019-01-22 00:00:00.000000000 Z
|
37
37
|
dependencies: []
|
38
38
|
description: A full featured BSON specification implementation, in Ruby
|
39
39
|
email:
|
@@ -159,7 +159,7 @@ files:
|
|
159
159
|
- spec/support/spec_config.rb
|
160
160
|
homepage: http://bsonspec.org
|
161
161
|
licenses:
|
162
|
-
- Apache
|
162
|
+
- Apache-2.0
|
163
163
|
metadata: {}
|
164
164
|
post_install_message:
|
165
165
|
rdoc_options: []
|
metadata.gz.sig
CHANGED
Binary file
|