outrigger 1.0.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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: ce0d4c69f2e2c7deb1ec22cb1ab210085f2a0d13
4
+ data.tar.gz: 0c54dfeb820e336ca9425ee1da1a810dc7f46e01
5
+ SHA512:
6
+ metadata.gz: c721ec0072acea8a9b41c3781df16c3b27b1d07c776f6c4e93005db9d776cb04fc369ded36e56051bd9eb4fef49788c0ad40c21bdfbf3d224c339d39de1b452d
7
+ data.tar.gz: 0351e8c9d161fa5727ae0db061e95889734aac627619cd80494ac5601f4acb3f93467edf225ad9163ff24a0abcb8bfe079efee9b105f5c2d548c475aedbb2283
@@ -0,0 +1,19 @@
1
+ require "bundler/gem_tasks"
2
+
3
+ begin
4
+ require "rspec/core/rake_task"
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ task(default: :spec)
9
+ rescue LoadError
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
19
+ end
@@ -0,0 +1,13 @@
1
+ require "active_record" unless defined? ActiveRecord
2
+
3
+ require "outrigger/taggable"
4
+ require "outrigger/taggable_proxy"
5
+
6
+ require "outrigger/railtie" if defined?(Rails)
7
+
8
+ module Outrigger
9
+ def self.filter(*tags)
10
+ tags = tags.flatten.map(&:to_sym)
11
+ proc { |migration| (tags - migration.tags).empty? }
12
+ end
13
+ end
@@ -0,0 +1,20 @@
1
+ require "taggable_migrations"
2
+ require "rails"
3
+ require "rake"
4
+
5
+ module Outrigger
6
+ class Railtie < Rails::Railtie
7
+ railtie_name :taggable_migrations
8
+
9
+ rake_tasks do
10
+ load "tasks/migrate.rake"
11
+ end
12
+
13
+ initializer "extend_migrations" do
14
+ ActiveSupport.on_load :active_record do
15
+ ActiveRecord::Migration.send :include, Outrigger::Taggable
16
+ ActiveRecord::MigrationProxy.send :include, Outrigger::TaggableProxy
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,21 @@
1
+ module Outrigger
2
+ module Taggable
3
+ def self.included(base)
4
+ base.extend(ClassMethods)
5
+
6
+ def tags
7
+ self.class.tags
8
+ end
9
+ end
10
+
11
+ module ClassMethods
12
+ def tag(*new_tags)
13
+ @tags = tags.concat(new_tags).uniq
14
+ end
15
+
16
+ def tags
17
+ @tags ||= []
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,7 @@
1
+ module Outrigger
2
+ module TaggableProxy
3
+ def self.included(_body)
4
+ delegate :tags, to: :migration
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,3 @@
1
+ module Outrigger
2
+ VERSION = "1.0.0"
3
+ end
@@ -0,0 +1,9 @@
1
+ namespace :db do
2
+ namespace :migrate do
3
+ desc "Run migrations for a Tag"
4
+ task :tagged => %i[environment load_config] do |_t, args|
5
+ puts("Migrating Tags: #{args.extras}")
6
+ ActiveRecord::Migrator.migrate(ActiveRecord::Migrator.migrations_paths, &Outrigger.filter(args.extras))
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,31 @@
1
+ require "spec_helper"
2
+
3
+ describe Outrigger do
4
+ describe "filter" do
5
+ before do
6
+ class PreDeployMigration < ActiveRecord::Migration
7
+ tag :predeploy
8
+ end
9
+
10
+ class UntaggedMigration < ActiveRecord::Migration
11
+ end
12
+
13
+ class MultiMigration < ActiveRecord::Migration
14
+ tag :predeploy, :dynamo
15
+ end
16
+ end
17
+
18
+ it "should return a proc that tests migrations" do
19
+ filter = Outrigger.filter(:predeploy)
20
+
21
+ expect(filter.call(PreDeployMigration)).to eq(true)
22
+ end
23
+
24
+ it "should accept multiple tags" do
25
+ filter = Outrigger.filter(:predeploy, :dynamo)
26
+
27
+ expect(filter.call(MultiMigration)).to eq(true)
28
+ expect(filter.call(PreDeployMigration)).to eq(false)
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,21 @@
1
+ require "spec_helper"
2
+
3
+ class TestProxy
4
+ include Outrigger::TaggableProxy
5
+ attr_accessor :migration
6
+ end
7
+
8
+ describe Outrigger::TaggableProxy do
9
+ before do
10
+ class PreDeployMigration < ActiveRecord::Migration
11
+ tag :predeploy
12
+ end
13
+ end
14
+
15
+ it "it should delegate tags to the migration" do
16
+ proxy = TestProxy.new
17
+ proxy.migration = PreDeployMigration.new
18
+
19
+ expect(proxy.tags).to eq([:predeploy])
20
+ end
21
+ end
@@ -0,0 +1,38 @@
1
+ require "spec_helper"
2
+
3
+ module ActiveRecord
4
+ class Migration
5
+ include Outrigger::Taggable
6
+ end
7
+ end
8
+
9
+ describe Outrigger::Taggable do
10
+ before do
11
+ class PreDeployMigration < ActiveRecord::Migration
12
+ tag :predeploy
13
+ end
14
+
15
+ class UntaggedMigration < ActiveRecord::Migration
16
+ end
17
+
18
+ class PostDeployMigration < ActiveRecord::Migration
19
+ tag :postdeploy
20
+ end
21
+ end
22
+
23
+ it "PreDeployMigration should be predeploy" do
24
+ expect(PreDeployMigration.tags).to eq([:predeploy])
25
+ end
26
+
27
+ it "UntaggedMigration should be have no tags" do
28
+ expect(UntaggedMigration.tags).to eq([])
29
+ end
30
+
31
+ it "PostDeployMigration should be predeploy" do
32
+ expect(PostDeployMigration.tags).to eq([:postdeploy])
33
+ end
34
+
35
+ it "instance tags should point to class tags" do
36
+ expect(PreDeployMigration.new.tags).to eq([:predeploy])
37
+ end
38
+ end
@@ -0,0 +1,20 @@
1
+ # This file was generated by the `rspec --init` command. Conventionally, all
2
+ # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
3
+ # Require this file using `require "spec_helper"` to ensure that it is only
4
+ # loaded once.
5
+ #
6
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
7
+ require "active_record"
8
+ require "outrigger"
9
+
10
+ RSpec.configure do |config|
11
+ config.treat_symbols_as_metadata_keys_with_true_values = true
12
+ config.run_all_when_everything_filtered = true
13
+ config.filter_run :focus
14
+
15
+ # Run specs in random order to surface order dependencies. If you find an
16
+ # order dependency and want to debug it, you can fix the order by providing
17
+ # the seed, which is printed after each run.
18
+ # --seed 1234
19
+ config.order = "random"
20
+ end
metadata ADDED
@@ -0,0 +1,116 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: outrigger
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Drew Bowman
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-08-26 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: activerecord
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '4.1'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '4.1'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.5'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.5'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '10.2'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '10.2'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '='
60
+ - !ruby/object:Gem::Version
61
+ version: 2.14.1
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '='
67
+ - !ruby/object:Gem::Version
68
+ version: 2.14.1
69
+ description: Migrations
70
+ email:
71
+ - dbowman@instructure.com
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - Rakefile
77
+ - lib/outrigger.rb
78
+ - lib/outrigger/railtie.rb
79
+ - lib/outrigger/taggable.rb
80
+ - lib/outrigger/taggable_proxy.rb
81
+ - lib/outrigger/version.rb
82
+ - lib/tasks/migrate.rake
83
+ - spec/outrigger/outrigger_spec.rb
84
+ - spec/outrigger/taggable_proxy_spec.rb
85
+ - spec/outrigger/taggable_spec.rb
86
+ - spec/spec_helper.rb
87
+ homepage: http://www.instructure.com
88
+ licenses:
89
+ - MIT
90
+ metadata: {}
91
+ post_install_message:
92
+ rdoc_options: []
93
+ require_paths:
94
+ - lib
95
+ required_ruby_version: !ruby/object:Gem::Requirement
96
+ requirements:
97
+ - - ">="
98
+ - !ruby/object:Gem::Version
99
+ version: '0'
100
+ required_rubygems_version: !ruby/object:Gem::Requirement
101
+ requirements:
102
+ - - ">="
103
+ - !ruby/object:Gem::Version
104
+ version: '0'
105
+ requirements: []
106
+ rubyforge_project:
107
+ rubygems_version: 2.4.6
108
+ signing_key:
109
+ specification_version: 4
110
+ summary: Tag migrations and run them separately
111
+ test_files:
112
+ - spec/outrigger/outrigger_spec.rb
113
+ - spec/outrigger/taggable_proxy_spec.rb
114
+ - spec/outrigger/taggable_spec.rb
115
+ - spec/spec_helper.rb
116
+ has_rdoc: