bson 1.3.0.rc0-jruby → 1.3.1-jruby
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.
- data/ext/java/jar/jbson.jar +0 -0
- data/ext/java/jar/mongo-2.4.jar +0 -0
- data/lib/bson/bson_java.rb +1 -1
- data/lib/bson/bson_ruby.rb +5 -1
- data/lib/bson/byte_buffer.rb +4 -4
- data/lib/bson/exceptions.rb +1 -4
- data/lib/bson/ordered_hash.rb +25 -9
- data/lib/bson/types/dbref.rb +1 -1
- data/lib/bson.rb +2 -3
- data/test/bson/bson_test.rb +5 -0
- data/test/bson/byte_buffer_test.rb +7 -0
- data/test/bson/ordered_hash_test.rb +7 -1
- metadata +50 -55
- data/ext/java/jar/bson-2.2.jar +0 -0
- data/test/bson/bson_string_test.rb +0 -30
data/ext/java/jar/jbson.jar
CHANGED
Binary file
|
data/ext/java/jar/mongo-2.4.jar
CHANGED
Binary file
|
data/lib/bson/bson_java.rb
CHANGED
@@ -11,7 +11,7 @@ module BSON
|
|
11
11
|
end
|
12
12
|
|
13
13
|
def self.deserialize(buf)
|
14
|
-
dec = Java::
|
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
|
data/lib/bson/bson_ruby.rb
CHANGED
@@ -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
|
-
|
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
|
data/lib/bson/byte_buffer.rb
CHANGED
@@ -236,12 +236,12 @@ module BSON
|
|
236
236
|
other.respond_to?(:to_s) && @str == other.to_s
|
237
237
|
end
|
238
238
|
|
239
|
-
def to_a
|
240
|
-
@str.unpack(
|
239
|
+
def to_a(format="C*")
|
240
|
+
@str.unpack(format)
|
241
241
|
end
|
242
242
|
|
243
|
-
def unpack(
|
244
|
-
to_a
|
243
|
+
def unpack(format="C*")
|
244
|
+
to_a(format)
|
245
245
|
end
|
246
246
|
|
247
247
|
def to_s
|
data/lib/bson/exceptions.rb
CHANGED
@@ -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
|
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
|
data/lib/bson/ordered_hash.rb
CHANGED
@@ -57,16 +57,21 @@ 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
|
65
|
-
@ordered_keys || []
|
70
|
+
@ordered_keys# || []
|
66
71
|
end
|
67
72
|
|
68
73
|
def []=(key, value)
|
69
|
-
|
74
|
+
#@ordered_keys ||= []
|
70
75
|
unless has_key?(key)
|
71
76
|
@ordered_keys << key
|
72
77
|
end
|
@@ -74,14 +79,14 @@ module BSON
|
|
74
79
|
end
|
75
80
|
|
76
81
|
def each
|
77
|
-
|
82
|
+
#@ordered_keys ||= []
|
78
83
|
@ordered_keys.each { |k| yield k, self[k] }
|
79
84
|
self
|
80
85
|
end
|
81
86
|
alias :each_pair :each
|
82
87
|
|
83
88
|
def to_a
|
84
|
-
|
89
|
+
#@ordered_keys ||= []
|
85
90
|
@ordered_keys.map { |k| [k, self[k]] }
|
86
91
|
end
|
87
92
|
|
@@ -96,7 +101,7 @@ module BSON
|
|
96
101
|
end
|
97
102
|
|
98
103
|
def merge!(other)
|
99
|
-
|
104
|
+
#@ordered_keys ||= []
|
100
105
|
@ordered_keys += other.keys # unordered if not an BSON::OrderedHash
|
101
106
|
@ordered_keys.uniq!
|
102
107
|
super(other)
|
@@ -106,7 +111,7 @@ module BSON
|
|
106
111
|
|
107
112
|
def dup
|
108
113
|
result = OrderedHash.new
|
109
|
-
|
114
|
+
#@ordered_keys ||= []
|
110
115
|
@ordered_keys.each do |key|
|
111
116
|
result[key] = self[key]
|
112
117
|
end
|
@@ -125,11 +130,11 @@ module BSON
|
|
125
130
|
end
|
126
131
|
|
127
132
|
def delete_if(&block)
|
128
|
-
self.each
|
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 = []
|
data/lib/bson/types/dbref.rb
CHANGED
@@ -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 [
|
29
|
+
# @param [ObjectId] an object id
|
30
30
|
#
|
31
31
|
# @core dbrefs constructor_details
|
32
32
|
def initialize(namespace, object_id)
|
data/lib/bson.rb
CHANGED
@@ -18,10 +18,10 @@
|
|
18
18
|
|
19
19
|
$:.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
20
20
|
|
21
|
-
MINIMUM_BSON_EXT_VERSION = "1.3.
|
21
|
+
MINIMUM_BSON_EXT_VERSION = "1.3.1"
|
22
22
|
|
23
23
|
module BSON
|
24
|
-
VERSION = "1.3.
|
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
|
data/test/bson/bson_test.rb
CHANGED
@@ -21,6 +21,13 @@ class ByteBufferTest < Test::Unit::TestCase
|
|
21
21
|
assert_equal 1, @buf.get
|
22
22
|
end
|
23
23
|
|
24
|
+
def test_unpack
|
25
|
+
@buf.put_array([17, 2, 3, 4])
|
26
|
+
assert_equal [17, 2, 3, 4], @buf.to_a
|
27
|
+
assert_equal ["11020304"], @buf.unpack("H*")
|
28
|
+
assert_equal ["11020304"], @buf.to_a("H*")
|
29
|
+
end
|
30
|
+
|
24
31
|
def test_one_get_returns_array_length_one
|
25
32
|
@buf.put_array([1, 2, 3, 4])
|
26
33
|
@buf.rewind
|
@@ -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
@@ -1,59 +1,53 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bson
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
prerelease:
|
5
|
-
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 1
|
7
|
+
- 3
|
8
|
+
- 1
|
9
|
+
version: 1.3.1
|
6
10
|
platform: jruby
|
7
11
|
authors:
|
8
|
-
- Jim Menard
|
9
|
-
- Mike Dirolf
|
10
|
-
- Kyle Banker
|
12
|
+
- Jim Menard
|
13
|
+
- Mike Dirolf
|
14
|
+
- Kyle Banker
|
11
15
|
autorequire:
|
12
16
|
bindir: bin
|
13
17
|
cert_chain: []
|
14
18
|
|
15
|
-
date: 2011-
|
19
|
+
date: 2011-05-11 00:00:00 -04:00
|
16
20
|
default_executable:
|
17
21
|
dependencies: []
|
18
22
|
|
19
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.
|
20
24
|
email: mongodb-dev@googlegroups.com
|
21
25
|
executables:
|
22
|
-
- b2json
|
23
|
-
- j2bson
|
26
|
+
- b2json
|
27
|
+
- j2bson
|
24
28
|
extensions: []
|
25
29
|
|
26
30
|
extra_rdoc_files: []
|
27
31
|
|
28
32
|
files:
|
29
|
-
- LICENSE.txt
|
30
|
-
- lib/bson.rb
|
31
|
-
- lib/bson/
|
32
|
-
- lib/bson/
|
33
|
-
- lib/bson/
|
34
|
-
- lib/bson/
|
35
|
-
- lib/bson/
|
36
|
-
- lib/bson/
|
37
|
-
- lib/bson/types/
|
38
|
-
- lib/bson/types/code.rb
|
39
|
-
- lib/bson/types/
|
40
|
-
- lib/bson/types/
|
41
|
-
- lib/bson/types/
|
42
|
-
- lib/bson/types/
|
43
|
-
- bin/b2json
|
44
|
-
- bin/j2bson
|
45
|
-
- ext/java/jar/
|
46
|
-
- ext/java/jar/
|
47
|
-
- ext/java/jar/mongo-2.4.jar
|
48
|
-
- test/bson/binary_test.rb
|
49
|
-
- test/bson/bson_string_test.rb
|
50
|
-
- test/bson/bson_test.rb
|
51
|
-
- test/bson/byte_buffer_test.rb
|
52
|
-
- test/bson/hash_with_indifferent_access_test.rb
|
53
|
-
- test/bson/json_test.rb
|
54
|
-
- test/bson/object_id_test.rb
|
55
|
-
- test/bson/ordered_hash_test.rb
|
56
|
-
- test/bson/timestamp_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
|
49
|
+
- ext/java/jar/jbson.jar
|
50
|
+
- ext/java/jar/mongo-2.4.jar
|
57
51
|
has_rdoc: true
|
58
52
|
homepage: http://www.mongodb.org
|
59
53
|
licenses: []
|
@@ -62,33 +56,34 @@ post_install_message:
|
|
62
56
|
rdoc_options: []
|
63
57
|
|
64
58
|
require_paths:
|
65
|
-
- lib
|
59
|
+
- lib
|
66
60
|
required_ruby_version: !ruby/object:Gem::Requirement
|
67
|
-
none: false
|
68
61
|
requirements:
|
69
|
-
|
70
|
-
|
71
|
-
|
62
|
+
- - ">="
|
63
|
+
- !ruby/object:Gem::Version
|
64
|
+
segments:
|
65
|
+
- 0
|
66
|
+
version: "0"
|
72
67
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
73
|
-
none: false
|
74
68
|
requirements:
|
75
|
-
|
76
|
-
|
77
|
-
|
69
|
+
- - ">="
|
70
|
+
- !ruby/object:Gem::Version
|
71
|
+
segments:
|
72
|
+
- 0
|
73
|
+
version: "0"
|
78
74
|
requirements: []
|
79
75
|
|
80
76
|
rubyforge_project:
|
81
|
-
rubygems_version: 1.
|
77
|
+
rubygems_version: 1.3.6
|
82
78
|
signing_key:
|
83
79
|
specification_version: 3
|
84
80
|
summary: Ruby implementation of BSON
|
85
81
|
test_files:
|
86
|
-
- test/bson/
|
87
|
-
- test/bson/
|
88
|
-
- test/bson/
|
89
|
-
- test/bson/
|
90
|
-
- test/bson/
|
91
|
-
- test/bson/
|
92
|
-
- test/bson/
|
93
|
-
- test/bson/
|
94
|
-
- test/bson/timestamp_test.rb
|
82
|
+
- test/bson/byte_buffer_test.rb
|
83
|
+
- test/bson/binary_test.rb
|
84
|
+
- test/bson/object_id_test.rb
|
85
|
+
- test/bson/json_test.rb
|
86
|
+
- test/bson/timestamp_test.rb
|
87
|
+
- test/bson/bson_test.rb
|
88
|
+
- test/bson/ordered_hash_test.rb
|
89
|
+
- test/bson/hash_with_indifferent_access_test.rb
|
data/ext/java/jar/bson-2.2.jar
DELETED
Binary file
|
@@ -1,30 +0,0 @@
|
|
1
|
-
# encoding:utf-8
|
2
|
-
require './test/test_helper'
|
3
|
-
require 'complex'
|
4
|
-
require 'bigdecimal'
|
5
|
-
require 'rational'
|
6
|
-
|
7
|
-
class BSONTest < Test::Unit::TestCase
|
8
|
-
|
9
|
-
include BSON
|
10
|
-
|
11
|
-
def setup
|
12
|
-
@encoder = BSON::BSON_CODER
|
13
|
-
end
|
14
|
-
|
15
|
-
def assert_doc_pass(doc, options={})
|
16
|
-
bson = @encoder.serialize(doc)
|
17
|
-
if options[:debug]
|
18
|
-
puts "DEBUGGING DOC:"
|
19
|
-
p bson.to_a
|
20
|
-
puts "DESERIALIZES TO:"
|
21
|
-
end
|
22
|
-
assert_equal @encoder.serialize(doc).to_a, bson.to_a
|
23
|
-
assert_equal doc, @encoder.deserialize(bson)
|
24
|
-
end
|
25
|
-
|
26
|
-
def test_string
|
27
|
-
assert_doc_pass({:a => "hello"})
|
28
|
-
end
|
29
|
-
|
30
|
-
end
|