bson 1.3.0 → 1.3.1

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.

@@ -18,10 +18,10 @@
18
18
 
19
19
  $:.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
20
20
 
21
- MINIMUM_BSON_EXT_VERSION = "1.3.0"
21
+ MINIMUM_BSON_EXT_VERSION = "1.3.1"
22
22
 
23
23
  module BSON
24
- VERSION = "1.3.0"
24
+ VERSION = "1.3.1"
25
25
 
26
26
  if defined? Mongo::DEFAULT_MAX_BSON_SIZE
27
27
  DEFAULT_MAX_BSON_SIZE = Mongo::DEFAULT_MAX_BSON_SIZE
@@ -57,7 +57,6 @@ end
57
57
  if RUBY_PLATFORM =~ /java/
58
58
  jar_dir = File.join(File.dirname(__FILE__), '..', 'ext', 'java', 'jar')
59
59
  require File.join(jar_dir, 'mongo-2.4.jar')
60
- require File.join(jar_dir, 'bson-2.2.jar')
61
60
  require File.join(jar_dir, 'jbson.jar')
62
61
  require 'bson/bson_java'
63
62
  module BSON
@@ -11,7 +11,7 @@ module BSON
11
11
  end
12
12
 
13
13
  def self.deserialize(buf)
14
- dec = Java::OrgBson::BSONDecoder.new
14
+ dec = Java::OrgJbson::RubyBSONDecoder.new
15
15
  callback = Java::OrgJbson::RubyBSONCallback.new(JRuby.runtime)
16
16
  dec.decode(buf.to_s.to_java_bytes, callback)
17
17
  callback.get
@@ -343,6 +343,7 @@ module BSON
343
343
  opts = 0
344
344
  opts |= Regexp::IGNORECASE if options_str.include?('i')
345
345
  opts |= Regexp::MULTILINE if options_str.include?('m')
346
+ opts |= Regexp::MULTILINE if options_str.include?('s')
346
347
  opts |= Regexp::EXTENDED if options_str.include?('x')
347
348
  Regexp.new(str, opts)
348
349
  end
@@ -500,7 +501,10 @@ module BSON
500
501
  options = val.options
501
502
  options_str = ''
502
503
  options_str << 'i' if ((options & Regexp::IGNORECASE) != 0)
503
- options_str << 'm' if ((options & Regexp::MULTILINE) != 0)
504
+ if ((options & Regexp::MULTILINE) != 0)
505
+ options_str << 'm'
506
+ options_str << 's'
507
+ end
504
508
  options_str << 'x' if ((options & Regexp::EXTENDED) != 0)
505
509
  options_str << val.extra_options_str if val.respond_to?(:extra_options_str)
506
510
  # Must store option chars in alphabetical order
@@ -29,10 +29,7 @@ module BSON
29
29
  # Raised when given a string is not valid utf-8 (Ruby 1.8 only).
30
30
  class InvalidStringEncoding < BSONError; end
31
31
 
32
- # Raised when attempting to initialize an invalid ObjectID.
33
- class InvalidObjectID < BSONError; end
34
-
35
- # Raised when attempting to initialize an invalid ObjectID.
32
+ # Raised when attempting to initialize an invalid ObjectId.
36
33
  class InvalidObjectId < BSONError; end
37
34
 
38
35
  # Raised when trying to insert a document that exceeds the 4MB limit or
@@ -57,8 +57,13 @@ module BSON
57
57
  end
58
58
 
59
59
  def initialize(*a, &b)
60
- super
61
60
  @ordered_keys = []
61
+ super
62
+ end
63
+
64
+ def yaml_initialize(tag, val)
65
+ @ordered_keys = []
66
+ super
62
67
  end
63
68
 
64
69
  def keys
@@ -125,11 +130,11 @@ module BSON
125
130
  end
126
131
 
127
132
  def delete_if(&block)
128
- self.each { |k,v|
133
+ self.each do |k,v|
129
134
  if yield k, v
130
135
  delete(k)
131
136
  end
132
- }
137
+ end
133
138
  end
134
139
 
135
140
  def reject(&block)
@@ -138,6 +143,17 @@ module BSON
138
143
  clone.delete_if(&block)
139
144
  end
140
145
 
146
+ def reject!(&block)
147
+ changed = false
148
+ self.each do |k,v|
149
+ if yield k, v
150
+ changed = true
151
+ delete(k)
152
+ end
153
+ end
154
+ changed ? self : nil
155
+ end
156
+
141
157
  def clear
142
158
  super
143
159
  @ordered_keys = []
@@ -26,7 +26,7 @@ module BSON
26
26
  # Create a DBRef. Use this class in conjunction with DB#dereference.
27
27
  #
28
28
  # @param [String] a collection name
29
- # @param [ObjectID] an object id
29
+ # @param [ObjectId] an object id
30
30
  #
31
31
  # @core dbrefs constructor_details
32
32
  def initialize(namespace, object_id)
@@ -245,6 +245,11 @@ class BSONTest < Test::Unit::TestCase
245
245
  assert_doc_pass(doc)
246
246
  end
247
247
 
248
+ def test_regex_multiline
249
+ doc = {'doc' => /foobar/m}
250
+ assert_doc_pass(doc)
251
+ end
252
+
248
253
  def test_boolean
249
254
  doc = {'doc' => true}
250
255
  assert_doc_pass(doc)
@@ -187,6 +187,12 @@ class OrderedHashTest < Test::Unit::TestCase
187
187
  assert !new.keys.include?('z')
188
188
  end
189
189
 
190
+ def test_reject_bang
191
+ @oh.reject! { |k, v| k == 'z' }
192
+ assert !@oh.keys.include?('z')
193
+ assert_nil @oh.reject! { |k, v| k == 'z' }
194
+ end
195
+
190
196
  def test_clone
191
197
  copy = @oh.clone
192
198
  assert copy.keys == @oh.keys
@@ -194,7 +200,7 @@ class OrderedHashTest < Test::Unit::TestCase
194
200
  copy[:foo] = 1
195
201
  assert copy.keys != @oh.keys
196
202
  end
197
-
203
+
198
204
  def test_dup
199
205
  oh2 = @oh.dup
200
206
  oh2['f'] = 9
metadata CHANGED
@@ -3,57 +3,49 @@ name: bson
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
- - 1
7
- - 3
8
- - 0
9
- version: 1.3.0
6
+ - 1
7
+ - 3
8
+ - 1
9
+ version: 1.3.1
10
10
  platform: ruby
11
11
  authors:
12
- - Jim Menard
13
- - Mike Dirolf
14
- - Kyle Banker
12
+ - Jim Menard
13
+ - Mike Dirolf
14
+ - Kyle Banker
15
15
  autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2011-04-01 00:00:00 -04:00
19
+ date: 2011-05-11 00:00:00 -04:00
20
20
  default_executable:
21
21
  dependencies: []
22
22
 
23
23
  description: A Ruby BSON implementation for MongoDB. For more information about Mongo, see http://www.mongodb.org. For more information on BSON, see http://www.bsonspec.org.
24
24
  email: mongodb-dev@googlegroups.com
25
25
  executables:
26
- - b2json
27
- - j2bson
26
+ - b2json
27
+ - j2bson
28
28
  extensions: []
29
29
 
30
30
  extra_rdoc_files: []
31
31
 
32
32
  files:
33
- - LICENSE.txt
34
- - lib/bson.rb
35
- - lib/bson/bson_ruby.rb
36
- - lib/bson/bson_c.rb
37
- - lib/bson/exceptions.rb
38
- - lib/bson/ordered_hash.rb
39
- - lib/bson/types/dbref.rb
40
- - lib/bson/types/code.rb
41
- - lib/bson/types/object_id.rb
42
- - lib/bson/types/binary.rb
43
- - lib/bson/types/timestamp.rb
44
- - lib/bson/types/min_max_keys.rb
45
- - lib/bson/byte_buffer.rb
46
- - lib/bson/bson_java.rb
47
- - bin/b2json
48
- - bin/j2bson
49
- - test/bson/byte_buffer_test.rb
50
- - test/bson/binary_test.rb
51
- - test/bson/object_id_test.rb
52
- - test/bson/json_test.rb
53
- - test/bson/timestamp_test.rb
54
- - test/bson/bson_test.rb
55
- - test/bson/ordered_hash_test.rb
56
- - test/bson/hash_with_indifferent_access_test.rb
33
+ - LICENSE.txt
34
+ - lib/bson.rb
35
+ - lib/bson/bson_ruby.rb
36
+ - lib/bson/bson_c.rb
37
+ - lib/bson/exceptions.rb
38
+ - lib/bson/ordered_hash.rb
39
+ - lib/bson/byte_buffer.rb
40
+ - lib/bson/bson_java.rb
41
+ - lib/bson/types/dbref.rb
42
+ - lib/bson/types/code.rb
43
+ - lib/bson/types/object_id.rb
44
+ - lib/bson/types/binary.rb
45
+ - lib/bson/types/timestamp.rb
46
+ - lib/bson/types/min_max_keys.rb
47
+ - bin/b2json
48
+ - bin/j2bson
57
49
  has_rdoc: true
58
50
  homepage: http://www.mongodb.org
59
51
  licenses: []
@@ -62,36 +54,34 @@ post_install_message:
62
54
  rdoc_options: []
63
55
 
64
56
  require_paths:
65
- - lib
57
+ - lib
66
58
  required_ruby_version: !ruby/object:Gem::Requirement
67
- none: false
68
59
  requirements:
69
- - - ">="
70
- - !ruby/object:Gem::Version
71
- segments:
72
- - 0
73
- version: "0"
60
+ - - ">="
61
+ - !ruby/object:Gem::Version
62
+ segments:
63
+ - 0
64
+ version: "0"
74
65
  required_rubygems_version: !ruby/object:Gem::Requirement
75
- none: false
76
66
  requirements:
77
- - - ">="
78
- - !ruby/object:Gem::Version
79
- segments:
80
- - 0
81
- version: "0"
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ segments:
70
+ - 0
71
+ version: "0"
82
72
  requirements: []
83
73
 
84
74
  rubyforge_project:
85
- rubygems_version: 1.3.7
75
+ rubygems_version: 1.3.6
86
76
  signing_key:
87
77
  specification_version: 3
88
78
  summary: Ruby implementation of BSON
89
79
  test_files:
90
- - test/bson/byte_buffer_test.rb
91
- - test/bson/binary_test.rb
92
- - test/bson/object_id_test.rb
93
- - test/bson/json_test.rb
94
- - test/bson/timestamp_test.rb
95
- - test/bson/bson_test.rb
96
- - test/bson/ordered_hash_test.rb
97
- - test/bson/hash_with_indifferent_access_test.rb
80
+ - test/bson/byte_buffer_test.rb
81
+ - test/bson/binary_test.rb
82
+ - test/bson/object_id_test.rb
83
+ - test/bson/json_test.rb
84
+ - test/bson/timestamp_test.rb
85
+ - test/bson/bson_test.rb
86
+ - test/bson/ordered_hash_test.rb
87
+ - test/bson/hash_with_indifferent_access_test.rb