outrigger 2.1.0 → 3.0.1

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: afe3d83c6bdd3dcb7cca66b9c4dafb871003caa20a67054059ebed4ab22bf516
4
- data.tar.gz: ef8343569aaa000a0cc61897f8d33e6404cd4833d54b187cb364922f91f18ed1
3
+ metadata.gz: 392d8062869e177e23c6860452029c08aad9ecdcf50cdf066c2adf2acbfa986f
4
+ data.tar.gz: 6e88773c9dc2c53f6d248018c54498ff4d824d79ae0fdc02c6577a0b4e154d2b
5
5
  SHA512:
6
- metadata.gz: 594e9b14db63bdc8742dc34e809a088c30c41ae2624313d1be3580d58d5ced891bd8b799ad15cf69571541c19f2698f34185832686996b9777c61cc49bf8717a
7
- data.tar.gz: 535727d4166e69a14b1fa6d188d3608d5b3e4e21f0d3c4601c130523d9e0ef7f900d78dbab4766cbcddf65f71a4f4db8939db5eb84934fe6661f49c44d31a885
6
+ metadata.gz: 19200055e92e31aa92dd87003a17df97752544847754957db78420a6470c08d2e63d812095a088e05a326593ba2b7ade2c1fbf764e78cad7f92a1a236a6ac546
7
+ data.tar.gz: 23710d99de6a88968cc2f812a600ad62364a4bd39d9124206ac0fe541f7d5153ddc463d54e89d41c6a210eeda386bccd91d00866fe6133fe09747fb4e86da315
data/Rakefile CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'bundler/gem_tasks'
2
4
 
3
5
  begin
@@ -6,14 +8,6 @@ begin
6
8
  RSpec::Core::RakeTask.new(:spec)
7
9
 
8
10
  task(default: :spec)
9
- rescue LoadError # rubocop:disable Lint/HandleExceptions
10
- # no rspec available
11
- end
12
-
13
- task :console do
14
- require 'irb'
15
- require 'irb/completion'
16
- require 'outrigger'
17
- ARGV.clear
18
- IRB.start
11
+ rescue LoadError
12
+ nil
19
13
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module RuboCop
2
4
  module Cop
3
5
  module Migration
@@ -5,6 +7,7 @@ module RuboCop
5
7
  def on_class(node)
6
8
  _name, _superclass, body = *node
7
9
  return unless body && migration_class?(node)
10
+
8
11
  check(node, body)
9
12
  end
10
13
 
@@ -33,6 +36,7 @@ module RuboCop
33
36
  message: 'No allowed tags have been defined in the RuboCop configuration.'
34
37
  elsif tag
35
38
  return if allowed_tags.include? tag.children.last.to_a.last
39
+
36
40
  add_offense tag,
37
41
  location: :expression,
38
42
  message: "Tags may only be one of #{allowed_tags}."
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Outrigger
4
+ module Migrator
5
+ def runnable
6
+ result = super
7
+ return result unless Outrigger.ordered
8
+
9
+ # re-order according to configuration
10
+ result.sort_by! { |m| [Outrigger.ordered[m.tags.first] || 0, m.version] }
11
+ result.reverse! if down?
12
+ result
13
+ end
14
+ end
15
+ end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Outrigger
2
4
  class Railtie < Rails::Railtie
3
5
  railtie_name :taggable_migrations
@@ -8,8 +10,9 @@ module Outrigger
8
10
 
9
11
  initializer 'extend_migrations' do
10
12
  ActiveSupport.on_load :active_record do
11
- ActiveRecord::Migration.send :include, Outrigger::Taggable
12
- ActiveRecord::MigrationProxy.send :include, Outrigger::TaggableProxy
13
+ ActiveRecord::Migration.include(Outrigger::Taggable)
14
+ ActiveRecord::MigrationProxy.include(Outrigger::TaggableProxy)
15
+ ActiveRecord::Migrator.prepend(Outrigger::Migrator)
13
16
  end
14
17
  end
15
18
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Outrigger
2
4
  module Taggable
3
5
  def self.included(base)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Outrigger
2
4
  module TaggableProxy
3
5
  def self.included(_body)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Outrigger
2
- VERSION = '2.1.0'.freeze
4
+ VERSION = '3.0.1'
3
5
  end
data/lib/outrigger.rb CHANGED
@@ -1,13 +1,20 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'active_record' unless defined? ActiveRecord
2
4
 
5
+ require 'outrigger/migrator'
3
6
  require 'outrigger/taggable'
4
7
  require 'outrigger/taggable_proxy'
5
8
 
6
9
  require 'outrigger/railtie' if defined? Rails::Railtie
7
10
 
8
11
  module Outrigger
9
- def self.filter(*tags)
10
- tags = tags.flatten.map(&:to_sym)
11
- proc { |migration| (tags - migration.tags).empty? }
12
+ class << self
13
+ attr_accessor :ordered
14
+
15
+ def filter(*tags)
16
+ tags = tags.flatten.map(&:to_sym)
17
+ proc { |migration| (tags - migration.tags).empty? }
18
+ end
12
19
  end
13
20
  end
@@ -1,13 +1,11 @@
1
+ # frozen_string_literal: true
2
+
1
3
  namespace :db do
2
4
  namespace :migrate do
3
5
  desc 'Run migrations for a Tag'
4
6
  task tagged: %i[environment load_config] do |_t, args|
5
7
  puts("Migrating Tags: #{args.extras}")
6
- if ActiveRecord.gem_version >= Gem::Version.new('5.2.0')
7
- ActiveRecord::Base.connection.migration_context.migrate(nil, &Outrigger.filter(args.extras))
8
- else
9
- ActiveRecord::Migrator.migrate(ActiveRecord::Migrator.migrations_paths, &Outrigger.filter(args.extras))
10
- end
8
+ ActiveRecord::Base.connection.migration_context.migrate(nil, &Outrigger.filter(args.extras))
11
9
  end
12
10
  end
13
11
  end
@@ -1,7 +1,8 @@
1
- require 'spec_helper'
1
+ # frozen_string_literal: true
2
+
2
3
  require 'outrigger/cops/migration/tagged'
3
4
 
4
- RSpec.describe RuboCop::Cop::Migration::Tagged do # rubocop:disable Metrics/BlockLength
5
+ RSpec.describe RuboCop::Cop::Migration::Tagged do # rubocop:disable RSpec/FilePath
5
6
  let(:config_hash) do
6
7
  {
7
8
  'Migration/Tagged' => {
@@ -23,7 +24,7 @@ RSpec.describe RuboCop::Cop::Migration::Tagged do # rubocop:disable Metrics/Bloc
23
24
  RUBY
24
25
  end
25
26
 
26
- subject(:cop) { described_class.new(config) }
27
+ subject(:cop) { described_class.new(config) } # rubocop:disable RSpec/LeadingSubject
27
28
 
28
29
  shared_examples_for 'valid migrations' do
29
30
  it 'passes valid versioned migration' do
@@ -32,10 +33,10 @@ RSpec.describe RuboCop::Cop::Migration::Tagged do # rubocop:disable Metrics/Bloc
32
33
  end
33
34
  end
34
35
 
35
- context 'valid config' do # rubocop:disable Metrics/BlockLength
36
+ context 'with valid config' do
36
37
  include_examples 'valid migrations'
37
38
 
38
- context 'missing tags' do
39
+ context 'with missing tags' do
39
40
  let(:migration_class) do
40
41
  <<~RUBY
41
42
  class Test < ActiveRecord::Migration[4.2]
@@ -52,7 +53,7 @@ RSpec.describe RuboCop::Cop::Migration::Tagged do # rubocop:disable Metrics/Bloc
52
53
  end
53
54
  end
54
55
 
55
- context 'invalid tag' do
56
+ context 'with invalid tag' do
56
57
  let(:migration_class) do
57
58
  <<~RUBY
58
59
  class Test < ActiveRecord::Migration[4.2]
@@ -71,7 +72,7 @@ RSpec.describe RuboCop::Cop::Migration::Tagged do # rubocop:disable Metrics/Bloc
71
72
  end
72
73
  end
73
74
 
74
- context 'invalid config' do
75
+ context 'with invalid config' do
75
76
  let(:config_hash) do
76
77
  {
77
78
  'Migration/Tagged' => {
@@ -0,0 +1,39 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Outrigger
4
+ describe Migrator do
5
+ around do |example|
6
+ Outrigger.ordered = { predeploy: -1, postdeploy: 1 }
7
+ example.call
8
+ ensure
9
+ Outrigger.ordered = nil
10
+ end
11
+
12
+ let(:migrations) do
13
+ [PostDeployMigration.new(nil, 1), UntaggedMigration.new(nil, 2), PreDeployMigration.new(nil, 3),
14
+ MultiMigration.new(nil, 4)]
15
+ end
16
+
17
+ before do
18
+ allow(ActiveRecord::InternalMetadata).to receive(:create_table)
19
+ end
20
+
21
+ it 'sorts' do
22
+ schema_migration = object_double(ActiveRecord::SchemaMigration, create_table: nil, all_versions: [])
23
+ expect(ActiveRecord::Migrator.new(:up, migrations, schema_migration).runnable.map(&:class)).to eq(
24
+ [
25
+ PreDeployMigration, MultiMigration, UntaggedMigration, PostDeployMigration
26
+ ]
27
+ )
28
+ end
29
+
30
+ it 'reverse sorts when going down' do
31
+ schema_migration = object_double(ActiveRecord::SchemaMigration, create_table: nil, all_versions: [1, 2, 3, 4])
32
+ expect(ActiveRecord::Migrator.new(:down, migrations, schema_migration).runnable.map(&:class)).to eq(
33
+ [
34
+ PostDeployMigration, UntaggedMigration, MultiMigration, PreDeployMigration
35
+ ]
36
+ )
37
+ end
38
+ end
39
+ end
@@ -1,18 +1,18 @@
1
- require 'spec_helper'
1
+ # frozen_string_literal: true
2
2
 
3
3
  describe Outrigger do
4
4
  describe 'filter' do
5
- it 'should return a proc that tests migrations' do
6
- filter = Outrigger.filter(:predeploy)
5
+ it 'returns a proc that tests migrations' do
6
+ filter = described_class.filter(:predeploy)
7
7
 
8
- expect(filter.call(PreDeployMigration)).to eq(true)
8
+ expect(filter.call(PreDeployMigration)).to be(true)
9
9
  end
10
10
 
11
- it 'should accept multiple tags' do
12
- filter = Outrigger.filter(:predeploy, :postdeploy)
11
+ it 'accepts multiple tags' do
12
+ filter = described_class.filter(:predeploy, :postdeploy)
13
13
 
14
- expect(filter.call(MultiMigration)).to eq(true)
15
- expect(filter.call(PreDeployMigration)).to eq(false)
14
+ expect(filter.call(MultiMigration)).to be(true)
15
+ expect(filter.call(PreDeployMigration)).to be(false)
16
16
  end
17
17
  end
18
18
  end
@@ -1,9 +1,7 @@
1
- require 'spec_helper'
1
+ # frozen_string_literal: true
2
2
 
3
3
  describe Outrigger::Railtie do
4
- let(:subject) { Outrigger::Railtie }
5
-
6
4
  it 'provides a railtie_name' do
7
- expect(subject.railtie_name).to eq 'taggable_migrations'
5
+ expect(described_class.railtie_name).to eq 'taggable_migrations'
8
6
  end
9
7
  end
@@ -1,4 +1,4 @@
1
- require 'spec_helper'
1
+ # frozen_string_literal: true
2
2
 
3
3
  class TestProxy
4
4
  include Outrigger::TaggableProxy
@@ -6,7 +6,7 @@ class TestProxy
6
6
  end
7
7
 
8
8
  describe Outrigger::TaggableProxy do
9
- it 'it should delegate tags to the migration' do
9
+ it 'delegates tags to the migration' do
10
10
  proxy = TestProxy.new
11
11
  proxy.migration = PreDeployMigration.new
12
12
 
@@ -1,4 +1,4 @@
1
- require 'spec_helper'
1
+ # frozen_string_literal: true
2
2
 
3
3
  describe Outrigger::Taggable do
4
4
  it 'PreDeployMigration should be predeploy' do
data/spec/spec_helper.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'simplecov'
2
4
  SimpleCov.start do
3
5
  add_filter 'lib/outrigger/version.rb'
@@ -7,14 +9,16 @@ end
7
9
  SimpleCov.minimum_coverage(85)
8
10
 
9
11
  require 'bundler/setup'
12
+ require 'byebug'
10
13
  require 'rails/railtie'
11
14
  require 'rubocop'
12
15
  require 'rubocop/rspec/support'
13
16
 
14
17
  require 'outrigger'
15
18
 
16
- ActiveRecord::Migration.send :include, Outrigger::Taggable
17
- ActiveRecord::MigrationProxy.send :include, Outrigger::TaggableProxy
19
+ ActiveRecord::Migration.include(Outrigger::Taggable)
20
+ ActiveRecord::MigrationProxy.include(Outrigger::TaggableProxy)
21
+ ActiveRecord::Migrator.prepend(Outrigger::Migrator)
18
22
 
19
23
  class PreDeployMigration < ActiveRecord::Migration[5.0]
20
24
  tag :predeploy
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: outrigger
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.0
4
+ version: 3.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Drew Bowman
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-11-20 00:00:00.000000000 Z
11
+ date: 2022-03-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -16,22 +16,42 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '5.0'
19
+ version: '6.0'
20
20
  - - "<"
21
21
  - !ruby/object:Gem::Version
22
- version: '6.1'
22
+ version: '7.1'
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
26
26
  requirements:
27
27
  - - ">="
28
28
  - !ruby/object:Gem::Version
29
- version: '5.0'
29
+ version: '6.0'
30
30
  - - "<"
31
31
  - !ruby/object:Gem::Version
32
- version: '6.1'
32
+ version: '7.1'
33
33
  - !ruby/object:Gem::Dependency
34
- name: bundler
34
+ name: railties
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ">="
38
+ - !ruby/object:Gem::Version
39
+ version: '6.0'
40
+ - - "<"
41
+ - !ruby/object:Gem::Version
42
+ version: '7.1'
43
+ type: :runtime
44
+ prerelease: false
45
+ version_requirements: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - ">="
48
+ - !ruby/object:Gem::Version
49
+ version: '6.0'
50
+ - - "<"
51
+ - !ruby/object:Gem::Version
52
+ version: '7.1'
53
+ - !ruby/object:Gem::Dependency
54
+ name: appraisal
35
55
  requirement: !ruby/object:Gem::Requirement
36
56
  requirements:
37
57
  - - ">="
@@ -45,25 +65,33 @@ dependencies:
45
65
  - !ruby/object:Gem::Version
46
66
  version: '0'
47
67
  - !ruby/object:Gem::Dependency
48
- name: railties
68
+ name: bundler
49
69
  requirement: !ruby/object:Gem::Requirement
50
70
  requirements:
51
- - - ">="
52
- - !ruby/object:Gem::Version
53
- version: '5.0'
54
- - - "<"
71
+ - - "~>"
55
72
  - !ruby/object:Gem::Version
56
- version: '6.1'
73
+ version: '2.2'
57
74
  type: :development
58
75
  prerelease: false
59
76
  version_requirements: !ruby/object:Gem::Requirement
60
77
  requirements:
61
- - - ">="
78
+ - - "~>"
62
79
  - !ruby/object:Gem::Version
63
- version: '5.0'
64
- - - "<"
80
+ version: '2.2'
81
+ - !ruby/object:Gem::Dependency
82
+ name: byebug
83
+ requirement: !ruby/object:Gem::Requirement
84
+ requirements:
85
+ - - "~>"
65
86
  - !ruby/object:Gem::Version
66
- version: '6.1'
87
+ version: '11.1'
88
+ type: :development
89
+ prerelease: false
90
+ version_requirements: !ruby/object:Gem::Requirement
91
+ requirements:
92
+ - - "~>"
93
+ - !ruby/object:Gem::Version
94
+ version: '11.1'
67
95
  - !ruby/object:Gem::Dependency
68
96
  name: rake
69
97
  requirement: !ruby/object:Gem::Requirement
@@ -98,44 +126,58 @@ dependencies:
98
126
  requirements:
99
127
  - - "~>"
100
128
  - !ruby/object:Gem::Version
101
- version: 0.52.0
129
+ version: '1.20'
102
130
  type: :development
103
131
  prerelease: false
104
132
  version_requirements: !ruby/object:Gem::Requirement
105
133
  requirements:
106
134
  - - "~>"
107
135
  - !ruby/object:Gem::Version
108
- version: 0.52.0
136
+ version: '1.20'
109
137
  - !ruby/object:Gem::Dependency
110
- name: simplecov
138
+ name: rubocop-rake
111
139
  requirement: !ruby/object:Gem::Requirement
112
140
  requirements:
113
141
  - - "~>"
114
142
  - !ruby/object:Gem::Version
115
- version: '0'
143
+ version: '0.6'
116
144
  type: :development
117
145
  prerelease: false
118
146
  version_requirements: !ruby/object:Gem::Requirement
119
147
  requirements:
120
148
  - - "~>"
121
149
  - !ruby/object:Gem::Version
122
- version: '0'
150
+ version: '0.6'
123
151
  - !ruby/object:Gem::Dependency
124
- name: wwtd
152
+ name: rubocop-rspec
153
+ requirement: !ruby/object:Gem::Requirement
154
+ requirements:
155
+ - - "~>"
156
+ - !ruby/object:Gem::Version
157
+ version: '2.4'
158
+ type: :development
159
+ prerelease: false
160
+ version_requirements: !ruby/object:Gem::Requirement
161
+ requirements:
162
+ - - "~>"
163
+ - !ruby/object:Gem::Version
164
+ version: '2.4'
165
+ - !ruby/object:Gem::Dependency
166
+ name: simplecov
125
167
  requirement: !ruby/object:Gem::Requirement
126
168
  requirements:
127
169
  - - "~>"
128
170
  - !ruby/object:Gem::Version
129
- version: '1.3'
171
+ version: '0.21'
130
172
  type: :development
131
173
  prerelease: false
132
174
  version_requirements: !ruby/object:Gem::Requirement
133
175
  requirements:
134
176
  - - "~>"
135
177
  - !ruby/object:Gem::Version
136
- version: '1.3'
178
+ version: '0.21'
137
179
  description: Migrations
138
- email:
180
+ email:
139
181
  executables: []
140
182
  extensions: []
141
183
  extra_rdoc_files: []
@@ -143,16 +185,14 @@ files:
143
185
  - Rakefile
144
186
  - lib/outrigger.rb
145
187
  - lib/outrigger/cops/migration/tagged.rb
188
+ - lib/outrigger/migrator.rb
146
189
  - lib/outrigger/railtie.rb
147
190
  - lib/outrigger/taggable.rb
148
191
  - lib/outrigger/taggable_proxy.rb
149
192
  - lib/outrigger/version.rb
150
193
  - lib/tasks/outrigger.rake
151
- - spec/gemfiles/rails-5.0.gemfile
152
- - spec/gemfiles/rails-5.1.gemfile
153
- - spec/gemfiles/rails-5.2.gemfile
154
- - spec/gemfiles/rails-6.0.gemfile
155
194
  - spec/outrigger/cops/migration/tagged_spec.rb
195
+ - spec/outrigger/migrator_spec.rb
156
196
  - spec/outrigger/outrigger_spec.rb
157
197
  - spec/outrigger/railtie_spec.rb
158
198
  - spec/outrigger/taggable_proxy_spec.rb
@@ -161,8 +201,9 @@ files:
161
201
  homepage: https://github.com/instructure/outrigger
162
202
  licenses:
163
203
  - MIT
164
- metadata: {}
165
- post_install_message:
204
+ metadata:
205
+ rubygems_mfa_required: 'true'
206
+ post_install_message:
166
207
  rdoc_options: []
167
208
  require_paths:
168
209
  - lib
@@ -170,23 +211,20 @@ required_ruby_version: !ruby/object:Gem::Requirement
170
211
  requirements:
171
212
  - - ">="
172
213
  - !ruby/object:Gem::Version
173
- version: 2.3.0
214
+ version: '2.6'
174
215
  required_rubygems_version: !ruby/object:Gem::Requirement
175
216
  requirements:
176
217
  - - ">="
177
218
  - !ruby/object:Gem::Version
178
219
  version: '0'
179
220
  requirements: []
180
- rubygems_version: 3.0.3
181
- signing_key:
221
+ rubygems_version: 3.1.4
222
+ signing_key:
182
223
  specification_version: 4
183
224
  summary: Tag migrations and run them separately
184
225
  test_files:
185
- - spec/gemfiles/rails-5.0.gemfile
186
- - spec/gemfiles/rails-5.1.gemfile
187
- - spec/gemfiles/rails-5.2.gemfile
188
- - spec/gemfiles/rails-6.0.gemfile
189
226
  - spec/outrigger/cops/migration/tagged_spec.rb
227
+ - spec/outrigger/migrator_spec.rb
190
228
  - spec/outrigger/outrigger_spec.rb
191
229
  - spec/outrigger/railtie_spec.rb
192
230
  - spec/outrigger/taggable_proxy_spec.rb
@@ -1,5 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- gemspec path: '../../'
4
-
5
- gem 'activerecord', '~> 5.0.7'
@@ -1,5 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- gemspec path: '../../'
4
-
5
- gem 'activerecord', '~> 5.1.6'
@@ -1,5 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- gemspec path: '../../'
4
-
5
- gem 'activerecord', '~> 5.2.0'
@@ -1,5 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- gemspec path: '../../'
4
-
5
- gem 'activerecord', '~> 6.0.0'