bson 3.1.2 → 3.2.0

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: b6a6c59b342df752f1bbbe7d374f05a24819ee0b
4
- data.tar.gz: 450450cd24ce715adfdbb4c8edf45f77e0420427
3
+ metadata.gz: 830d8156be21a282cce7f2ff5c7136c7c0cf5320
4
+ data.tar.gz: 1003e647f5ff7789f861838b4d7c4080237556c4
5
5
  SHA512:
6
- metadata.gz: f257986d690b5991b4a551b695cd2be4deb51821c87d0f451b65b9e9b696e182ac9aa4839695c265ef307dcf38a434b209acf15f0a96ba9dc0f6bd957c7a0252
7
- data.tar.gz: 51a08b8e0803c04cef956116f1b17513a128d184bb869eefd8c8df6d13d8393c0a4e3f24994797c36bad971e758dbad0db628f3dc82b9afb680ee78a1abb3098
6
+ metadata.gz: e1acb711445290f976f2754dbc20903f583f1f4c96efd993eb7982ace58742ebe96d0d243f35bb3c2b50e1cdfb7714065f14b2ff4ef5b75afd46c0de5eb52b9f
7
+ data.tar.gz: c3b549ae774b91c4af91dafca71ab78d47154c56871163cd4e31c7640f90c5557956ccae84843b85b59df13041977a96868a7cddea2f508639a5b70a921bcf34
Binary file
data.tar.gz.sig CHANGED
Binary file
@@ -1,6 +1,16 @@
1
1
  BSON Changelog
2
2
  ==============
3
3
 
4
+ ## 3.2.0
5
+
6
+ ### Bug Fixes
7
+
8
+ * [RUBY-950](https://jira.mongodb.org/browse/RUBY-950) Don't encode to UTF-8 in Binary#to_bson, only force BINARY encoding.
9
+
10
+ ### New features
11
+
12
+ * Add `BSON.ObjectId` constructor for instantiating an ObjectId from a String. Update ObjectId#inspect to print out a string that can be evaluated into the corresponding ObjectId. (Tony Ta)
13
+
4
14
  ## 3.1.2
5
15
 
6
16
  ### Bug Fixes
@@ -19,6 +19,22 @@ require "bson/environment"
19
19
  # @since 0.0.0
20
20
  module BSON
21
21
 
22
+ # Create a new object id from a string using ObjectId.from_string
23
+ #
24
+ # @example Create an object id from the string.
25
+ # BSON::ObjectId(id)
26
+ #
27
+ # @param [ String ] string The string to create the id from.
28
+ #
29
+ # @raise [ BSON::ObjectId::Invalid ] If the provided string is invalid.
30
+ #
31
+ # @return [ BSON::ObjectId ] The new object id.
32
+ #
33
+ # @see ObjectId.from_string
34
+ def self.ObjectId(string)
35
+ self::ObjectId.from_string(string)
36
+ end
37
+
22
38
  # Constant for binary string encoding.
23
39
  #
24
40
  # @since 2.0.0
@@ -134,7 +134,7 @@ module BSON
134
134
  encode_binary_data_with_placeholder(encoded) do |encoded|
135
135
  encoded << SUBTYPES.fetch(type)
136
136
  encoded << data.bytesize.to_bson if type == :old
137
- encoded << data.encode(UTF8).force_encoding(BINARY)
137
+ encoded << data.force_encoding(BINARY)
138
138
  end
139
139
  end
140
140
 
@@ -124,7 +124,7 @@ module BSON
124
124
  #
125
125
  # @since 2.0.0
126
126
  def inspect
127
- "<BSON::ObjectId:0x#{object_id} data=#{to_s}>"
127
+ "BSON::ObjectId('#{to_s}')"
128
128
  end
129
129
 
130
130
  # Dump the raw bson when calling Marshal.dump.
@@ -13,5 +13,5 @@
13
13
  # limitations under the License.
14
14
 
15
15
  module BSON
16
- VERSION = "3.1.2"
16
+ VERSION = "3.2.0"
17
17
  end
@@ -390,7 +390,11 @@ 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:0x#{object_id.object_id} data=#{object_id.to_s}>")
393
+ expect(object_id.inspect).to eq("BSON::ObjectId('#{object_id.to_s}')")
394
+ end
395
+
396
+ it "returns a string that evaluates into an equivalent object id" do
397
+ expect(eval object_id.inspect).to eq object_id
394
398
  end
395
399
  end
396
400
 
@@ -16,6 +16,16 @@ require "spec_helper"
16
16
 
17
17
  describe BSON do
18
18
 
19
+ describe ".ObjectId" do
20
+
21
+ let(:string) { "4e4d66343b39b68407000001" }
22
+
23
+ it "returns an BSON::ObjectId from given string" do
24
+ expect(described_class::ObjectId(string)).to be_a BSON::ObjectId
25
+ expect(described_class::ObjectId(string)).to eq BSON::ObjectId.from_string(string)
26
+ end
27
+ end
28
+
19
29
  describe "::BINARY" do
20
30
 
21
31
  it "returns BINARY" 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: 3.1.2
4
+ version: 3.2.0
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: 2015-07-01 00:00:00.000000000 Z
37
+ date: 2015-07-22 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