bson 2.0.0.rc2-java → 2.0.0.rc3-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.

Files changed (66) hide show
  1. data.tar.gz.sig +0 -0
  2. data/LICENSE +1 -1
  3. data/NOTICE +1 -1
  4. data/README.md +1 -1
  5. data/Rakefile +2 -1
  6. data/lib/bson-ruby.jar +0 -0
  7. data/lib/bson.rb +1 -1
  8. data/lib/bson/array.rb +18 -1
  9. data/lib/bson/binary.rb +56 -1
  10. data/lib/bson/boolean.rb +1 -1
  11. data/lib/bson/code.rb +1 -1
  12. data/lib/bson/code_with_scope.rb +1 -1
  13. data/lib/bson/document.rb +1 -1
  14. data/lib/bson/encodable.rb +1 -1
  15. data/lib/bson/environment.rb +1 -1
  16. data/lib/bson/false_class.rb +1 -1
  17. data/lib/bson/float.rb +1 -1
  18. data/lib/bson/hash.rb +1 -1
  19. data/lib/bson/int32.rb +1 -1
  20. data/lib/bson/int64.rb +1 -1
  21. data/lib/bson/integer.rb +1 -1
  22. data/lib/bson/json.rb +1 -1
  23. data/lib/bson/max_key.rb +1 -1
  24. data/lib/bson/min_key.rb +1 -1
  25. data/lib/bson/nil_class.rb +1 -1
  26. data/lib/bson/object_id.rb +28 -6
  27. data/lib/bson/regexp.rb +1 -1
  28. data/lib/bson/registry.rb +1 -1
  29. data/lib/bson/specialized.rb +1 -1
  30. data/lib/bson/string.rb +18 -1
  31. data/lib/bson/symbol.rb +1 -1
  32. data/lib/bson/time.rb +1 -1
  33. data/lib/bson/timestamp.rb +1 -1
  34. data/lib/bson/true_class.rb +1 -1
  35. data/lib/bson/undefined.rb +1 -1
  36. data/lib/bson/version.rb +2 -2
  37. data/spec/bson/array_spec.rb +28 -1
  38. data/spec/bson/binary_spec.rb +13 -1
  39. data/spec/bson/boolean_spec.rb +1 -1
  40. data/spec/bson/code_spec.rb +1 -1
  41. data/spec/bson/code_with_scope_spec.rb +1 -1
  42. data/spec/bson/document_spec.rb +1 -1
  43. data/spec/bson/false_class_spec.rb +1 -1
  44. data/spec/bson/float_spec.rb +1 -1
  45. data/spec/bson/hash_spec.rb +1 -1
  46. data/spec/bson/int32_spec.rb +1 -1
  47. data/spec/bson/int64_spec.rb +1 -1
  48. data/spec/bson/integer_spec.rb +1 -1
  49. data/spec/bson/json_spec.rb +1 -1
  50. data/spec/bson/max_key_spec.rb +1 -1
  51. data/spec/bson/min_key_spec.rb +1 -1
  52. data/spec/bson/nil_class_spec.rb +1 -1
  53. data/spec/bson/object_id_spec.rb +29 -1
  54. data/spec/bson/regexp_spec.rb +1 -1
  55. data/spec/bson/registry_spec.rb +1 -1
  56. data/spec/bson/string_spec.rb +28 -1
  57. data/spec/bson/symbol_spec.rb +1 -1
  58. data/spec/bson/time_spec.rb +1 -1
  59. data/spec/bson/timestamp_spec.rb +1 -1
  60. data/spec/bson/true_class_spec.rb +1 -1
  61. data/spec/bson/undefined_spec.rb +1 -1
  62. data/spec/bson_spec.rb +1 -1
  63. data/spec/spec_helper.rb +1 -1
  64. data/spec/support/shared_examples.rb +1 -1
  65. metadata +2 -2
  66. metadata.gz.sig +0 -0
data.tar.gz.sig CHANGED
Binary file
data/LICENSE CHANGED
@@ -175,7 +175,7 @@
175
175
 
176
176
  END OF TERMS AND CONDITIONS
177
177
 
178
- Copyright (C) 2008-2013 10gen, Inc.
178
+ Copyright (C) 2008-2013 MongoDB, Inc.
179
179
 
180
180
  Licensed under the Apache License, Version 2.0 (the "License");
181
181
  you may not use this file except in compliance with the License.
data/NOTICE CHANGED
@@ -1,2 +1,2 @@
1
1
  Ruby BSON
2
- Copyright (C) 2009-2013 10gen, Inc.
2
+ Copyright (C) 2009-2013 MongoDB, Inc.
data/README.md CHANGED
@@ -175,7 +175,7 @@ As of 2.0.0, this project adheres to the [Semantic Versioning Specification](htt
175
175
  License
176
176
  -------
177
177
 
178
- Copyright (C) 2013 10gen Inc.
178
+ Copyright (C) 2013 MongoDB Inc.
179
179
 
180
180
  Licensed under the Apache License, Version 2.0 (the "License");
181
181
  you may not use this file except in compliance with the License.
data/Rakefile CHANGED
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2013 10gen Inc.
1
+ # Copyright (C) 2013 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.
@@ -78,6 +78,7 @@ task :clean_all => :clean do
78
78
  end
79
79
  end
80
80
 
81
+ # Run bundle exec rake release with mri and jruby.
81
82
  task :release => :build do
82
83
  system "git tag -a v#{BSON::VERSION} -m 'Tagging release: #{BSON::VERSION}'"
83
84
  system "git push --tags"
Binary file
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2013 10gen Inc.
1
+ # Copyright (C) 2013 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.
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2013 10gen Inc.
1
+ # Copyright (C) 2013 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.
@@ -51,6 +51,23 @@ module BSON
51
51
  end
52
52
  end
53
53
 
54
+ # Convert the array to an object id. This will only work for arrays of size
55
+ # 12 where the elements are all strings.
56
+ #
57
+ # @example Convert the array to an object id.
58
+ # array.to_bson_object_id
59
+ #
60
+ # @note This is used for repairing legacy bson data.
61
+ #
62
+ # @raise [ InvalidObjectId ] If the array is not 12 elements.
63
+ #
64
+ # @return [ String ] The raw object id bytes.
65
+ #
66
+ # @since 2.0.0
67
+ def to_bson_object_id
68
+ ObjectId.repair(self) { pack("C*") }
69
+ end
70
+
54
71
  module ClassMethods
55
72
 
56
73
  # Deserialize the array from BSON.
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2013 10gen Inc.
1
+ # Copyright (C) 2013 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.
@@ -91,6 +91,7 @@ module BSON
91
91
  #
92
92
  # @since 2.0.0
93
93
  def initialize(data = "", type = :generic)
94
+ validate_type!(type)
94
95
  @data = data
95
96
  @type = type
96
97
  end
@@ -130,6 +131,60 @@ module BSON
130
131
  new(data, type)
131
132
  end
132
133
 
134
+ # Raised when providing an invalid type to the Binary.
135
+ #
136
+ # @since 2.0.0
137
+ class InvalidType < RuntimeError
138
+
139
+ # @!attribute type
140
+ # @return [ Object ] The invalid type.
141
+ # @since 2.0.0
142
+ attr_reader :type
143
+
144
+ # Instantiate the new error.
145
+ #
146
+ # @example Instantiate the error.
147
+ # InvalidType.new(:error)
148
+ #
149
+ # @param [ Object ] type The invalid type.
150
+ #
151
+ # @since 2.0.0
152
+ def initialize(type)
153
+ @type = type
154
+ end
155
+
156
+ # Get the custom error message for the exception.
157
+ #
158
+ # @example Get the message.
159
+ # error.message
160
+ #
161
+ # @return [ String ] The error message.
162
+ #
163
+ # @since 2.0.0
164
+ def message
165
+ "#{type.inspect} is not a valid binary type. " +
166
+ "Please use one of #{SUBTYPES.keys.map(&:inspect).join(", ")}."
167
+ end
168
+ end
169
+
170
+ private
171
+
172
+ # Validate the provided type is a valid type.
173
+ #
174
+ # @api private
175
+ #
176
+ # @example Validate the type.
177
+ # binary.validate_type!(:user)
178
+ #
179
+ # @param [ Object ] type The provided type.
180
+ #
181
+ # @raise [ InvalidType ] The the type is invalid.
182
+ #
183
+ # @since 2.0.0
184
+ def validate_type!(type)
185
+ raise InvalidType.new(type) unless SUBTYPES.has_key?(type)
186
+ end
187
+
133
188
  # Register this type when the module is loaded.
134
189
  #
135
190
  # @since 2.0.0
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2013 10gen Inc.
1
+ # Copyright (C) 2013 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.
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2013 10gen Inc.
1
+ # Copyright (C) 2013 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.
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2013 10gen Inc.
1
+ # Copyright (C) 2013 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.
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2013 10gen Inc.
1
+ # Copyright (C) 2013 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.
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2013 10gen Inc.
1
+ # Copyright (C) 2013 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.
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2013 10gen Inc.
1
+ # Copyright (C) 2013 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.
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2013 10gen Inc.
1
+ # Copyright (C) 2013 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.
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2013 10gen Inc.
1
+ # Copyright (C) 2013 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.
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2013 10gen Inc.
1
+ # Copyright (C) 2013 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.
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2013 10gen Inc.
1
+ # Copyright (C) 2013 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.
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2013 10gen Inc.
1
+ # Copyright (C) 2013 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.
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2013 10gen Inc.
1
+ # Copyright (C) 2013 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.
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2013 10gen Inc.
1
+ # Copyright (C) 2013 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.
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2013 10gen Inc.
1
+ # Copyright (C) 2013 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.
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2013 10gen Inc.
1
+ # Copyright (C) 2013 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.
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2013 10gen Inc.
1
+ # Copyright (C) 2013 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.
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2013 10gen Inc.
1
+ # Copyright (C) 2013 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.
@@ -158,7 +158,7 @@ module BSON
158
158
  # @example Get the raw bson bytes.
159
159
  # object_id.to_bson
160
160
  #
161
- # @note Since Moped's BSON and 10gen BSON before 2.0.0 have different
161
+ # @note Since Moped's BSON and MongoDB BSON before 2.0.0 have different
162
162
  # internal representations, we will attempt to repair the data for cases
163
163
  # where the object was instantiated in a non-standard way. (Like a
164
164
  # Marshal.load)
@@ -169,7 +169,7 @@ module BSON
169
169
  #
170
170
  # @since 2.0.0
171
171
  def to_bson(encoded = ''.force_encoding(BINARY))
172
- repair!(@data) if defined?(@data)
172
+ repair if defined?(@data)
173
173
  @raw_data ||= @@generator.next
174
174
  encoded << @raw_data
175
175
  end
@@ -194,8 +194,9 @@ module BSON
194
194
 
195
195
  private
196
196
 
197
- def data=(data)
198
- @raw_data = data
197
+ def repair
198
+ @raw_data = @data.to_bson_object_id
199
+ remove_instance_variable(:@data)
199
200
  end
200
201
 
201
202
  class << self
@@ -226,7 +227,7 @@ module BSON
226
227
  # @since 2.0.0
227
228
  def from_data(data)
228
229
  object_id = allocate
229
- object_id.send(:data=, data)
230
+ object_id.instance_variable_set(:@raw_data, data)
230
231
  object_id
231
232
  end
232
233
 
@@ -283,6 +284,27 @@ module BSON
283
284
  def legal?(string)
284
285
  string.to_s =~ /^[0-9a-f]{24}$/i ? true : false
285
286
  end
287
+
288
+ # Executes the provided block only if the size of the provided object is
289
+ # 12. Used in legacy id repairs.
290
+ #
291
+ # @example Execute in a repairing block.
292
+ # BSON::ObjectId.repair("test") { obj }
293
+ #
294
+ # @param [ String, Array ] object The object to repair.
295
+ #
296
+ # @raise [ Invalid ] If the array is not 12 elements.
297
+ #
298
+ # @return [ String ] The result of the block.
299
+ #
300
+ # @since 2.0.0
301
+ def repair(object)
302
+ if object.size == 12
303
+ block_given? ? yield(object) : object
304
+ else
305
+ raise Invalid.new("#{object.inspect} is not a valid object id.")
306
+ end
307
+ end
286
308
  end
287
309
 
288
310
  # Inner class that encapsulates the behaviour of actually generating each
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2013 10gen Inc.
1
+ # Copyright (C) 2013 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.
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2013 10gen Inc.
1
+ # Copyright (C) 2013 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.
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2013 10gen Inc.
1
+ # Copyright (C) 2013 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.
@@ -1,5 +1,5 @@
1
1
  # -*- coding: utf-8 -*-
2
- # Copyright (C) 2013 10gen Inc.
2
+ # Copyright (C) 2013 MongoDB Inc.
3
3
  #
4
4
  # Licensed under the Apache License, Version 2.0 (the "License");
5
5
  # you may not use this file except in compliance with the License.
@@ -80,6 +80,23 @@ module BSON
80
80
  to_bson_string(encoded) << NULL_BYTE
81
81
  end
82
82
 
83
+ # Convert the string to an object id. This will only work for strings of size
84
+ # 12.
85
+ #
86
+ # @example Convert the string to an object id.
87
+ # string.to_bson_object_id
88
+ #
89
+ # @note This is used for repairing legacy bson data.
90
+ #
91
+ # @raise [ InvalidObjectId ] If the string is not 12 elements.
92
+ #
93
+ # @return [ String ] The raw object id bytes.
94
+ #
95
+ # @since 2.0.0
96
+ def to_bson_object_id
97
+ ObjectId.repair(self)
98
+ end
99
+
83
100
  # Convert the string to a UTF-8 string then force to binary. This is so
84
101
  # we get errors for strings that are not UTF-8 encoded.
85
102
  #
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2013 10gen Inc.
1
+ # Copyright (C) 2013 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.
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2013 10gen Inc.
1
+ # Copyright (C) 2013 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.
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2013 10gen Inc.
1
+ # Copyright (C) 2013 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.
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2013 10gen Inc.
1
+ # Copyright (C) 2013 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.
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2013 10gen Inc.
1
+ # Copyright (C) 2013 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.
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2013 10gen Inc.
1
+ # Copyright (C) 2013 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.0.0.rc2"
16
+ VERSION = "2.0.0.rc3"
17
17
  end
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2013 10gen Inc.
1
+ # Copyright (C) 2013 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.
@@ -28,4 +28,31 @@ describe Array do
28
28
  it_behaves_like "a serializable bson element"
29
29
  it_behaves_like "a deserializable bson element"
30
30
  end
31
+
32
+ describe "#to_bson_object_id" do
33
+
34
+ context "when the array has 12 elements" do
35
+
36
+ let(:array) do
37
+ [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 ]
38
+ end
39
+
40
+ let(:converted) do
41
+ array.to_bson_object_id
42
+ end
43
+
44
+ it "returns the array as a string" do
45
+ expect(converted).to eq(array.pack("C*"))
46
+ end
47
+ end
48
+
49
+ context "when the array does not have 12 elements" do
50
+
51
+ it "raises an exception" do
52
+ expect {
53
+ [ 1 ].to_bson_object_id
54
+ }.to raise_error(BSON::ObjectId::Invalid)
55
+ end
56
+ end
57
+ end
31
58
  end
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2013 10gen Inc.
1
+ # Copyright (C) 2013 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.
@@ -31,6 +31,18 @@ describe BSON::Binary do
31
31
  it_behaves_like "a JSON serializable object"
32
32
  end
33
33
 
34
+ describe "#initialize" do
35
+
36
+ context "when he type is invalid" do
37
+
38
+ it "raises an error" do
39
+ expect {
40
+ described_class.new("testing", :error)
41
+ }.to raise_error(BSON::Binary::InvalidType)
42
+ end
43
+ end
44
+ end
45
+
34
46
  describe "#to_bson/#from_bson" do
35
47
 
36
48
  let(:type) { 5.chr }
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2013 10gen Inc.
1
+ # Copyright (C) 2013 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.
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2013 10gen Inc.
1
+ # Copyright (C) 2013 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.
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2013 10gen Inc.
1
+ # Copyright (C) 2013 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.
@@ -1,6 +1,6 @@
1
1
  # encoding: utf-8
2
2
 
3
- # Copyright (C) 2013 10gen Inc.
3
+ # Copyright (C) 2013 MongoDB Inc.
4
4
  #
5
5
  # Licensed under the Apache License, Version 2.0 (the "License");
6
6
  # you may not use this file except in compliance with the License.
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2013 10gen Inc.
1
+ # Copyright (C) 2013 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.
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2013 10gen Inc.
1
+ # Copyright (C) 2013 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.
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2013 10gen Inc.
1
+ # Copyright (C) 2013 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.
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2013 10gen Inc.
1
+ # Copyright (C) 2013 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.
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2013 10gen Inc.
1
+ # Copyright (C) 2013 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.
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2013 10gen Inc.
1
+ # Copyright (C) 2013 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.
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2013 10gen Inc.
1
+ # Copyright (C) 2013 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.
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2013 10gen Inc.
1
+ # Copyright (C) 2013 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.
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2013 10gen Inc.
1
+ # Copyright (C) 2013 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.
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2013 10gen Inc.
1
+ # Copyright (C) 2013 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.
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2013 10gen Inc.
1
+ # Copyright (C) 2013 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.
@@ -444,6 +444,34 @@ describe BSON::ObjectId do
444
444
  end
445
445
  end
446
446
 
447
+ describe "#marshal_load" do
448
+
449
+ context "when the object id was dumped in the old format" do
450
+
451
+ let(:legacy) do
452
+ "\x04\bo:\x13BSON::ObjectId\x06:\n" +
453
+ "@data[\x11iUi\x01\xE2i,i\x00i\x00i\x00i\x00i\x00i\x00i\x00i\x00i\x00"
454
+ end
455
+
456
+ let(:object_id) do
457
+ Marshal.load(legacy)
458
+ end
459
+
460
+ let(:expected) do
461
+ described_class.from_time(Time.utc(2013, 1, 1))
462
+ end
463
+
464
+ it "properly loads the object id" do
465
+ expect(object_id).to eq(expected)
466
+ end
467
+
468
+ it "removes the bad legacy data" do
469
+ object_id.to_bson
470
+ expect(object_id.instance_variable_get(:@data)).to be_nil
471
+ end
472
+ end
473
+ end
474
+
447
475
  describe "#to_bson/#from_bson" do
448
476
 
449
477
  let(:time) { Time.utc(2013, 1, 1) }
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2013 10gen Inc.
1
+ # Copyright (C) 2013 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.
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2013 10gen Inc.
1
+ # Copyright (C) 2013 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.
@@ -1,6 +1,6 @@
1
1
  # encoding: utf-8
2
2
 
3
- # Copyright (C) 2013 10gen Inc.
3
+ # Copyright (C) 2013 MongoDB Inc.
4
4
  #
5
5
  # Licensed under the Apache License, Version 2.0 (the "License");
6
6
  # you may not use this file except in compliance with the License.
@@ -128,6 +128,33 @@ describe String do
128
128
  end
129
129
  end
130
130
 
131
+ describe "#to_bson_object_id" do
132
+
133
+ context "when the string has 12 characters" do
134
+
135
+ let(:string) do
136
+ "123456789012"
137
+ end
138
+
139
+ let(:converted) do
140
+ string.to_bson_object_id
141
+ end
142
+
143
+ it "returns the array as a string" do
144
+ expect(converted).to eq(string)
145
+ end
146
+ end
147
+
148
+ context "when the array does not have 12 elements" do
149
+
150
+ it "raises an exception" do
151
+ expect {
152
+ "test".to_bson_object_id
153
+ }.to raise_error(BSON::ObjectId::Invalid)
154
+ end
155
+ end
156
+ end
157
+
131
158
  describe "#to_bson_string" do
132
159
 
133
160
  context "when the string is valid" do
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2013 10gen Inc.
1
+ # Copyright (C) 2013 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.
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2013 10gen Inc.
1
+ # Copyright (C) 2013 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.
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2013 10gen Inc.
1
+ # Copyright (C) 2013 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.
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2013 10gen Inc.
1
+ # Copyright (C) 2013 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.
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2013 10gen Inc.
1
+ # Copyright (C) 2013 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.
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2013 10gen Inc.
1
+ # Copyright (C) 2013 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.
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2013 10gen Inc.
1
+ # Copyright (C) 2013 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.
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2013 10gen Inc.
1
+ # Copyright (C) 2013 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.
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: bson
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease: 6
5
- version: 2.0.0.rc2
5
+ version: 2.0.0.rc3
6
6
  platform: java
7
7
  authors:
8
8
  - Tyler Brock
@@ -34,7 +34,7 @@ cert_chain:
34
34
  8v7zLF2XliYbfurYIwkcXs8yPn8ggApBIy9bX6VJxRs/l2+UvqzaHIFaFy/F8/GP
35
35
  RNTuXsVG5NDACo7Q
36
36
  -----END CERTIFICATE-----
37
- date: 2013-09-23 00:00:00.000000000 Z
37
+ date: 2013-10-14 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