mongodb 0.0.10 → 0.0.11
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/Rakefile +1 -6
- data/lib/mongo/driver.rb +2 -1
- data/lib/mongo/driver/collection.rb +1 -1
- data/lib/mongo/driver/connection.rb +2 -0
- data/lib/mongo/driver/database.rb +11 -0
- data/lib/mongo/driver/spec.rb +1 -8
- data/lib/mongo/object/object.rb +1 -0
- data/readme.md +2 -2
- metadata +2 -2
data/Rakefile
CHANGED
data/lib/mongo/driver.rb
CHANGED
@@ -18,8 +18,9 @@ Mongo.class_eval do
|
|
18
18
|
def defaults; @defaults ||= {} end
|
19
19
|
attr_writer :defaults
|
20
20
|
|
21
|
-
# Override this method to provide Your own custom database initialization.
|
21
|
+
# Override this method to provide Your own custom database initialization logic.
|
22
22
|
def db name
|
23
|
+
name = name.to_s
|
23
24
|
@databases ||= {}
|
24
25
|
@databases[name] ||= begin
|
25
26
|
connection = Mongo::Connection.new
|
@@ -1,4 +1,15 @@
|
|
1
1
|
module Mongo::DBExt
|
2
|
+
def drop
|
3
|
+
connection.drop_database name
|
4
|
+
end
|
5
|
+
|
6
|
+
def clear
|
7
|
+
collection_names.each do |name|
|
8
|
+
next if name =~ /^system\./
|
9
|
+
mongo.db.collection(name).drop
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
2
13
|
protected
|
3
14
|
def method_missing collection_name
|
4
15
|
self.collection collection_name
|
data/lib/mongo/driver/spec.rb
CHANGED
@@ -13,13 +13,6 @@ rspec do
|
|
13
13
|
$mongo || raise('Mongo not defined (use :with_mongo helper)!')
|
14
14
|
end
|
15
15
|
|
16
|
-
def clear_mongo name = MONGO_TEST_DATABASE_NAME
|
17
|
-
mongo.db.collection_names.each do |name|
|
18
|
-
next if name =~ /^system\./
|
19
|
-
mongo.db.collection(name).drop
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
16
|
class << self
|
24
17
|
def with_mongo
|
25
18
|
before :all do
|
@@ -33,7 +26,7 @@ rspec do
|
|
33
26
|
after(:all){$mongo = nil}
|
34
27
|
|
35
28
|
before do
|
36
|
-
|
29
|
+
mongo.db.clear
|
37
30
|
end
|
38
31
|
end
|
39
32
|
end
|
data/lib/mongo/object/object.rb
CHANGED
data/readme.md
CHANGED
@@ -34,7 +34,7 @@ connection = Mongo::Connection.new
|
|
34
34
|
db = connection.default_test
|
35
35
|
db.drop
|
36
36
|
|
37
|
-
# Collection shortcuts, access collection directly by typing
|
37
|
+
# Collection shortcuts, access collection directly by typing its name,
|
38
38
|
# instead of `db.collection('some_collection')`.
|
39
39
|
db.some_collection
|
40
40
|
|
@@ -140,7 +140,7 @@ class Unit
|
|
140
140
|
|
141
141
|
attr_reader :name, :stats
|
142
142
|
|
143
|
-
# We need
|
143
|
+
# We need the initializer to be used also without arguments.
|
144
144
|
def initialize name = nil, stats = nil
|
145
145
|
@name, @stats = name, stats
|
146
146
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mongodb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.11
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-09-
|
12
|
+
date: 2011-09-15 00:00:00.000000000Z
|
13
13
|
dependencies: []
|
14
14
|
description:
|
15
15
|
email:
|