mongify 0.0.6 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.rdoc +7 -0
- data/Gemfile.lock +4 -1
- data/README.rdoc +110 -30
- data/features/process.feature +9 -13
- data/lib/mongify/cli/options.rb +1 -1
- data/lib/mongify/database/base_connection.rb +1 -1
- data/lib/mongify/database/column.rb +1 -1
- data/lib/mongify/database/no_sql_connection.rb +4 -0
- data/lib/mongify/database/sql_connection.rb +1 -1
- data/lib/mongify/translation.rb +1 -1
- data/lib/mongify/translation/process.rb +8 -7
- data/lib/mongify/version.rb +1 -1
- data/mongify.gemspec +1 -0
- data/spec/files/simple_translation.rb +19 -19
- data/spec/mongify/database/column_spec.rb +10 -3
- data/spec/mongify/database/no_sql_connection_spec.rb +7 -0
- data/spec/mongify/translation/process_spec.rb +45 -9
- metadata +40 -26
data/CHANGELOG.rdoc
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
+
== 0.0.7 / 17 Jan 2011
|
2
|
+
* Added mysql2 as a dependency
|
3
|
+
* Improved error message when configuration file not provided
|
4
|
+
* More detailed README file
|
5
|
+
* Removed :default flag for column (there was no need for this)
|
6
|
+
* Removed 'pre_mongified_id' from all collections (including embedded)
|
7
|
+
* Removed the parent_id from an embedded row
|
1
8
|
== 0.0.6 / 16 Jan 2011
|
2
9
|
* Added the ability to embed tables into collections (currently only one to many relationship)
|
3
10
|
* Few tweaks and improvements in code
|
data/Gemfile.lock
CHANGED
@@ -1,11 +1,12 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
mongify (0.0.
|
4
|
+
mongify (0.0.7)
|
5
5
|
activerecord (>= 2.3.10)
|
6
6
|
activesupport (>= 2.3.10)
|
7
7
|
bson_ext (>= 1.1.5)
|
8
8
|
mongo (>= 1.1.5)
|
9
|
+
mysql2
|
9
10
|
net-ssh (>= 2.0)
|
10
11
|
|
11
12
|
GEM
|
@@ -32,6 +33,7 @@ GEM
|
|
32
33
|
mongo (1.1.5)
|
33
34
|
bson (>= 1.1.5)
|
34
35
|
mysql (2.8.1)
|
36
|
+
mysql2 (0.2.6)
|
35
37
|
net-ssh (2.0.24)
|
36
38
|
rake (0.8.7)
|
37
39
|
rcov (0.9.9)
|
@@ -60,6 +62,7 @@ DEPENDENCIES
|
|
60
62
|
mongify!
|
61
63
|
mongo (>= 1.1.5)
|
62
64
|
mysql (>= 2.8.1)
|
65
|
+
mysql2
|
63
66
|
net-ssh (>= 2.0)
|
64
67
|
rcov (>= 0.9.9)
|
65
68
|
rspec (>= 2.0)
|
data/README.rdoc
CHANGED
@@ -2,77 +2,157 @@
|
|
2
2
|
|
3
3
|
A data translator from sql database to mongoDB.
|
4
4
|
|
5
|
-
Supports MySQL, PostgreSQL, SQLite, Oracle, SQLServer, and DB2 (Basically anything ActiveRecord has built-in)
|
5
|
+
Supports MySQL, PostgreSQL, SQLite, Oracle, SQLServer, and DB2 (Basically anything ActiveRecord has built-in).
|
6
|
+
However, I've only tested it with MySql and SQLite
|
7
|
+
|
6
8
|
Supports any version of MongoDB
|
7
9
|
|
8
10
|
Learn more about mongoDB at: http://www.mongodb.org
|
9
11
|
|
10
12
|
== Install
|
11
13
|
|
12
|
-
|
14
|
+
<b>WARNING: This gem is still in alpha</b>
|
13
15
|
|
14
16
|
gem install mongify
|
15
17
|
|
16
18
|
== Usage
|
17
19
|
|
18
|
-
===
|
20
|
+
===Creating a configuration file
|
21
|
+
|
22
|
+
In order for Mongify to do it's job, it needs to know where your databases are located.
|
19
23
|
|
20
|
-
|
24
|
+
Building a config file is as simple as this:
|
21
25
|
|
22
26
|
sql_connection do
|
23
|
-
adaptor
|
24
|
-
host
|
25
|
-
|
27
|
+
adaptor "mysql"
|
28
|
+
host "localhost"
|
29
|
+
username "root"
|
30
|
+
password "passw0rd"
|
31
|
+
database "my_database"
|
26
32
|
end
|
27
33
|
|
28
34
|
mongodb_connection do
|
29
|
-
host
|
30
|
-
database
|
35
|
+
host "localhost"
|
36
|
+
database "my_collection"
|
31
37
|
end
|
38
|
+
|
39
|
+
You can check your configuration by running
|
40
|
+
mongify check -c datbase.config
|
41
|
+
|
42
|
+
<em>You can omit the mongodb connection till you're ready to process your translation</em>
|
32
43
|
|
33
|
-
Build a translation file such as:
|
34
44
|
|
35
|
-
|
45
|
+
=== Generating or create a translation
|
36
46
|
|
37
|
-
|
47
|
+
==== Generating a translation
|
48
|
+
If you're database is large and complex, it might be a bit too much to hand write the translation file, Mongify can help by running the translate command:
|
49
|
+
mongify transalte -c database.config
|
50
|
+
Or pipe it right into a file by running
|
51
|
+
mongify transalte -c database.config > translation_file.rb
|
38
52
|
|
39
|
-
|
40
|
-
|
53
|
+
==== Creating a translation
|
54
|
+
Creating a translation is pretty straight forward. It looks something like this:
|
55
|
+
|
56
|
+
table "users" do
|
57
|
+
column "id", :key
|
58
|
+
column "first_name", :string
|
59
|
+
column "last_name", :string
|
60
|
+
column "created_at", :datetime
|
61
|
+
column "updated_at", :datetime
|
41
62
|
end
|
42
63
|
|
43
|
-
|
64
|
+
table "posts" do
|
65
|
+
column "id", :key
|
66
|
+
column "title", :string
|
67
|
+
column "owner_id", :integer, :references => :users
|
68
|
+
column "body", :text
|
69
|
+
column "published_at", :datetime
|
70
|
+
column "created_at", :datetime
|
71
|
+
column "updated_at", :datetime
|
72
|
+
end
|
73
|
+
|
74
|
+
table "comments", :embed_in => :posts, :on => :post_id do
|
75
|
+
column "id", :key
|
76
|
+
column "body", :text
|
77
|
+
column "post_id", :integer, :referneces => :posts
|
78
|
+
column "user_id", :integer, :references => :users
|
79
|
+
column "created_at", :datetime
|
80
|
+
column "updated_at", :datetime
|
81
|
+
end
|
82
|
+
|
83
|
+
Save the file as <tt>"translation_file.rb"</tt> and run the command:
|
84
|
+
|
85
|
+
mongify process translation_file.rb -c database.config
|
86
|
+
|
87
|
+
== Translation Options
|
88
|
+
|
89
|
+
When dealing with a translation, there is a few options you can set
|
90
|
+
|
91
|
+
=== Table
|
92
|
+
|
93
|
+
Tables have the ability to be embedded into another collection on durring processing by passing :embed_in => 'collection_name'.
|
94
|
+
You can also specify :on option (while embedding) to specify which field you're linking the tables together on.
|
95
|
+
|
96
|
+
=== Columns
|
97
|
+
Columns take a few more options:
|
98
|
+
column "id", :key # Columns that are primary keys and need to be marked as :key
|
99
|
+
column "title", :string # Data from this column will be copied straight over without modification
|
100
|
+
column "body", :text # Since mongo doesn't care about text fields, this will just be converted to string
|
101
|
+
column "post_id", :integer, :referneces => :posts # Referenced columns need to be marked as such, this will mean that they will be updated
|
102
|
+
# with the new BSON::ObjectID.
|
103
|
+
column "created_at", :datetime # Specifying a field as :datetime will convert it to Time format as it
|
104
|
+
# gets imported into MongoDB
|
105
|
+
column "name" # Columns without a type will be set to :string
|
106
|
+
|
107
|
+
Leaving a column out of the list will just result in a straight copy of the information.
|
108
|
+
|
109
|
+
<em>**this is subject to change during the alpha (0.0.x release)**</em>
|
44
110
|
|
45
|
-
mongify check -c datbase.config
|
46
|
-
mongify process database_translation.rb -c database.config
|
47
|
-
|
48
|
-
**this is subject to change during the alpha (0.0.x release)**
|
49
111
|
|
50
112
|
== Notes
|
51
|
-
|
113
|
+
|
114
|
+
I have currently only tested this in Ruby 1.8.7-p330
|
115
|
+
|
52
116
|
More testing will be done once the basic functionality is done
|
53
|
-
|
117
|
+
|
118
|
+
|
119
|
+
== TODO
|
120
|
+
|
121
|
+
* Allow you to set a :force => true for mongodb_connection, so that it drops existing database before importing
|
122
|
+
|
123
|
+
=== while processing
|
124
|
+
|
125
|
+
* Allow the ability to embed_table with a one to one relationship
|
126
|
+
* Allow renaming tables
|
127
|
+
* Allow renaming of columns
|
128
|
+
* Allow deleting of columns
|
129
|
+
* Allow running a proc on column value
|
130
|
+
* Update user on what is being processed
|
131
|
+
|
132
|
+
|
54
133
|
== Development
|
134
|
+
|
55
135
|
=== Requirements
|
136
|
+
|
56
137
|
You just need bundler 1.0
|
57
|
-
|
138
|
+
|
58
139
|
gem install bundler
|
59
140
|
bundle install
|
60
141
|
copy over spec/support/database.example to spec/support/database.yml and fill in required info
|
61
142
|
rake test:mysql:setup
|
62
143
|
|
63
|
-
=== Setup
|
64
|
-
Before you can run the specs, you need to make sure to setup the spec/support/database.yml file with your database info
|
65
|
-
(you can copy database.example within the same folder).
|
66
|
-
|
67
144
|
== Special Thanks
|
145
|
+
|
68
146
|
Just want to thank my wife (Alessia) who not only puts up with me working on my free time but sometimes helps out listening to my craziness or helping me name classes or functions.
|
147
|
+
|
69
148
|
=== More Special Thanks
|
149
|
+
|
70
150
|
I'd like to thank Mon_Ouie on the Ruby IRC channel for helping me figure out how to setup the internal configuration file reading.
|
71
151
|
|
72
152
|
== License
|
73
153
|
|
74
154
|
Copyright (c) 2011 Andrew Kalek, Anlek Consulting
|
75
|
-
|
155
|
+
|
76
156
|
Permission is hereby granted, free of charge, to any person obtaining
|
77
157
|
a copy of this software and associated documentation files (the
|
78
158
|
"Software"), to deal in the Software without restriction, including
|
@@ -80,14 +160,14 @@ without limitation the rights to use, copy, modify, merge, publish,
|
|
80
160
|
distribute, sublicense, and/or sell copies of the Software, and to
|
81
161
|
permit persons to whom the Software is furnished to do so, subject to
|
82
162
|
the following conditions:
|
83
|
-
|
163
|
+
|
84
164
|
The above copyright notice and this permission notice shall be
|
85
165
|
included in all copies or substantial portions of the Software.
|
86
|
-
|
166
|
+
|
87
167
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
88
168
|
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
89
169
|
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
90
170
|
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
91
171
|
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
92
172
|
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
93
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
173
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/features/process.feature
CHANGED
@@ -3,19 +3,15 @@ Feature: Processing a translation
|
|
3
3
|
As a user
|
4
4
|
I want to be able to process a translation and move my data to mongodb!
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
6
|
+
@wip
|
7
|
+
Scenario: Process
|
8
|
+
Given a database exists
|
9
|
+
And a blank mongodb
|
10
10
|
When I run mongify process spec/files/simple_translation.rb -c spec/files/base_configuration.rb
|
11
11
|
Then it succeeds
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
12
|
+
And there should be 3 users in mongodb
|
13
|
+
And there should be 3 posts in mongodb
|
14
|
+
And the first post's owner_id should be first user
|
15
|
+
And there should be 0 comments in mongodb
|
16
|
+
And the first post should have 1 comment
|
20
17
|
|
21
|
-
|
data/lib/mongify/cli/options.rb
CHANGED
@@ -63,7 +63,7 @@ EOB
|
|
63
63
|
elsif @command_class == VersionCommand
|
64
64
|
VersionCommand.new(@parser.program_name)
|
65
65
|
else
|
66
|
-
raise ConfigurationFileNotFound unless @config_file
|
66
|
+
raise ConfigurationFileNotFound, "You need to provide a configuration file location #{@config_file}" unless @config_file
|
67
67
|
#TODO: In the future, request sql_connection and nosql_connection from user input
|
68
68
|
config = Configuration.parse(@config_file)
|
69
69
|
|
@@ -8,7 +8,7 @@ module Mongify
|
|
8
8
|
class BaseConnection
|
9
9
|
|
10
10
|
REQUIRED_FIELDS = %w{host}
|
11
|
-
AVAILABLE_FIELDS = %w{adapter host username password database socket port}
|
11
|
+
AVAILABLE_FIELDS = %w{adapter host username password database socket port encoding}
|
12
12
|
|
13
13
|
def initialize(options=nil)
|
14
14
|
if options
|
@@ -56,6 +56,10 @@ module Mongify
|
|
56
56
|
db[colleciton_name].find_one('pre_mongified_id' => pre_mongified_id).try(:[], '_id')
|
57
57
|
end
|
58
58
|
|
59
|
+
def remove_pre_mongified_ids(collection_name)
|
60
|
+
db[collection_name].update({}, { '$unset' => { 'pre_mongified_id' => 1} })
|
61
|
+
end
|
62
|
+
|
59
63
|
|
60
64
|
def reset!
|
61
65
|
@connection = nil
|
data/lib/mongify/translation.rb
CHANGED
@@ -23,7 +23,7 @@ module Mongify
|
|
23
23
|
connection.tables.each do |t|
|
24
24
|
columns = []
|
25
25
|
connection.columns_for(t).each do |ar_col|
|
26
|
-
columns << Mongify::Database::Column.new(ar_col.name, ar_col.type
|
26
|
+
columns << Mongify::Database::Column.new(ar_col.name, ar_col.type)
|
27
27
|
end
|
28
28
|
translation.table(t, :columns => columns)
|
29
29
|
end
|
@@ -22,6 +22,7 @@ module Mongify
|
|
22
22
|
copy_data
|
23
23
|
copy_embedded_tables
|
24
24
|
update_reference_ids
|
25
|
+
remove_pre_mongified_ids
|
25
26
|
nil
|
26
27
|
end
|
27
28
|
|
@@ -43,7 +44,9 @@ module Mongify
|
|
43
44
|
target_row = no_sql_connection.find_one(t.embed_in, {:pre_mongified_id => row[t.embed_on]})
|
44
45
|
next unless target_row.present?
|
45
46
|
row = t.translate(row)
|
47
|
+
row.delete(t.embed_on)
|
46
48
|
row.merge!(fetch_reference_ids(t, row))
|
49
|
+
row.delete('pre_mongified_id')
|
47
50
|
no_sql_connection.update(t.embed_in, target_row['_id'], {'$addToSet' => {t.name => row}})
|
48
51
|
end
|
49
52
|
end
|
@@ -68,12 +71,10 @@ module Mongify
|
|
68
71
|
attributes
|
69
72
|
end
|
70
73
|
|
74
|
+
def remove_pre_mongified_ids
|
75
|
+
self.copy_tables.each { |t| no_sql_connection.remove_pre_mongified_ids(t.name) }
|
76
|
+
end
|
77
|
+
|
71
78
|
end
|
72
79
|
end
|
73
|
-
end
|
74
|
-
|
75
|
-
|
76
|
-
# Process that needs to take place
|
77
|
-
# import the data (moving the id to premongified_id)
|
78
|
-
# fix all the references to the new ids
|
79
|
-
#
|
80
|
+
end
|
data/lib/mongify/version.rb
CHANGED
data/mongify.gemspec
CHANGED
@@ -15,6 +15,7 @@ Gem::Specification.new do |s|
|
|
15
15
|
|
16
16
|
s.add_dependency('activerecord', ">= 2.3.10")
|
17
17
|
s.add_dependency('activesupport', ">= 2.3.10")
|
18
|
+
s.add_dependency('mysql2')
|
18
19
|
s.add_dependency('mongo', ">= 1.1.5")
|
19
20
|
s.add_dependency('bson_ext', ">= 1.1.5")
|
20
21
|
s.add_dependency('net-ssh', ">= 2.0")
|
@@ -1,26 +1,26 @@
|
|
1
1
|
table "users" do
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
2
|
+
column "id", :key
|
3
|
+
column "first_name", :string
|
4
|
+
column "last_name", :string
|
5
|
+
column "created_at", :datetime
|
6
|
+
column "updated_at", :datetime
|
7
7
|
end
|
8
8
|
|
9
9
|
table "posts" do
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
10
|
+
column "id", :key
|
11
|
+
column "title", :string
|
12
|
+
column "owner_id", :integer, :references => :users
|
13
|
+
column "body", :text
|
14
|
+
column "published_at", :datetime
|
15
|
+
column "created_at", :datetime
|
16
|
+
column "updated_at", :datetime
|
17
17
|
end
|
18
18
|
|
19
19
|
table "comments", :embed_in => :posts, :on => :post_id do
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
end
|
20
|
+
column "id", :key
|
21
|
+
column "body", :text
|
22
|
+
column "post_id", :integer, :referneces => :posts
|
23
|
+
column "user_id", :integer, :references => :users
|
24
|
+
column "created_at", :datetime
|
25
|
+
column "updated_at", :datetime
|
26
|
+
end
|
@@ -91,10 +91,17 @@ describe Mongify::Database::Column do
|
|
91
91
|
@column = Mongify::Database::Column.new('first_name', :string)
|
92
92
|
@column.translate('bob').should == {'first_name' => 'bob'}
|
93
93
|
end
|
94
|
-
|
95
|
-
|
96
|
-
|
94
|
+
context "datetime" do
|
95
|
+
it "should return a datetime format" do
|
96
|
+
@column = Mongify::Database::Column.new('created_at', :datetime)
|
97
|
+
@column.translate('2011-01-14 21:23:39').should == {'created_at' => Time.utc(2011, 01, 14, 21, 23,39)}
|
98
|
+
end
|
99
|
+
it "should return nil if input is nil" do
|
100
|
+
@column = Mongify::Database::Column.new('created_at', :datetime)
|
101
|
+
@column.translate(nil).should == {'created_at' => nil}
|
102
|
+
end
|
97
103
|
end
|
104
|
+
|
98
105
|
it "should return pre_mongified_id when type is a key" do
|
99
106
|
@column = Mongify::Database::Column.new('id', :key)
|
100
107
|
@column.translate(123123).should == {"pre_mongified_id" => 123123}
|
@@ -117,6 +117,13 @@ describe Mongify::Database::NoSqlConnection do
|
|
117
117
|
@mongodb_connection.find_one('users', query)
|
118
118
|
end
|
119
119
|
end
|
120
|
+
|
121
|
+
context "remove_pre_mongified_ids" do
|
122
|
+
it "should call update with unset" do
|
123
|
+
@collection.should_receive(:update).with({},{'$unset' => {'pre_mongified_id' => 1}})
|
124
|
+
@mongodb_connection.remove_pre_mongified_ids('users')
|
125
|
+
end
|
126
|
+
end
|
120
127
|
end
|
121
128
|
|
122
129
|
|
@@ -16,17 +16,33 @@ describe Mongify::Translation::Process do
|
|
16
16
|
lambda { @translation.process(@sql_connection, 'bad param2') }.should raise_error(Mongify::NoSqlConnectionRequired)
|
17
17
|
end
|
18
18
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
19
|
+
describe "process" do
|
20
|
+
before(:each) do
|
21
|
+
@translation.stub(:remove_pre_mongified_ids)
|
22
|
+
@translation.stub(:update_reference_ids)
|
23
|
+
@translation.stub(:copy_data)
|
24
|
+
@translation.stub(:copy_embedded_tables)
|
25
|
+
end
|
26
|
+
it "should call copy_data" do
|
27
|
+
@translation.should_receive(:copy_data)
|
28
|
+
@translation.process(@sql_connection, @no_sql_connection)
|
29
|
+
end
|
30
|
+
it "should call update_reference_ids" do
|
31
|
+
@translation.should_receive(:update_reference_ids)
|
32
|
+
@translation.process(@sql_connection, @no_sql_connection)
|
33
|
+
end
|
34
|
+
it "should call copy_embedded_tables" do
|
35
|
+
@translation.should_receive(:copy_embedded_tables)
|
36
|
+
@translation.process(@sql_connection, @no_sql_connection)
|
37
|
+
end
|
38
|
+
it "shuld call remove_pre_mongified_ids" do
|
39
|
+
@translation.should_receive(:remove_pre_mongified_ids)
|
40
|
+
@translation.process(@sql_connection, @no_sql_connection)
|
41
|
+
end
|
28
42
|
end
|
29
43
|
|
44
|
+
|
45
|
+
|
30
46
|
context "fetch_reference_ids" do
|
31
47
|
it "should get correct information" do
|
32
48
|
@no_sql_connection = mock()
|
@@ -63,6 +79,7 @@ describe Mongify::Translation::Process do
|
|
63
79
|
before(:each) do
|
64
80
|
@target_table = mock(:name => 'posts', :embed? => false)
|
65
81
|
@embed_table = mock(:translate => {}, :name => 'comments', :embed? => true, :embed_on => 'post_id', :embed_in => 'posts')
|
82
|
+
@no_sql_connection.stub(:find_one).and_return({'_id' => 500})
|
66
83
|
@translation.stub(:tables).and_return([@target_table, @embed_table])
|
67
84
|
@translation.stub(:fetch_reference_ids).and_return({})
|
68
85
|
end
|
@@ -72,6 +89,18 @@ describe Mongify::Translation::Process do
|
|
72
89
|
@no_sql_connection.should_receive(:update)
|
73
90
|
@translation.send(:copy_embedded_tables)
|
74
91
|
end
|
92
|
+
it "should remove the pre_mongified_id before embedding" do
|
93
|
+
@embed_table = mock(:translate => {'first_name' => 'bob', 'pre_mongified_id' => 1}, :name => 'comments', :embed? => true, :embed_on => 'post_id', :embed_in => 'posts')
|
94
|
+
@translation.stub(:tables).and_return([@target_table, @embed_table])
|
95
|
+
@no_sql_connection.should_receive(:update).with("posts", 500, {"$addToSet"=>{"comments"=>{'first_name' => 'bob'}}})
|
96
|
+
@translation.send(:copy_embedded_tables)
|
97
|
+
end
|
98
|
+
it "should remove the parent_id from the embedding row" do
|
99
|
+
@embed_table = mock(:translate => {'first_name' => 'bob', 'post_id' => 1}, :name => 'comments', :embed? => true, :embed_on => 'post_id', :embed_in => 'posts')
|
100
|
+
@translation.stub(:tables).and_return([@target_table, @embed_table])
|
101
|
+
@no_sql_connection.should_receive(:update).with("posts", 500, {"$addToSet"=>{"comments"=>{'first_name' => 'bob'}}})
|
102
|
+
@translation.send(:copy_embedded_tables)
|
103
|
+
end
|
75
104
|
end
|
76
105
|
|
77
106
|
context "update_reference_ids" do
|
@@ -90,5 +119,12 @@ describe Mongify::Translation::Process do
|
|
90
119
|
@translation.send(:update_reference_ids)
|
91
120
|
end
|
92
121
|
end
|
122
|
+
|
123
|
+
context "remove_pre_mongified_ids" do
|
124
|
+
it "should remove_pre_mongified_ids on no_sql_connection" do
|
125
|
+
@no_sql_connection.should_receive(:remove_pre_mongified_ids).with(anything)
|
126
|
+
@translation.send(:remove_pre_mongified_ids)
|
127
|
+
end
|
128
|
+
end
|
93
129
|
end
|
94
130
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mongify
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 17
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 7
|
10
|
+
version: 0.0.7
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Andrew Kalek
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-01-
|
18
|
+
date: 2011-01-17 00:00:00 -05:00
|
19
19
|
default_executable: mongify
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -51,9 +51,23 @@ dependencies:
|
|
51
51
|
type: :runtime
|
52
52
|
version_requirements: *id002
|
53
53
|
- !ruby/object:Gem::Dependency
|
54
|
-
name:
|
54
|
+
name: mysql2
|
55
55
|
prerelease: false
|
56
56
|
requirement: &id003 !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
hash: 3
|
62
|
+
segments:
|
63
|
+
- 0
|
64
|
+
version: "0"
|
65
|
+
type: :runtime
|
66
|
+
version_requirements: *id003
|
67
|
+
- !ruby/object:Gem::Dependency
|
68
|
+
name: mongo
|
69
|
+
prerelease: false
|
70
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
57
71
|
none: false
|
58
72
|
requirements:
|
59
73
|
- - ">="
|
@@ -65,11 +79,11 @@ dependencies:
|
|
65
79
|
- 5
|
66
80
|
version: 1.1.5
|
67
81
|
type: :runtime
|
68
|
-
version_requirements: *
|
82
|
+
version_requirements: *id004
|
69
83
|
- !ruby/object:Gem::Dependency
|
70
84
|
name: bson_ext
|
71
85
|
prerelease: false
|
72
|
-
requirement: &
|
86
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
73
87
|
none: false
|
74
88
|
requirements:
|
75
89
|
- - ">="
|
@@ -81,11 +95,11 @@ dependencies:
|
|
81
95
|
- 5
|
82
96
|
version: 1.1.5
|
83
97
|
type: :runtime
|
84
|
-
version_requirements: *
|
98
|
+
version_requirements: *id005
|
85
99
|
- !ruby/object:Gem::Dependency
|
86
100
|
name: net-ssh
|
87
101
|
prerelease: false
|
88
|
-
requirement: &
|
102
|
+
requirement: &id006 !ruby/object:Gem::Requirement
|
89
103
|
none: false
|
90
104
|
requirements:
|
91
105
|
- - ">="
|
@@ -96,11 +110,11 @@ dependencies:
|
|
96
110
|
- 0
|
97
111
|
version: "2.0"
|
98
112
|
type: :runtime
|
99
|
-
version_requirements: *
|
113
|
+
version_requirements: *id006
|
100
114
|
- !ruby/object:Gem::Dependency
|
101
115
|
name: rspec
|
102
116
|
prerelease: false
|
103
|
-
requirement: &
|
117
|
+
requirement: &id007 !ruby/object:Gem::Requirement
|
104
118
|
none: false
|
105
119
|
requirements:
|
106
120
|
- - ">="
|
@@ -111,11 +125,11 @@ dependencies:
|
|
111
125
|
- 0
|
112
126
|
version: "2.0"
|
113
127
|
type: :development
|
114
|
-
version_requirements: *
|
128
|
+
version_requirements: *id007
|
115
129
|
- !ruby/object:Gem::Dependency
|
116
130
|
name: rcov
|
117
131
|
prerelease: false
|
118
|
-
requirement: &
|
132
|
+
requirement: &id008 !ruby/object:Gem::Requirement
|
119
133
|
none: false
|
120
134
|
requirements:
|
121
135
|
- - ">="
|
@@ -127,11 +141,11 @@ dependencies:
|
|
127
141
|
- 9
|
128
142
|
version: 0.9.9
|
129
143
|
type: :development
|
130
|
-
version_requirements: *
|
144
|
+
version_requirements: *id008
|
131
145
|
- !ruby/object:Gem::Dependency
|
132
146
|
name: cucumber
|
133
147
|
prerelease: false
|
134
|
-
requirement: &
|
148
|
+
requirement: &id009 !ruby/object:Gem::Requirement
|
135
149
|
none: false
|
136
150
|
requirements:
|
137
151
|
- - ">="
|
@@ -142,11 +156,11 @@ dependencies:
|
|
142
156
|
- 10
|
143
157
|
version: "0.10"
|
144
158
|
type: :development
|
145
|
-
version_requirements: *
|
159
|
+
version_requirements: *id009
|
146
160
|
- !ruby/object:Gem::Dependency
|
147
161
|
name: mocha
|
148
162
|
prerelease: false
|
149
|
-
requirement: &
|
163
|
+
requirement: &id010 !ruby/object:Gem::Requirement
|
150
164
|
none: false
|
151
165
|
requirements:
|
152
166
|
- - ">="
|
@@ -158,11 +172,11 @@ dependencies:
|
|
158
172
|
- 8
|
159
173
|
version: 0.9.8
|
160
174
|
type: :development
|
161
|
-
version_requirements: *
|
175
|
+
version_requirements: *id010
|
162
176
|
- !ruby/object:Gem::Dependency
|
163
177
|
name: yard
|
164
178
|
prerelease: false
|
165
|
-
requirement: &
|
179
|
+
requirement: &id011 !ruby/object:Gem::Requirement
|
166
180
|
none: false
|
167
181
|
requirements:
|
168
182
|
- - ">="
|
@@ -174,11 +188,11 @@ dependencies:
|
|
174
188
|
- 3
|
175
189
|
version: 0.5.3
|
176
190
|
type: :development
|
177
|
-
version_requirements: *
|
191
|
+
version_requirements: *id011
|
178
192
|
- !ruby/object:Gem::Dependency
|
179
193
|
name: watchr
|
180
194
|
prerelease: false
|
181
|
-
requirement: &
|
195
|
+
requirement: &id012 !ruby/object:Gem::Requirement
|
182
196
|
none: false
|
183
197
|
requirements:
|
184
198
|
- - ">="
|
@@ -189,11 +203,11 @@ dependencies:
|
|
189
203
|
- 6
|
190
204
|
version: "0.6"
|
191
205
|
type: :development
|
192
|
-
version_requirements: *
|
206
|
+
version_requirements: *id012
|
193
207
|
- !ruby/object:Gem::Dependency
|
194
208
|
name: sqlite3-ruby
|
195
209
|
prerelease: false
|
196
|
-
requirement: &
|
210
|
+
requirement: &id013 !ruby/object:Gem::Requirement
|
197
211
|
none: false
|
198
212
|
requirements:
|
199
213
|
- - ">="
|
@@ -204,11 +218,11 @@ dependencies:
|
|
204
218
|
- 3
|
205
219
|
version: "1.3"
|
206
220
|
type: :development
|
207
|
-
version_requirements: *
|
221
|
+
version_requirements: *id013
|
208
222
|
- !ruby/object:Gem::Dependency
|
209
223
|
name: mysql
|
210
224
|
prerelease: false
|
211
|
-
requirement: &
|
225
|
+
requirement: &id014 !ruby/object:Gem::Requirement
|
212
226
|
none: false
|
213
227
|
requirements:
|
214
228
|
- - ">="
|
@@ -220,7 +234,7 @@ dependencies:
|
|
220
234
|
- 1
|
221
235
|
version: 2.8.1
|
222
236
|
type: :development
|
223
|
-
version_requirements: *
|
237
|
+
version_requirements: *id014
|
224
238
|
description: Mongify allows you to map your sql data into a mongodb document database.
|
225
239
|
email:
|
226
240
|
- andrew.kalek@anlek.com
|