rails_pending_migration_errors 0.0.1

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 7eef8c4257d60313f2710c1dc334ee00ded3bcef
4
+ data.tar.gz: e3fa6ec2d241f6b2733ff0118f48841f52c24f0f
5
+ SHA512:
6
+ metadata.gz: 04909b3bc42a3b5ace7fe31793502f81fb837c85dc2b8d5182bacba43773bc6920614cb565fe55639eeb204705186e6784b9029ceefad24c60a5387cdd2231e6
7
+ data.tar.gz: 01099cd05d31a4d1c03879dcb24aa73549dccdb15f0dc997c1c3b2c3b67a5554443a458c6ed8de0f5865bfeb7a78c0e852fc6aa1621f00ade22b7aa98f054beb
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,2 @@
1
+ source 'https://rubygems.org'
2
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Vincent Roy
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,19 @@
1
+ # Rails Pending Migration Errors
2
+
3
+ Raise errors in development mode when there are pending migrations to run.
4
+
5
+ It is essentially a backport of [this feature](https://github.com/rails/rails/pull/6665) that made it in Rails 4.
6
+
7
+ ![Example](http://f.cl.ly/items/3a3Q0i3e1D0s12420t0v/Screen%20Shot%202013-10-09%20at%207.19.28%20PM.png "Example")
8
+
9
+ **Note:** this has only been tested against Rails 3.2.13 on ruby 2.0.0p247.
10
+
11
+ ## Installation
12
+
13
+ Add this line to your application's Gemfile:
14
+
15
+ gem 'rails_pending_migration_errors', group: :development
16
+
17
+ And then execute:
18
+
19
+ $ bundle
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,44 @@
1
+ module ActiveRecord
2
+ class PendingMigrationError < ActiveRecordError#:nodoc:
3
+ def initialize
4
+ super("Migrations are pending; run 'bin/rake db:migrate RAILS_ENV=#{::Rails.env}' to resolve this issue.")
5
+ end
6
+ end
7
+ end
8
+
9
+ module RailsPendingMigrationErrors
10
+
11
+ class Middleware
12
+
13
+ def initialize(app)
14
+ @app = app
15
+ end
16
+
17
+ def call(env)
18
+ ActiveRecord::Base.logger.quietly do
19
+ check_pending_migrations!
20
+ end
21
+
22
+ @app.call(env)
23
+ end
24
+
25
+ private
26
+
27
+ def check_pending_migrations!
28
+ raise ActiveRecord::PendingMigrationError if needs_migrations?
29
+ end
30
+
31
+ def needs_migrations?
32
+ (file_versions - db_versions).size > 0
33
+ end
34
+
35
+ def file_versions
36
+ ActiveRecord::Migrator.migrations( ActiveRecord::Migrator.migrations_paths ).map(&:version)
37
+ end
38
+
39
+ def db_versions
40
+ ActiveRecord::Migrator.get_all_versions
41
+ end
42
+
43
+ end
44
+ end
@@ -0,0 +1,11 @@
1
+ module RailsPendingMigrationErrors
2
+
3
+ class Railtie < Rails::Railtie
4
+ initializer "rails_pending_migration_errors.configure_rails_initialization" do
5
+ if Rails.env.development?
6
+ Rails.application.middleware.use RailsPendingMigrationErrors::Middleware
7
+ end
8
+ end
9
+ end
10
+
11
+ end
@@ -0,0 +1,3 @@
1
+ module RailsPendingMigrationErrors
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,6 @@
1
+ require "rails_pending_migration_errors/version"
2
+ require "rails_pending_migration_errors/middleware"
3
+ require "rails_pending_migration_errors/rails"
4
+
5
+ module RailsPendingMigrationErrors
6
+ end
@@ -0,0 +1,23 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'rails_pending_migration_errors/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "rails_pending_migration_errors"
8
+ spec.version = RailsPendingMigrationErrors::VERSION
9
+ spec.authors = ["Vincent Roy"]
10
+ spec.email = ["vincentroy8@gmail.com"]
11
+ spec.description = "Raise errors in development mode when there are pending migrations to run."
12
+ spec.summary = ""
13
+ spec.homepage = ""
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.3"
22
+ spec.add_development_dependency "rake"
23
+ end
metadata ADDED
@@ -0,0 +1,83 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rails_pending_migration_errors
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Vincent Roy
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-10-09 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '1.3'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.3'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ description: Raise errors in development mode when there are pending migrations to
42
+ run.
43
+ email:
44
+ - vincentroy8@gmail.com
45
+ executables: []
46
+ extensions: []
47
+ extra_rdoc_files: []
48
+ files:
49
+ - .gitignore
50
+ - Gemfile
51
+ - LICENSE.txt
52
+ - README.md
53
+ - Rakefile
54
+ - lib/rails_pending_migration_errors.rb
55
+ - lib/rails_pending_migration_errors/middleware.rb
56
+ - lib/rails_pending_migration_errors/rails.rb
57
+ - lib/rails_pending_migration_errors/version.rb
58
+ - rails_pending_migration_errors.gemspec
59
+ homepage: ''
60
+ licenses:
61
+ - MIT
62
+ metadata: {}
63
+ post_install_message:
64
+ rdoc_options: []
65
+ require_paths:
66
+ - lib
67
+ required_ruby_version: !ruby/object:Gem::Requirement
68
+ requirements:
69
+ - - '>='
70
+ - !ruby/object:Gem::Version
71
+ version: '0'
72
+ required_rubygems_version: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - '>='
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
77
+ requirements: []
78
+ rubyforge_project:
79
+ rubygems_version: 2.0.6
80
+ signing_key:
81
+ specification_version: 4
82
+ summary: ''
83
+ test_files: []