data_migrater 1.1.0 → 1.2.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
  SHA256:
3
- metadata.gz: f399d2a9cb8f0b2b4308d800542e259b9944d208ff2ed31ecdf8c001dbbc3861
4
- data.tar.gz: 75dda4543f8a3eefac6c7158763891f51dbd73585653a0dfaeee89022f691663
3
+ metadata.gz: 3f791dd42967bc0a4750e2f0d8da897c3206b9ea9d30616aacf098e2ff484a6d
4
+ data.tar.gz: 5d1452dbbafd5c24741ffe89d784f71243ef345e998fb79c175fb739125defbb
5
5
  SHA512:
6
- metadata.gz: ec764ed1b0e4804054925a43443fc470f1e14d5698e0979cc3dccd264661e91ce8a77cfbe199c2d8ca9364d98c134445003a2c88121bfe0ff82cfcb77f3cc0f6
7
- data.tar.gz: 644d8766d959b196401874fbaa7edfcfc32b3590dd0ebcf11a6a37c51b58ec891202c29c0a27837bb14a54c65d46fcfcea8e3c01565173a9dec8e239d815e48a
6
+ metadata.gz: 6aad01b6d6426d231de12ff2b683fa2a01af09dc1e9f3b2a9e741e20698248c0f120d3d2b473c39e65aa247f506c7767d5de9a18df0c0eb6a4a5e1904cbcf092
7
+ data.tar.gz: caca6da38fd70296d8d773c92e370a948b2a05d8bd5bc0a2f8c1019e8b7e5e8f10c0bbda7e2a6af5e753cd0394c7add33faa3b8c06c1c45594ed31328b96a8ae
@@ -1,3 +1,10 @@
1
+ ## v1.2.0
2
+
3
+ ### Updates
4
+
5
+ - Support Ruby 2.6.5;
6
+ - Support Rails 6.
7
+
1
8
  ## v1.1.0
2
9
 
3
10
  ### Fixes
@@ -16,7 +16,7 @@ module DataMigrater
16
16
  @collection.migrations.each(&:execute)
17
17
  end
18
18
  rescue ActiveRecord::PendingMigrationError
19
- puts "DataMigrater stopped. Pending migrations need to executed!"
19
+ puts 'DataMigrater stopped. Pending migrations need to executed!'
20
20
  end
21
21
  end
22
22
  end
@@ -32,8 +32,8 @@ module DataMigrater
32
32
 
33
33
  def default_credentials
34
34
  {
35
- access_key_id: ENV['AWS_ACCESS_KEY_ID'],
36
- region: ENV.fetch('AWS_REGION', 'us-east-1'),
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module DataMigrater
4
- VERSION = '1.1.0'
4
+ VERSION = '1.2.0'
5
5
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  module DataMigrater
4
4
  class CreateGenerator < Rails::Generators::Base
5
- source_root File.expand_path('../templates', __FILE__)
5
+ source_root File.expand_path('templates', __dir__)
6
6
 
7
7
  argument :name, type: :string
8
8
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  module DataMigrater
4
4
  class InstallGenerator < Rails::Generators::Base
5
- source_root File.expand_path('../templates', __FILE__)
5
+ source_root File.expand_path('templates', __dir__)
6
6
 
7
7
  desc 'creates an initializer and copy necessary files.'
8
8
 
@@ -2,6 +2,4 @@
2
2
 
3
3
  require 'data_migrater'
4
4
 
5
- unless Rails.env.test? || ENV['DATA_MIGRATER'] == 'false'
6
- DataMigrater::Migrator.new.migrate
7
- end
5
+ DataMigrater::Migrator.new.migrate unless Rails.env.test? || ENV['DATA_MIGRATER'] == 'false'
@@ -8,7 +8,7 @@ describe DataMigrater::Collection do
8
8
  before do
9
9
  FileUtils.mkdir_p path
10
10
 
11
- allow(Rails).to receive(:root) { '.' }
11
+ allow(Rails).to receive(:root).and_return('.')
12
12
  end
13
13
 
14
14
  after { FileUtils.rm_rf 'db' }
@@ -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: 'Botelho',
24
- username: 'wbotelhos',
25
- age: 32,
26
- birthday: Date.strptime('23/10/1984', '%d/%m/%y')
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: 'Souza',
32
- username: 'lucasas'
31
+ last_name: 'Souza',
32
+ username: 'lucasas'
33
33
  }
34
34
  ]
35
35
  end
@@ -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: 'Botelho',
19
- username: 'wbotelhos',
20
- age: 32,
21
- birthday: '23/10/1984'
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: 'Souza',
27
- username: 'lucasas'
26
+ last_name: 'Souza',
27
+ username: 'lucasas'
28
28
  }
29
29
  ]
30
30
  end
@@ -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: 'Washington',
16
+ first: 'Washington',
17
17
  last_name: 'Botelho',
18
- username: 'wbotelhos',
19
- age: 32,
20
- birthday: '23/10/1984'
18
+ username: 'wbotelhos',
19
+ age: 32,
20
+ birthday: '23/10/1984'
21
21
  }],
22
22
 
23
23
  [{
24
- first: 'Lucas',
24
+ first: 'Lucas',
25
25
  last_name: 'Souza',
26
- username: 'lucasas'
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
 
@@ -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?) { false }
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 { version.call } }
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
@@ -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
- begin
68
- subject.execute
69
- rescue
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
@@ -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') { 'AWS_ACCESS_KEY_ID' }
10
- allow(ENV).to receive(:fetch).with('AWS_REGION', 'us-east-1') { 'AWS_REGION' }
11
- allow(ENV).to receive(:[]).with('AWS_SECRET_ACCESS_KEY') { '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.1.0
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-05-28 00:00:00.000000000 Z
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: '1'
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: '1'
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: '1.1'
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: '1.1'
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.3
189
+ rubygems_version: 3.0.6
202
190
  signing_key:
203
191
  specification_version: 4
204
192
  summary: A Data Migrator gem