mongodb-mongo 0.6.2 → 0.6.3
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +11 -10
- data/bin/run_test_script +1 -1
- data/bin/standard_benchmark +82 -23
- data/examples/info.rb +1 -1
- data/examples/queries.rb +1 -1
- data/lib/mongo/admin.rb +9 -9
- data/lib/mongo/collection.rb +16 -15
- data/lib/mongo/cursor.rb +9 -9
- data/lib/mongo/db.rb +36 -18
- data/lib/mongo/gridfs/chunk.rb +16 -0
- data/lib/mongo/gridfs/grid_store.rb +28 -5
- data/lib/mongo/gridfs.rb +15 -0
- data/lib/mongo/message/get_more_message.rb +16 -0
- data/lib/mongo/message/insert_message.rb +16 -0
- data/lib/mongo/message/kill_cursors_message.rb +16 -0
- data/lib/mongo/message/message.rb +16 -0
- data/lib/mongo/message/message_header.rb +16 -0
- data/lib/mongo/message/msg_message.rb +16 -0
- data/lib/mongo/message/opcodes.rb +16 -0
- data/lib/mongo/message/query_message.rb +16 -0
- data/lib/mongo/message/remove_message.rb +16 -0
- data/lib/mongo/message/update_message.rb +16 -0
- data/lib/mongo/message.rb +16 -0
- data/lib/mongo/mongo.rb +9 -9
- data/lib/mongo/query.rb +9 -9
- data/lib/mongo/types/binary.rb +9 -9
- data/lib/mongo/types/dbref.rb +9 -9
- data/lib/mongo/types/objectid.rb +9 -9
- data/lib/mongo/types/regexp_of_holding.rb +9 -9
- data/lib/mongo/types/undefined.rb +9 -9
- data/lib/mongo/util/byte_buffer.rb +9 -9
- data/lib/mongo/util/ordered_hash.rb +9 -9
- data/lib/mongo/util/xml_to_ruby.rb +9 -9
- data/lib/mongo.rb +7 -0
- data/mongo-ruby-driver.gemspec +3 -3
- data/tests/mongo-qa/indices +5 -2
- data/tests/test_bson.rb +6 -3
- data/tests/test_db_api.rb +11 -11
- data/tests/test_grid_store.rb +19 -2
- metadata +2 -2
@@ -1,3 +1,19 @@
|
|
1
|
+
# --
|
2
|
+
# Copyright (C) 2008-2009 10gen Inc.
|
3
|
+
#
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
# you may not use this file except in compliance with the License.
|
6
|
+
# You may obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
# See the License for the specific language governing permissions and
|
14
|
+
# limitations under the License.
|
15
|
+
# ++
|
16
|
+
|
1
17
|
module XGen
|
2
18
|
module Mongo
|
3
19
|
module Driver
|
@@ -1,3 +1,19 @@
|
|
1
|
+
# --
|
2
|
+
# Copyright (C) 2008-2009 10gen Inc.
|
3
|
+
#
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
# you may not use this file except in compliance with the License.
|
6
|
+
# You may obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
# See the License for the specific language governing permissions and
|
14
|
+
# limitations under the License.
|
15
|
+
# ++
|
16
|
+
|
1
17
|
require 'mongo/message/message'
|
2
18
|
require 'mongo/message/opcodes'
|
3
19
|
require 'mongo/util/ordered_hash'
|
@@ -1,3 +1,19 @@
|
|
1
|
+
# --
|
2
|
+
# Copyright (C) 2008-2009 10gen Inc.
|
3
|
+
#
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
# you may not use this file except in compliance with the License.
|
6
|
+
# You may obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
# See the License for the specific language governing permissions and
|
14
|
+
# limitations under the License.
|
15
|
+
# ++
|
16
|
+
|
1
17
|
require 'mongo/message/message'
|
2
18
|
require 'mongo/message/opcodes'
|
3
19
|
|
@@ -1,3 +1,19 @@
|
|
1
|
+
# --
|
2
|
+
# Copyright (C) 2008-2009 10gen Inc.
|
3
|
+
#
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
# you may not use this file except in compliance with the License.
|
6
|
+
# You may obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
# See the License for the specific language governing permissions and
|
14
|
+
# limitations under the License.
|
15
|
+
# ++
|
16
|
+
|
1
17
|
require 'mongo/message/message'
|
2
18
|
require 'mongo/message/opcodes'
|
3
19
|
|
data/lib/mongo/message.rb
CHANGED
@@ -1,3 +1,19 @@
|
|
1
|
+
# --
|
2
|
+
# Copyright (C) 2008-2009 10gen Inc.
|
3
|
+
#
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
# you may not use this file except in compliance with the License.
|
6
|
+
# You may obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
# See the License for the specific language governing permissions and
|
14
|
+
# limitations under the License.
|
15
|
+
# ++
|
16
|
+
|
1
17
|
%w(get_more_message insert_message kill_cursors_message message_header
|
2
18
|
msg_message query_message remove_message update_message).each { |f|
|
3
19
|
require "mongo/message/#{f}"
|
data/lib/mongo/mongo.rb
CHANGED
@@ -1,17 +1,17 @@
|
|
1
1
|
# --
|
2
2
|
# Copyright (C) 2008-2009 10gen Inc.
|
3
3
|
#
|
4
|
-
#
|
5
|
-
#
|
6
|
-
#
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
# you may not use this file except in compliance with the License.
|
6
|
+
# You may obtain a copy of the License at
|
7
7
|
#
|
8
|
-
#
|
9
|
-
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
10
|
-
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License
|
11
|
-
# for more details.
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
12
9
|
#
|
13
|
-
#
|
14
|
-
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
# See the License for the specific language governing permissions and
|
14
|
+
# limitations under the License.
|
15
15
|
# ++
|
16
16
|
|
17
17
|
require 'mongo/db'
|
data/lib/mongo/query.rb
CHANGED
@@ -1,17 +1,17 @@
|
|
1
1
|
# --
|
2
2
|
# Copyright (C) 2008-2009 10gen Inc.
|
3
3
|
#
|
4
|
-
#
|
5
|
-
#
|
6
|
-
#
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
# you may not use this file except in compliance with the License.
|
6
|
+
# You may obtain a copy of the License at
|
7
7
|
#
|
8
|
-
#
|
9
|
-
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
10
|
-
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License
|
11
|
-
# for more details.
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
12
9
|
#
|
13
|
-
#
|
14
|
-
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
# See the License for the specific language governing permissions and
|
14
|
+
# limitations under the License.
|
15
15
|
# ++
|
16
16
|
|
17
17
|
require 'mongo/collection'
|
data/lib/mongo/types/binary.rb
CHANGED
@@ -1,17 +1,17 @@
|
|
1
1
|
# --
|
2
2
|
# Copyright (C) 2008-2009 10gen Inc.
|
3
3
|
#
|
4
|
-
#
|
5
|
-
#
|
6
|
-
#
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
# you may not use this file except in compliance with the License.
|
6
|
+
# You may obtain a copy of the License at
|
7
7
|
#
|
8
|
-
#
|
9
|
-
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
10
|
-
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License
|
11
|
-
# for more details.
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
12
9
|
#
|
13
|
-
#
|
14
|
-
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
# See the License for the specific language governing permissions and
|
14
|
+
# limitations under the License.
|
15
15
|
# ++
|
16
16
|
|
17
17
|
require 'mongo/util/byte_buffer'
|
data/lib/mongo/types/dbref.rb
CHANGED
@@ -1,17 +1,17 @@
|
|
1
1
|
# --
|
2
2
|
# Copyright (C) 2008-2009 10gen Inc.
|
3
3
|
#
|
4
|
-
#
|
5
|
-
#
|
6
|
-
#
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
# you may not use this file except in compliance with the License.
|
6
|
+
# You may obtain a copy of the License at
|
7
7
|
#
|
8
|
-
#
|
9
|
-
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
10
|
-
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License
|
11
|
-
# for more details.
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
12
9
|
#
|
13
|
-
#
|
14
|
-
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
# See the License for the specific language governing permissions and
|
14
|
+
# limitations under the License.
|
15
15
|
# ++
|
16
16
|
|
17
17
|
module XGen
|
data/lib/mongo/types/objectid.rb
CHANGED
@@ -1,17 +1,17 @@
|
|
1
1
|
# --
|
2
2
|
# Copyright (C) 2008-2009 10gen Inc.
|
3
3
|
#
|
4
|
-
#
|
5
|
-
#
|
6
|
-
#
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
# you may not use this file except in compliance with the License.
|
6
|
+
# You may obtain a copy of the License at
|
7
7
|
#
|
8
|
-
#
|
9
|
-
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
10
|
-
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License
|
11
|
-
# for more details.
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
12
9
|
#
|
13
|
-
#
|
14
|
-
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
# See the License for the specific language governing permissions and
|
14
|
+
# limitations under the License.
|
15
15
|
# ++
|
16
16
|
|
17
17
|
require 'mutex_m'
|
@@ -1,17 +1,17 @@
|
|
1
1
|
# --
|
2
2
|
# Copyright (C) 2008-2009 10gen Inc.
|
3
3
|
#
|
4
|
-
#
|
5
|
-
#
|
6
|
-
#
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
# you may not use this file except in compliance with the License.
|
6
|
+
# You may obtain a copy of the License at
|
7
7
|
#
|
8
|
-
#
|
9
|
-
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
10
|
-
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License
|
11
|
-
# for more details.
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
12
9
|
#
|
13
|
-
#
|
14
|
-
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
# See the License for the specific language governing permissions and
|
14
|
+
# limitations under the License.
|
15
15
|
# ++
|
16
16
|
|
17
17
|
module XGen
|
@@ -1,17 +1,17 @@
|
|
1
1
|
# --
|
2
2
|
# Copyright (C) 2008-2009 10gen Inc.
|
3
3
|
#
|
4
|
-
#
|
5
|
-
#
|
6
|
-
#
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
# you may not use this file except in compliance with the License.
|
6
|
+
# You may obtain a copy of the License at
|
7
7
|
#
|
8
|
-
#
|
9
|
-
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
10
|
-
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License
|
11
|
-
# for more details.
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
12
9
|
#
|
13
|
-
#
|
14
|
-
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
# See the License for the specific language governing permissions and
|
14
|
+
# limitations under the License.
|
15
15
|
# ++
|
16
16
|
|
17
17
|
module XGen
|
@@ -1,17 +1,17 @@
|
|
1
1
|
# --
|
2
2
|
# Copyright (C) 2008-2009 10gen Inc.
|
3
3
|
#
|
4
|
-
#
|
5
|
-
#
|
6
|
-
#
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
# you may not use this file except in compliance with the License.
|
6
|
+
# You may obtain a copy of the License at
|
7
7
|
#
|
8
|
-
#
|
9
|
-
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
10
|
-
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License
|
11
|
-
# for more details.
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
12
9
|
#
|
13
|
-
#
|
14
|
-
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
# See the License for the specific language governing permissions and
|
14
|
+
# limitations under the License.
|
15
15
|
# ++
|
16
16
|
|
17
17
|
# A byte buffer.
|
@@ -1,17 +1,17 @@
|
|
1
1
|
# --
|
2
2
|
# Copyright (C) 2008-2009 10gen Inc.
|
3
3
|
#
|
4
|
-
#
|
5
|
-
#
|
6
|
-
#
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
# you may not use this file except in compliance with the License.
|
6
|
+
# You may obtain a copy of the License at
|
7
7
|
#
|
8
|
-
#
|
9
|
-
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
10
|
-
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License
|
11
|
-
# for more details.
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
12
9
|
#
|
13
|
-
#
|
14
|
-
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
# See the License for the specific language governing permissions and
|
14
|
+
# limitations under the License.
|
15
15
|
# ++
|
16
16
|
|
17
17
|
# A hash in which the order of keys are preserved.
|
@@ -1,17 +1,17 @@
|
|
1
1
|
# --
|
2
2
|
# Copyright (C) 2008-2009 10gen Inc.
|
3
3
|
#
|
4
|
-
#
|
5
|
-
#
|
6
|
-
#
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
# you may not use this file except in compliance with the License.
|
6
|
+
# You may obtain a copy of the License at
|
7
7
|
#
|
8
|
-
#
|
9
|
-
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
10
|
-
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License
|
11
|
-
# for more details.
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
12
9
|
#
|
13
|
-
#
|
14
|
-
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
# See the License for the specific language governing permissions and
|
14
|
+
# limitations under the License.
|
15
15
|
# ++
|
16
16
|
|
17
17
|
require 'rexml/document'
|
data/lib/mongo.rb
CHANGED
data/mongo-ruby-driver.gemspec
CHANGED
@@ -74,16 +74,16 @@ TEST_FILES = ['tests/mongo-qa/_common.rb',
|
|
74
74
|
|
75
75
|
Gem::Specification.new do |s|
|
76
76
|
s.name = 'mongo'
|
77
|
-
s.version = '0.6.
|
77
|
+
s.version = '0.6.3'
|
78
78
|
s.platform = Gem::Platform::RUBY
|
79
79
|
s.summary = 'Simple pure-Ruby driver for the 10gen Mongo DB'
|
80
80
|
s.description = 'A pure-Ruby driver for the 10gen Mongo DB. For more information about Mongo, see http://www.mongodb.org.'
|
81
81
|
|
82
82
|
s.require_paths = ['lib']
|
83
|
-
|
83
|
+
|
84
84
|
s.files = PACKAGE_FILES
|
85
85
|
s.test_files = TEST_FILES
|
86
|
-
|
86
|
+
|
87
87
|
s.has_rdoc = true
|
88
88
|
s.rdoc_options = ['--main', 'README.rdoc', '--inline-source']
|
89
89
|
s.extra_rdoc_files = ['README.rdoc']
|
data/tests/mongo-qa/indices
CHANGED
@@ -1,6 +1,9 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
3
|
require File.join(File.dirname(__FILE__), '_common.rb')
|
4
|
+
|
5
|
+
include XGen::Mongo
|
6
|
+
|
4
7
|
db = Mongo.new(DEFAULT_HOST, DEFAULT_PORT).db(DEFAULT_DB)
|
5
8
|
x = db.collection('x')
|
6
9
|
y = db.collection('y')
|
@@ -41,6 +44,6 @@ raise "\n#{err.join("\n")}" unless err == ['', '']
|
|
41
44
|
x.drop_index('field1_1')
|
42
45
|
sorted_index_info(x).each { |info| puts sorted_info_keys(info) }
|
43
46
|
|
44
|
-
y.create_index(
|
45
|
-
y.create_index('d'
|
47
|
+
y.create_index([['a', ASCENDING], ['b', ASCENDING], ['c', ASCENDING]])
|
48
|
+
y.create_index('d')
|
46
49
|
sorted_index_info(y).each { |info| puts sorted_info_keys(info) }
|
data/tests/test_bson.rb
CHANGED
@@ -16,6 +16,9 @@ class BSONTest < Test::Unit::TestCase
|
|
16
16
|
def test_string
|
17
17
|
doc = {'doc' => 'hello, world'}
|
18
18
|
@b.serialize(doc)
|
19
|
+
assert_equal @b.to_a, [0x1b, 0x00, 0x00, 0x00, 0x02, ?d, ?o, ?c, 0x00, 0x0D,
|
20
|
+
0x00, 0x00, 0x00, ?h, ?e, ?l, ?l, ?o, ","[0], " "[0],
|
21
|
+
?w, ?o, ?r, ?l, ?d, 0x00, 0x00]
|
19
22
|
assert_equal doc, @b.deserialize
|
20
23
|
end
|
21
24
|
|
@@ -90,9 +93,8 @@ class BSONTest < Test::Unit::TestCase
|
|
90
93
|
doc = {'date' => Time.now}
|
91
94
|
@b.serialize(doc)
|
92
95
|
doc2 = @b.deserialize
|
93
|
-
# Mongo only stores
|
94
|
-
|
95
|
-
assert_equal doc['date'].to_i, doc2['date'].to_i
|
96
|
+
# Mongo only stores up to the millisecond
|
97
|
+
assert_in_delta doc['date'], doc2['date'], 0.001
|
96
98
|
end
|
97
99
|
|
98
100
|
def test_dbref
|
@@ -122,6 +124,7 @@ class BSONTest < Test::Unit::TestCase
|
|
122
124
|
bin2 = doc2['bin']
|
123
125
|
assert_kind_of Binary, bin2
|
124
126
|
assert_equal 'binstring', bin2.to_s
|
127
|
+
assert_equal Binary::SUBTYPE_BYTES, bin2.subtype
|
125
128
|
end
|
126
129
|
|
127
130
|
def test_binary_type
|
data/tests/test_db_api.rb
CHANGED
@@ -4,7 +4,7 @@ require 'test/unit'
|
|
4
4
|
|
5
5
|
# NOTE: assumes Mongo is running
|
6
6
|
class DBAPITest < Test::Unit::TestCase
|
7
|
-
|
7
|
+
include XGen::Mongo
|
8
8
|
include XGen::Mongo::Driver
|
9
9
|
|
10
10
|
@@db = Mongo.new(ENV['MONGO_RUBY_DRIVER_HOST'] || 'localhost',
|
@@ -275,28 +275,30 @@ class DBAPITest < Test::Unit::TestCase
|
|
275
275
|
end
|
276
276
|
|
277
277
|
def test_index_information
|
278
|
-
@@db.create_index(@@coll.name, '
|
278
|
+
name = @@db.create_index(@@coll.name, 'a')
|
279
279
|
list = @@db.index_information(@@coll.name)
|
280
280
|
assert_equal 1, list.length
|
281
281
|
|
282
282
|
info = list[0]
|
283
|
-
assert_equal '
|
283
|
+
assert_equal name, 'a_1'
|
284
|
+
assert_equal name, info[:name]
|
284
285
|
assert_equal 1, info[:keys]['a']
|
285
286
|
ensure
|
286
|
-
@@db.drop_index(@@coll.name,
|
287
|
+
@@db.drop_index(@@coll.name, name)
|
287
288
|
end
|
288
289
|
|
289
290
|
def test_multiple_index_cols
|
290
|
-
@@db.create_index(@@coll.name,
|
291
|
+
name = @@db.create_index(@@coll.name, [['a', DESCENDING], ['b', ASCENDING], ['c', DESCENDING]])
|
291
292
|
list = @@db.index_information(@@coll.name)
|
292
293
|
assert_equal 1, list.length
|
293
294
|
|
294
295
|
info = list[0]
|
295
|
-
assert_equal '
|
296
|
+
assert_equal name, 'a_-1_b_1_c_-1'
|
297
|
+
assert_equal name, info[:name]
|
296
298
|
keys = info[:keys].keys
|
297
299
|
assert_equal ['a', 'b', 'c'], keys.sort
|
298
300
|
ensure
|
299
|
-
@@db.drop_index(@@coll.name,
|
301
|
+
@@db.drop_index(@@coll.name, name)
|
300
302
|
end
|
301
303
|
|
302
304
|
def test_array
|
@@ -403,7 +405,7 @@ class DBAPITest < Test::Unit::TestCase
|
|
403
405
|
end
|
404
406
|
|
405
407
|
def test_hint
|
406
|
-
@@coll.create_index('
|
408
|
+
name = @@coll.create_index('a')
|
407
409
|
begin
|
408
410
|
assert_nil @@coll.hint
|
409
411
|
assert_equal 1, @@coll.find({'a' => 1}, :hint => 'a').to_a.size
|
@@ -425,10 +427,8 @@ class DBAPITest < Test::Unit::TestCase
|
|
425
427
|
@@coll.hint = nil
|
426
428
|
assert_nil @@coll.hint
|
427
429
|
assert_equal 1, @@coll.find('a' => 1).to_a.size
|
428
|
-
rescue => ex
|
429
|
-
fail ex.to_s
|
430
430
|
ensure
|
431
|
-
@@coll.drop_index(
|
431
|
+
@@coll.drop_index(name)
|
432
432
|
end
|
433
433
|
end
|
434
434
|
|
data/tests/test_grid_store.rb
CHANGED
@@ -10,8 +10,8 @@ class GridStoreTest < Test::Unit::TestCase
|
|
10
10
|
|
11
11
|
@@db = Mongo.new(ENV['MONGO_RUBY_DRIVER_HOST'] || 'localhost',
|
12
12
|
ENV['MONGO_RUBY_DRIVER_PORT'] || Mongo::DEFAULT_PORT).db('ruby-mongo-test')
|
13
|
-
@@files = @@db.collection('
|
14
|
-
@@chunks = @@db.collection('
|
13
|
+
@@files = @@db.collection('fs.files')
|
14
|
+
@@chunks = @@db.collection('fs.chunks')
|
15
15
|
|
16
16
|
def setup
|
17
17
|
@@chunks.clear
|
@@ -208,6 +208,23 @@ class GridStoreTest < Test::Unit::TestCase
|
|
208
208
|
}
|
209
209
|
end
|
210
210
|
|
211
|
+
def test_md5
|
212
|
+
GridStore.open(@@db, 'new-file', 'w') { |f| f.write("hello world\n")}
|
213
|
+
GridStore.open(@@db, 'new-file', 'r') { |f|
|
214
|
+
assert f.md5 == '6f5902ac237024bdd0c176cb93063dc4'
|
215
|
+
begin
|
216
|
+
f.md5 = 'cant do this'
|
217
|
+
fail "should have seen error"
|
218
|
+
rescue => ex
|
219
|
+
true
|
220
|
+
end
|
221
|
+
}
|
222
|
+
GridStore.open(@@db, 'new-file', 'w') {}
|
223
|
+
GridStore.open(@@db, 'new-file', 'r') { |f|
|
224
|
+
assert f.md5 == 'd41d8cd98f00b204e9800998ecf8427e'
|
225
|
+
}
|
226
|
+
end
|
227
|
+
|
211
228
|
def test_upload_date
|
212
229
|
now = Time.now
|
213
230
|
orig_file_upload_date = nil
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mongodb-mongo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jim Menard
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-02-
|
12
|
+
date: 2009-02-25 00:00:00 -08:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|