bson 4.3.0.beta → 4.3.0

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
  SHA1:
3
- metadata.gz: 3a8c878410e043f1b920f996932401686eb2ef59
4
- data.tar.gz: e459f34a04cbc3cc71f4723e95225fc69af98796
3
+ metadata.gz: b2cdf98517b40720fa4e2cdfaae83903ac8d1907
4
+ data.tar.gz: 821e69506dcde2eca70b737a97a8d0f3f4cce3f3
5
5
  SHA512:
6
- metadata.gz: e0ba9d2a810a8dd77520b0605b351dfc9c06525dab2998f77755480e1600a2d799dd6ca2084268a903e335e4336b6c96a829c2943cc2f7adeea55ee8b1bf1f15
7
- data.tar.gz: 54c0d9e149895d20f857273a392d4895b55c61f2642d5c6561a0ce2478707f56a0bf810c8ea5220a1fbdf1b69d59f6ce0ced391cbd00e7dd4f8b25ade6418d6d
6
+ metadata.gz: 285a6ba405445c535fc2157c81bee4ce48825716d2048acd3060221371b1cecd6081c5e1c487f67e373292ed97841d6e45b78abdb98cf3f81bf854d10c5f4473
7
+ data.tar.gz: 194eed21affeaf868a337ba758034f11496c077f02945a403c923a29de0c1f1e11f8da2a9318ecc5aefd3964b56b4aafd3ea167ee24edde962e580ac08f4f3ce
Binary file
data.tar.gz.sig CHANGED
Binary file
@@ -64,7 +64,7 @@ module BSON
64
64
  #
65
65
  # @note This is used for repairing legacy bson data.
66
66
  #
67
- # @raise [ InvalidObjectId ] If the array is not 12 elements.
67
+ # @raise [ BSON::ObjectId::Invalid ] If the array is not 12 elements.
68
68
  #
69
69
  # @return [ String ] The raw object id bytes.
70
70
  #
@@ -172,6 +172,26 @@ module BSON
172
172
 
173
173
  alias :update :merge!
174
174
 
175
+ if instance_methods.include?(:dig)
176
+ # Retrieves the value object corresponding to the each key objects repeatedly.
177
+ # Will normalize symbol keys into strings.
178
+ #
179
+ # @example Get value from nested sub-documents, handling missing levels.
180
+ # document # => { :key1 => { "key2" => "value"}}
181
+ # document.dig(:key1, :key2) # => "value"
182
+ # document.dig("key1", "key2") # => "value"
183
+ # document.dig("foo", "key2") # => nil
184
+ #
185
+ # @param [ Array<String, Symbol> ] *keys Keys, which constitute a "path" to the nested value.
186
+ #
187
+ # @return [ Object, NilClass ] The requested value or nil.
188
+ #
189
+ # @since 3.0.0
190
+ def dig(*keys)
191
+ super(*keys.map{|key| convert_key(key)})
192
+ end
193
+ end
194
+
175
195
  private
176
196
 
177
197
  def convert_key(key)
@@ -79,7 +79,7 @@ module BSON
79
79
  #
80
80
  # @note This is used for repairing legacy bson data.
81
81
  #
82
- # @raise [ InvalidObjectId ] If the string is not 12 elements.
82
+ # @raise [ BSON::ObjectId::Invalid ] If the string is not 12 elements.
83
83
  #
84
84
  # @return [ String ] The raw object id bytes.
85
85
  #
@@ -13,5 +13,5 @@
13
13
  # limitations under the License.
14
14
 
15
15
  module BSON
16
- VERSION = "4.3.0.beta".freeze
16
+ VERSION = "4.3.0".freeze
17
17
  end
@@ -96,6 +96,28 @@ describe BSON::Document do
96
96
  end
97
97
  end
98
98
 
99
+ if described_class.instance_methods.include?(:dig)
100
+ describe "#dig" do
101
+ let(:document) do
102
+ described_class.new("key1" => { :key2 => "value" })
103
+ end
104
+
105
+ context "when provided string keys" do
106
+
107
+ it "returns the value" do
108
+ expect(document.dig("key1", "key2")).to eq("value")
109
+ end
110
+ end
111
+
112
+ context "when provided symbol keys" do
113
+
114
+ it "returns the value" do
115
+ expect(document.dig(:key1, :key2)).to eq("value")
116
+ end
117
+ end
118
+ end
119
+ end
120
+
99
121
  describe "#delete" do
100
122
 
101
123
  shared_examples_for "a document with deletable pairs" do
@@ -766,7 +788,7 @@ describe BSON::Document do
766
788
  "#{35.to_bson}"+
767
789
  "#{BSON::Document::BSON_TYPE}0#{BSON::NULL_BYTE}#{12.to_bson}#{BSON::Int32::BSON_TYPE}a#{BSON::NULL_BYTE}#{1.to_bson}#{BSON::NULL_BYTE}" +
768
790
  "#{BSON::Document::BSON_TYPE}1#{BSON::NULL_BYTE}#{12.to_bson}#{BSON::Int32::BSON_TYPE}b#{BSON::NULL_BYTE}#{2.to_bson}#{BSON::NULL_BYTE}" +
769
- "#{BSON::NULL_BYTE}" +
791
+ "#{BSON::NULL_BYTE}" +
770
792
  "#{BSON::NULL_BYTE}"
771
793
  end
772
794
 
@@ -24,7 +24,6 @@ require "bson"
24
24
  require "json"
25
25
  require "rspec"
26
26
  require "yaml"
27
- require "pry-nav"
28
27
 
29
28
  Dir["./spec/support/**/*.rb"].each { |file| require file }
30
29
 
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.3.0.beta
4
+ version: 4.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tyler Brock
@@ -34,7 +34,7 @@ cert_chain:
34
34
  UgLdYyyGANc+TOKLFmx0eAJlCljAurbX7ctO2XI0f1AUdEYSqGzut+datXK/9nwQ
35
35
  FACf8zd11PEds/Opai2Qp4aOBgaxXhhFG357umy1vRs=
36
36
  -----END CERTIFICATE-----
37
- date: 2017-09-20 00:00:00.000000000 Z
37
+ date: 2018-01-17 00:00:00.000000000 Z
38
38
  dependencies: []
39
39
  description: A full featured BSON specification implementation, in Ruby
40
40
  email:
@@ -177,76 +177,76 @@ required_rubygems_version: !ruby/object:Gem::Requirement
177
177
  version: 1.3.6
178
178
  requirements: []
179
179
  rubyforge_project: bson
180
- rubygems_version: 2.6.11
180
+ rubygems_version: 2.6.14
181
181
  signing_key:
182
182
  specification_version: 4
183
183
  summary: Ruby Implementation of the BSON specification
184
184
  test_files:
185
- - spec/bson/array_spec.rb
186
- - spec/bson/binary_spec.rb
187
- - spec/bson/boolean_spec.rb
188
- - spec/bson/byte_buffer_spec.rb
185
+ - spec/bson/regexp_spec.rb
186
+ - spec/bson/min_key_spec.rb
187
+ - spec/bson/time_spec.rb
188
+ - spec/bson/int32_spec.rb
189
189
  - spec/bson/code_spec.rb
190
- - spec/bson/code_with_scope_spec.rb
191
190
  - spec/bson/config_spec.rb
191
+ - spec/bson/undefined_spec.rb
192
192
  - spec/bson/corpus_spec.rb
193
+ - spec/bson/boolean_spec.rb
194
+ - spec/bson/object_spec.rb
195
+ - spec/bson/array_spec.rb
196
+ - spec/bson/hash_spec.rb
193
197
  - spec/bson/date_spec.rb
198
+ - spec/bson/json_spec.rb
199
+ - spec/bson/int64_spec.rb
200
+ - spec/bson/registry_spec.rb
201
+ - spec/bson/raw_spec.rb
202
+ - spec/bson/binary_spec.rb
203
+ - spec/bson/max_key_spec.rb
204
+ - spec/bson/code_with_scope_spec.rb
194
205
  - spec/bson/date_time_spec.rb
195
- - spec/bson/decimal128_spec.rb
196
- - spec/bson/document_spec.rb
197
206
  - spec/bson/driver_bson_spec.rb
198
207
  - spec/bson/false_class_spec.rb
199
- - spec/bson/float_spec.rb
200
- - spec/bson/hash_spec.rb
201
- - spec/bson/int32_spec.rb
202
- - spec/bson/int64_spec.rb
203
- - spec/bson/integer_spec.rb
204
- - spec/bson/json_spec.rb
205
- - spec/bson/max_key_spec.rb
206
- - spec/bson/min_key_spec.rb
207
- - spec/bson/nil_class_spec.rb
208
- - spec/bson/object_id_spec.rb
209
- - spec/bson/object_spec.rb
210
- - spec/bson/open_struct_spec.rb
211
- - spec/bson/raw_spec.rb
212
- - spec/bson/regexp_spec.rb
213
- - spec/bson/registry_spec.rb
208
+ - spec/bson/byte_buffer_spec.rb
214
209
  - spec/bson/string_spec.rb
215
- - spec/bson/symbol_spec.rb
216
- - spec/bson/time_spec.rb
210
+ - spec/bson/open_struct_spec.rb
217
211
  - spec/bson/timestamp_spec.rb
212
+ - spec/bson/symbol_spec.rb
213
+ - spec/bson/decimal128_spec.rb
214
+ - spec/bson/integer_spec.rb
215
+ - spec/bson/document_spec.rb
216
+ - spec/bson/float_spec.rb
217
+ - spec/bson/nil_class_spec.rb
218
218
  - spec/bson/true_class_spec.rb
219
- - spec/bson/undefined_spec.rb
220
- - spec/bson_spec.rb
219
+ - spec/bson/object_id_spec.rb
221
220
  - spec/spec_helper.rb
222
- - spec/support/common_driver.rb
223
- - spec/support/corpus-tests/array.json
224
- - spec/support/corpus-tests/boolean.json
225
- - spec/support/corpus-tests/code.json
226
- - spec/support/corpus-tests/code_w_scope.json
227
- - spec/support/corpus-tests/document.json
228
- - spec/support/corpus-tests/double.json
229
- - spec/support/corpus-tests/failures/binary.json
221
+ - spec/bson_spec.rb
222
+ - spec/support/corpus.rb
230
223
  - spec/support/corpus-tests/failures/datetime.json
231
- - spec/support/corpus-tests/failures/dbpointer.json
232
- - spec/support/corpus-tests/failures/int64.json
233
224
  - spec/support/corpus-tests/failures/symbol.json
225
+ - spec/support/corpus-tests/failures/int64.json
226
+ - spec/support/corpus-tests/failures/dbpointer.json
234
227
  - spec/support/corpus-tests/failures/undefined.json
235
- - spec/support/corpus-tests/int32.json
228
+ - spec/support/corpus-tests/failures/binary.json
236
229
  - spec/support/corpus-tests/maxkey.json
237
- - spec/support/corpus-tests/minkey.json
238
- - spec/support/corpus-tests/null.json
230
+ - spec/support/corpus-tests/boolean.json
239
231
  - spec/support/corpus-tests/oid.json
240
- - spec/support/corpus-tests/regex.json
232
+ - spec/support/corpus-tests/code.json
233
+ - spec/support/corpus-tests/array.json
234
+ - spec/support/corpus-tests/double.json
235
+ - spec/support/corpus-tests/code_w_scope.json
241
236
  - spec/support/corpus-tests/string.json
242
- - spec/support/corpus-tests/timestamp.json
237
+ - spec/support/corpus-tests/document.json
243
238
  - spec/support/corpus-tests/top.json
244
- - spec/support/corpus.rb
239
+ - spec/support/corpus-tests/null.json
240
+ - spec/support/corpus-tests/int32.json
241
+ - spec/support/corpus-tests/timestamp.json
242
+ - spec/support/corpus-tests/minkey.json
243
+ - spec/support/corpus-tests/regex.json
244
+ - spec/support/shared_examples.rb
245
245
  - spec/support/driver-spec-tests/decimal128/decimal128-1.json
246
- - spec/support/driver-spec-tests/decimal128/decimal128-2.json
247
- - spec/support/driver-spec-tests/decimal128/decimal128-3.json
248
- - spec/support/driver-spec-tests/decimal128/decimal128-4.json
249
- - spec/support/driver-spec-tests/decimal128/decimal128-5.json
250
- - spec/support/driver-spec-tests/decimal128/decimal128-6.json
251
246
  - spec/support/driver-spec-tests/decimal128/decimal128-7.json
252
- - spec/support/shared_examples.rb
247
+ - spec/support/driver-spec-tests/decimal128/decimal128-6.json
248
+ - spec/support/driver-spec-tests/decimal128/decimal128-5.json
249
+ - spec/support/driver-spec-tests/decimal128/decimal128-4.json
250
+ - spec/support/driver-spec-tests/decimal128/decimal128-3.json
251
+ - spec/support/driver-spec-tests/decimal128/decimal128-2.json
252
+ - spec/support/common_driver.rb
metadata.gz.sig CHANGED
Binary file