bson 2.2.4-java → 2.3.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: 5a7dd76416c2ce339619e60856e3948622ab724e
4
- data.tar.gz: 302faf27ea7bd5292880751709ddb010b92cefff
3
+ metadata.gz: e6a273f6fa537d5cc00fc4dadb9115ac0b0fa205
4
+ data.tar.gz: e64fe5120499d7d5d98159833d04e32f9cc45ecf
5
5
  SHA512:
6
- metadata.gz: 99a3260fef8ea1b28f35e4c61de1d668ec74074fe50dc943d26aa35c6061f31e2f1f38f544c12081bb6350e844844f65831df6acc2b7c6703365b73da373b5cb
7
- data.tar.gz: 3bb12b493125b6adda513b551ebe9ef3831ff36ec06d5e60a4051c6e1f87bb69b146cf95f9930487dfcba5a2d50573d6c53671354b32cd9c5cda8af5ea111746
6
+ metadata.gz: 0bd9c997edf798e75e12244a4d39f30f246e0db0ed902d765fb281338a415907a86ae4dbe51658541e1aa041b580d0e0e367ea8484a0a6caa28ef16039a872d9
7
+ data.tar.gz: caaf315f18150af9d5e42d86997063b1492b7699aad31fbf7e08ff48c26ee4a29191d95a49aa684b9df63a070d79c0bd81077a0dbf0599d551737cfc930d0df4
Binary file
Binary file
data/README.md CHANGED
@@ -15,7 +15,7 @@ With bundler, add the `bson` gem to your `Gemfile`. As of 2.0.0 native extension
15
15
  are bundled with the `bson` gem and `bson_ext` is no longer needed.
16
16
 
17
17
  ```ruby
18
- gem "bson", "~> 2.2"
18
+ gem "bson", "~> 2.3"
19
19
  ```
20
20
 
21
21
  Require the `bson` gem in your application.
@@ -181,7 +181,7 @@ As of 2.0.0, this project adheres to the [Semantic Versioning Specification](htt
181
181
  License
182
182
  -------
183
183
 
184
- Copyright (C) 2009-2013 MongoDB Inc.
184
+ Copyright (C) 2009-2014 MongoDB Inc.
185
185
 
186
186
  Licensed under the Apache License, Version 2.0 (the "License");
187
187
  you may not use this file except in compliance with the License.
Binary file
@@ -68,6 +68,18 @@ module BSON
68
68
  ObjectId.repair(self) { pack("C*") }
69
69
  end
70
70
 
71
+ # Converts the array to a normalized value in a BSON document.
72
+ #
73
+ # @example Convert the array to a normalized value.
74
+ # array.to_bson_normalized_value
75
+ #
76
+ # @return [ Array ] The normazlied array.
77
+ #
78
+ # @since 3.0.0
79
+ def to_bson_normalized_value
80
+ map!{ |value| value.to_bson_normalized_value }
81
+ end
82
+
71
83
  module ClassMethods
72
84
 
73
85
  # Deserialize the array from BSON.
@@ -50,7 +50,72 @@ module BSON
50
50
  #
51
51
  # @since 2.0.0
52
52
  def [](key)
53
- super(key) || super(key.to_s)
53
+ super(key.to_bson_normalized_key)
54
54
  end
55
+
56
+ # Set a value on the document. Will normalize symbol keys into strings.
57
+ #
58
+ # @example Set a value on the document.
59
+ # document[:test] = "value"
60
+ #
61
+ # @param [ String, Symbol ] key The key to update.
62
+ # @param [ Object ] value The value to update.
63
+ #
64
+ # @return [ Object ] The updated value.
65
+ #
66
+ # @since 3.0.0
67
+ def []=(key, value)
68
+ super(key.to_bson_normalized_key, value.to_bson_normalized_value)
69
+ end
70
+
71
+ # Instantiate a new Document. Valid parameters for instantiation is a hash
72
+ # only or nothing.
73
+ #
74
+ # @example Create the new Document.
75
+ # BSON::Document.new(name: "Joe", age: 33)
76
+ #
77
+ # @param [ Hash ] elements The elements of the document.
78
+ #
79
+ # @since 3.0.0
80
+ def initialize(elements = nil)
81
+ super()
82
+ (elements || {}).each_pair{ |key, value| self[key] = value }
83
+ end
84
+
85
+ # Merge this document with another document, returning a new document in
86
+ # the process.
87
+ #
88
+ # @example Merge with another document.
89
+ # document.merge(name: "Bob")
90
+ #
91
+ # @param [ BSON::Document, Hash ] other The document/hash to merge with.
92
+ #
93
+ # @eturn [ BSON::Document ] The result of the merge.
94
+ #
95
+ # @since 3.0.0
96
+ def merge(other, &block)
97
+ dup.merge!(other, &block)
98
+ end
99
+
100
+ # Merge this document with another document, returning the same document in
101
+ # the process.
102
+ #
103
+ # @example Merge with another document.
104
+ # document.merge(name: "Bob")
105
+ #
106
+ # @param [ BSON::Document, Hash ] other The document/hash to merge with.
107
+ #
108
+ # @eturn [ BSON::Document ] The result of the merge.
109
+ #
110
+ # @since 3.0.0
111
+ def merge!(other)
112
+ other.each_pair do |key, value|
113
+ value = yield(key.to_bson_normalized_key, self[key], value.to_bson_normalized_value) if block_given?
114
+ self[key] = value
115
+ end
116
+ self
117
+ end
118
+
119
+ alias :update :merge!
55
120
  end
56
121
  end
@@ -48,6 +48,18 @@ module BSON
48
48
  end
49
49
  end
50
50
 
51
+ # Converts the hash to a normalized value in a BSON document.
52
+ #
53
+ # @example Convert the hash to a normalized value.
54
+ # hash.to_bson_normalized_value
55
+ #
56
+ # @return [ BSON::Document ] The normazlied hash.
57
+ #
58
+ # @since 3.0.0
59
+ def to_bson_normalized_value
60
+ Document.new(self)
61
+ end
62
+
51
63
  module ClassMethods
52
64
 
53
65
  # Deserialize the hash from BSON.
@@ -34,6 +34,30 @@ module BSON
34
34
  def to_bson_key(encoded = ''.force_encoding(BINARY))
35
35
  raise InvalidKey.new(self)
36
36
  end
37
+
38
+ # Converts the object to a normalized key in a BSON document.
39
+ #
40
+ # @example Convert the object to a normalized key.
41
+ # object.to_bson_normalized_key
42
+ #
43
+ # @return [ Object ] self.
44
+ #
45
+ # @since 3.0.0
46
+ def to_bson_normalized_key
47
+ self
48
+ end
49
+
50
+ # Converts the object to a normalized value in a BSON document.
51
+ #
52
+ # @example Convert the object to a normalized value.
53
+ # object.to_bson_normalized_value
54
+ #
55
+ # @return [ Object ] self.
56
+ #
57
+ # @since 3.0.0
58
+ def to_bson_normalized_value
59
+ self
60
+ end
37
61
  end
38
62
 
39
63
  # Raised when trying to serialize an object into a key.
@@ -58,6 +58,18 @@ module BSON
58
58
  to_s.to_bson_key(encoded)
59
59
  end
60
60
 
61
+ # Converts the symbol to a normalized key in a BSON document.
62
+ #
63
+ # @example Convert the symbol to a normalized key.
64
+ # :test.to_bson_normalized_key
65
+ #
66
+ # @return [ String ] The symbol as a non interned string.
67
+ #
68
+ # @since 3.0.0
69
+ def to_bson_normalized_key
70
+ to_s
71
+ end
72
+
61
73
  module ClassMethods
62
74
  # Deserialize a symbol from BSON.
63
75
  #
@@ -13,5 +13,5 @@
13
13
  # limitations under the License.
14
14
 
15
15
  module BSON
16
- VERSION = "2.2.4"
16
+ VERSION = "2.3.0"
17
17
  end
@@ -39,8 +39,8 @@ describe BSON::Binary do
39
39
  expect {
40
40
  described_class.new("testing", :error)
41
41
  }.to raise_error { |error|
42
- error.should be_a(BSON::Binary::InvalidType)
43
- error.message.should match /is not a valid binary type/
42
+ expect(error).to be_a(BSON::Binary::InvalidType)
43
+ expect(error.message).to match /is not a valid binary type/
44
44
  }
45
45
  end
46
46
  end
@@ -149,14 +149,14 @@ describe BSON::Document do
149
149
  context "when the key exists" do
150
150
 
151
151
  it "returns true" do
152
- expect(doc.send(method, "blue")).to be_true
152
+ expect(doc.send(method, "blue")).to be true
153
153
  end
154
154
  end
155
155
 
156
156
  context "when the key does not exist" do
157
157
 
158
158
  it "returns false" do
159
- expect(doc.send(method, "indigo")).to be_false
159
+ expect(doc.send(method, "indigo")).to be false
160
160
  end
161
161
  end
162
162
  end
@@ -169,14 +169,14 @@ describe BSON::Document do
169
169
  context "when the value exists" do
170
170
 
171
171
  it "returns true" do
172
- expect(doc.send(method, "000099")).to be_true
172
+ expect(doc.send(method, "000099")).to be true
173
173
  end
174
174
  end
175
175
 
176
176
  context "when the value does not exist" do
177
177
 
178
178
  it "returns false" do
179
- expect(doc.send(method, "ABCABC")).to be_false
179
+ expect(doc.send(method, "ABCABC")).to be false
180
180
  end
181
181
  end
182
182
  end
@@ -439,7 +439,7 @@ describe BSON::Document do
439
439
  it "executes the block on each merged element" do
440
440
  expect(merged[:a]).to eq(0)
441
441
  expect(merged[:b]).to eq(3)
442
- expect(merged[:c]).to eq(7)
442
+ expect(merged[:c]).to eq(8)
443
443
  end
444
444
  end
445
445
  end
@@ -488,7 +488,7 @@ describe BSON::Document do
488
488
  it "executes the block on each merged element" do
489
489
  expect(other[:a]).to eq(0)
490
490
  expect(other[:b]).to eq(3)
491
- expect(other[:c]).to eq(7)
491
+ expect(other[:c]).to eq(8)
492
492
  end
493
493
  end
494
494
  end
@@ -517,60 +517,58 @@ describe BSON::Document do
517
517
 
518
518
  describe "#initialize" do
519
519
 
520
- context "when provided for splat args" do
520
+ context "when providing symbol keys" do
521
521
 
522
- context "when an even number of args" do
522
+ let(:document) do
523
+ described_class.new(:test => 2, :testing => 4)
524
+ end
523
525
 
524
- let(:alternate) do
525
- described_class[1, 2, 3, 4]
526
- end
526
+ it "converts the symbols to strings" do
527
+ expect(document).to eq({ "test" => 2, "testing" => 4 })
528
+ end
529
+ end
527
530
 
528
- it "treats the arguments are an array" do
529
- expect(alternate.keys).to eq([ 1, 3 ])
530
- end
531
+ context "when providing duplicate symbol and string keys" do
531
532
 
532
- it "instantiates a document" do
533
- expect(alternate).to be_a(BSON::Document)
534
- end
533
+ let(:document) do
534
+ described_class.new(:test => 2, "test" => 4)
535
535
  end
536
536
 
537
- context "when an odd number of arguments" do
538
-
539
- it "raises an argument error" do
540
- expect {
541
- described_class[1, 2, 3]
542
- }.to raise_error(ArgumentError)
543
- end
537
+ it "uses the last provided string key value" do
538
+ expect(document[:test]).to eq(4)
544
539
  end
545
540
  end
546
541
 
547
- context "when provided an array" do
542
+ context "when providing a nested hash with symbol keys" do
548
543
 
549
- let(:alternate) do
550
- described_class[[[ 1, 2 ], [ 3, 4 ], [ "missing" ]]]
551
- end
552
-
553
- it "sets the keys" do
554
- expect(alternate.keys).to eq([ 1, 3, "missing" ])
544
+ let(:document) do
545
+ described_class.new(:test => { :test => 4 })
555
546
  end
556
547
 
557
- it "sets the values" do
558
- expect(alternate.values).to eq([ 2, 4, nil ])
548
+ it "converts the nested keys to strings" do
549
+ expect(document).to eq({ "test" => { "test" => 4 }})
559
550
  end
560
551
  end
561
552
 
562
- context "when provided hashes" do
553
+ context "when providing a nested hash multiple levels deep with symbol keys" do
554
+
555
+ let(:document) do
556
+ described_class.new(:test => { :test => { :test => 4 }})
557
+ end
563
558
 
564
- let(:alternate) do
565
- described_class[1 => 2, 3 => 4]
559
+ it "converts the nested keys to strings" do
560
+ expect(document).to eq({ "test" => { "test" => { "test" => 4 }}})
566
561
  end
562
+ end
563
+
564
+ context "when providing an array of nested hashes" do
567
565
 
568
- it "sets the keys" do
569
- expect(alternate.keys).to eq([ 1, 3 ])
566
+ let(:document) do
567
+ described_class.new(:test => [{ :test => 4 }])
570
568
  end
571
569
 
572
- it "sets the values" do
573
- expect(alternate.values).to eq([ 2, 4 ])
570
+ it "converts the nested keys to strings" do
571
+ expect(document).to eq({ "test" => [{ "test" => 4 }]})
574
572
  end
575
573
  end
576
574
  end
@@ -601,12 +599,16 @@ describe BSON::Document do
601
599
  end
602
600
 
603
601
  it "updates the keys" do
604
- expect(updated.keys).to eq([ :name ])
602
+ expect(updated.keys).to eq([ "name" ])
605
603
  end
606
604
 
607
605
  it "updates the values" do
608
606
  expect(updated.values).to eq([ "Bob" ])
609
607
  end
608
+
609
+ it "returns the same document" do
610
+ expect(updated.update(:name => "Bob")).to equal(updated)
611
+ end
610
612
  end
611
613
 
612
614
  describe "#invert" do
@@ -38,14 +38,14 @@ describe BSON::MaxKey do
38
38
  describe "#>" do
39
39
 
40
40
  it "always returns true" do
41
- expect(subject > Integer::MAX_64BIT).to be_true
41
+ expect(subject > Integer::MAX_64BIT).to be true
42
42
  end
43
43
  end
44
44
 
45
45
  describe "#<" do
46
46
 
47
47
  it "always returns false" do
48
- expect(subject < Integer::MAX_64BIT).to be_false
48
+ expect(subject < Integer::MAX_64BIT).to be false
49
49
  end
50
50
  end
51
51
 
@@ -51,14 +51,14 @@ describe BSON::MinKey do
51
51
  describe "#>" do
52
52
 
53
53
  it "always returns false" do
54
- expect(subject > Integer::MAX_64BIT).to be_false
54
+ expect(subject > Integer::MAX_64BIT).to be false
55
55
  end
56
56
  end
57
57
 
58
58
  describe "#<" do
59
59
 
60
60
  it "always returns true" do
61
- expect(subject < Integer::MAX_64BIT).to be_true
61
+ expect(subject < Integer::MAX_64BIT).to be true
62
62
  end
63
63
  end
64
64
 
@@ -76,7 +76,7 @@ describe BSON::ObjectId do
76
76
  end
77
77
 
78
78
  it "returns true" do
79
- expect(object_id === other).to be_true
79
+ expect(object_id === other).to be true
80
80
  end
81
81
  end
82
82
 
@@ -87,7 +87,7 @@ describe BSON::ObjectId do
87
87
  end
88
88
 
89
89
  it "returns false" do
90
- expect(object_id === other).to be_false
90
+ expect(object_id === other).to be false
91
91
  end
92
92
  end
93
93
  end
@@ -95,7 +95,7 @@ describe BSON::ObjectId do
95
95
  context "when comparing to an object id class" do
96
96
 
97
97
  it "returns false" do
98
- expect(object_id === BSON::ObjectId).to be_false
98
+ expect(object_id === BSON::ObjectId).to be false
99
99
  end
100
100
  end
101
101
 
@@ -108,7 +108,7 @@ describe BSON::ObjectId do
108
108
  end
109
109
 
110
110
  it "returns true" do
111
- expect(object_id === other).to be_true
111
+ expect(object_id === other).to be true
112
112
  end
113
113
  end
114
114
 
@@ -119,7 +119,7 @@ describe BSON::ObjectId do
119
119
  end
120
120
 
121
121
  it "returns false" do
122
- expect(object_id === other).to be_false
122
+ expect(object_id === other).to be false
123
123
  end
124
124
  end
125
125
  end
@@ -127,14 +127,14 @@ describe BSON::ObjectId do
127
127
  context "when comparing with a non string or object id" do
128
128
 
129
129
  it "returns false" do
130
- expect(object_id === "test").to be_false
130
+ expect(object_id === "test").to be false
131
131
  end
132
132
  end
133
133
 
134
134
  context "when comparing with a non object id class" do
135
135
 
136
136
  it "returns false" do
137
- expect(object_id === String).to be_false
137
+ expect(object_id === String).to be false
138
138
  end
139
139
  end
140
140
  end
@@ -152,14 +152,14 @@ describe BSON::ObjectId do
152
152
  context "when the generation time before the other" do
153
153
 
154
154
  it "returns true" do
155
- expect(object_id < other_id).to be_true
155
+ expect(object_id < other_id).to be true
156
156
  end
157
157
  end
158
158
 
159
159
  context "when the generation time is after the other" do
160
160
 
161
161
  it "returns false" do
162
- expect(other_id < object_id).to be_false
162
+ expect(other_id < object_id).to be false
163
163
  end
164
164
  end
165
165
  end
@@ -177,14 +177,14 @@ describe BSON::ObjectId do
177
177
  context "when the generation time before the other" do
178
178
 
179
179
  it "returns false" do
180
- expect(object_id > other_id).to be_false
180
+ expect(object_id > other_id).to be false
181
181
  end
182
182
  end
183
183
 
184
184
  context "when the generation time is after the other" do
185
185
 
186
186
  it "returns true" do
187
- expect(other_id > object_id).to be_true
187
+ expect(other_id > object_id).to be true
188
188
  end
189
189
  end
190
190
  end
@@ -333,7 +333,7 @@ describe BSON::ObjectId do
333
333
  end
334
334
 
335
335
  it "does not include process or sequence information" do
336
- expect(object_id.to_s =~ /\A[0-9a-f]{8}[0]{16}\Z/).to be_true
336
+ expect(object_id.to_s =~ /\A[0-9a-f]{8}[0]{16}\Z/).to be_truthy
337
337
  end
338
338
  end
339
339
 
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.2.4
4
+ version: 2.3.0
5
5
  platform: java
6
6
  authors:
7
7
  - Tyler Brock
@@ -11,8 +11,30 @@ authors:
11
11
  - Gary Murakami
12
12
  autorequire:
13
13
  bindir: bin
14
- cert_chain: []
15
- date: 2014-05-20 00:00:00.000000000 Z
14
+ cert_chain:
15
+ - |
16
+ -----BEGIN CERTIFICATE-----
17
+ MIIDfDCCAmSgAwIBAgIBATANBgkqhkiG9w0BAQUFADBCMRQwEgYDVQQDDAtkcml2
18
+ ZXItcnVieTEVMBMGCgmSJomT8ixkARkWBTEwZ2VuMRMwEQYKCZImiZPyLGQBGRYD
19
+ Y29tMB4XDTE0MDIxOTE1MTEyNloXDTE1MDIxOTE1MTEyNlowQjEUMBIGA1UEAwwL
20
+ ZHJpdmVyLXJ1YnkxFTATBgoJkiaJk/IsZ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----
37
+ date: 2014-06-02 00:00:00.000000000 Z
16
38
  dependencies: []
17
39
  description: A full featured BSON specification implementation, in Ruby
18
40
  email:
Binary file