bson 2.3.0-java → 3.0.0-java

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of bson might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e6a273f6fa537d5cc00fc4dadb9115ac0b0fa205
4
- data.tar.gz: e64fe5120499d7d5d98159833d04e32f9cc45ecf
3
+ metadata.gz: 42015e5083036417f5fadff7a52a0e093175c610
4
+ data.tar.gz: b4e9b72953e1e15bafaf81a8851532388d75d799
5
5
  SHA512:
6
- metadata.gz: 0bd9c997edf798e75e12244a4d39f30f246e0db0ed902d765fb281338a415907a86ae4dbe51658541e1aa041b580d0e0e367ea8484a0a6caa28ef16039a872d9
7
- data.tar.gz: caaf315f18150af9d5e42d86997063b1492b7699aad31fbf7e08ff48c26ee4a29191d95a49aa684b9df63a070d79c0bd81077a0dbf0599d551737cfc930d0df4
6
+ metadata.gz: 54fab55d9de7dc905e793fd8598831ece681abd6a3c17eea2573a908d7f1e01f65425b5a00afa2e6e2a22dc8bc8060458fb81534b3e38ad7640f9b8895b90a15
7
+ data.tar.gz: 5e87eab43925eeab75b9e4f237f2cd4a6f116f2478103cf034a6acb3046bc95cb9b69273667f93360773a5acd52d04e9a494bd8b1b01a058dd24d2deac8afe8b
@@ -1,6 +1,28 @@
1
1
  BSON Changelog
2
2
  ==============
3
3
 
4
+ ## 3.0.0
5
+
6
+ ### Backwards Incompatible Changes
7
+
8
+ * [RUBY-852](https://jira.mongodb.org/browse/RUBY-852) Regular expressions that
9
+ are deserialized now return a `BSON::Regexp::Raw` instead of a `Regexp` object.
10
+ In order to get the regular expression compiled, call `#compile` on the returned object.
11
+
12
+ raw.compile
13
+
14
+ ### New Features
15
+
16
+ * `BSON::Binary` now implements `#inspect` with a truncated view of the data for
17
+ better readability.
18
+
19
+ ### Bug Fixes
20
+
21
+ * The native object id generation was fixed to match the raw Ruby. (Conrad Irwin)
22
+
23
+ * [#23](http://github.com/mongodb/bson-ruby/pull/23):
24
+ `BSON::Binary` types can be now used as hash keys. (Adam Wróbel)
25
+
4
26
  ## 2.2.3
5
27
 
6
28
  ### Bug Fixes
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- BSON [![Build Status](https://secure.travis-ci.org/mongodb/bson-ruby.png?branch=master&.png)](http://travis-ci.org/mongodb/bson-ruby) [![Code Climate](https://codeclimate.com/github/mongodb/bson-ruby.png)](https://codeclimate.com/github/mongodb/bson-ruby) [![Coverage Status](https://coveralls.io/repos/mongodb/bson-ruby/badge.png?branch=master)](https://coveralls.io/r/mongodb/bson-ruby?branch=master)
1
+ BSON [![Build Status](https://secure.travis-ci.org/mongodb/bson-ruby.png?branch=master&.png)](http://travis-ci.org/mongodb/bson-ruby) [![Code Climate](https://codeclimate.com/github/mongodb/bson-ruby.png)](https://codeclimate.com/github/mongodb/bson-ruby) [![Coverage Status](https://coveralls.io/repos/mongodb/bson-ruby/badge.png?branch=master)](https://coveralls.io/r/mongodb/bson-ruby?branch=master) [![Inline docs](http://inch-ci.org/github/mongodb/bson-ruby.svg?branch=master)](http://inch-ci.org/github/mongodb/bson-ruby)
2
2
  ====
3
3
 
4
4
  An implementation of the BSON specification in Ruby.
Binary file
@@ -68,6 +68,18 @@ module BSON
68
68
  return false unless other.is_a?(Binary)
69
69
  type == other.type && data == other.data
70
70
  end
71
+ alias eql? ==
72
+
73
+ # Generates a Fixnum hash value for this object.
74
+ #
75
+ # Allows using Binary as hash keys.
76
+ #
77
+ # @return [ Fixnum ]
78
+ #
79
+ # @since 2.3.1
80
+ def hash
81
+ data.hash + type.hash
82
+ end
71
83
 
72
84
  # Get the binary as JSON hash data.
73
85
  #
@@ -96,6 +108,18 @@ module BSON
96
108
  @type = type
97
109
  end
98
110
 
111
+ # Get a nice string for use with object inspection.
112
+ #
113
+ # @example Inspect the binary.
114
+ # object_id.inspect
115
+ #
116
+ # @return [ String ] The binary in form BSON::Binary:object_id
117
+ #
118
+ # @since 2.3.0
119
+ def inspect
120
+ "<BSON::Binary:0x#{object_id} type=#{type} data=#{data[0, 8]}...>"
121
+ end
122
+
99
123
  # Encode the binary type
100
124
  #
101
125
  # @example Encode the binary.
@@ -14,7 +14,7 @@
14
14
 
15
15
  module BSON
16
16
 
17
- # Represents a $maxKey type, which compares less than any other value in the
17
+ # Represents a boolean type, which compares less than any other value in the
18
18
  # specification.
19
19
  #
20
20
  # @see http://bsonspec.org/#/specification
@@ -118,13 +118,13 @@ module BSON
118
118
  # Get a nice string for use with object inspection.
119
119
  #
120
120
  # @example Inspect the object id.
121
- # obhect_id.inspect
121
+ # object_id.inspect
122
122
  #
123
123
  # @return [ String ] The object id in form BSON::ObjectId('id')
124
124
  #
125
125
  # @since 2.0.0
126
126
  def inspect
127
- "BSON::ObjectId('#{to_s}')"
127
+ "<BSON::ObjectId:0x#{object_id} data=#{to_s}>"
128
128
  end
129
129
 
130
130
  # Dump the raw bson when calling Marshal.dump.
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2009-2014 MongoDB Inc.
1
+ # Copyright (C) 2009-2015 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.
@@ -82,7 +82,48 @@ module BSON
82
82
  (options & ::Regexp::MULTILINE != 0) ? "ms" : NO_VALUE
83
83
  end
84
84
 
85
+ # Represents the raw values for the regular expression.
86
+ #
87
+ # @see https://jira.mongodb.org/browse/RUBY-698
88
+ #
89
+ # @since 3.0.0
90
+ class Raw
91
+
92
+ # @return [ String ] pattern The regex pattern.
93
+ attr_reader :pattern
94
+
95
+ # @return [ Integer ] options The options.
96
+ attr_reader :options
97
+
98
+ # Compile the Regular expression into the native type.
99
+ #
100
+ # @example Compile the regular expression.
101
+ # raw.compile
102
+ #
103
+ # @return [ ::Regexp ] The compiled regular expression.
104
+ #
105
+ # @since 3.0.0
106
+ def compile
107
+ @compiled ||= ::Regexp.new(pattern, options)
108
+ end
109
+
110
+ # Initialize the new raw regular expression.
111
+ #
112
+ # @example Initialize the raw regexp.
113
+ # Raw.new(pattern, options)
114
+ #
115
+ # @param [ String ] pattern The regular expression pattern.
116
+ # @param [ Integer ] options The options.
117
+ #
118
+ # @since 3.0.0
119
+ def initialize(pattern, options)
120
+ @pattern = pattern
121
+ @options = options
122
+ end
123
+ end
124
+
85
125
  module ClassMethods
126
+
86
127
  # Deserialize the regular expression from BSON.
87
128
  #
88
129
  # @param [ BSON ] bson The bson representing a regular expression.
@@ -105,8 +146,7 @@ module BSON
105
146
  options |= ::Regexp::EXTENDED
106
147
  end
107
148
  end
108
-
109
- new(pattern, options)
149
+ Raw.new(pattern, options)
110
150
  end
111
151
  end
112
152
 
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2009-2014 MongoDB Inc.
1
+ # Copyright (C) 2009-2015 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.
@@ -13,5 +13,5 @@
13
13
  # limitations under the License.
14
14
 
15
15
  module BSON
16
- VERSION = "2.3.0"
16
+ VERSION = "3.0.0"
17
17
  end
@@ -15,6 +15,44 @@
15
15
  require "spec_helper"
16
16
 
17
17
  describe BSON::Binary do
18
+ let(:testing1) { described_class.new("testing") }
19
+ let(:testing2) { described_class.new("testing") }
20
+ let(:not_testing) { described_class.new("not testing") }
21
+
22
+ describe "#eql?" do
23
+ context "for two equal objects" do
24
+ it "returns true" do
25
+ expect(testing1).to eql(testing2)
26
+ end
27
+ end
28
+
29
+ context "for two different objects" do
30
+ it "returns false" do
31
+ expect(testing1).not_to eql(not_testing)
32
+ end
33
+ end
34
+ end
35
+
36
+ describe "#hash" do
37
+ context "for two equal objects" do
38
+ it "is the same" do
39
+ expect(testing1.hash).to eq(testing2.hash)
40
+ end
41
+ end
42
+
43
+ context "for two different objects" do
44
+ it "is different" do
45
+ expect(testing1.hash).not_to eq(not_testing.hash)
46
+ end
47
+ end
48
+ end
49
+
50
+ let(:hash) do { testing1 => "my value" } end
51
+
52
+ it "can be used as Hash key" do
53
+ expect(hash[testing2]).to eq("my value")
54
+ expect(hash[not_testing]).to be_nil
55
+ end
18
56
 
19
57
  describe "#as_json" do
20
58
 
@@ -46,6 +84,17 @@ describe BSON::Binary do
46
84
  end
47
85
  end
48
86
 
87
+ describe '#inspect' do
88
+
89
+ let(:object) do
90
+ described_class.new('testing123', :user)
91
+ end
92
+
93
+ it 'returns the truncated data and type' do
94
+ expect(object.inspect).to eq("<BSON::Binary:0x#{object.object_id} type=user data=testing1...>")
95
+ end
96
+ end
97
+
49
98
  describe "#to_bson/#from_bson" do
50
99
 
51
100
  let(:type) { 5.chr }
@@ -723,7 +723,13 @@ describe BSON::Document do
723
723
  described_class["type", /^gültig/]
724
724
  end
725
725
 
726
- it_behaves_like "a document able to handle utf-8"
726
+ let(:deserialized) do
727
+ described_class.from_bson(StringIO.new(document.to_bson))
728
+ end
729
+
730
+ it "serializes and deserializes properly" do
731
+ expect(deserialized['type'].compile).to eq(/^gültig/)
732
+ end
727
733
  end
728
734
 
729
735
  context "when the symbols are utf-8" do
@@ -25,4 +25,18 @@ describe BSON::Int32 do
25
25
  it_behaves_like "a bson element"
26
26
  it_behaves_like "a deserializable bson element"
27
27
  end
28
+
29
+ describe "when the integer is negative" do
30
+ let(:decoded) { -1 }
31
+ let(:encoded) {StringIO.new([ -1 ].pack(BSON::Int32::PACK))}
32
+ let(:decoded_2) { -50 }
33
+ let(:encoded_2) {StringIO.new([ -50 ].pack(BSON::Int32::PACK))}
34
+ it "decodes a -1 correctly" do
35
+ expect(BSON::Int32.from_bson(encoded)).to eq(decoded)
36
+ end
37
+ it "decodes a -50 correctly" do
38
+ expect(BSON::Int32.from_bson(encoded_2)).to eq(decoded_2)
39
+ end
40
+ end
41
+
28
42
  end
@@ -390,7 +390,7 @@ describe BSON::ObjectId do
390
390
  end
391
391
 
392
392
  it "returns the inspection with the object id to_s" do
393
- expect(object_id.inspect).to eq("BSON::ObjectId('#{object_id.to_s}')")
393
+ expect(object_id.inspect).to eq("<BSON::ObjectId:0x#{object_id.object_id} data=#{object_id.to_s}>")
394
394
  end
395
395
  end
396
396
 
@@ -36,6 +36,14 @@ describe Regexp do
36
36
  let(:type) { 11.chr }
37
37
  let(:obj) { /test/ }
38
38
 
39
+ let(:io) do
40
+ StringIO.new(bson)
41
+ end
42
+
43
+ let(:result) do
44
+ described_class.from_bson(io).compile
45
+ end
46
+
39
47
  it_behaves_like "a bson element"
40
48
 
41
49
  context "when the regexp has no options" do
@@ -44,7 +52,10 @@ describe Regexp do
44
52
  let(:bson) { "#{obj.source}#{BSON::NULL_BYTE}#{BSON::NULL_BYTE}" }
45
53
 
46
54
  it_behaves_like "a serializable bson element"
47
- it_behaves_like "a deserializable bson element"
55
+
56
+ it "deserializes from bson" do
57
+ expect(result).to eq(obj)
58
+ end
48
59
  end
49
60
 
50
61
  context "when the regexp has options" do
@@ -55,7 +66,10 @@ describe Regexp do
55
66
  let(:bson) { "#{obj.source}#{BSON::NULL_BYTE}i#{BSON::NULL_BYTE}" }
56
67
 
57
68
  it_behaves_like "a serializable bson element"
58
- it_behaves_like "a deserializable bson element"
69
+
70
+ it "deserializes from bson" do
71
+ expect(result).to eq(obj)
72
+ end
59
73
  end
60
74
 
61
75
  context "when matching multiline" do
@@ -64,7 +78,10 @@ describe Regexp do
64
78
  let(:bson) { "#{obj.source}#{BSON::NULL_BYTE}ms#{BSON::NULL_BYTE}" }
65
79
 
66
80
  it_behaves_like "a serializable bson element"
67
- it_behaves_like "a deserializable bson element"
81
+
82
+ it "deserializes from bson" do
83
+ expect(result).to eq(obj)
84
+ end
68
85
  end
69
86
 
70
87
  context "when matching extended" do
@@ -73,7 +90,10 @@ describe Regexp do
73
90
  let(:bson) { "#{obj.source}#{BSON::NULL_BYTE}x#{BSON::NULL_BYTE}" }
74
91
 
75
92
  it_behaves_like "a serializable bson element"
76
- it_behaves_like "a deserializable bson element"
93
+
94
+ it "deserializes from bson" do
95
+ expect(result).to eq(obj)
96
+ end
77
97
  end
78
98
 
79
99
  context "when all options are present" do
@@ -82,7 +102,10 @@ describe Regexp do
82
102
  let(:bson) { "#{obj.source}#{BSON::NULL_BYTE}imsx#{BSON::NULL_BYTE}" }
83
103
 
84
104
  it_behaves_like "a serializable bson element"
85
- it_behaves_like "a deserializable bson element"
105
+
106
+ it "deserializes from bson" do
107
+ expect(result).to eq(obj)
108
+ end
86
109
  end
87
110
  end
88
111
  end
@@ -57,8 +57,12 @@ shared_examples_for "a deserializable bson element" do
57
57
  StringIO.new(bson)
58
58
  end
59
59
 
60
+ let(:result) do
61
+ described_class.from_bson(io)
62
+ end
63
+
60
64
  it "deserializes from bson" do
61
- expect(described_class.from_bson(io)).to eq(obj)
65
+ expect(result).to eq(obj)
62
66
  end
63
67
  end
64
68
 
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: 2.3.0
4
+ version: 3.0.0
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
- Y29tMB4XDTE0MDIxOTE1MTEyNloXDTE1MDIxOTE1MTEyNlowQjEUMBIGA1UEAwwL
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
- KoZIhvcNAQEFBQADggEBALGvdxHF+CnH6QO4PeIce3S8EHuHsYiGLk4sWgNGZkjD
31
- V3C4XjlI8rQZxalwQwcauacOGj9x94flWUXruEF7+rjUtig7OIrQK2+uVg86vl8r
32
- xy1n2s1d31KsuazEVExe5o19tnVbI9+30P9qPkS+NgaellXpj5c5qnJUGn5BJtzo
33
- 3D001zXpVnuZvCcE/A4fQ+BEM0zm0oOmA/gWIAFrufOL9oYg1881dRZ+kQytF/9c
34
- JrZM8w8wGbIOeLtoQqa7HB/jOYbTahH7KMNh2LHAbOR93hNIJxVRa4iwxiMQ75tN
35
- 9WUIAJ4AEtjwRg1Bz0OwDo3aucPCBpx77+/FWhv7JYY=
36
- -----END CERTIFICATE-----
37
- date: 2014-06-02 00:00:00.000000000 Z
14
+ cert_chain: []
15
+ date: 2015-02-18 00:00:00.000000000 Z
38
16
  dependencies: []
39
17
  description: A full featured BSON specification implementation, in Ruby
40
18
  email:
@@ -43,8 +21,8 @@ executables: []
43
21
  extensions: []
44
22
  extra_rdoc_files: []
45
23
  files:
46
- - CHANGELOG.md
47
24
  - CONTRIBUTING.md
25
+ - CHANGELOG.md
48
26
  - LICENSE
49
27
  - NOTICE
50
28
  - README.md
@@ -83,6 +61,8 @@ files:
83
61
  - lib/bson/true_class.rb
84
62
  - lib/bson/undefined.rb
85
63
  - lib/bson/version.rb
64
+ - spec/bson_spec.rb
65
+ - spec/spec_helper.rb
86
66
  - spec/bson/array_spec.rb
87
67
  - spec/bson/binary_spec.rb
88
68
  - spec/bson/boolean_spec.rb
@@ -111,8 +91,6 @@ files:
111
91
  - spec/bson/timestamp_spec.rb
112
92
  - spec/bson/true_class_spec.rb
113
93
  - spec/bson/undefined_spec.rb
114
- - spec/bson_spec.rb
115
- - spec/spec_helper.rb
116
94
  - spec/support/shared_examples.rb
117
95
  homepage: http://bsonspec.org
118
96
  licenses:
@@ -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.2.2
115
+ rubygems_version: 2.1.9
138
116
  signing_key:
139
117
  specification_version: 4
140
118
  summary: Ruby Implementation of the BSON specification
Binary file
data.tar.gz.sig DELETED
Binary file
metadata.gz.sig DELETED
Binary file