data_migrater 1.1.0 → 1.2.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/CHANGELOG.md +7 -0
- data/lib/data_migrater/migrator.rb +1 -1
- data/lib/data_migrater/s3.rb +2 -2
- data/lib/data_migrater/version.rb +1 -1
- data/lib/generators/data_migrater/create_generator.rb +1 -1
- data/lib/generators/data_migrater/install_generator.rb +1 -1
- data/lib/generators/data_migrater/templates/config/initializers/data_migrater.rb +1 -3
- data/spec/collection_spec.rb +1 -1
- data/spec/csv/converters_spec.rb +6 -6
- data/spec/csv/csv_spec.rb +6 -6
- data/spec/csv/options_spec.rb +6 -6
- data/spec/logger/data_logger_spec.rb +6 -6
- data/spec/migrater_spec.rb +5 -4
- data/spec/migration_spec.rb +3 -5
- data/spec/s3/initialize_spec.rb +3 -3
- metadata +11 -23
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3f791dd42967bc0a4750e2f0d8da897c3206b9ea9d30616aacf098e2ff484a6d
|
4
|
+
data.tar.gz: 5d1452dbbafd5c24741ffe89d784f71243ef345e998fb79c175fb739125defbb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6aad01b6d6426d231de12ff2b683fa2a01af09dc1e9f3b2a9e741e20698248c0f120d3d2b473c39e65aa247f506c7767d5de9a18df0c0eb6a4a5e1904cbcf092
|
7
|
+
data.tar.gz: caca6da38fd70296d8d773c92e370a948b2a05d8bd5bc0a2f8c1019e8b7e5e8f10c0bbda7e2a6af5e753cd0394c7add33faa3b8c06c1c45594ed31328b96a8ae
|
data/CHANGELOG.md
CHANGED
@@ -16,7 +16,7 @@ module DataMigrater
|
|
16
16
|
@collection.migrations.each(&:execute)
|
17
17
|
end
|
18
18
|
rescue ActiveRecord::PendingMigrationError
|
19
|
-
puts
|
19
|
+
puts 'DataMigrater stopped. Pending migrations need to executed!'
|
20
20
|
end
|
21
21
|
end
|
22
22
|
end
|
data/lib/data_migrater/s3.rb
CHANGED
@@ -32,8 +32,8 @@ module DataMigrater
|
|
32
32
|
|
33
33
|
def default_credentials
|
34
34
|
{
|
35
|
-
access_key_id:
|
36
|
-
region:
|
35
|
+
access_key_id: ENV['AWS_ACCESS_KEY_ID'],
|
36
|
+
region: ENV.fetch('AWS_REGION', 'us-east-1'),
|
37
37
|
secret_access_key: ENV['AWS_SECRET_ACCESS_KEY']
|
38
38
|
}
|
39
39
|
end
|
data/spec/collection_spec.rb
CHANGED
data/spec/csv/converters_spec.rb
CHANGED
@@ -20,16 +20,16 @@ RSpec.describe '#converters' do
|
|
20
20
|
expect(Dummy.new.csv).to eq [
|
21
21
|
{
|
22
22
|
first_name: 'Washington',
|
23
|
-
last_name:
|
24
|
-
username:
|
25
|
-
age:
|
26
|
-
birthday:
|
23
|
+
last_name: 'Botelho',
|
24
|
+
username: 'wbotelhos',
|
25
|
+
age: 32,
|
26
|
+
birthday: Date.strptime('23/10/1984', '%d/%m/%y')
|
27
27
|
},
|
28
28
|
|
29
29
|
{
|
30
30
|
first_name: 'Lucas',
|
31
|
-
last_name:
|
32
|
-
username:
|
31
|
+
last_name: 'Souza',
|
32
|
+
username: 'lucasas'
|
33
33
|
}
|
34
34
|
]
|
35
35
|
end
|
data/spec/csv/csv_spec.rb
CHANGED
@@ -15,16 +15,16 @@ RSpec.describe '#data_csv' do
|
|
15
15
|
expect(Dummy.new.csv).to eq [
|
16
16
|
{
|
17
17
|
first_name: 'Washington',
|
18
|
-
last_name:
|
19
|
-
username:
|
20
|
-
age:
|
21
|
-
birthday:
|
18
|
+
last_name: 'Botelho',
|
19
|
+
username: 'wbotelhos',
|
20
|
+
age: 32,
|
21
|
+
birthday: '23/10/1984'
|
22
22
|
},
|
23
23
|
|
24
24
|
{
|
25
25
|
first_name: 'Lucas',
|
26
|
-
last_name:
|
27
|
-
username:
|
26
|
+
last_name: 'Souza',
|
27
|
+
username: 'lucasas'
|
28
28
|
}
|
29
29
|
]
|
30
30
|
end
|
data/spec/csv/options_spec.rb
CHANGED
@@ -13,17 +13,17 @@ RSpec.describe '#options' do
|
|
13
13
|
it 'applies the options on csv gem' do
|
14
14
|
expect(Dummy.new.csv).to eq [
|
15
15
|
[{
|
16
|
-
first:
|
16
|
+
first: 'Washington',
|
17
17
|
last_name: 'Botelho',
|
18
|
-
username:
|
19
|
-
age:
|
20
|
-
birthday:
|
18
|
+
username: 'wbotelhos',
|
19
|
+
age: 32,
|
20
|
+
birthday: '23/10/1984'
|
21
21
|
}],
|
22
22
|
|
23
23
|
[{
|
24
|
-
first:
|
24
|
+
first: 'Lucas',
|
25
25
|
last_name: 'Souza',
|
26
|
-
username:
|
26
|
+
username: 'lucasas'
|
27
27
|
}]
|
28
28
|
]
|
29
29
|
end
|
@@ -4,6 +4,8 @@ require 'spec_helper'
|
|
4
4
|
|
5
5
|
RSpec.describe '#data_logger' do
|
6
6
|
context 'with :path' do
|
7
|
+
subject { Dummy.new }
|
8
|
+
|
7
9
|
before do
|
8
10
|
stub_const 'Dummy', Class.new
|
9
11
|
|
@@ -11,8 +13,6 @@ RSpec.describe '#data_logger' do
|
|
11
13
|
Dummy.class_eval { data_logger path: 'custom.log' }
|
12
14
|
end
|
13
15
|
|
14
|
-
subject { Dummy.new }
|
15
|
-
|
16
16
|
it 'logs on the given path file with right content' do
|
17
17
|
subject.logger.info 'done!'
|
18
18
|
|
@@ -23,6 +23,8 @@ RSpec.describe '#data_logger' do
|
|
23
23
|
end
|
24
24
|
|
25
25
|
context 'with no :path' do
|
26
|
+
subject { Dummy.new }
|
27
|
+
|
26
28
|
before do
|
27
29
|
stub_const 'Dummy', Class.new
|
28
30
|
|
@@ -30,8 +32,6 @@ RSpec.describe '#data_logger' do
|
|
30
32
|
Dummy.class_eval { data_logger }
|
31
33
|
end
|
32
34
|
|
33
|
-
subject { Dummy.new }
|
34
|
-
|
35
35
|
it 'logs on log folder with class name with right content' do
|
36
36
|
subject.logger.info 'done!'
|
37
37
|
|
@@ -42,14 +42,14 @@ RSpec.describe '#data_logger' do
|
|
42
42
|
end
|
43
43
|
|
44
44
|
context 'with no :data_logger' do
|
45
|
+
subject { Dummy.new }
|
46
|
+
|
45
47
|
before do
|
46
48
|
stub_const 'Dummy', Class.new
|
47
49
|
|
48
50
|
Dummy.class_eval { include DataMigrater::Logger }
|
49
51
|
end
|
50
52
|
|
51
|
-
subject { Dummy.new }
|
52
|
-
|
53
53
|
it 'logs on log folder with class name with right content' do
|
54
54
|
subject.logger.info 'done!'
|
55
55
|
|
data/spec/migrater_spec.rb
CHANGED
@@ -6,7 +6,7 @@ describe DataMigrater::Migrator do
|
|
6
6
|
before do
|
7
7
|
FileUtils.mkdir_p 'db/migrate'
|
8
8
|
|
9
|
-
allow(Rails).to receive(:root)
|
9
|
+
allow(Rails).to receive(:root).and_return('.')
|
10
10
|
end
|
11
11
|
|
12
12
|
after do
|
@@ -36,7 +36,7 @@ describe DataMigrater::Migrator do
|
|
36
36
|
let(:collection) { double migrations: [data_migration] }
|
37
37
|
|
38
38
|
before do
|
39
|
-
allow(DataMigration).to receive(:table_exists?)
|
39
|
+
allow(DataMigration).to receive(:table_exists?).and_return(false)
|
40
40
|
end
|
41
41
|
|
42
42
|
it 'does not executes data migration' do
|
@@ -52,7 +52,7 @@ describe DataMigrater::Migrator do
|
|
52
52
|
|
53
53
|
let(:collection) { double migrations: [] }
|
54
54
|
|
55
|
-
it { expect { subject.migrate }.not_to change
|
55
|
+
it { expect { subject.migrate }.not_to change(version, :call) }
|
56
56
|
end
|
57
57
|
|
58
58
|
context 'and has data migration on collection' do
|
@@ -77,7 +77,7 @@ describe DataMigrater::Migrator do
|
|
77
77
|
it 'keeps the actual version' do
|
78
78
|
begin
|
79
79
|
subject.migrate
|
80
|
-
rescue
|
80
|
+
rescue StandardError
|
81
81
|
end
|
82
82
|
|
83
83
|
expect(version.call).to eq '21161023010203'
|
@@ -92,6 +92,7 @@ describe DataMigrater::Migrator do
|
|
92
92
|
let(:next_migration) { "#{Rails.root}/db/migrate/#{next_version}_migration.rb" }
|
93
93
|
|
94
94
|
before { FileUtils.touch next_migration }
|
95
|
+
|
95
96
|
after { FileUtils.rm next_migration }
|
96
97
|
|
97
98
|
it 'does not run the data migrations' do
|
data/spec/migration_spec.rb
CHANGED
@@ -64,11 +64,9 @@ describe DataMigrater::Migration do
|
|
64
64
|
specify { expect { subject.execute }.to raise_error RuntimeError }
|
65
65
|
|
66
66
|
it 'removes data migration object' do
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
expect(DataMigration.exists?(version: version)).to eq false
|
71
|
-
end
|
67
|
+
subject.execute
|
68
|
+
rescue StandardError
|
69
|
+
expect(DataMigration.exists?(version: version)).to eq false
|
72
70
|
end
|
73
71
|
end
|
74
72
|
end
|
data/spec/s3/initialize_spec.rb
CHANGED
@@ -6,9 +6,9 @@ RSpec.describe DataMigrater::S3, 'initialize' do
|
|
6
6
|
subject(:s3) { described_class.new 'data-migrater', credentials, 'dummy.csv' }
|
7
7
|
|
8
8
|
before do
|
9
|
-
allow(ENV).to receive(:[]).with('AWS_ACCESS_KEY_ID')
|
10
|
-
allow(ENV).to receive(:fetch).with('AWS_REGION', 'us-east-1')
|
11
|
-
allow(ENV).to receive(:[]).with('AWS_SECRET_ACCESS_KEY')
|
9
|
+
allow(ENV).to receive(:[]).with('AWS_ACCESS_KEY_ID').and_return('AWS_ACCESS_KEY_ID')
|
10
|
+
allow(ENV).to receive(:fetch).with('AWS_REGION', 'us-east-1').and_return('AWS_REGION')
|
11
|
+
allow(ENV).to receive(:[]).with('AWS_SECRET_ACCESS_KEY').and_return('AWS_SECRET_ACCESS_KEY')
|
12
12
|
end
|
13
13
|
|
14
14
|
context 'when credentials is not given' do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: data_migrater
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Washington Botelho
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2019-
|
12
|
+
date: 2019-10-15 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activerecord
|
@@ -18,9 +18,6 @@ dependencies:
|
|
18
18
|
- - ">="
|
19
19
|
- !ruby/object:Gem::Version
|
20
20
|
version: '4.1'
|
21
|
-
- - "<"
|
22
|
-
- !ruby/object:Gem::Version
|
23
|
-
version: '6'
|
24
21
|
type: :runtime
|
25
22
|
prerelease: false
|
26
23
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -28,23 +25,20 @@ dependencies:
|
|
28
25
|
- - ">="
|
29
26
|
- !ruby/object:Gem::Version
|
30
27
|
version: '4.1'
|
31
|
-
- - "<"
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '6'
|
34
28
|
- !ruby/object:Gem::Dependency
|
35
29
|
name: aws-sdk-s3
|
36
30
|
requirement: !ruby/object:Gem::Requirement
|
37
31
|
requirements:
|
38
|
-
- - "
|
32
|
+
- - ">="
|
39
33
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
34
|
+
version: '0'
|
41
35
|
type: :runtime
|
42
36
|
prerelease: false
|
43
37
|
version_requirements: !ruby/object:Gem::Requirement
|
44
38
|
requirements:
|
45
|
-
- - "
|
39
|
+
- - ">="
|
46
40
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
41
|
+
version: '0'
|
48
42
|
- !ruby/object:Gem::Dependency
|
49
43
|
name: railties
|
50
44
|
requirement: !ruby/object:Gem::Requirement
|
@@ -52,9 +46,6 @@ dependencies:
|
|
52
46
|
- - ">="
|
53
47
|
- !ruby/object:Gem::Version
|
54
48
|
version: '4.1'
|
55
|
-
- - "<"
|
56
|
-
- !ruby/object:Gem::Version
|
57
|
-
version: '6'
|
58
49
|
type: :runtime
|
59
50
|
prerelease: false
|
60
51
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -62,23 +53,20 @@ dependencies:
|
|
62
53
|
- - ">="
|
63
54
|
- !ruby/object:Gem::Version
|
64
55
|
version: '4.1'
|
65
|
-
- - "<"
|
66
|
-
- !ruby/object:Gem::Version
|
67
|
-
version: '6'
|
68
56
|
- !ruby/object:Gem::Dependency
|
69
57
|
name: smarter_csv
|
70
58
|
requirement: !ruby/object:Gem::Requirement
|
71
59
|
requirements:
|
72
|
-
- - "
|
60
|
+
- - ">="
|
73
61
|
- !ruby/object:Gem::Version
|
74
|
-
version: '
|
62
|
+
version: '0'
|
75
63
|
type: :runtime
|
76
64
|
prerelease: false
|
77
65
|
version_requirements: !ruby/object:Gem::Requirement
|
78
66
|
requirements:
|
79
|
-
- - "
|
67
|
+
- - ">="
|
80
68
|
- !ruby/object:Gem::Version
|
81
|
-
version: '
|
69
|
+
version: '0'
|
82
70
|
- !ruby/object:Gem::Dependency
|
83
71
|
name: pry-byebug
|
84
72
|
requirement: !ruby/object:Gem::Requirement
|
@@ -198,7 +186,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
198
186
|
- !ruby/object:Gem::Version
|
199
187
|
version: '0'
|
200
188
|
requirements: []
|
201
|
-
rubygems_version: 3.0.
|
189
|
+
rubygems_version: 3.0.6
|
202
190
|
signing_key:
|
203
191
|
specification_version: 4
|
204
192
|
summary: A Data Migrator gem
|