bson 4.0.0.rc0-java → 4.0.1-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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2540fdae127dd050a3c83fedec8707ed8519defd
4
- data.tar.gz: bae6dcf4f6e19199b97617df10034f9630f078aa
3
+ metadata.gz: ef64079fa7f0ed77c5224cc5a7cd03731a0fb753
4
+ data.tar.gz: 7274658271159a428734e639bac21973d5e9fbdc
5
5
  SHA512:
6
- metadata.gz: 80f092ebc7ae36f05f6a337dc00f41f05bb5591e146599226e01979766c021781c8b83c3e911adaf95b5f46e07052da60f31364a3fb208754b1f7cc2789edf2f
7
- data.tar.gz: c4b9e796a00b9c275a7d2523984300bc68ac85d5d48370e055cbfcec0e5c0e0e72f77a21edbd8716ae6741ab7bab7cc08cd7d52afd4f25dc074960f8a7153be8
6
+ metadata.gz: 1444e118cae9f3843009cff4cbb5e972f4691824bdd9cfc32b342076e316ac065fee2177a416d04b92f6e0de8fee788f4ede5b15574a8aad2644abf7ff33204e
7
+ data.tar.gz: 03e6026a72a239fe037bf4fd715da2513e1bbf51b15f8ae61157ad4c5eb1c6b7e7519fcb16a27e1adedadee2b2bfb2591950a567688e4fb7b1d7dd8dc85ffd31
data/lib/bson-ruby.jar CHANGED
Binary file
data/lib/bson/binary.rb CHANGED
@@ -132,7 +132,7 @@ module BSON
132
132
  def to_bson(buffer = ByteBuffer.new)
133
133
  position = buffer.length
134
134
  buffer.put_int32(0)
135
- buffer.put_byte(SUBTYPES.fetch(type))
135
+ buffer.put_byte(SUBTYPES[type])
136
136
  buffer.put_int32(data.bytesize) if type == :old
137
137
  buffer.put_bytes(data.force_encoding(BINARY))
138
138
  buffer.replace_int32(position, buffer.length - position - 5)
data/lib/bson/hash.rb CHANGED
@@ -74,7 +74,7 @@ module BSON
74
74
  # @since 2.0.0
75
75
  def from_bson(buffer)
76
76
  hash = Document.allocate
77
- buffer.get_int32 # Throw away the size - todo: just move read position?
77
+ buffer.get_int32 # Throw away the size.
78
78
  while (type = buffer.get_byte) != NULL_BYTE
79
79
  field = buffer.get_cstring
80
80
  hash.store(field, BSON::Registry.get(type).from_bson(buffer))
data/lib/bson/integer.rb CHANGED
@@ -145,8 +145,8 @@ module BSON
145
145
  encoded << ((self >> 56) & 255)
146
146
  end
147
147
 
148
- def to_bson_key(buffer = ByteBuffer.new)
149
- buffer.put_cstring(to_s)
148
+ def to_bson_key
149
+ to_s
150
150
  end
151
151
 
152
152
  private
@@ -161,7 +161,6 @@ module BSON
161
161
  def out_of_range!
162
162
  raise RangeError.new("#{self} is not a valid 8 byte integer value.")
163
163
  end
164
-
165
164
  end
166
165
 
167
166
  # Enrich the core Integer class with this module.
@@ -331,7 +331,7 @@ module BSON
331
331
  #
332
332
  # @since 2.0.0
333
333
  def initialize
334
- @counter = 0
334
+ @counter = rand(0x1000000)
335
335
  @machine_id = Digest::MD5.digest(Socket.gethostname).unpack("N")[0]
336
336
  @mutex = Mutex.new
337
337
  end
data/lib/bson/registry.rb CHANGED
@@ -40,7 +40,7 @@ module BSON
40
40
  #
41
41
  # @since 2.0.0
42
42
  def get(byte)
43
- MAPPINGS.fetch(byte)
43
+ MAPPINGS[byte]
44
44
  end
45
45
 
46
46
  # Register the Ruby type for the corresponding single byte.
data/lib/bson/symbol.rb CHANGED
@@ -30,6 +30,22 @@ module BSON
30
30
  # @since 2.0.0
31
31
  BSON_TYPE = 14.chr.force_encoding(BINARY).freeze
32
32
 
33
+ # Symbols are serialized as strings as symbols are now removed from the
34
+ # BSON specification. Therefore the bson_type when serializing must be a
35
+ # string.
36
+ #
37
+ # @example Get the BSON type for the symbol.
38
+ # :test.bson_type
39
+ #
40
+ # @return [ String ] The single byte BSON type.
41
+ #
42
+ # @see http://bsonspec.org/#/specification
43
+ #
44
+ # @since 4.0.0
45
+ def bson_type
46
+ String::BSON_TYPE
47
+ end
48
+
33
49
  # Get the symbol as encoded BSON.
34
50
  #
35
51
  # @example Get the symbol as encoded BSON.
@@ -89,7 +105,7 @@ module BSON
89
105
  # Register this type when the module is loaded.
90
106
  #
91
107
  # @since 2.0.0
92
- Registry.register(BSON_TYPE, ::Symbol)
108
+ Registry::MAPPINGS.store(BSON_TYPE, ::Symbol)
93
109
  end
94
110
 
95
111
  # Enrich the core Symbol class with this module.
data/lib/bson/version.rb CHANGED
@@ -13,5 +13,5 @@
13
13
  # limitations under the License.
14
14
 
15
15
  module BSON
16
- VERSION = "4.0.0.rc0"
16
+ VERSION = "4.0.1"
17
17
  end
@@ -442,4 +442,28 @@ describe BSON::ByteBuffer do
442
442
  expect(modified.to_s).to eq("#{exp_first}#{exp_second}")
443
443
  end
444
444
  end
445
+
446
+ describe '#rewind!' do
447
+
448
+ let(:string) do
449
+ "#{BSON::Int32::BSON_TYPE}#{BSON::Int32::BSON_TYPE}"
450
+ end
451
+
452
+ let(:buffer) do
453
+ described_class.new(string)
454
+ end
455
+
456
+ before do
457
+ buffer.get_bytes(1)
458
+ buffer.rewind!
459
+ end
460
+
461
+ it 'resets the read position to 0' do
462
+ expect(buffer.read_position).to eq(0)
463
+ end
464
+
465
+ it 'starts subsequent reads at position 0' do
466
+ expect(buffer.get_bytes(2)).to eq(string)
467
+ end
468
+ end
445
469
  end
@@ -840,15 +840,6 @@ describe BSON::Document do
840
840
  end
841
841
  end
842
842
 
843
- context "when the symbols are utf-8" do
844
-
845
- let(:document) do
846
- described_class["type", "gültig".to_sym]
847
- end
848
-
849
- it_behaves_like "a document able to handle utf-8"
850
- end
851
-
852
843
  context "when utf-8 string values are in an array" do
853
844
 
854
845
  let(:document) do
@@ -896,7 +887,7 @@ describe BSON::Document do
896
887
  end
897
888
  end
898
889
 
899
- context "when binary strings with utf-8 values exist", if: BSON::Environment.jruby? && !(ENV['RUBY_VERSION'] =~ /jruby-9/) do
890
+ context "when binary strings with utf-8 values exist", if: BSON::Environment.jruby? && (JRUBY_VERSION !~ /9.0/) do
900
891
 
901
892
  let(:string) { "europäisch" }
902
893
  let(:document) do
@@ -37,6 +37,21 @@ describe Hash do
37
37
  it_behaves_like "a deserializable bson element"
38
38
  end
39
39
 
40
+ context "when the hash has non-string keys" do
41
+
42
+ let(:obj) do
43
+ { 1 => "value" }
44
+ end
45
+
46
+ let(:expected) do
47
+ { "1" => "value" }
48
+ end
49
+
50
+ it "properly converts to bson" do
51
+ expect(BSON::Document.from_bson(BSON::ByteBuffer.new(obj.to_bson.to_s))).to eq(expected)
52
+ end
53
+ end
54
+
40
55
  context "when the hash is embedded" do
41
56
 
42
57
  let(:obj) do
@@ -62,10 +62,10 @@ describe Integer do
62
62
  describe "#to_bson_key" do
63
63
 
64
64
  let(:obj) { Integer::MAX_32BIT - 1 }
65
- let(:encoded) { obj.to_s + BSON::NULL_BYTE }
65
+ let(:encoded) { obj.to_s }
66
66
 
67
- it "returns the encoded string" do
68
- expect(obj.to_bson_key.to_s).to eq(encoded)
67
+ it "returns the key as a string" do
68
+ expect(obj.to_bson_key).to eq(encoded)
69
69
  end
70
70
  end
71
71
  end
@@ -35,10 +35,8 @@ describe BSON::Registry do
35
35
 
36
36
  context "when the type has no corresponding class" do
37
37
 
38
- it "raises an error" do
39
- expect {
40
- described_class.get("test")
41
- }.to raise_error(KeyError)
38
+ it "returns nil" do
39
+ expect(described_class.get("test")).to be_nil
42
40
  end
43
41
  end
44
42
  end
@@ -16,16 +16,22 @@ require "spec_helper"
16
16
 
17
17
  describe Symbol do
18
18
 
19
+ describe "#bson_type" do
20
+
21
+ it "returns the type for a string" do
22
+ expect(:type.bson_type).to eq("type".bson_type)
23
+ end
24
+ end
25
+
19
26
  describe "#to_bson/#from_bson" do
20
27
 
21
- let(:type) { 14.chr }
28
+ let(:type) { 2.chr }
22
29
  let(:obj) { :test }
23
30
  let(:bson) { "#{5.to_bson.to_s}test#{BSON::NULL_BYTE}" }
24
31
 
25
32
  it_behaves_like "a bson element"
26
33
  it_behaves_like "a serializable bson element"
27
34
  it_behaves_like "a deserializable bson element"
28
-
29
35
  end
30
36
 
31
37
  describe "#to_bson_key" do
data/spec/spec_helper.rb CHANGED
@@ -15,15 +15,6 @@
15
15
  $LOAD_PATH.unshift(File.dirname(__FILE__))
16
16
  $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), "..", "lib"))
17
17
 
18
- if ENV["CI"] && !ENV["WITH_EXT"]
19
- require "simplecov"
20
- require "coveralls"
21
- SimpleCov.formatter = Coveralls::SimpleCov::Formatter
22
- SimpleCov.start do
23
- add_filter "spec"
24
- end
25
- end
26
-
27
18
  require "bson"
28
19
  require "json"
29
20
  require "rspec"
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.0.rc0
4
+ version: 4.0.1
5
5
  platform: java
6
6
  authors:
7
7
  - Tyler Brock
@@ -11,30 +11,8 @@ authors:
11
11
  - Gary Murakami
12
12
  autorequire:
13
13
  bindir: bin
14
- cert_chain:
15
- - |
16
- -----BEGIN CERTIFICATE-----
17
- MIIDfDCCAmSgAwIBAgIBATANBgkqhkiG9w0BAQUFADBCMRQwEgYDVQQDDAtkcml2
18
- ZXItcnVieTEVMBMGCgmSJomT8ixkARkWBTEwZ2VuMRMwEQYKCZImiZPyLGQBGRYD
19
- Y29tMB4XDTE1MDMzMTA5NDIzNVoXDTE2MDMzMDA5NDIzNVowQjEUMBIGA1UEAwwL
20
- ZHJpdmVyLXJ1YnkxFTATBgoJkiaJk/IsZAEZFgUxMGdlbjETMBEGCgmSJomT8ixk
21
- ARkWA2NvbTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBANFdSAa8fRm1
22
- bAM9za6Z0fAH4g02bqM1NGnw8zJQrE/PFrFfY6IFCT2AsLfOwr1maVm7iU1+kdVI
23
- IQ+iI/9+E+ArJ+rbGV3dDPQ+SLl3mLT+vXjfjcxMqI2IW6UuVtt2U3Rxd4QU0kdT
24
- JxmcPYs5fDN6BgYc6XXgUjy3m+Kwha2pGctdciUOwEfOZ4RmNRlEZKCMLRHdFP8j
25
- 4WTnJSGfXDiuoXICJb5yOPOZPuaapPSNXp93QkUdsqdKC32I+KMpKKYGBQ6yisfA
26
- 5MyVPPCzLR1lP5qXVGJPnOqUAkvEUfCahg7EP9tI20qxiXrR6TSEraYhIFXL0EGY
27
- u8KAcPHm5KkCAwEAAaN9MHswCQYDVR0TBAIwADALBgNVHQ8EBAMCBLAwHQYDVR0O
28
- BBYEFFt3WbF+9JpUjAoj62cQBgNb8HzXMCAGA1UdEQQZMBeBFWRyaXZlci1ydWJ5
29
- QDEwZ2VuLmNvbTAgBgNVHRIEGTAXgRVkcml2ZXItcnVieUAxMGdlbi5jb20wDQYJ
30
- KoZIhvcNAQEFBQADggEBAH+jEbhVRjZke7ZgM3EjERSblLM8RtHZBczjQKuG0Eor
31
- HUF/hyq7D+mz75Ch7K8m5NRwvppePbBV4lAF+DzuDGjh+V6cz4wNKaWWFIL8eNCY
32
- F+0vDVtGok06CXnb2swHEtd1Z8zpQviJ3xpSGAvF88+glzvPQmCyA071kPUAmDvd
33
- 5og5x3Bv8IxaxmEpFndXhT3NHL/tOBeT9VJuJWMCxOXRCv4y9bBBTrxoRVuos59Z
34
- XZOS48LlWh15EG4yZo/gRzqNAW2LUIkYA5eMS2Kp6r+KV8IBUO/LaHdrXbdilpa8
35
- BRsuCo7UZDbFVRns04HLyjVvkj+K/ywIcdKdS0csz5M=
36
- -----END CERTIFICATE-----
37
- date: 2015-11-10 00:00:00.000000000 Z
14
+ cert_chain: []
15
+ date: 2016-01-25 00:00:00.000000000 Z
38
16
  dependencies: []
39
17
  description: A full featured BSON specification implementation, in Ruby
40
18
  email:
@@ -134,7 +112,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
134
112
  version: 1.3.6
135
113
  requirements: []
136
114
  rubyforge_project: bson
137
- rubygems_version: 2.4.5
115
+ rubygems_version: 2.4.8
138
116
  signing_key:
139
117
  specification_version: 4
140
118
  summary: Ruby Implementation of the BSON specification
checksums.yaml.gz.sig DELETED
@@ -1,2 +0,0 @@
1
- �\�~cỳ���2���k{5�B��bB�
2
- ��X^C X��%��ЭT݂i�SpR�vrGS%Ž�:�I���RL
data.tar.gz.sig DELETED
Binary file
metadata.gz.sig DELETED
@@ -1,2 +0,0 @@
1
- uP1<���߫#U��¦`b���X�q%����`q6�jJ�����XX�3!xa#��*>��` {��]-�;7�/��:�y����Ԑ����S2�]u췛�|�H],�zpٗo@���s���R���Tp�G)�r流#p�?��}:��{M����o�d;�`�F�9���TJ2qw#K�[��ri�<Jp �g�9�ȌG���V!p�ۥWwÕ��u�Mb��UKDa�%�@
2
- �2��Rb�cJ�F��4���դ$j� :>K