mongify 1.2.4 → 1.3.0
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.
- checksums.yaml +4 -4
- data/.gitignore +3 -1
- data/CHANGELOG.rdoc +10 -0
- data/Gemfile.lock +94 -87
- data/README.rdoc +7 -0
- data/Rakefile +59 -32
- data/features/step_definitions/process_steps.rb +1 -1
- data/lib/mongify/database/column.rb +7 -9
- data/lib/mongify/translation/sync.rb +3 -1
- data/lib/mongify/version.rb +1 -1
- data/mongify.gemspec +9 -8
- data/spec/mongify/cli/command/help_spec.rb +1 -1
- data/spec/mongify/cli/command/version_spec.rb +1 -1
- data/spec/mongify/cli/worker_command_spec.rb +8 -8
- data/spec/mongify/database/base_connection_spec.rb +1 -1
- data/spec/mongify/database/column_spec.rb +6 -6
- data/spec/mongify/database/data_row_spec.rb +3 -3
- data/spec/mongify/database/no_sql_connection_spec.rb +6 -6
- data/spec/mongify/database/sql_connection_spec.rb +5 -5
- data/spec/mongify/database/table_spec.rb +5 -5
- data/spec/mongify/status_spec.rb +1 -1
- data/spec/mongify/translation/process_spec.rb +24 -24
- data/spec/mongify/translation/sync_spec.rb +12 -12
- data/spec/mongify/translation_spec.rb +8 -8
- data/spec/mongify/ui_spec.rb +3 -3
- data/spec/spec_helper.rb +1 -0
- data/spec/support/database.example +9 -0
- data/spec/support/database_generator.rb +7 -7
- metadata +67 -53
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1b8acafd0be6a12f8eb24750b59af5748aaf41b0
|
4
|
+
data.tar.gz: ee61b8d9b9cbbdf81cb58e443d39f662c982048b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 87d7fed9f8548673b99a170f0171977459630e9efcd107a846467eca69a0b980465c50b69a30a9111107c554f483997756c7313b4c47b3933d60162aa0416e06
|
7
|
+
data.tar.gz: f3c84de2581d41a28a79dd386992f54b2bac3e68e026700cfc10325939872442bafe63fc853ee3b67cb54d719c539b033a2953484016d51fb5dffe2b583af672
|
data/.gitignore
CHANGED
data/CHANGELOG.rdoc
CHANGED
@@ -1,3 +1,13 @@
|
|
1
|
+
== 1.3.0 / 07 May 2016
|
2
|
+
* Updated gem requirements to ActiveRecord 4.2
|
3
|
+
* Updated type casting to ActiveRecord 4.2 style.
|
4
|
+
* NOTE: Timezone is set to UTC by default in the database
|
5
|
+
* Removed tons of deprication warnings during tests
|
6
|
+
* Improved contribution set-up rake tasks
|
7
|
+
* Included Postgres config for Contributors (NOTE: No tests for this)
|
8
|
+
* Ensured updated_at doesn't get parsed multiple times in `sync` command (thanks @hammady)
|
9
|
+
* Improved error message during `sync` command (thanks @hammady)
|
10
|
+
* Minor bug fixes
|
1
11
|
== 1.2.4 / 29 July 2014
|
2
12
|
* Fixed bug with ActiveSupport::Autoload (thanks [altieres](https://github.com/anlek/mongify/pull/46))
|
3
13
|
* Moved the order of reference updating to be second (after copying tables), this way embed tables can use new references
|
data/Gemfile.lock
CHANGED
@@ -1,124 +1,131 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
mongify (1.
|
5
|
-
activerecord (
|
6
|
-
activesupport (
|
7
|
-
bson (
|
8
|
-
bson_ext (
|
4
|
+
mongify (1.3.0)
|
5
|
+
activerecord (>= 4.2)
|
6
|
+
activesupport (>= 4.2)
|
7
|
+
bson (>= 1.10.2)
|
8
|
+
bson_ext (>= 1.10.2)
|
9
9
|
highline (>= 1.6.1)
|
10
|
-
mongo (
|
10
|
+
mongo (>= 1.10.2)
|
11
11
|
|
12
12
|
GEM
|
13
13
|
remote: http://rubygems.org/
|
14
14
|
specs:
|
15
|
-
activemodel (
|
16
|
-
activesupport (=
|
17
|
-
builder (~> 3.
|
18
|
-
activerecord (
|
19
|
-
activemodel (=
|
20
|
-
activesupport (=
|
21
|
-
arel (~>
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
bson (1.
|
31
|
-
bson_ext (1.
|
32
|
-
bson (~> 1.
|
33
|
-
builder (3.
|
34
|
-
|
35
|
-
|
36
|
-
|
15
|
+
activemodel (4.2.6)
|
16
|
+
activesupport (= 4.2.6)
|
17
|
+
builder (~> 3.1)
|
18
|
+
activerecord (4.2.6)
|
19
|
+
activemodel (= 4.2.6)
|
20
|
+
activesupport (= 4.2.6)
|
21
|
+
arel (~> 6.0)
|
22
|
+
activesupport (4.2.6)
|
23
|
+
i18n (~> 0.7)
|
24
|
+
json (~> 1.7, >= 1.7.7)
|
25
|
+
minitest (~> 5.1)
|
26
|
+
thread_safe (~> 0.3, >= 0.3.4)
|
27
|
+
tzinfo (~> 1.1)
|
28
|
+
arel (6.0.3)
|
29
|
+
awesome_print (1.6.1)
|
30
|
+
bson (1.12.5)
|
31
|
+
bson_ext (1.12.5)
|
32
|
+
bson (~> 1.12.5)
|
33
|
+
builder (3.2.2)
|
34
|
+
byebug (2.7.0)
|
35
|
+
columnize (~> 0.3)
|
36
|
+
debugger-linecache (~> 1.2)
|
37
|
+
coderay (1.1.1)
|
38
|
+
columnize (0.9.0)
|
39
|
+
coolline (0.5.0)
|
40
|
+
unicode_utils (~> 1.4)
|
41
|
+
cucumber (2.3.3)
|
37
42
|
builder (>= 2.1.2)
|
43
|
+
cucumber-core (~> 1.4.0)
|
44
|
+
cucumber-wire (~> 0.0.1)
|
38
45
|
diff-lcs (>= 1.1.3)
|
39
|
-
gherkin (~> 2.
|
46
|
+
gherkin (~> 3.2.0)
|
40
47
|
multi_json (>= 1.7.5, < 2.0)
|
41
|
-
multi_test (>= 0.1.
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
debugger-linecache (~> 1.2.0)
|
46
|
-
debugger-ruby_core_source (~> 1.3.5)
|
48
|
+
multi_test (>= 0.1.2)
|
49
|
+
cucumber-core (1.4.0)
|
50
|
+
gherkin (~> 3.2.0)
|
51
|
+
cucumber-wire (0.0.1)
|
47
52
|
debugger-linecache (1.2.0)
|
48
|
-
debugger-ruby_core_source (1.3.5)
|
49
53
|
diff-lcs (1.2.5)
|
50
|
-
gherkin (2.
|
51
|
-
|
52
|
-
|
53
|
-
i18n (0.
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
54
|
+
gherkin (3.2.0)
|
55
|
+
highline (1.7.8)
|
56
|
+
hirb (0.7.3)
|
57
|
+
i18n (0.7.0)
|
58
|
+
jazz_fingers (3.0.2)
|
59
|
+
awesome_print (~> 1.6)
|
60
|
+
hirb (~> 0.7)
|
61
|
+
pry (~> 0.10)
|
62
|
+
pry-byebug (= 1.3.3)
|
63
|
+
pry-coolline (~> 0.2)
|
64
|
+
pry-doc (~> 0.6)
|
65
|
+
pry-remote (>= 0.1.7)
|
66
|
+
json (1.8.3)
|
58
67
|
metaclass (0.0.4)
|
59
68
|
method_source (0.8.2)
|
69
|
+
minitest (5.8.4)
|
60
70
|
mocha (1.1.0)
|
61
71
|
metaclass (~> 0.0.1)
|
62
|
-
mongo (1.
|
63
|
-
bson (= 1.
|
64
|
-
multi_json (1.
|
65
|
-
multi_test (0.1.
|
66
|
-
mysql2 (0.
|
67
|
-
pg (0.
|
68
|
-
pry (0.10.
|
72
|
+
mongo (1.12.5)
|
73
|
+
bson (= 1.12.5)
|
74
|
+
multi_json (1.12.0)
|
75
|
+
multi_test (0.1.2)
|
76
|
+
mysql2 (0.4.4)
|
77
|
+
pg (0.18.4)
|
78
|
+
pry (0.10.3)
|
69
79
|
coderay (~> 1.1.0)
|
70
80
|
method_source (~> 0.8.1)
|
71
81
|
slop (~> 3.4)
|
72
|
-
pry-
|
73
|
-
|
74
|
-
pry (
|
75
|
-
pry-
|
82
|
+
pry-byebug (1.3.3)
|
83
|
+
byebug (~> 2.7)
|
84
|
+
pry (~> 0.10)
|
85
|
+
pry-coolline (0.2.5)
|
86
|
+
coolline (~> 0.5)
|
87
|
+
pry-doc (0.8.0)
|
76
88
|
pry (~> 0.9)
|
77
89
|
yard (~> 0.8)
|
78
|
-
pry-
|
79
|
-
pry
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
interception (>= 0.5)
|
91
|
-
pry
|
92
|
-
pry-stack_explorer (0.4.9.1)
|
93
|
-
binding_of_caller (>= 0.7)
|
94
|
-
pry (>= 0.9.11)
|
95
|
-
rake (10.3.2)
|
96
|
-
rspec (2.14.1)
|
97
|
-
rspec-core (~> 2.14.0)
|
98
|
-
rspec-expectations (~> 2.14.0)
|
99
|
-
rspec-mocks (~> 2.14.0)
|
100
|
-
rspec-core (2.14.7)
|
101
|
-
rspec-expectations (2.14.4)
|
90
|
+
pry-remote (0.1.8)
|
91
|
+
pry (~> 0.9)
|
92
|
+
slop (~> 3.0)
|
93
|
+
rake (11.1.2)
|
94
|
+
rspec (2.99.0)
|
95
|
+
rspec-core (~> 2.99.0)
|
96
|
+
rspec-expectations (~> 2.99.0)
|
97
|
+
rspec-mocks (~> 2.99.0)
|
98
|
+
rspec-collection_matchers (1.1.2)
|
99
|
+
rspec-expectations (>= 2.99.0.beta1)
|
100
|
+
rspec-core (2.99.2)
|
101
|
+
rspec-expectations (2.99.2)
|
102
102
|
diff-lcs (>= 1.1.3, < 2.0)
|
103
|
-
rspec-mocks (2.
|
104
|
-
slop (3.
|
105
|
-
sqlite3 (1.3.
|
106
|
-
|
103
|
+
rspec-mocks (2.99.4)
|
104
|
+
slop (3.6.0)
|
105
|
+
sqlite3 (1.3.11)
|
106
|
+
thread_safe (0.3.5)
|
107
|
+
tzinfo (1.2.2)
|
108
|
+
thread_safe (~> 0.1)
|
109
|
+
unicode_utils (1.4.0)
|
107
110
|
watchr (0.7)
|
108
|
-
yard (0.8.7.
|
111
|
+
yard (0.8.7.6)
|
109
112
|
|
110
113
|
PLATFORMS
|
111
114
|
ruby
|
112
115
|
|
113
116
|
DEPENDENCIES
|
114
117
|
cucumber (>= 0.10)
|
118
|
+
jazz_fingers
|
115
119
|
mocha (>= 0.9.8)
|
116
120
|
mongify!
|
117
|
-
mysql2 (
|
121
|
+
mysql2 (>= 0.4)
|
118
122
|
pg (>= 0.17)
|
119
|
-
pry-plus
|
120
123
|
rake
|
121
124
|
rspec (~> 2.0)
|
125
|
+
rspec-collection_matchers (~> 1.0)
|
122
126
|
sqlite3 (>= 1.3)
|
123
127
|
watchr (>= 0.6)
|
124
|
-
yard (>= 0.
|
128
|
+
yard (>= 0.8)
|
129
|
+
|
130
|
+
BUNDLED WITH
|
131
|
+
1.11.2
|
data/README.rdoc
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
= Mongify
|
2
2
|
|
3
|
+
{<img src="https://badges.gitter.im/Join%20Chat.svg" alt="Join the chat at https://gitter.im/anlek/mongify">}[https://gitter.im/anlek/mongify?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge]
|
4
|
+
|
3
5
|
http://mongify.com
|
4
6
|
|
5
7
|
A data translator from sql database to mongoDB.
|
@@ -15,6 +17,10 @@ Learn more about MongoDB at: http://www.mongodb.org
|
|
15
17
|
|
16
18
|
gem install mongify
|
17
19
|
|
20
|
+
=== NOTICE
|
21
|
+
|
22
|
+
You might have to install active record database gems (you'll know if you get an error message while running mongify command)
|
23
|
+
|
18
24
|
== Usage
|
19
25
|
|
20
26
|
=== Creating a configuration file
|
@@ -38,6 +44,7 @@ Building a config file is as simple as this:
|
|
38
44
|
end
|
39
45
|
|
40
46
|
You can check your configuration by running
|
47
|
+
|
41
48
|
mongify check database.config
|
42
49
|
|
43
50
|
==== Options
|
data/Rakefile
CHANGED
@@ -4,7 +4,6 @@ Bundler::GemHelper.install_tasks
|
|
4
4
|
require 'cucumber/rake/task'
|
5
5
|
require 'rspec/core/rake_task'
|
6
6
|
|
7
|
-
|
8
7
|
task :cleanup_rcov_files do
|
9
8
|
rm_rf 'coverage.data'
|
10
9
|
end
|
@@ -13,7 +12,6 @@ desc 'clobber generated files'
|
|
13
12
|
task :clobber do
|
14
13
|
rm_rf "pkg"
|
15
14
|
rm_rf "tmp"
|
16
|
-
rm "Gemfile.lock" if File.exist?("Gemfile.lock")
|
17
15
|
end
|
18
16
|
|
19
17
|
if RUBY_VERSION.to_f == 1.8
|
@@ -52,64 +50,93 @@ namespace :test do
|
|
52
50
|
Cucumber::Rake::Task.new(:cucumber)
|
53
51
|
|
54
52
|
namespace :setup do
|
55
|
-
|
56
|
-
|
53
|
+
task :environment do
|
54
|
+
require 'mongify'
|
57
55
|
require './spec/support/config_reader'
|
56
|
+
require 'yaml'
|
57
|
+
end
|
58
|
+
|
59
|
+
desc "Setup a postgresql database based on the spec/support/database.yml settings (under postgresql)"
|
60
|
+
task postgresql: :environment do
|
58
61
|
require 'active_record'
|
62
|
+
require 'pg'
|
63
|
+
|
59
64
|
::CONNECTION_CONFIG = ConfigReader.new('spec/support/database.yml')
|
65
|
+
|
66
|
+
create_pg_database(CONNECTION_CONFIG)
|
67
|
+
|
60
68
|
ActiveRecord::Base.establish_connection(CONNECTION_CONFIG.postgresql)
|
61
69
|
conn = ActiveRecord::Base.connection
|
62
|
-
conn.create_table(:users, :force => true) do |t|
|
63
|
-
t.string :first_name, :last_name
|
64
|
-
t.timestamps
|
65
|
-
end
|
66
70
|
|
67
|
-
conn
|
68
|
-
t.string :title
|
69
|
-
t.integer :owner_id
|
70
|
-
t.text :body
|
71
|
-
t.datetime :published_at
|
72
|
-
t.timestamps
|
73
|
-
end
|
71
|
+
build_tables(conn)
|
74
72
|
|
75
|
-
|
76
|
-
t.text :body
|
77
|
-
t.integer :post_id
|
78
|
-
t.integer :user_id
|
79
|
-
t.timestamps
|
80
|
-
end
|
81
|
-
puts "Finished"
|
73
|
+
puts "Database Setup Finished"
|
82
74
|
end
|
83
75
|
|
84
76
|
desc "Setup a mysql database based on the spec/support/database.yml settings"
|
85
|
-
task :
|
86
|
-
require '
|
77
|
+
task mysql: :environment do
|
78
|
+
require 'mysql2'
|
87
79
|
require 'active_record'
|
80
|
+
|
88
81
|
::CONNECTION_CONFIG = ConfigReader.new('spec/support/database.yml')
|
82
|
+
|
83
|
+
create_mysql_database(CONNECTION_CONFIG)
|
84
|
+
|
89
85
|
ActiveRecord::Base.establish_connection(CONNECTION_CONFIG.mysql)
|
90
86
|
conn = ActiveRecord::Base.connection
|
91
|
-
|
87
|
+
|
88
|
+
build_tables(conn)
|
89
|
+
|
90
|
+
puts "Database Setup Finished"
|
91
|
+
end
|
92
|
+
|
93
|
+
#######
|
94
|
+
private
|
95
|
+
#######
|
96
|
+
|
97
|
+
def build_tables(conn)
|
98
|
+
conn.create_table(:users, force: true) do |t|
|
92
99
|
t.string :first_name, :last_name
|
93
|
-
t.timestamps
|
100
|
+
t.timestamps null: false
|
94
101
|
end
|
95
102
|
|
96
|
-
conn.create_table(:posts, :
|
103
|
+
conn.create_table(:posts, force: true) do |t|
|
97
104
|
t.string :title
|
98
105
|
t.integer :owner_id
|
99
106
|
t.text :body
|
100
107
|
t.datetime :published_at
|
101
|
-
t.timestamps
|
108
|
+
t.timestamps null: false
|
102
109
|
end
|
103
110
|
|
104
|
-
conn.create_table(:comments, :
|
111
|
+
conn.create_table(:comments, force: true) do |t|
|
105
112
|
t.text :body
|
106
113
|
t.integer :post_id
|
107
114
|
t.integer :user_id
|
108
|
-
t.timestamps
|
115
|
+
t.timestamps null: false
|
109
116
|
end
|
110
|
-
|
117
|
+
end
|
118
|
+
|
119
|
+
def create_mysql_database(config)
|
120
|
+
client = Mysql2::Client.new(host: config.mysql["host"] || "localhost",
|
121
|
+
username: config.mysql["username"] || "root",
|
122
|
+
password: config.mysql["password"])
|
123
|
+
|
124
|
+
client.query("CREATE DATABASE IF NOT EXISTS #{config.mysql["database"]}")
|
125
|
+
client.close
|
126
|
+
end
|
127
|
+
|
128
|
+
def create_pg_database(config)
|
129
|
+
client = PG.connect(host: config.postgresql["host"] || "localhost",
|
130
|
+
dbname: 'postgres',
|
131
|
+
user: config.postgresql["username"] || "root",
|
132
|
+
password: config.postgresql["password"])
|
133
|
+
|
134
|
+
missing_db = client.exec("SELECT 1 FROM pg_database where datname='#{config.postgresql["database"]}'").values.empty?
|
135
|
+
client.exec("CREATE DATABASE #{config.postgresql["database"]}") if missing_db
|
136
|
+
client.flush
|
137
|
+
client.close
|
111
138
|
end
|
112
139
|
end
|
113
140
|
end
|
114
141
|
|
115
|
-
task :
|
142
|
+
task default: ['test']
|
@@ -5,7 +5,7 @@ end
|
|
5
5
|
|
6
6
|
Then /^the (first|second|third) ([^\s]+)'s ([^\s]+) attribute should( not)? be present$/ do |collection_place, collection_name, field, negate|
|
7
7
|
DatabaseGenerator.mongo_connection.db[collection_name.pluralize].
|
8
|
-
find.to_a.send(collection_place.to_sym).has_key?(field).should (negate ?
|
8
|
+
find.to_a.send(collection_place.to_sym).has_key?(field).should (negate ? be_falsey : be_truthy)
|
9
9
|
end
|
10
10
|
|
11
11
|
Then /^the (first|second|third) ([^\s]+)'s ([^\s]+)'s ([^\s]+) attribute should be (.+)$/ do |collection_place, collection_name, embedded_name, field, value|
|
@@ -237,18 +237,18 @@ module Mongify
|
|
237
237
|
when :integer then value.to_i
|
238
238
|
when :float then value.to_f
|
239
239
|
when :decimal
|
240
|
-
value = ActiveRecord::
|
240
|
+
value = ActiveRecord::Type::Decimal.new.type_cast_from_database(value)
|
241
241
|
if as_integer?
|
242
242
|
(value * (10 ** self.scale)).round.to_i
|
243
243
|
else
|
244
244
|
value.to_s
|
245
245
|
end
|
246
|
-
when :datetime then ActiveRecord::
|
247
|
-
when :timestamp then ActiveRecord::
|
248
|
-
when :time then ActiveRecord::
|
249
|
-
when :date then ActiveRecord::
|
250
|
-
when :binary then ActiveRecord::
|
251
|
-
when :boolean then ActiveRecord::
|
246
|
+
when :datetime then ActiveRecord::Type::DateTime.new.type_cast_from_database(value)
|
247
|
+
when :timestamp then ActiveRecord::Type::DateTime.new.type_cast_from_database(value)
|
248
|
+
when :time then ActiveRecord::Type::Time.new.type_cast_from_database(value)
|
249
|
+
when :date then ActiveRecord::Type::DateTime.new.type_cast_from_database(value)
|
250
|
+
when :binary then ActiveRecord::Type::Binary.new.type_cast_from_database(value)
|
251
|
+
when :boolean then ActiveRecord::Type::Boolean.new.type_cast_from_database(value)
|
252
252
|
else value.to_s
|
253
253
|
end
|
254
254
|
end
|
@@ -261,8 +261,6 @@ module Mongify
|
|
261
261
|
def run_auto_detect!
|
262
262
|
self.class.auto_detect(self) if auto_detect?
|
263
263
|
end
|
264
|
-
|
265
|
-
|
266
264
|
end
|
267
265
|
end
|
268
266
|
end
|