mongify 1.2.4 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d776c4e2b8bf22a98623d59b45e4bf75be2cc0e3
4
- data.tar.gz: b5ab7a5eb421002ba78fd81a6ccd5761deb4a18e
3
+ metadata.gz: 1b8acafd0be6a12f8eb24750b59af5748aaf41b0
4
+ data.tar.gz: ee61b8d9b9cbbdf81cb58e443d39f662c982048b
5
5
  SHA512:
6
- metadata.gz: c068b8eaf519cd59a4b849480e9f63092ab5c5580feac75e7bb6b06be8f75f5ea8a2c25ceb9e5f7a85d4fb99d32a53a989ce0e0600f2dfde82484d5907fd7e7b
7
- data.tar.gz: eff866a595049a1a6b52a21eb17d966cfb8e9576cde47938becc4d6b527ed2d122f694dcad77c7f60f7e8bd04a1533994967a982430c4c0be55af087280440a3
6
+ metadata.gz: 87d7fed9f8548673b99a170f0171977459630e9efcd107a846467eca69a0b980465c50b69a30a9111107c554f483997756c7313b4c47b3933d60162aa0416e06
7
+ data.tar.gz: f3c84de2581d41a28a79dd386992f54b2bac3e68e026700cfc10325939872442bafe63fc853ee3b67cb54d719c539b033a2953484016d51fb5dffe2b583af672
data/.gitignore CHANGED
@@ -15,11 +15,13 @@ coverage.data
15
15
 
16
16
  tmp/*
17
17
  spec/tmp/*
18
+ tmp
19
+ log
20
+ vendor
18
21
 
19
22
  .idea/*
20
23
  .bundle/*
21
24
 
22
- .rvmrc
23
25
  .ruby-gemset
24
26
  .ruby-version
25
27
 
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.2.4)
5
- activerecord (~> 3.2)
6
- activesupport (~> 3.2)
7
- bson (~> 1.10.2)
8
- bson_ext (~> 1.10.2)
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 (~> 1.10.2)
10
+ mongo (>= 1.10.2)
11
11
 
12
12
  GEM
13
13
  remote: http://rubygems.org/
14
14
  specs:
15
- activemodel (3.2.19)
16
- activesupport (= 3.2.19)
17
- builder (~> 3.0.0)
18
- activerecord (3.2.19)
19
- activemodel (= 3.2.19)
20
- activesupport (= 3.2.19)
21
- arel (~> 3.0.2)
22
- tzinfo (~> 0.3.29)
23
- activesupport (3.2.19)
24
- i18n (~> 0.6, >= 0.6.4)
25
- multi_json (~> 1.0)
26
- arel (3.0.3)
27
- binding_of_caller (0.7.2)
28
- debug_inspector (>= 0.0.1)
29
- bond (0.5.1)
30
- bson (1.10.2)
31
- bson_ext (1.10.2)
32
- bson (~> 1.10.2)
33
- builder (3.0.4)
34
- coderay (1.1.0)
35
- columnize (0.8.9)
36
- cucumber (1.3.15)
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.12)
46
+ gherkin (~> 3.2.0)
40
47
  multi_json (>= 1.7.5, < 2.0)
41
- multi_test (>= 0.1.1)
42
- debug_inspector (0.0.2)
43
- debugger (1.6.8)
44
- columnize (>= 0.3.1)
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.12.2)
51
- multi_json (~> 1.3)
52
- highline (1.6.21)
53
- i18n (0.6.9)
54
- interception (0.5)
55
- jist (1.5.1)
56
- json
57
- json (1.8.1)
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.10.2)
63
- bson (= 1.10.2)
64
- multi_json (1.10.1)
65
- multi_test (0.1.1)
66
- mysql2 (0.3.16)
67
- pg (0.17.1)
68
- pry (0.10.0)
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-debugger (0.2.3)
73
- debugger (~> 1.3)
74
- pry (>= 0.9.10, < 0.11.0)
75
- pry-doc (0.6.0)
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-docmore (0.1.1)
79
- pry
80
- pry-doc
81
- pry-plus (1.0.0)
82
- bond
83
- jist
84
- pry-debugger
85
- pry-doc
86
- pry-docmore
87
- pry-rescue
88
- pry-stack_explorer
89
- pry-rescue (1.4.1)
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.14.4)
104
- slop (3.5.0)
105
- sqlite3 (1.3.9)
106
- tzinfo (0.3.39)
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.4)
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 (~> 0.3.1)
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.5.3)
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
- desc "Setup a postgresql database based on the spec/support/database.yml settings (under postgresql)"
56
- task :postgresql do
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.create_table(:posts, :force => true) do |t|
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
- conn.create_table(:comments, :force => true) do |t|
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 :mysql do
86
- require './spec/support/config_reader'
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
- conn.create_table(:users, :force => true) do |t|
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, :force => true) do |t|
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, :force => true) do |t|
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
- puts "Finished"
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 :default => ['test']
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 ? be_false : be_true)
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::ConnectionAdapters::Column.value_to_decimal(value)
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::ConnectionAdapters::Column.string_to_time(value)
247
- when :timestamp then ActiveRecord::ConnectionAdapters::Column.string_to_time(value)
248
- when :time then ActiveRecord::ConnectionAdapters::Column.string_to_dummy_time(value)
249
- when :date then ActiveRecord::ConnectionAdapters::Column.string_to_time(value)
250
- when :binary then ActiveRecord::ConnectionAdapters::Column.binary_to_string(value)
251
- when :boolean then ActiveRecord::ConnectionAdapters::Column.value_to_boolean(value)
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