bson 1.7.1-java → 1.8.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.
- data/{LICENSE.txt → LICENSE} +0 -0
- data/VERSION +1 -0
- data/bson.gemspec +29 -0
- data/lib/bson.rb +4 -3
- data/lib/bson/bson_c.rb +1 -1
- data/lib/bson/bson_java.rb +2 -0
- data/lib/bson/bson_ruby.rb +4 -2
- data/lib/bson/byte_buffer.rb +1 -1
- data/lib/bson/exceptions.rb +1 -1
- data/lib/bson/ordered_hash.rb +1 -1
- data/lib/bson/types/binary.rb +1 -1
- data/lib/bson/types/code.rb +1 -1
- data/lib/bson/types/dbref.rb +1 -1
- data/lib/bson/types/min_max_keys.rb +1 -1
- data/lib/bson/types/object_id.rb +1 -1
- data/lib/bson/types/timestamp.rb +1 -1
- data/test/bson/binary_test.rb +1 -1
- data/test/bson/bson_test.rb +60 -36
- data/test/bson/byte_buffer_test.rb +1 -1
- data/test/bson/hash_with_indifferent_access_test.rb +2 -2
- data/test/bson/json_test.rb +1 -2
- data/test/bson/object_id_test.rb +1 -2
- data/test/bson/ordered_hash_test.rb +1 -1
- data/test/bson/timestamp_test.rb +1 -1
- metadata +101 -52
- data/lib/bson/version.rb +0 -3
- data/test/bson/test_helper.rb +0 -30
data/{LICENSE.txt → LICENSE}
RENAMED
File without changes
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
1.8.0
|
data/bson.gemspec
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
Gem::Specification.new do |s|
|
2
|
+
s.name = 'bson'
|
3
|
+
|
4
|
+
s.version = File.read(File.join(File.dirname(__FILE__), 'VERSION'))
|
5
|
+
s.authors = ['Tyler Brock', 'Gary Murakami', 'Emily Stolfo', 'Brandon Black']
|
6
|
+
s.email = 'mongodb-dev@googlegroups.com'
|
7
|
+
s.homepage = 'http://www.mongodb.org'
|
8
|
+
s.summary = 'Ruby implementation of BSON'
|
9
|
+
s.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.'
|
10
|
+
s.rubyforge_project = 'bson'
|
11
|
+
|
12
|
+
s.files = ['bson.gemspec', 'LICENSE', 'VERSION']
|
13
|
+
s.files += ['bin/b2json', 'bin/j2bson', 'lib/bson.rb']
|
14
|
+
s.files += Dir['lib/bson/**/*.rb']
|
15
|
+
|
16
|
+
if RUBY_PLATFORM =~ /java/
|
17
|
+
s.files += ['ext/java/jar/jbson.jar', 'ext/java/jar/mongo-2.6.5.jar']
|
18
|
+
s.platform = Gem::Platform::JAVA
|
19
|
+
else
|
20
|
+
s.platform = Gem::Platform::RUBY
|
21
|
+
end
|
22
|
+
|
23
|
+
s.test_files = Dir['test/bson/*.rb']
|
24
|
+
s.executables = ['b2json', 'j2bson']
|
25
|
+
s.require_paths = ['lib']
|
26
|
+
s.has_rdoc = 'yard'
|
27
|
+
|
28
|
+
s.add_dependency('activesupport')
|
29
|
+
end
|
data/lib/bson.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
#
|
3
3
|
# --
|
4
|
-
# Copyright (C) 2008-
|
4
|
+
# Copyright (C) 2008-2012 10gen Inc.
|
5
5
|
#
|
6
6
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
7
|
# you may not use this file except in compliance with the License.
|
@@ -16,8 +16,6 @@
|
|
16
16
|
# limitations under the License.
|
17
17
|
# ++
|
18
18
|
|
19
|
-
require 'bson/version'
|
20
|
-
|
21
19
|
module BSON
|
22
20
|
if defined? Mongo::DEFAULT_MAX_BSON_SIZE
|
23
21
|
DEFAULT_MAX_BSON_SIZE = Mongo::DEFAULT_MAX_BSON_SIZE
|
@@ -87,6 +85,9 @@ else
|
|
87
85
|
end
|
88
86
|
end
|
89
87
|
|
88
|
+
require 'active_support'
|
89
|
+
require 'active_support/hash_with_indifferent_access'
|
90
|
+
|
90
91
|
require 'bson/types/binary'
|
91
92
|
require 'bson/types/code'
|
92
93
|
require 'bson/types/dbref'
|
data/lib/bson/bson_c.rb
CHANGED
data/lib/bson/bson_java.rb
CHANGED
data/lib/bson/bson_ruby.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
|
3
3
|
# --
|
4
|
-
# Copyright (C) 2008-
|
4
|
+
# Copyright (C) 2008-2012 10gen Inc.
|
5
5
|
#
|
6
6
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
7
|
# you may not use this file except in compliance with the License.
|
@@ -628,7 +628,9 @@ module BSON
|
|
628
628
|
raise InvalidDocument, "#{o.class} is not currently supported; " +
|
629
629
|
"use a UTC Time instance instead."
|
630
630
|
else
|
631
|
-
if defined?(ActiveSupport::
|
631
|
+
if defined?(ActiveSupport::Multibyte::Chars) && o.is_a?(ActiveSupport::Multibyte::Chars)
|
632
|
+
STRING
|
633
|
+
elsif defined?(ActiveSupport::TimeWithZone) && o.is_a?(ActiveSupport::TimeWithZone)
|
632
634
|
raise InvalidDocument, "ActiveSupport::TimeWithZone is not currently supported; " +
|
633
635
|
"use a UTC Time instance instead."
|
634
636
|
else
|
data/lib/bson/byte_buffer.rb
CHANGED
data/lib/bson/exceptions.rb
CHANGED
data/lib/bson/ordered_hash.rb
CHANGED
data/lib/bson/types/binary.rb
CHANGED
data/lib/bson/types/code.rb
CHANGED
data/lib/bson/types/dbref.rb
CHANGED
data/lib/bson/types/object_id.rb
CHANGED
data/lib/bson/types/timestamp.rb
CHANGED
data/test/bson/binary_test.rb
CHANGED
data/test/bson/bson_test.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
# encoding:utf-8
|
2
|
-
require
|
2
|
+
require 'test_helper'
|
3
3
|
require 'set'
|
4
4
|
|
5
5
|
if RUBY_VERSION < '1.9'
|
@@ -27,6 +27,18 @@ rescue LoadError
|
|
27
27
|
Zone = ActiveSupport::TimeWithZone.new(Time.now.utc, 'EST')
|
28
28
|
end
|
29
29
|
|
30
|
+
begin
|
31
|
+
require 'active_support/multibyte/chars'
|
32
|
+
rescue LoadError
|
33
|
+
warn 'Mocking ActiveSupport::Multibyte::Chars'
|
34
|
+
module ActiveSupport
|
35
|
+
module Multibyte
|
36
|
+
class Chars < String
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
30
42
|
class BSONTest < Test::Unit::TestCase
|
31
43
|
|
32
44
|
include BSON
|
@@ -70,6 +82,17 @@ class BSONTest < Test::Unit::TestCase
|
|
70
82
|
assert_doc_pass(doc)
|
71
83
|
end
|
72
84
|
|
85
|
+
def test_valid_active_support_multibyte_chars
|
86
|
+
unless RUBY_PLATFORM =~ /java/
|
87
|
+
doc = {'doc' => ActiveSupport::Multibyte::Chars.new('aé')}
|
88
|
+
assert_doc_pass(doc)
|
89
|
+
|
90
|
+
bson = @encoder.serialize(doc)
|
91
|
+
doc = @encoder.deserialize(bson)
|
92
|
+
assert_equal doc['doc'], 'aé'
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
73
96
|
def test_valid_utf8_key
|
74
97
|
doc = {'aé' => 'hello'}
|
75
98
|
assert_doc_pass(doc)
|
@@ -101,12 +124,11 @@ class BSONTest < Test::Unit::TestCase
|
|
101
124
|
# In 1.8 we test that other string encodings raise an exception.
|
102
125
|
# In 1.9 we test that they get auto-converted.
|
103
126
|
if RUBY_VERSION < '1.9'
|
104
|
-
|
127
|
+
unless RUBY_PLATFORM == 'java'
|
105
128
|
require 'iconv'
|
106
129
|
def test_non_utf8_string
|
107
130
|
string = Iconv.conv('iso-8859-1', 'utf-8', 'aé')
|
108
131
|
doc = {'doc' => string}
|
109
|
-
assert_doc_pass(doc)
|
110
132
|
assert_raise InvalidStringEncoding do
|
111
133
|
@encoder.serialize(doc)
|
112
134
|
end
|
@@ -121,48 +143,50 @@ class BSONTest < Test::Unit::TestCase
|
|
121
143
|
end
|
122
144
|
end
|
123
145
|
else
|
124
|
-
|
125
|
-
|
126
|
-
BSON::
|
146
|
+
unless RUBY_PLATFORM == 'java'
|
147
|
+
def test_non_utf8_string
|
148
|
+
assert_raise BSON::InvalidStringEncoding do
|
149
|
+
BSON::BSON_CODER.serialize({'str' => 'aé'.encode('iso-8859-1')})
|
150
|
+
end
|
127
151
|
end
|
128
|
-
end
|
129
152
|
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
153
|
+
def test_invalid_utf8_string
|
154
|
+
str = "123\xD9"
|
155
|
+
assert !str.valid_encoding?
|
156
|
+
assert_raise BSON::InvalidStringEncoding do
|
157
|
+
BSON::BSON_CODER.serialize({'str' => str})
|
158
|
+
end
|
135
159
|
end
|
136
|
-
end
|
137
160
|
|
138
|
-
|
139
|
-
|
140
|
-
|
161
|
+
def test_non_utf8_key
|
162
|
+
assert_raise BSON::InvalidStringEncoding do
|
163
|
+
BSON::BSON_CODER.serialize({'aé'.encode('iso-8859-1') => 'hello'})
|
164
|
+
end
|
141
165
|
end
|
142
|
-
end
|
143
166
|
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
167
|
+
def test_forced_encoding_with_valid_utf8
|
168
|
+
doc = {'doc' => "\xC3\xB6".force_encoding("ISO-8859-1")}
|
169
|
+
serialized = @encoder.serialize(doc)
|
170
|
+
deserialized = @encoder.deserialize(serialized)
|
171
|
+
assert_equal(doc['doc'], deserialized['doc'].force_encoding("ISO-8859-1"))
|
172
|
+
end
|
150
173
|
|
151
|
-
|
152
|
-
|
153
|
-
|
174
|
+
# Based on a test from sqlite3-ruby
|
175
|
+
def test_default_internal_is_honored
|
176
|
+
before_enc = Encoding.default_internal
|
154
177
|
|
155
|
-
|
156
|
-
|
178
|
+
str = "壁に耳あり、障子に目あり"
|
179
|
+
bson = BSON::BSON_CODER.serialize("x" => str)
|
157
180
|
|
158
|
-
|
159
|
-
|
181
|
+
silently { Encoding.default_internal = 'EUC-JP' }
|
182
|
+
out = BSON::BSON_CODER.deserialize(bson)["x"]
|
160
183
|
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
184
|
+
assert_equal Encoding.default_internal, out.encoding
|
185
|
+
assert_equal str.encode('EUC-JP'), out
|
186
|
+
assert_equal str, out.encode(str.encoding)
|
187
|
+
ensure
|
188
|
+
silently { Encoding.default_internal = before_enc }
|
189
|
+
end
|
166
190
|
end
|
167
191
|
end
|
168
192
|
|
@@ -287,7 +311,7 @@ class BSONTest < Test::Unit::TestCase
|
|
287
311
|
end
|
288
312
|
|
289
313
|
def test_date_before_epoch
|
290
|
-
if RbConfig::CONFIG['host_os'] =~ /mswin|mingw|cygwin/ then return true end
|
314
|
+
if RbConfig::CONFIG['host_os'] =~ /mswin|mingw|cygwin/ then return true end
|
291
315
|
begin
|
292
316
|
doc = {'date' => Time.utc(1600)}
|
293
317
|
bson = @encoder.serialize(doc)
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# encoding:utf-8
|
2
|
-
require
|
3
|
-
require '
|
2
|
+
require 'test_helper'
|
3
|
+
require 'support/hash_with_indifferent_access'
|
4
4
|
|
5
5
|
class HashWithIndifferentAccessTest < Test::Unit::TestCase
|
6
6
|
include BSON
|
data/test/bson/json_test.rb
CHANGED
data/test/bson/object_id_test.rb
CHANGED
data/test/bson/timestamp_test.rb
CHANGED
metadata
CHANGED
@@ -1,20 +1,38 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bson
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
5
|
-
prerelease:
|
4
|
+
version: 1.8.0
|
5
|
+
prerelease:
|
6
6
|
platform: java
|
7
7
|
authors:
|
8
|
-
-
|
9
|
-
-
|
10
|
-
-
|
11
|
-
|
8
|
+
- Tyler Brock
|
9
|
+
- Gary Murakami
|
10
|
+
- Emily Stolfo
|
11
|
+
- Brandon Black
|
12
|
+
autorequire:
|
12
13
|
bindir: bin
|
13
14
|
cert_chain: []
|
14
|
-
date: 2012-11-
|
15
|
-
dependencies:
|
16
|
-
|
17
|
-
|
15
|
+
date: 2012-11-27 00:00:00.000000000 Z
|
16
|
+
dependencies:
|
17
|
+
- !ruby/object:Gem::Dependency
|
18
|
+
name: activesupport
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ! '>='
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: !binary |-
|
24
|
+
MA==
|
25
|
+
none: false
|
26
|
+
requirement: !ruby/object:Gem::Requirement
|
27
|
+
requirements:
|
28
|
+
- - ! '>='
|
29
|
+
- !ruby/object:Gem::Version
|
30
|
+
version: !binary |-
|
31
|
+
MA==
|
32
|
+
none: false
|
33
|
+
prerelease: false
|
34
|
+
type: :runtime
|
35
|
+
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.
|
18
36
|
email: mongodb-dev@googlegroups.com
|
19
37
|
executables:
|
20
38
|
- b2json
|
@@ -22,69 +40,100 @@ executables:
|
|
22
40
|
extensions: []
|
23
41
|
extra_rdoc_files: []
|
24
42
|
files:
|
25
|
-
-
|
26
|
-
-
|
27
|
-
-
|
28
|
-
- lib/bson/bson_java.rb
|
29
|
-
- lib/bson/bson_ruby.rb
|
30
|
-
- lib/bson/byte_buffer.rb
|
31
|
-
- lib/bson/exceptions.rb
|
32
|
-
- lib/bson/ordered_hash.rb
|
33
|
-
- lib/bson/types/binary.rb
|
34
|
-
- lib/bson/types/code.rb
|
35
|
-
- lib/bson/types/dbref.rb
|
36
|
-
- lib/bson/types/min_max_keys.rb
|
37
|
-
- lib/bson/types/object_id.rb
|
38
|
-
- lib/bson/types/timestamp.rb
|
39
|
-
- lib/bson/version.rb
|
43
|
+
- bson.gemspec
|
44
|
+
- LICENSE
|
45
|
+
- VERSION
|
40
46
|
- bin/b2json
|
41
47
|
- bin/j2bson
|
48
|
+
- lib/bson.rb
|
49
|
+
- !binary |-
|
50
|
+
bGliL2Jzb24vb3JkZXJlZF9oYXNoLnJi
|
51
|
+
- !binary |-
|
52
|
+
bGliL2Jzb24vYnNvbl9jLnJi
|
53
|
+
- !binary |-
|
54
|
+
bGliL2Jzb24vYnNvbl9qYXZhLnJi
|
55
|
+
- !binary |-
|
56
|
+
bGliL2Jzb24vYnl0ZV9idWZmZXIucmI=
|
57
|
+
- !binary |-
|
58
|
+
bGliL2Jzb24vZXhjZXB0aW9ucy5yYg==
|
59
|
+
- !binary |-
|
60
|
+
bGliL2Jzb24vYnNvbl9ydWJ5LnJi
|
61
|
+
- !binary |-
|
62
|
+
bGliL2Jzb24vdHlwZXMvZGJyZWYucmI=
|
63
|
+
- !binary |-
|
64
|
+
bGliL2Jzb24vdHlwZXMvbWluX21heF9rZXlzLnJi
|
65
|
+
- !binary |-
|
66
|
+
bGliL2Jzb24vdHlwZXMvdGltZXN0YW1wLnJi
|
67
|
+
- !binary |-
|
68
|
+
bGliL2Jzb24vdHlwZXMvY29kZS5yYg==
|
69
|
+
- !binary |-
|
70
|
+
bGliL2Jzb24vdHlwZXMvYmluYXJ5LnJi
|
71
|
+
- !binary |-
|
72
|
+
bGliL2Jzb24vdHlwZXMvb2JqZWN0X2lkLnJi
|
42
73
|
- ext/java/jar/jbson.jar
|
43
74
|
- ext/java/jar/mongo-2.6.5.jar
|
44
|
-
-
|
45
|
-
|
46
|
-
|
47
|
-
-
|
48
|
-
|
49
|
-
-
|
50
|
-
|
51
|
-
-
|
52
|
-
|
75
|
+
- !binary |-
|
76
|
+
dGVzdC9ic29uL2hhc2hfd2l0aF9pbmRpZmZlcmVudF9hY2Nlc3NfdGVzdC5y
|
77
|
+
Yg==
|
78
|
+
- !binary |-
|
79
|
+
dGVzdC9ic29uL2Jzb25fdGVzdC5yYg==
|
80
|
+
- !binary |-
|
81
|
+
dGVzdC9ic29uL2JpbmFyeV90ZXN0LnJi
|
82
|
+
- !binary |-
|
83
|
+
dGVzdC9ic29uL29yZGVyZWRfaGFzaF90ZXN0LnJi
|
84
|
+
- !binary |-
|
85
|
+
dGVzdC9ic29uL3RpbWVzdGFtcF90ZXN0LnJi
|
86
|
+
- !binary |-
|
87
|
+
dGVzdC9ic29uL2J5dGVfYnVmZmVyX3Rlc3QucmI=
|
88
|
+
- !binary |-
|
89
|
+
dGVzdC9ic29uL29iamVjdF9pZF90ZXN0LnJi
|
90
|
+
- !binary |-
|
91
|
+
dGVzdC9ic29uL2pzb25fdGVzdC5yYg==
|
53
92
|
homepage: http://www.mongodb.org
|
54
93
|
licenses: []
|
55
|
-
post_install_message:
|
94
|
+
post_install_message:
|
56
95
|
rdoc_options: []
|
57
96
|
require_paths:
|
58
97
|
- lib
|
59
98
|
required_ruby_version: !ruby/object:Gem::Requirement
|
60
|
-
none: false
|
61
99
|
requirements:
|
62
100
|
- - ! '>='
|
63
101
|
- !ruby/object:Gem::Version
|
64
|
-
version: '0'
|
65
102
|
segments:
|
66
103
|
- 0
|
67
|
-
|
68
|
-
|
104
|
+
version: !binary |-
|
105
|
+
MA==
|
106
|
+
hash: 2
|
69
107
|
none: false
|
108
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
70
109
|
requirements:
|
71
110
|
- - ! '>='
|
72
111
|
- !ruby/object:Gem::Version
|
73
|
-
version:
|
112
|
+
version: !binary |-
|
113
|
+
MA==
|
114
|
+
none: false
|
74
115
|
requirements: []
|
75
|
-
rubyforge_project:
|
116
|
+
rubyforge_project: bson
|
76
117
|
rubygems_version: 1.8.24
|
77
|
-
signing_key:
|
118
|
+
signing_key:
|
78
119
|
specification_version: 3
|
79
120
|
summary: Ruby implementation of BSON
|
80
121
|
test_files:
|
81
|
-
-
|
82
|
-
|
83
|
-
|
84
|
-
-
|
85
|
-
|
86
|
-
-
|
87
|
-
|
88
|
-
-
|
89
|
-
|
90
|
-
|
122
|
+
- !binary |-
|
123
|
+
dGVzdC9ic29uL2hhc2hfd2l0aF9pbmRpZmZlcmVudF9hY2Nlc3NfdGVzdC5y
|
124
|
+
Yg==
|
125
|
+
- !binary |-
|
126
|
+
dGVzdC9ic29uL2Jzb25fdGVzdC5yYg==
|
127
|
+
- !binary |-
|
128
|
+
dGVzdC9ic29uL2JpbmFyeV90ZXN0LnJi
|
129
|
+
- !binary |-
|
130
|
+
dGVzdC9ic29uL29yZGVyZWRfaGFzaF90ZXN0LnJi
|
131
|
+
- !binary |-
|
132
|
+
dGVzdC9ic29uL3RpbWVzdGFtcF90ZXN0LnJi
|
133
|
+
- !binary |-
|
134
|
+
dGVzdC9ic29uL2J5dGVfYnVmZmVyX3Rlc3QucmI=
|
135
|
+
- !binary |-
|
136
|
+
dGVzdC9ic29uL29iamVjdF9pZF90ZXN0LnJi
|
137
|
+
- !binary |-
|
138
|
+
dGVzdC9ic29uL2pzb25fdGVzdC5yYg==
|
139
|
+
has_rdoc: yard
|
data/lib/bson/version.rb
DELETED
data/test/bson/test_helper.rb
DELETED
@@ -1,30 +0,0 @@
|
|
1
|
-
require File.join(File.dirname(__FILE__), '..', '..', 'lib', 'bson')
|
2
|
-
require 'rubygems' if RUBY_VERSION < '1.9.0'
|
3
|
-
gem 'test-unit'
|
4
|
-
require 'test/unit'
|
5
|
-
|
6
|
-
def silently
|
7
|
-
warn_level = $VERBOSE
|
8
|
-
$VERBOSE = nil
|
9
|
-
result = yield
|
10
|
-
$VERBOSE = warn_level
|
11
|
-
result
|
12
|
-
end
|
13
|
-
|
14
|
-
require 'bson_ext/cbson' if !(RUBY_PLATFORM =~ /java/) && ENV['C_EXT']
|
15
|
-
|
16
|
-
class Test::Unit::TestCase
|
17
|
-
include BSON
|
18
|
-
|
19
|
-
def assert_raise_error(klass, message)
|
20
|
-
begin
|
21
|
-
yield
|
22
|
-
rescue => e
|
23
|
-
assert_equal klass, e.class
|
24
|
-
assert e.message.include?(message), "#{e.message} does not include #{message}."
|
25
|
-
else
|
26
|
-
flunk "Expected assertion #{klass} but none was raised."
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
end
|