mongodb-mongo 0.14 → 0.14.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.rdoc +4 -1
- data/lib/mongo/db.rb +8 -0
- data/mongo-ruby-driver.gemspec +1 -2
- data/test/test_collection.rb +9 -7
- data/test/test_db.rb +12 -0
- data/test/test_db_api.rb +20 -0
- metadata +2 -3
data/README.rdoc
CHANGED
@@ -256,7 +256,7 @@ validator script.
|
|
256
256
|
|
257
257
|
= Documentation
|
258
258
|
|
259
|
-
This documentation is available online at http://
|
259
|
+
This documentation is available online at http://api.mongodb.org/ruby. You can
|
260
260
|
generate the documentation if you have the source by typing
|
261
261
|
|
262
262
|
$ rake rdoc
|
@@ -297,6 +297,9 @@ Paul Dlug, paul.dlug@gmail.com
|
|
297
297
|
* Generate _id on the client side if not provided
|
298
298
|
* Collection#insert and Collection#save return _id
|
299
299
|
|
300
|
+
Durran Jordan and Les Hill, durran@gmail.com
|
301
|
+
* DB#collections
|
302
|
+
|
300
303
|
= License
|
301
304
|
|
302
305
|
Copyright 2008-2009 10gen Inc.
|
data/lib/mongo/db.rb
CHANGED
@@ -192,6 +192,14 @@ module Mongo
|
|
192
192
|
names.map {|name| name.sub(@name + '.', '')}
|
193
193
|
end
|
194
194
|
|
195
|
+
# Retruns an array of Collection instances, one for each collection in this
|
196
|
+
# database.
|
197
|
+
def collections
|
198
|
+
collection_names.map do |collection_name|
|
199
|
+
Collection.new(self, collection_name)
|
200
|
+
end
|
201
|
+
end
|
202
|
+
|
195
203
|
# Returns a cursor over query result hashes. Each hash contains a
|
196
204
|
# 'name' string and optionally an 'options' hash. If +coll_name+ is
|
197
205
|
# specified, an array of length 1 is returned.
|
data/mongo-ruby-driver.gemspec
CHANGED
@@ -83,13 +83,12 @@ TEST_FILES = ['test/mongo-qa/_common.rb',
|
|
83
83
|
|
84
84
|
Gem::Specification.new do |s|
|
85
85
|
s.name = 'mongo'
|
86
|
-
s.version = '0.14'
|
86
|
+
s.version = '0.14.1'
|
87
87
|
s.platform = Gem::Platform::RUBY
|
88
88
|
s.summary = 'Ruby driver for the 10gen Mongo DB'
|
89
89
|
s.description = 'A Ruby driver for the 10gen Mongo DB. For more information about Mongo, see http://www.mongodb.org.'
|
90
90
|
|
91
91
|
s.require_paths = ['lib']
|
92
|
-
|
93
92
|
s.files = PACKAGE_FILES
|
94
93
|
s.test_files = TEST_FILES
|
95
94
|
|
data/test/test_collection.rb
CHANGED
@@ -48,7 +48,7 @@ class TestCollection < Test::Unit::TestCase
|
|
48
48
|
a = {"hello" => "world"}
|
49
49
|
@@test.insert(a)
|
50
50
|
@@test.insert(a)
|
51
|
-
assert
|
51
|
+
assert(@@db.error.include?("E11000"))
|
52
52
|
|
53
53
|
assert_raise OperationFailure do
|
54
54
|
@@test.insert(a, :safe => true)
|
@@ -92,7 +92,7 @@ class TestCollection < Test::Unit::TestCase
|
|
92
92
|
|
93
93
|
@@test.save("hello" => "world")
|
94
94
|
@@test.save("hello" => "world")
|
95
|
-
assert
|
95
|
+
assert(@@db.error.include?("E11000"))
|
96
96
|
|
97
97
|
assert_raise OperationFailure do
|
98
98
|
@@test.save({"hello" => "world"}, :safe => true)
|
@@ -137,19 +137,19 @@ class TestCollection < Test::Unit::TestCase
|
|
137
137
|
def test_insert_adds_id
|
138
138
|
doc = {"hello" => "world"}
|
139
139
|
@@test.insert(doc)
|
140
|
-
assert
|
140
|
+
assert(doc.include?(:_id))
|
141
141
|
|
142
142
|
docs = [{"hello" => "world"}, {"hello" => "world"}]
|
143
143
|
@@test.insert(docs)
|
144
144
|
docs.each do |doc|
|
145
|
-
assert
|
145
|
+
assert(doc.include?(:_id))
|
146
146
|
end
|
147
147
|
end
|
148
148
|
|
149
149
|
def test_save_adds_id
|
150
150
|
doc = {"hello" => "world"}
|
151
151
|
@@test.save(doc)
|
152
|
-
assert
|
152
|
+
assert(doc.include?(:_id))
|
153
153
|
end
|
154
154
|
|
155
155
|
def test_optional_find_block
|
@@ -183,8 +183,10 @@ class TestCollection < Test::Unit::TestCase
|
|
183
183
|
|
184
184
|
assert_equal :mike, @@test.find_one(:foo => :mike)["foo"]
|
185
185
|
assert_equal :mike, @@test.find_one("foo" => :mike)["foo"]
|
186
|
-
|
187
|
-
|
186
|
+
|
187
|
+
# TODO enable these tests conditionally based on server version (if >1.0)
|
188
|
+
# assert_equal :mike, @@test.find_one(:foo => "mike")["foo"]
|
189
|
+
# assert_equal :mike, @@test.find_one("foo" => "mike")["foo"]
|
188
190
|
end
|
189
191
|
|
190
192
|
def test_group_with_scope
|
data/test/test_db.rb
CHANGED
@@ -63,6 +63,18 @@ class DBTest < Test::Unit::TestCase
|
|
63
63
|
}
|
64
64
|
end
|
65
65
|
|
66
|
+
def test_collections
|
67
|
+
@@db.collection("test.durran").insert("foo" => 5)
|
68
|
+
@@db.collection("test.les").insert("bar" => 0)
|
69
|
+
|
70
|
+
colls = @@db.collections()
|
71
|
+
assert_not_nil colls.select { |coll| coll.name == "test.durran" }
|
72
|
+
assert_not_nil colls.select { |coll| coll.name == "test.les" }
|
73
|
+
assert_equal [], colls.select { |coll| coll.name == "does_not_exist" }
|
74
|
+
|
75
|
+
assert_kind_of Collection, colls[0]
|
76
|
+
end
|
77
|
+
|
66
78
|
def test_pair
|
67
79
|
@@db.close
|
68
80
|
@@users = nil
|
data/test/test_db_api.rb
CHANGED
@@ -809,4 +809,24 @@ class DBAPITest < Test::Unit::TestCase
|
|
809
809
|
@@db.collection("test").find({}, :snapshot => true, :sort => 'a').to_a
|
810
810
|
end
|
811
811
|
end
|
812
|
+
|
813
|
+
def test_encodings
|
814
|
+
if RUBY_VERSION >= '1.9'
|
815
|
+
ascii = "hello world"
|
816
|
+
utf8 = "hello world".encode("UTF-8")
|
817
|
+
iso8859 = "hello world".encode("ISO-8859-1")
|
818
|
+
|
819
|
+
assert_equal "US-ASCII", ascii.encoding.name
|
820
|
+
assert_equal "UTF-8", utf8.encoding.name
|
821
|
+
assert_equal "ISO-8859-1", iso8859.encoding.name
|
822
|
+
|
823
|
+
@@coll.clear
|
824
|
+
@@coll.save("ascii" => ascii, "utf8" => utf8, "iso8859" => iso8859)
|
825
|
+
doc = @@coll.find_one()
|
826
|
+
|
827
|
+
assert_equal "UTF-8", doc["ascii"].encoding.name
|
828
|
+
assert_equal "UTF-8", doc["utf8"].encoding.name
|
829
|
+
assert_equal "UTF-8", doc["iso8859"].encoding.name
|
830
|
+
end
|
831
|
+
end
|
812
832
|
end
|
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:
|
4
|
+
version: 0.14.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jim Menard
|
@@ -76,7 +76,6 @@ files:
|
|
76
76
|
- lib/mongo.rb
|
77
77
|
has_rdoc: true
|
78
78
|
homepage: http://www.mongodb.org
|
79
|
-
licenses:
|
80
79
|
post_install_message:
|
81
80
|
rdoc_options:
|
82
81
|
- --main
|
@@ -99,7 +98,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
99
98
|
requirements: []
|
100
99
|
|
101
100
|
rubyforge_project:
|
102
|
-
rubygems_version: 1.
|
101
|
+
rubygems_version: 1.2.0
|
103
102
|
signing_key:
|
104
103
|
specification_version: 2
|
105
104
|
summary: Ruby driver for the 10gen Mongo DB
|