stub_protected_environments 0.1.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: 23e47cd7ff10834676c2e7338fea7ca7bca21a95
4
+ data.tar.gz: cb0239827ebacb03a3496ba11c9d9456fe65561a
5
+ SHA512:
6
+ metadata.gz: eac5c65f9148c7e31003fa921e73ccf5d869daf19b1b6361a5001a157e429b057d340e65dd6a81cdbed33c947046350c0f738aa70a4b5e6499d2a746cf9a2b6d
7
+ data.tar.gz: 153a23788ac86ef7086e41a560a3f0d96ade0e17ae575497e28221641abb2ce5e498641527a001decd97dfe7dbde6f0c56eb35eea10fe9c0e10e3e8a3701fa04
data/.gitignore ADDED
@@ -0,0 +1,8 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in stub_protected_environments.gemspec
6
+ gemspec
data/README.md ADDED
@@ -0,0 +1,61 @@
1
+ # Stub Protected Environments
2
+
3
+ This gem stubs the `db:check_protected_environments` rake task that was introduced in Rails 5
4
+ to protect users from performing database actions on production databases.
5
+
6
+ While that endeavor may be founded on good intentions, we feel that the protected environment feature is a bike shed on core `rails`
7
+ and is extremely obtrusive and negatively impacts the productivity of a Rails application development.
8
+
9
+ Using this gem, you will no longer experience
10
+
11
+ ```
12
+ rake db:migrate
13
+ rake aborted!
14
+ ActiveRecord::NoEnvironmentInSchemaError:
15
+
16
+ Environment data not found in the schema. To resolve this issue, run:
17
+
18
+ bin/rails db:environment:set RAILS_ENV=development
19
+
20
+ ```
21
+
22
+ ## Philosophy
23
+
24
+ Should Rails protect you from dropping a database? or migrating a change? We think not.
25
+ If you are attempting to upgrade your Rails 4 application to Rails 5, you might experience this miserable scenario:
26
+
27
+ ```
28
+ rake db:migrate
29
+ ActiveRecord::NoEnvironmentInSchemaError <-- rails stops you
30
+ rails db:environment:set RAILS_ENV=development <-- makes you type more stuff
31
+ rake db:migrate <-- yes, that is what we are trying to do in the first place
32
+
33
+ Directly inheriting from ActiveRecord::Migration is not supported. Please specify the Rails release the migration was written for:
34
+ class DeviseCreateUsers < ActiveRecord::Migration[4.2]
35
+ Migration error -
36
+
37
+ OK, let's fix the migration and run again...
38
+ rake db:migrate
39
+ ActiveRecord::NoEnvironmentInSchemaError <-- !#$%^ I ALREADY DID THAT!
40
+ ```
41
+
42
+
43
+ ## Installation
44
+
45
+ Include this gem in your Gemfile:
46
+ ```
47
+ gem 'stub_protected_environments'
48
+ ```
49
+
50
+ > TIP: include the gem in the development and test sections of your Gemfile to retain the Rails protection in production
51
+
52
+ ## Usage
53
+
54
+ Run your database rake tasks without obstruction:
55
+
56
+ `rake db:drop db:create db:schema_load`
57
+
58
+ And have a great day!
59
+
60
+ ## Contributing
61
+ Submit pull requests, propose features and discuss issues. We are in this together.
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+ task :default => :spec
data/lib/railtie.rb ADDED
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+ module StubProtectedEnvironments
3
+ class Railtie < Rails::Railtie
4
+ railtie_name :stub_protected_environments
5
+
6
+ rake_tasks do
7
+ path = File.expand_path(__dir__)
8
+ Dir.glob("#{path}/stub_protected_environments/tasks/**/*.rake").each { |f| load f }
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,6 @@
1
+ Rake.application.instance_variable_get("@tasks").delete('db:check_protected_environments')
2
+ namespace :db do
3
+ task :check_protected_environments=>:environment do
4
+ puts "Stubbed Rails protected environment check."
5
+ end
6
+ end
@@ -0,0 +1,3 @@
1
+ module StubProtectedEnvironments
2
+ VERSION = "0.1.1"
3
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'stub_protected_environments/version'
4
+
5
+ module StubProtectedEnvironments
6
+ require 'railtie' if defined?(Rails)
7
+ end
@@ -0,0 +1,27 @@
1
+
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "stub_protected_environments/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "stub_protected_environments"
8
+ spec.version = StubProtectedEnvironments::VERSION
9
+ spec.authors = ["Vanboom"]
10
+ spec.email = ["dvboom@hotmail.com"]
11
+
12
+ spec.summary = %q{Stub the db:check_protected_environments rake task introduced in Rails 5}
13
+ spec.homepage = "https://github.com/vanboom/stub_protected_environments"
14
+
15
+ # Specify which files should be added to the gem when it is released.
16
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
17
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
18
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
19
+ end
20
+ spec.bindir = "exe"
21
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
22
+ spec.require_paths = ["lib"]
23
+
24
+ spec.add_development_dependency "bundler", "~> 1.16"
25
+ spec.add_development_dependency "rake", "~> 10.0"
26
+ spec.add_development_dependency "rails", "> 5.1"
27
+ end
metadata ADDED
@@ -0,0 +1,94 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: stub_protected_environments
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
+ platform: ruby
6
+ authors:
7
+ - Vanboom
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2021-03-24 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.16'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.16'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rails
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">"
46
+ - !ruby/object:Gem::Version
47
+ version: '5.1'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">"
53
+ - !ruby/object:Gem::Version
54
+ version: '5.1'
55
+ description:
56
+ email:
57
+ - dvboom@hotmail.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - ".gitignore"
63
+ - Gemfile
64
+ - README.md
65
+ - Rakefile
66
+ - lib/railtie.rb
67
+ - lib/stub_protected_environments.rb
68
+ - lib/stub_protected_environments/tasks/db/check_protected_environments.rake
69
+ - lib/stub_protected_environments/version.rb
70
+ - stub_protected_environments.gemspec
71
+ homepage: https://github.com/vanboom/stub_protected_environments
72
+ licenses: []
73
+ metadata: {}
74
+ post_install_message:
75
+ rdoc_options: []
76
+ require_paths:
77
+ - lib
78
+ required_ruby_version: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ required_rubygems_version: !ruby/object:Gem::Requirement
84
+ requirements:
85
+ - - ">="
86
+ - !ruby/object:Gem::Version
87
+ version: '0'
88
+ requirements: []
89
+ rubyforge_project:
90
+ rubygems_version: 2.5.2.3
91
+ signing_key:
92
+ specification_version: 4
93
+ summary: Stub the db:check_protected_environments rake task introduced in Rails 5
94
+ test_files: []