bson 4.0.3-java → 4.0.4-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
  SHA1:
3
- metadata.gz: be5129c7952e6a2a86156048dbc4d60dc547a3d3
4
- data.tar.gz: c8ac419eb53773f4aeb98ea7dd4da272a00481fa
3
+ metadata.gz: 2acb70e11a8426afd8b5b1269f34f4bd0fe73b2e
4
+ data.tar.gz: d62bbc6fb021e6a275e6a3853ad7bbee770dff06
5
5
  SHA512:
6
- metadata.gz: 2a75dafd474621f63c9fdbc5bca73371af35ddc9b05c91e1abeb20b509da908f3171ea6f882b14a48147673a0bf549d104e9f31a32eea136ec296eb8b22810ac
7
- data.tar.gz: 3838c53795aaa265cdad691c65cd7bd3b10fe50372d29619cebeb595d8c313aff244feb5d03a7b1d32a3a08f0ff4766a7a28d20d7aec6dabc2527bae666d2b36
6
+ metadata.gz: 315abfefcae86c1c3924c04d89aef67a07bc043a53c5d2fb2bd1e30b0e02d3be6d1edb12430b6790ff6eceea117332688e4a6d7b67fdf8db70e263598f624ee6
7
+ data.tar.gz: f556ff6be0e50c33f6525f9ce5992f50a188aedcb76fcd38c4a2584b8eb37bad9f185c306e21af99a1320f9549f59786baa9829f1ec0052a09a35c5e5d14deaa
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-2014 MongoDB Inc.
35
+ Copyright (C) 2009-2016 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
@@ -77,7 +77,7 @@ module BSON
77
77
  buffer.get_int32 # Throw away the size.
78
78
  while (type = buffer.get_byte) != NULL_BYTE
79
79
  field = buffer.get_cstring
80
- hash.store(field, BSON::Registry.get(type).from_bson(buffer))
80
+ hash.store(field, BSON::Registry.get(type, field).from_bson(buffer))
81
81
  end
82
82
  hash
83
83
  end
@@ -152,8 +152,8 @@ module BSON
152
152
  # @param [ String] method The name of a method.
153
153
  #
154
154
  # @since 3.1.0
155
- def respond_to?(method)
156
- compile.respond_to?(method) || super
155
+ def respond_to?(method, include_private = false)
156
+ compile.respond_to?(method, include_private = false) || super
157
157
  end
158
158
 
159
159
  private
@@ -39,8 +39,12 @@ module BSON
39
39
  # @see http://bsonspec.org/#/specification
40
40
  #
41
41
  # @since 2.0.0
42
- def get(byte)
43
- MAPPINGS[byte]
42
+ def get(byte, field = nil)
43
+ if type = MAPPINGS[byte]
44
+ type
45
+ else
46
+ handle_unsupported_type!(byte, field)
47
+ end
44
48
  end
45
49
 
46
50
  # Register the Ruby type for the corresponding single byte.
@@ -59,6 +63,11 @@ module BSON
59
63
  define_type_reader(type)
60
64
  end
61
65
 
66
+ # Raised when trying to get a type from the registry that doesn't exist.
67
+ #
68
+ # @since 4.1.0
69
+ class UnsupportedType < RuntimeError; end
70
+
62
71
  private
63
72
 
64
73
  def define_type_reader(type)
@@ -66,5 +75,12 @@ module BSON
66
75
  def bson_type; BSON_TYPE; end
67
76
  MOD
68
77
  end
78
+
79
+ def handle_unsupported_type!(byte, field)
80
+ message = "Detected unknown BSON type #{byte.inspect} "
81
+ message += (field ? "for fieldname \"#{field}\". " : "in array. ")
82
+ message +="Are you using the latest BSON version?"
83
+ raise UnsupportedType.new(message)
84
+ end
69
85
  end
70
86
  end
@@ -13,5 +13,5 @@
13
13
  # limitations under the License.
14
14
 
15
15
  module BSON
16
- VERSION = "4.0.3".freeze
16
+ VERSION = "4.0.4".freeze
17
17
  end
@@ -534,7 +534,7 @@ describe BSON::ObjectId do
534
534
  context "when the class is loaded" do
535
535
 
536
536
  let(:registered) do
537
- BSON::Registry.get(BSON::ObjectId::BSON_TYPE)
537
+ BSON::Registry.get(BSON::ObjectId::BSON_TYPE, 'field')
538
538
  end
539
539
 
540
540
  it "registers the type" do
@@ -25,7 +25,7 @@ describe BSON::Registry do
25
25
  end
26
26
 
27
27
  let(:klass) do
28
- described_class.get(BSON::MinKey::BSON_TYPE)
28
+ described_class.get(BSON::MinKey::BSON_TYPE, "field")
29
29
  end
30
30
 
31
31
  it "returns the class" do
@@ -35,8 +35,10 @@ describe BSON::Registry do
35
35
 
36
36
  context "when the type has no corresponding class" do
37
37
 
38
- it "returns nil" do
39
- expect(described_class.get("test")).to be_nil
38
+ it "raises an error" do
39
+ expect {
40
+ described_class.get(25.chr, "field")
41
+ }.to raise_error(BSON::Registry::UnsupportedType)
40
42
  end
41
43
  end
42
44
  end
@@ -59,7 +59,7 @@ describe String do
59
59
  context "when the class is loaded" do
60
60
 
61
61
  let(:registered) do
62
- BSON::Registry.get(String::BSON_TYPE)
62
+ BSON::Registry.get(String::BSON_TYPE, 'field')
63
63
  end
64
64
 
65
65
  it "registers the type" do
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.0.3
4
+ version: 4.0.4
5
5
  platform: java
6
6
  authors:
7
7
  - Tyler Brock
@@ -34,7 +34,7 @@ cert_chain:
34
34
  XZOS48LlWh15EG4yZo/gRzqNAW2LUIkYA5eMS2Kp6r+KV8IBUO/LaHdrXbdilpa8
35
35
  BRsuCo7UZDbFVRns04HLyjVvkj+K/ywIcdKdS0csz5M=
36
36
  -----END CERTIFICATE-----
37
- date: 2016-02-28 00:00:00.000000000 Z
37
+ date: 2016-03-06 00:00:00.000000000 Z
38
38
  dependencies: []
39
39
  description: A full featured BSON specification implementation, in Ruby
40
40
  email:
metadata.gz.sig CHANGED
Binary file