mongodb 0.0.9 → 0.0.10
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +8 -3
- data/lib/mongo/driver.rb +12 -2
- data/lib/mongo/driver/collection.rb +1 -0
- data/lib/mongo/driver/connection.rb +6 -0
- data/lib/mongo/driver/spec.rb +8 -0
- data/lib/mongo/migration.rb +1 -0
- data/lib/mongo/migration/dsl.rb +26 -0
- data/lib/mongo/migration/migration.rb +12 -8
- data/lib/mongo/migration/tasks.rb +27 -19
- data/lib/mongo/object/object.rb +35 -15
- data/readme.md +95 -80
- data/spec/driver/connection_spec.rb +9 -0
- data/spec/migration/migration_spec.rb +4 -1
- metadata +7 -4
data/Rakefile
CHANGED
@@ -4,8 +4,13 @@ project(
|
|
4
4
|
name: "mongodb",
|
5
5
|
# version: '0.1.0',
|
6
6
|
gem: true,
|
7
|
-
summary: "
|
7
|
+
summary: "Persistence for any Ruby Object & Driver enhancements for MongoDB.",
|
8
8
|
|
9
9
|
author: "Alexey Petrushin",
|
10
|
-
homepage: "http://github.com/
|
11
|
-
)
|
10
|
+
homepage: "http://alexeypetrushin.github.com/mongodb"
|
11
|
+
)
|
12
|
+
|
13
|
+
desc "Generate documentation"
|
14
|
+
task :docs do
|
15
|
+
%x(cd docs && rocco -o site *.rb)
|
16
|
+
end
|
data/lib/mongo/driver.rb
CHANGED
@@ -6,6 +6,7 @@ class Mongo::Error < StandardError; end
|
|
6
6
|
class Mongo::NotFound < Mongo::Error; end
|
7
7
|
|
8
8
|
%w(
|
9
|
+
connection
|
9
10
|
database
|
10
11
|
collection
|
11
12
|
dynamic_finders
|
@@ -16,14 +17,23 @@ Mongo.class_eval do
|
|
16
17
|
class << self
|
17
18
|
def defaults; @defaults ||= {} end
|
18
19
|
attr_writer :defaults
|
20
|
+
|
21
|
+
# Override this method to provide Your own custom database initialization.
|
22
|
+
def db name
|
23
|
+
@databases ||= {}
|
24
|
+
@databases[name] ||= begin
|
25
|
+
connection = Mongo::Connection.new
|
26
|
+
connection.db name
|
27
|
+
end
|
28
|
+
end
|
19
29
|
end
|
20
30
|
end
|
21
31
|
Mongo.defaults[:convert_id_to_string] = true
|
22
32
|
|
23
|
-
|
33
|
+
Mongo::Connection.send :include, Mongo::ConnectionExt
|
34
|
+
|
24
35
|
Mongo::DB.send :include, Mongo::DBExt
|
25
36
|
|
26
|
-
# collection
|
27
37
|
Mongo::Collection.class_eval do
|
28
38
|
include Mongo::CollectionExt, Mongo::DynamicFinders
|
29
39
|
|
data/lib/mongo/driver/spec.rb
CHANGED
@@ -1,5 +1,13 @@
|
|
1
1
|
MONGO_TEST_DATABASE_NAME = 'default_test'
|
2
2
|
|
3
|
+
Mongo.class_eval do
|
4
|
+
class << self
|
5
|
+
def db name
|
6
|
+
($mongo || raise('Mongo not defined (use :with_mongo helper)!')).db
|
7
|
+
end
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
3
11
|
rspec do
|
4
12
|
def mongo
|
5
13
|
$mongo || raise('Mongo not defined (use :with_mongo helper)!')
|
data/lib/mongo/migration.rb
CHANGED
@@ -0,0 +1,26 @@
|
|
1
|
+
Mongo.class_eval do
|
2
|
+
class << self
|
3
|
+
def migration *args, &block
|
4
|
+
if block
|
5
|
+
version, database_name = *args
|
6
|
+
version or raise("migration version not provided!")
|
7
|
+
database_name ||= :default
|
8
|
+
add_migration version, database_name, &block
|
9
|
+
elsif !block
|
10
|
+
database_name = args.first
|
11
|
+
database_name ||= :default
|
12
|
+
get_migration(database_name)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def add_migration version, database_name, &block
|
17
|
+
get_migration(database_name).add version, &block
|
18
|
+
end
|
19
|
+
|
20
|
+
def get_migration database_name
|
21
|
+
migrations[database_name] ||= Mongo::Migration.new
|
22
|
+
end
|
23
|
+
|
24
|
+
def migrations; @migrations ||= {} end
|
25
|
+
end
|
26
|
+
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
class Mongo::Migration
|
2
|
-
def initialize
|
3
|
-
@
|
2
|
+
def initialize
|
3
|
+
@definitions = {}
|
4
4
|
end
|
5
5
|
|
6
6
|
def add version, &block
|
@@ -12,6 +12,7 @@ class Mongo::Migration
|
|
12
12
|
|
13
13
|
def update version = nil
|
14
14
|
version ||= definitions.keys.max
|
15
|
+
version = version.to_i
|
15
16
|
|
16
17
|
if current_version == version
|
17
18
|
info "database '#{db.name}' already is of #{version} version, no migration needed"
|
@@ -33,17 +34,20 @@ class Mongo::Migration
|
|
33
34
|
end
|
34
35
|
end
|
35
36
|
|
36
|
-
|
37
|
-
|
37
|
+
attr_writer :db
|
38
|
+
def db; @db || raise("Database for Migration not defined!") end
|
39
|
+
|
40
|
+
def update_version new_version
|
41
|
+
db.db_metadata.update({name: 'migration'}, {name: 'migration', version: new_version}, {upsert: true, safe: true})
|
42
|
+
end
|
43
|
+
|
44
|
+
attr_accessor :definitions
|
38
45
|
|
46
|
+
protected
|
39
47
|
def info msg
|
40
48
|
db.connection.logger and db.connection.logger.info(msg)
|
41
49
|
end
|
42
50
|
|
43
|
-
def update_version new_version
|
44
|
-
db.db_metadata.update({name: 'migration'}, {name: 'migration', version: new_version}, {upsert: true, safe: true})
|
45
|
-
end
|
46
|
-
|
47
51
|
def increase_db_version
|
48
52
|
new_version = current_version + 1
|
49
53
|
migration = definitions[new_version]
|
@@ -1,19 +1,27 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
1
|
+
namespace :db do
|
2
|
+
desc "Clear migration version for Database"
|
3
|
+
task clear_version: :migration_evnironment do
|
4
|
+
require 'mongo/migration'
|
5
|
+
|
6
|
+
database_name = (ENV['d'] || ENV['database'] || :default).to_sym
|
7
|
+
|
8
|
+
db = Mongo.db database_name
|
9
|
+
migration = Mongo::Migration.new
|
10
|
+
migration.db = db
|
11
|
+
migration.update_version 0
|
12
|
+
end
|
13
|
+
|
14
|
+
desc "Migrate Database"
|
15
|
+
task migrate: :migration_evnironment do
|
16
|
+
require 'mongo/migration'
|
17
|
+
|
18
|
+
database_name = (ENV['d'] || ENV['database'] || :default).to_sym
|
19
|
+
version = ENV['v'] || ENV['version']
|
20
|
+
|
21
|
+
if migration = Mongo.migrations[database_name]
|
22
|
+
db = Mongo.db database_name
|
23
|
+
migration.db = db
|
24
|
+
migration.update version
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
data/lib/mongo/object/object.rb
CHANGED
@@ -75,16 +75,18 @@ module Mongo::Object
|
|
75
75
|
options
|
76
76
|
end
|
77
77
|
|
78
|
-
def
|
79
|
-
obj.
|
80
|
-
# skipping variables starting with _xx, usually they
|
81
|
-
# have specific meaning and used for example for cache
|
82
|
-
next if iv_name =~ SKIP_IV_REGEXP
|
83
|
-
|
78
|
+
def each_instance_variable obj, &block
|
79
|
+
instance_variables(obj).each do |iv_name|
|
84
80
|
block.call iv_name, obj.instance_variable_get(iv_name)
|
85
81
|
end
|
86
82
|
end
|
87
83
|
|
84
|
+
def instance_variables obj
|
85
|
+
# skipping variables starting with _xx, usually they
|
86
|
+
# have specific meaning and used for example for cache
|
87
|
+
obj.instance_variables.select{|n| n !~ SKIP_IV_REGEXP}
|
88
|
+
end
|
89
|
+
|
88
90
|
# converts object to document (also works with nested & arrays)
|
89
91
|
def to_mongo obj
|
90
92
|
return obj.to_mongo if obj.respond_to? :to_mongo
|
@@ -101,7 +103,7 @@ module Mongo::Object
|
|
101
103
|
doc = {}
|
102
104
|
|
103
105
|
# copying instance variables
|
104
|
-
|
106
|
+
each_instance_variable obj do |iv_name, v|
|
105
107
|
k = iv_name.to_s[1..-1]
|
106
108
|
doc[k] = to_mongo v
|
107
109
|
end
|
@@ -117,14 +119,30 @@ module Mongo::Object
|
|
117
119
|
end
|
118
120
|
end
|
119
121
|
|
120
|
-
def
|
122
|
+
def convert obj, method, options = {}
|
123
|
+
if obj.is_a? Hash
|
124
|
+
r = {}
|
125
|
+
obj.each do |k, v|
|
126
|
+
r[k] = convert v, method, options
|
127
|
+
end
|
128
|
+
r
|
129
|
+
elsif obj.is_a? Array
|
130
|
+
obj.collect{|v| convert v, method, options}
|
131
|
+
elsif obj.is_a? Mongo::Object
|
132
|
+
obj.send method, options
|
133
|
+
else # simple type
|
134
|
+
obj
|
135
|
+
end
|
136
|
+
end
|
137
|
+
|
138
|
+
def each_object obj, &block
|
121
139
|
if obj.is_a? Hash
|
122
140
|
obj.each{|k, v| each_object v, &block}
|
123
141
|
elsif obj.is_a? Array
|
124
142
|
obj.each{|v| each_object v, &block}
|
125
143
|
elsif obj.is_a? ::Mongo::Object
|
126
|
-
block.call obj
|
127
|
-
|
144
|
+
block.call obj
|
145
|
+
each_instance_variable obj do |iv_name, v|
|
128
146
|
each_object v, &block
|
129
147
|
end
|
130
148
|
end
|
@@ -211,8 +229,8 @@ module Mongo::Object
|
|
211
229
|
return unless ::Mongo.defaults[:callbacks]
|
212
230
|
|
213
231
|
original_children.clear
|
214
|
-
::Mongo::Object.each_object self
|
215
|
-
original_children << obj
|
232
|
+
::Mongo::Object.each_object self do |obj|
|
233
|
+
original_children << obj unless obj.equal?(self)
|
216
234
|
end
|
217
235
|
end
|
218
236
|
|
@@ -230,11 +248,13 @@ module Mongo::Object
|
|
230
248
|
created_children, updated_children, destroyed_children = [], [], []
|
231
249
|
|
232
250
|
original_children_ids = Set.new; original_children.each{|obj| original_children_ids << obj.object_id}
|
233
|
-
::Mongo::Object.each_object self
|
234
|
-
(original_children_ids.include?(obj.object_id) ? updated_children : created_children) << obj
|
251
|
+
::Mongo::Object.each_object self do |obj|
|
252
|
+
(original_children_ids.include?(obj.object_id) ? updated_children : created_children) << obj unless obj.equal?(self)
|
235
253
|
end
|
236
254
|
|
237
|
-
children_ids = Set.new; ::Mongo::Object.each_object
|
255
|
+
children_ids = Set.new; ::Mongo::Object.each_object self do |obj|
|
256
|
+
children_ids << obj.object_id unless obj.equal?(self)
|
257
|
+
end
|
238
258
|
destroyed_children = original_children.select{|obj| !children_ids.include?(obj.object_id)}
|
239
259
|
|
240
260
|
@_child_objects = [created_children, updated_children, destroyed_children]
|
data/readme.md
CHANGED
@@ -1,6 +1,8 @@
|
|
1
|
-
|
1
|
+
**Documentation:** http://alexeypetrushin.github.com/mongodb
|
2
2
|
|
3
|
-
|
3
|
+
Persistence for any Ruby Object & Driver enhancements for MongoDB.
|
4
|
+
|
5
|
+
1. Driver enhancements.
|
4
6
|
2. Migrations.
|
5
7
|
3. Persistence for any Ruby object.
|
6
8
|
4. Object Model [mongodb_model][mongodb_model]
|
@@ -17,48 +19,53 @@ These enhancements alter the driver's API and made it more simple and intuitive.
|
|
17
19
|
- 100% backward compatibility with original driver API (if not - it's a bug, report it please)
|
18
20
|
|
19
21
|
``` ruby
|
22
|
+
# Requiring driver enhancements.
|
20
23
|
require 'mongo/driver'
|
21
24
|
|
22
|
-
# Changing some defaults.
|
25
|
+
# Changing some defaults (optional, don't do it if You don't need it).
|
26
|
+
#
|
27
|
+
# By default they are set to false to provide maximum performance, but if You use MongoDB as
|
28
|
+
# major application database (and not only for logging, andalytics and other minor tasks) it's
|
29
|
+
# usually better to set it to true.
|
23
30
|
Mongo.defaults.merge! multi: true, safe: true
|
24
31
|
|
25
|
-
#
|
32
|
+
# Connecting to test database and cleaning it before starting the sample.
|
26
33
|
connection = Mongo::Connection.new
|
27
|
-
db = connection.
|
28
|
-
db.
|
34
|
+
db = connection.default_test
|
35
|
+
db.drop
|
29
36
|
|
30
|
-
# Collection shortcuts
|
37
|
+
# Collection shortcuts, access collection directly by typing it's name,
|
38
|
+
# instead of `db.collection('some_collection')`.
|
31
39
|
db.some_collection
|
32
40
|
|
33
|
-
#
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
db.units.save zeratul
|
38
|
-
db.units.save tassadar
|
41
|
+
# Let's create two Heroes.
|
42
|
+
db.units.save name: 'Zeratul'
|
43
|
+
db.units.save name: 'Tassadar'
|
39
44
|
|
40
|
-
#
|
41
|
-
|
42
|
-
db.units.
|
43
|
-
|
44
|
-
# Querying first & all, there's also :each, the same as :all.
|
45
|
-
db.units.first name: 'Zeratul' # => zeratul
|
46
|
-
db.units.all name: 'Zeratul' # => [zeratul]
|
45
|
+
# Querying first and all documents matching criteria (there's
|
46
|
+
# also `:each` method, the same as `:all`).
|
47
|
+
p db.units.first(name: 'Zeratul') # => zeratul
|
48
|
+
p db.units.all(name: 'Zeratul') # => [zeratul]
|
47
49
|
db.units.all name: 'Zeratul' do |unit|
|
48
|
-
unit
|
50
|
+
p unit # => zeratul
|
49
51
|
end
|
50
52
|
|
51
|
-
# Dynamic
|
52
|
-
db.units.by_name
|
53
|
-
db.units.first_by_name
|
54
|
-
db.units.all_by_name
|
53
|
+
# Dynamic finders, handy way to do simple queries.
|
54
|
+
p db.units.by_name('Zeratul') # => zeratul
|
55
|
+
p db.units.first_by_name('Zeratul') # => zeratul
|
56
|
+
p db.units.all_by_name('Zeratul') # => [zeratul]
|
57
|
+
|
58
|
+
# Bang versions, will raise error if nothing found.
|
59
|
+
p db.units.first!(name: 'Zeratul') # => zeratul
|
60
|
+
p db.units.by_name!('Zeratul') # => zeratul
|
55
61
|
|
56
|
-
# Query sugar, use
|
57
|
-
|
58
|
-
|
62
|
+
# Query sugar, use `:_gt` instead of `:$gt`. It's more convinient to use new hash
|
63
|
+
# syntax `{name: {_gt: 'Z'}}` instead of hashrockets `{name: {:$gt => 'Z'}}`.
|
64
|
+
Mongo.defaults[:convert_underscore_to_dollar] = true
|
65
|
+
p db.units.all(name: {_gt: 'Z'}) # => [zeratul]
|
59
66
|
```
|
60
67
|
|
61
|
-
Source:
|
68
|
+
Source: docs/driver.rb
|
62
69
|
|
63
70
|
More docs - there's no need for more docs, the whole point of this extension is to be small, intuitive, 100% compatible with the official driver, and require no extra knowledge.
|
64
71
|
So, please use standard Ruby driver documentation.
|
@@ -68,52 +75,50 @@ So, please use standard Ruby driver documentation.
|
|
68
75
|
Define migration steps, specify desired version and apply it (usually all this should be done via Rake task).
|
69
76
|
|
70
77
|
``` ruby
|
78
|
+
# Requiring support for migration.
|
71
79
|
require 'mongo/migration'
|
72
80
|
|
73
|
-
#
|
74
|
-
|
75
|
-
db
|
76
|
-
db.units.drop
|
77
|
-
|
78
|
-
# Initialize migration (usually all this should be done inside of :migrate
|
79
|
-
# rake task).
|
80
|
-
migration = Mongo::Migration.new db
|
81
|
-
|
82
|
-
# Define migrations.
|
83
|
-
# Usually they are defined as files in some folder and You loading it by
|
84
|
-
# using something like this:
|
85
|
-
# Dir['<runtime_dir>/db/migrations/*.rb'].each{|fname| load fname}
|
86
|
-
migration.add 1 do |m|
|
87
|
-
m.up{|db| db.units.save name: 'Zeratul'}
|
81
|
+
# Defining first migration, creating Zeratul (and removing it in rollback).
|
82
|
+
Mongo.migration 1 do |m|
|
83
|
+
m.up {|db| db.units.save name: 'Zeratul'}
|
88
84
|
m.down{|db| db.units.remove name: 'Zeratul'}
|
89
85
|
end
|
90
86
|
|
91
|
-
#
|
92
|
-
migration
|
93
|
-
m.up{|db|
|
87
|
+
# Defining second migration, creating Tassadar (and removing it in rollback).
|
88
|
+
Mongo.migration 2 do |m|
|
89
|
+
m.up {|db| db.units.save name: 'Tassadar'}
|
94
90
|
m.down{|db| db.units.remove name: 'Tassadar'}
|
95
91
|
end
|
96
92
|
|
97
|
-
#
|
98
|
-
|
93
|
+
# Connecting to test database and cleaning it before starting the sample.
|
94
|
+
connection = Mongo::Connection.new
|
95
|
+
db = connection.default_test
|
96
|
+
db.drop
|
97
|
+
|
98
|
+
# Assigning database to migration.
|
99
|
+
Mongo.migration.db = db
|
100
|
+
|
101
|
+
# Let's migrate to the first version and create mighty Zeratul.
|
102
|
+
Mongo.migration.update 1
|
99
103
|
|
100
|
-
migration.current_version
|
101
|
-
db.units.
|
104
|
+
p Mongo.migration.current_version # => 1
|
105
|
+
p db.units.all # => [Zeratul]
|
102
106
|
|
103
|
-
#
|
104
|
-
migration.update 0
|
107
|
+
# Rolling it back.
|
108
|
+
Mongo.migration.update 0
|
105
109
|
|
106
|
-
migration.current_version
|
107
|
-
db.units.
|
110
|
+
p Mongo.migration.current_version # => 0
|
111
|
+
p db.units.all # => []
|
108
112
|
|
109
|
-
#
|
110
|
-
|
113
|
+
# Updating to the latest version (if there's no explicit version
|
114
|
+
# then the highest available version will be chosen).
|
115
|
+
Mongo.migration.update
|
111
116
|
|
112
|
-
migration.current_version
|
113
|
-
db.units.
|
117
|
+
p Mongo.migration.current_version # => 2
|
118
|
+
p db.units.all # => [Zeratul, Tassadar]
|
114
119
|
```
|
115
120
|
|
116
|
-
Source:
|
121
|
+
Source: docs/migration.rb
|
117
122
|
|
118
123
|
# Persistence for any Ruby object
|
119
124
|
|
@@ -122,23 +127,25 @@ Save any Ruby object to MongoDB, as if it's a document. Objects can be any type,
|
|
122
127
|
Note: the :initialize method should allow to create object without arguments.
|
123
128
|
|
124
129
|
``` ruby
|
125
|
-
# Connecting to
|
130
|
+
# Connecting to test database and cleaning it before starting the sample.
|
126
131
|
require 'mongo/object'
|
127
|
-
Mongo.defaults.merge! multi: true, safe: true
|
128
132
|
connection = Mongo::Connection.new
|
129
|
-
db = connection.
|
130
|
-
db.
|
133
|
+
db = connection.default_test
|
134
|
+
db.drop
|
131
135
|
|
132
|
-
# Let's define
|
136
|
+
# Let's define Game Unit.
|
133
137
|
class Unit
|
138
|
+
# Including Mongo::Object.
|
134
139
|
include Mongo::Object
|
140
|
+
|
135
141
|
attr_reader :name, :stats
|
136
142
|
|
137
|
-
#
|
143
|
+
# We need to also the initializer to be used without arguments.
|
138
144
|
def initialize name = nil, stats = nil
|
139
145
|
@name, @stats = name, stats
|
140
146
|
end
|
141
147
|
|
148
|
+
# Creating internal object containing stats of the Unit.
|
142
149
|
class Stats
|
143
150
|
include Mongo::Object
|
144
151
|
attr_accessor :attack, :life, :shield
|
@@ -149,35 +156,43 @@ class Unit
|
|
149
156
|
end
|
150
157
|
end
|
151
158
|
|
152
|
-
#
|
159
|
+
# Let's create two Heroes.
|
160
|
+
#
|
161
|
+
# It uses the same Driver API, everything works the same way as with hashes.
|
153
162
|
zeratul = Unit.new('Zeratul', Unit::Stats.new(85, 300, 100))
|
154
163
|
tassadar = Unit.new('Tassadar', Unit::Stats.new(0, 80, 300))
|
155
164
|
|
156
165
|
db.units.save zeratul
|
157
166
|
db.units.save tassadar
|
158
167
|
|
159
|
-
#
|
168
|
+
# Udating, we made error - mistakenly set Tassadar's attack as zero, let's fix it.
|
160
169
|
tassadar.stats.attack = 20
|
161
170
|
db.units.save tassadar
|
162
171
|
|
163
|
-
# Querying first
|
164
|
-
|
165
|
-
db.units.
|
172
|
+
# Querying first and all documents matching criteria (there's also `:each` method,
|
173
|
+
# the same as `:all`).
|
174
|
+
p db.units.first(name: 'Zeratul') # => zeratul
|
175
|
+
p db.units.all(name: 'Zeratul') # => [zeratul]
|
166
176
|
db.units.all name: 'Zeratul' do |unit|
|
167
|
-
unit
|
177
|
+
p unit # => zeratul
|
168
178
|
end
|
169
179
|
|
170
|
-
#
|
171
|
-
db.units.by_name
|
172
|
-
db.units.first_by_name
|
173
|
-
db.units.all_by_name
|
180
|
+
# Dynamic finders, handy way to do simple queries.
|
181
|
+
p db.units.by_name('Zeratul') # => zeratul
|
182
|
+
p db.units.first_by_name('Zeratul') # => zeratul
|
183
|
+
p db.units.all_by_name('Zeratul') # => [zeratul]
|
184
|
+
|
185
|
+
# Bang versions, will raise error if nothing found.
|
186
|
+
p db.units.first!(name: 'Zeratul') # => zeratul
|
187
|
+
p db.units.by_name!('Zeratul') # => zeratul
|
174
188
|
|
175
|
-
# Query sugar, use
|
176
|
-
|
177
|
-
|
189
|
+
# Query sugar, use `:_gt` instead of `:$gt`. It's more convinient to use new hash
|
190
|
+
# syntax `{name: {_gt: 'Z'}}` instead of hashrockets `{name: {:$gt => 'Z'}}`.
|
191
|
+
Mongo.defaults[:convert_underscore_to_dollar] = true
|
192
|
+
p db.units.all(name: {_gt: 'Z'}) # => [zeratul]
|
178
193
|
```
|
179
194
|
|
180
|
-
Source:
|
195
|
+
Source: docs/object.rb
|
181
196
|
|
182
197
|
# Installation
|
183
198
|
|
@@ -3,7 +3,10 @@ require 'mongo/migration'
|
|
3
3
|
|
4
4
|
describe "Migration" do
|
5
5
|
with_mongo
|
6
|
-
before
|
6
|
+
before do
|
7
|
+
@migration = Mongo::Migration.new
|
8
|
+
@migration.db = mongo.db
|
9
|
+
end
|
7
10
|
|
8
11
|
it "shouldn't update if versions are the same" do
|
9
12
|
@migration.update(0).should be_false
|
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.10
|
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-13 00:00:00.000000000Z
|
13
13
|
dependencies: []
|
14
14
|
description:
|
15
15
|
email:
|
@@ -20,12 +20,14 @@ files:
|
|
20
20
|
- Rakefile
|
21
21
|
- readme.md
|
22
22
|
- lib/mongo/driver/collection.rb
|
23
|
+
- lib/mongo/driver/connection.rb
|
23
24
|
- lib/mongo/driver/database.rb
|
24
25
|
- lib/mongo/driver/dynamic_finders.rb
|
25
26
|
- lib/mongo/driver/spec.rb
|
26
27
|
- lib/mongo/driver.rb
|
27
28
|
- lib/mongo/gems.rb
|
28
29
|
- lib/mongo/migration/definition.rb
|
30
|
+
- lib/mongo/migration/dsl.rb
|
29
31
|
- lib/mongo/migration/migration.rb
|
30
32
|
- lib/mongo/migration/tasks.rb
|
31
33
|
- lib/mongo/migration.rb
|
@@ -35,6 +37,7 @@ files:
|
|
35
37
|
- lib/mongo/object/spec.rb
|
36
38
|
- lib/mongo/object.rb
|
37
39
|
- spec/driver/collection_spec.rb
|
40
|
+
- spec/driver/connection_spec.rb
|
38
41
|
- spec/driver/crud_spec.rb
|
39
42
|
- spec/driver/database_spec.rb
|
40
43
|
- spec/driver/dynamic_finders_spec.rb
|
@@ -46,7 +49,7 @@ files:
|
|
46
49
|
- spec/object/crud_spec.rb
|
47
50
|
- spec/object/spec_helper.rb
|
48
51
|
- spec/object/validation_spec.rb
|
49
|
-
homepage: http://github.com/
|
52
|
+
homepage: http://alexeypetrushin.github.com/mongodb
|
50
53
|
licenses: []
|
51
54
|
post_install_message:
|
52
55
|
rdoc_options: []
|
@@ -69,5 +72,5 @@ rubyforge_project:
|
|
69
72
|
rubygems_version: 1.8.6
|
70
73
|
signing_key:
|
71
74
|
specification_version: 3
|
72
|
-
summary:
|
75
|
+
summary: Persistence for any Ruby Object & Driver enhancements for MongoDB.
|
73
76
|
test_files: []
|