bson 1.3.0.rc0 → 1.3.0
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/lib/bson.rb +2 -2
- data/lib/bson/byte_buffer.rb +4 -4
- data/lib/bson/ordered_hash.rb +6 -6
- data/test/bson/byte_buffer_test.rb +7 -0
- metadata +30 -24
- data/test/bson/bson_string_test.rb +0 -30
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.0
|
21
|
+
MINIMUM_BSON_EXT_VERSION = "1.3.0"
|
22
22
|
|
23
23
|
module BSON
|
24
|
-
VERSION = "1.3.0
|
24
|
+
VERSION = "1.3.0"
|
25
25
|
|
26
26
|
if defined? Mongo::DEFAULT_MAX_BSON_SIZE
|
27
27
|
DEFAULT_MAX_BSON_SIZE = Mongo::DEFAULT_MAX_BSON_SIZE
|
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/ordered_hash.rb
CHANGED
@@ -62,11 +62,11 @@ module BSON
|
|
62
62
|
end
|
63
63
|
|
64
64
|
def keys
|
65
|
-
@ordered_keys || []
|
65
|
+
@ordered_keys# || []
|
66
66
|
end
|
67
67
|
|
68
68
|
def []=(key, value)
|
69
|
-
|
69
|
+
#@ordered_keys ||= []
|
70
70
|
unless has_key?(key)
|
71
71
|
@ordered_keys << key
|
72
72
|
end
|
@@ -74,14 +74,14 @@ module BSON
|
|
74
74
|
end
|
75
75
|
|
76
76
|
def each
|
77
|
-
|
77
|
+
#@ordered_keys ||= []
|
78
78
|
@ordered_keys.each { |k| yield k, self[k] }
|
79
79
|
self
|
80
80
|
end
|
81
81
|
alias :each_pair :each
|
82
82
|
|
83
83
|
def to_a
|
84
|
-
|
84
|
+
#@ordered_keys ||= []
|
85
85
|
@ordered_keys.map { |k| [k, self[k]] }
|
86
86
|
end
|
87
87
|
|
@@ -96,7 +96,7 @@ module BSON
|
|
96
96
|
end
|
97
97
|
|
98
98
|
def merge!(other)
|
99
|
-
|
99
|
+
#@ordered_keys ||= []
|
100
100
|
@ordered_keys += other.keys # unordered if not an BSON::OrderedHash
|
101
101
|
@ordered_keys.uniq!
|
102
102
|
super(other)
|
@@ -106,7 +106,7 @@ module BSON
|
|
106
106
|
|
107
107
|
def dup
|
108
108
|
result = OrderedHash.new
|
109
|
-
|
109
|
+
#@ordered_keys ||= []
|
110
110
|
@ordered_keys.each do |key|
|
111
111
|
result[key] = self[key]
|
112
112
|
end
|
@@ -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
|
metadata
CHANGED
@@ -1,8 +1,12 @@
|
|
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
|
+
- 0
|
9
|
+
version: 1.3.0
|
6
10
|
platform: ruby
|
7
11
|
authors:
|
8
12
|
- Jim Menard
|
@@ -12,7 +16,7 @@ autorequire:
|
|
12
16
|
bindir: bin
|
13
17
|
cert_chain: []
|
14
18
|
|
15
|
-
date: 2011-
|
19
|
+
date: 2011-04-01 00:00:00 -04:00
|
16
20
|
default_executable:
|
17
21
|
dependencies: []
|
18
22
|
|
@@ -28,29 +32,28 @@ extra_rdoc_files: []
|
|
28
32
|
files:
|
29
33
|
- LICENSE.txt
|
30
34
|
- lib/bson.rb
|
31
|
-
- lib/bson/bson_c.rb
|
32
|
-
- lib/bson/bson_java.rb
|
33
35
|
- lib/bson/bson_ruby.rb
|
34
|
-
- lib/bson/
|
36
|
+
- lib/bson/bson_c.rb
|
35
37
|
- lib/bson/exceptions.rb
|
36
38
|
- lib/bson/ordered_hash.rb
|
37
|
-
- lib/bson/types/binary.rb
|
38
|
-
- lib/bson/types/code.rb
|
39
39
|
- lib/bson/types/dbref.rb
|
40
|
-
- lib/bson/types/
|
40
|
+
- lib/bson/types/code.rb
|
41
41
|
- lib/bson/types/object_id.rb
|
42
|
+
- lib/bson/types/binary.rb
|
42
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
|
43
47
|
- bin/b2json
|
44
48
|
- bin/j2bson
|
45
|
-
- test/bson/binary_test.rb
|
46
|
-
- test/bson/bson_string_test.rb
|
47
|
-
- test/bson/bson_test.rb
|
48
49
|
- test/bson/byte_buffer_test.rb
|
49
|
-
- test/bson/
|
50
|
-
- test/bson/json_test.rb
|
50
|
+
- test/bson/binary_test.rb
|
51
51
|
- test/bson/object_id_test.rb
|
52
|
-
- test/bson/
|
52
|
+
- test/bson/json_test.rb
|
53
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
|
54
57
|
has_rdoc: true
|
55
58
|
homepage: http://www.mongodb.org
|
56
59
|
licenses: []
|
@@ -65,27 +68,30 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
65
68
|
requirements:
|
66
69
|
- - ">="
|
67
70
|
- !ruby/object:Gem::Version
|
71
|
+
segments:
|
72
|
+
- 0
|
68
73
|
version: "0"
|
69
74
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
70
75
|
none: false
|
71
76
|
requirements:
|
72
|
-
- - "
|
77
|
+
- - ">="
|
73
78
|
- !ruby/object:Gem::Version
|
74
|
-
|
79
|
+
segments:
|
80
|
+
- 0
|
81
|
+
version: "0"
|
75
82
|
requirements: []
|
76
83
|
|
77
84
|
rubyforge_project:
|
78
|
-
rubygems_version: 1.
|
85
|
+
rubygems_version: 1.3.7
|
79
86
|
signing_key:
|
80
87
|
specification_version: 3
|
81
88
|
summary: Ruby implementation of BSON
|
82
89
|
test_files:
|
83
|
-
- test/bson/binary_test.rb
|
84
|
-
- test/bson/bson_string_test.rb
|
85
|
-
- test/bson/bson_test.rb
|
86
90
|
- test/bson/byte_buffer_test.rb
|
87
|
-
- test/bson/
|
88
|
-
- test/bson/json_test.rb
|
91
|
+
- test/bson/binary_test.rb
|
89
92
|
- test/bson/object_id_test.rb
|
90
|
-
- test/bson/
|
93
|
+
- test/bson/json_test.rb
|
91
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
|
@@ -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
|