bson 4.4.1-java → 4.4.2-java

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9f504ac52d583814f30388165b6e3a07a2c59aa748b4fb39567c9561467156b4
4
- data.tar.gz: 0137c6f9f6673bd48e74c49ced4f270bdea4a6c4e71a3152f910fb24a22bdab1
3
+ metadata.gz: a193ca9ff338694aeab7171f3a3c920fb94261deafe530f3696bf5a462419fbd
4
+ data.tar.gz: 695be898e4b6dde3146147eea7c506de2d30150b4455410a385d03a8eaecda68
5
5
  SHA512:
6
- metadata.gz: 016111afc57e5358c29ea29689305753f9a42055d72fc1de9903c5cd8ac41c17f132500503a6bedd70f6335a96a5bc32e9b97562214977ec353b9dca48ab8b8b
7
- data.tar.gz: 899e76cd3c91479cc5c9af5a3eb258a1b6f61e4441dd61bec93a5d3174ecc738436dd3b2caab166466b101346e3f1399746a81a40385e60c66c20c891bdaedf9
6
+ metadata.gz: d2bfb46db770c6ba27bb349b38b115b0d62ea3593bdaf1a584469038a690f84b8ca3261a81a510dd294d096d9d82fadac10af0eb201379cdd796148c27d2bdbf
7
+ data.tar.gz: e38182cb056c75d83de991d57da743745605ec4e6f469375bccfdb48461525276b5641a838be080430c2a283385ef1a328893a23d3a9bb975fc9f6c43c4b2cad
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-2016 MongoDB Inc.
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.
Binary file
@@ -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
- super(convert_key(key))
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
@@ -13,5 +13,5 @@
13
13
  # limitations under the License.
14
14
 
15
15
  module BSON
16
- VERSION = "4.4.1".freeze
16
+ VERSION = "4.4.2".freeze
17
17
  end
@@ -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
 
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2016 MongoDB, Inc.
1
+ # Copyright (C) 2016-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.
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2016 MongoDB, Inc.
1
+ # Copyright (C) 2016-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.
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.1
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-17 00:00:00.000000000 Z
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 License Version 2.0
162
+ - Apache-2.0
163
163
  metadata: {}
164
164
  post_install_message:
165
165
  rdoc_options: []
metadata.gz.sig CHANGED
Binary file