bson 4.0.3 → 4.0.4

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: 1d8b033ffe340fc96c7b66aaf19781431ffad898
4
- data.tar.gz: 823b569f7937714f262af069499e076a97b5fac2
3
+ metadata.gz: 102b6e1ecbcea8594a6bec1c1f0f80f0ad33186a
4
+ data.tar.gz: 7d21bbdc3197fbf22feed60d9dac7960def90c55
5
5
  SHA512:
6
- metadata.gz: 8051d1c09e24966136c6c3f58331457cc036b515de444709008592b60a7b4ec1e35d35b97337e9118c8cf2aacd283138ffbd8626eaec868f73b339d90297fe02
7
- data.tar.gz: fa54d2417b7ed10d5a266f5cc568fa096e546745e269329a4deb302c89feee49839349c298a983930424c354d26ae5db077cea6a275a779f2a761ca807aa114b
6
+ metadata.gz: 16772cdfb99cfd32022abba1a63d763d3b0e8da6a77825b25aebace05f73e31455a723db12e6738e64c7a711ffe34d5b9005c6eac65c8adca00c696d7b7c2e1b
7
+ data.tar.gz: a21557e5e8080c90ae8869115c5a199617ca34a0aec7d06b74ce137e32bd128a65aaa58dc4b1a4a158f3de85e08cea2d6db392d6dd8dd8fc4c45052929ed3281
@@ -1 +1,2 @@
1
- 
1
+ �!�*��nw�Ʌ�>nl�eRd񩷺�JN��K º��+���Y��K��Q�b��4f{��e�w^�V!K�)�&l�8>&!q��9� %}8Z����~��Z����U��n��Y�7H�Z~iA����8>���s��;��C�8����F�QKZDon�~Ch<����9
2
+ ��`�Nfė��W�i�`r����
data.tar.gz.sig CHANGED
@@ -1,2 +1 @@
1
- ��99��{
2
- ������}��0����z��4t%�/���� �QE��Zt`R�����L�wzl��bk<M��n����ª�6�pH�D�[A�Ϋ�iV2_K��̎3PXNn%�f��GB0�Ih�W ���U���I�H=�,�좲յG{m�c���%��5A��"9�dpe�fȭ���2n9ڷ�^EN�4�������7�����z9n�pW����c2��В'��O��ٔt��ߌ��?��4����� �*Fh
1
+ ~ڶ�[�C�,���T�kS9���(��0�SY��Tz.APc4@�8*���yt�$��=kВr��nГ��}ϴ���*'�*��]�k�~&,[����T<@-��v�N�i<�f b�?zA"Lo\�}[;g;h�b�;��ȱ��
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.
@@ -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: ruby
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
@@ -1,2 +1,2 @@
1
- v;���]Uԃ����m����X �7�뼗�)_���~{o4=���^��;�+�tUm��
2
- |y|~�(SL�Bd>�u��w�٨��(����9c��l�����<�܎ꩧ"Ɠ�JM�@�I���0��[����^�T]�o�'E���V� 牕����1�d,�N
1
+
2
+ 2N��ؿ��W���'$�D�.����k��o�8�ӱ����J���'����