rake-guardian 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: c2b4c453d7707012b3078cf04053d808f852a199
4
+ data.tar.gz: a3d5fed1ba5be603ff77d2685509e9d2e2b366bb
5
+ SHA512:
6
+ metadata.gz: 56b35474c919d09c9c6e585848cd06e4572081263168e7b351ceed0ce6df72f71f41ac52c78f3d866b115916b8b762ccf4a5b68d56b1b297aab9ad2f040c071c
7
+ data.tar.gz: f02a0f4e0a441cec8cc4573df83172e6aa2b7fc2e7c35b3423be6a8cabbbc9a681513a099078cc9e7abe0e749498ba16101d145d3a94007873fa0f8c0b5550b8
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
@@ -0,0 +1,5 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.1.7
4
+ - 2.2.3
5
+ before_install: gem install bundler -v 1.10.6
@@ -0,0 +1,13 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
4
+
5
+ We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, ethnicity, age, or religion.
6
+
7
+ Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
8
+
9
+ Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
10
+
11
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
12
+
13
+ This Code of Conduct is adapted from the [Contributor Covenant](http://contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in rake-guardian.gemspec
4
+ gemspec
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Yuji Yaginuma
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,68 @@
1
+ # Rake::Guardian
2
+
3
+ To prevent the execution of the Rake in a particular environment in Rails application
4
+
5
+ [![Build Status](https://travis-ci.org/y-yagi/rake-guardian.svg?branch=master)](https://travis-ci.org/y-yagi/rake-guardian)
6
+ [![Gem Version](https://badge.fury.io/rb/rake-guardian.svg)](http://badge.fury.io/rb/rake-guardian)
7
+
8
+ ## Installation
9
+
10
+ Add this line to your application's Gemfile:
11
+
12
+ ```ruby
13
+ gem 'rake-guardian'
14
+ ```
15
+
16
+ And then execute:
17
+
18
+ $ bundle
19
+
20
+ Or install it yourself as:
21
+
22
+ $ gem install rake-guardian
23
+
24
+ ## Usage
25
+
26
+ If you were running the `rake db:drop` in in production environment by mistake, to prevent automatic processing.
27
+
28
+ ```
29
+ ./bin/rake db:drop RAILS_ENV=production
30
+ [rake-guardian] db:drop can not invoke.
31
+ ```
32
+ By default, it will prevent the execution of the `db:drop`, `db:reset`, `db:purge` and `db:drop:all`.
33
+ Judgment of environment I have performed in `RAILS_ENV`.
34
+
35
+ ### configuration options
36
+
37
+ You can configure the following default values by overriding these values using Rake::Guardian.configure method.
38
+
39
+ ```ruby
40
+ env # %w(production)
41
+ tasks # %w(db:drop db:reset db:purge db:drop:all)
42
+ ```
43
+
44
+ Example.
45
+
46
+ ```ruby
47
+ # config/initializers/rake_guardian.rb
48
+ Rake::Guardian.configure do |config|
49
+ config.env = %w(production staging)
50
+ config.tasks = %w(db:drop db:purge db:fixtures:load)
51
+ end
52
+ ```
53
+
54
+ ## Development
55
+
56
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
57
+
58
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
59
+
60
+ ## Contributing
61
+
62
+ Bug reports and pull requests are welcome on GitHub at https://github.com/y-yagi/rake-guardian. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](contributor-covenant.org) code of conduct.
63
+
64
+
65
+ ## License
66
+
67
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
68
+
@@ -0,0 +1,13 @@
1
+ require "bundler/gem_tasks"
2
+ require "rake/testtask"
3
+ require "rake/guardian"
4
+ load 'test/rake/test_task.rake'
5
+
6
+ Rake::TestTask.new(:test) do |t|
7
+ t.libs << "test"
8
+ t.libs << "lib"
9
+ t.test_files = FileList['test/**/*_test.rb']
10
+ end
11
+
12
+ task :default => :test
13
+
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "rake/guardian"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,28 @@
1
+ require "rake/guardian/version"
2
+ require "rake/guardian/config"
3
+ require "rake/application"
4
+
5
+ module Rake
6
+ module Guardian
7
+ def invoke_task(task_string)
8
+ name, args = parse_task_string(task_string)
9
+ if need_guard?(name)
10
+ $stderr.puts "[rake-guardian] #{name} can not invoke."
11
+ return 0
12
+ end
13
+ super
14
+ end
15
+
16
+ def need_guard?(task_name)
17
+ env = ENV['RAILS_ENV']
18
+ config = Rake::Guardian.config
19
+
20
+ if config.env.include?(env) && config.tasks.include?(task_name)
21
+ true
22
+ else
23
+ false
24
+ end
25
+ end
26
+ end
27
+ end
28
+ Rake::Application.prepend(Rake::Guardian)
@@ -0,0 +1,22 @@
1
+ require 'active_support/configurable'
2
+
3
+ module Rake::Guardian
4
+ class Configuration
5
+ include ActiveSupport::Configurable
6
+ config_accessor :env do
7
+ %w(production)
8
+ end
9
+
10
+ config_accessor :tasks do
11
+ %w(db:drop db:reset db:purge db:drop:all)
12
+ end
13
+ end
14
+
15
+ def self.configure(&block)
16
+ yield config
17
+ end
18
+
19
+ def self.config
20
+ @_config ||= Rake::Guardian::Configuration.new
21
+ end
22
+ end
@@ -0,0 +1,5 @@
1
+ module Rake
2
+ module Guardian
3
+ VERSION = "0.1.0"
4
+ end
5
+ end
@@ -0,0 +1,27 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'rake/guardian/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "rake-guardian"
8
+ spec.version = Rake::Guardian::VERSION
9
+ spec.authors = ["Yuji Yaginuma"]
10
+ spec.email = ["yuuji.yaginuma@gmail.com"]
11
+
12
+ spec.summary = %q{Prevent the Rake of execution in a particular environment}
13
+ spec.description = %q{Prevent the Rake of execution in a particular environment}
14
+ spec.homepage = "https://github.com/y-yagi/rake-guardian"
15
+ spec.license = "MIT"
16
+
17
+ spec.metadata['allowed_push_host'] = "https://rubygems.org"
18
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
19
+ spec.bindir = "exe"
20
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
21
+ spec.require_paths = ["lib"]
22
+
23
+ spec.add_dependency "rake", "~> 10.0"
24
+ spec.add_dependency "activesupport"
25
+ spec.add_development_dependency "bundler", "~> 1.10"
26
+ spec.add_development_dependency "minitest"
27
+ end
metadata ADDED
@@ -0,0 +1,114 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rake-guardian
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Yuji Yaginuma
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2015-09-13 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rake
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '10.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '10.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: activesupport
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.10'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.10'
55
+ - !ruby/object:Gem::Dependency
56
+ name: minitest
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ description: Prevent the Rake of execution in a particular environment
70
+ email:
71
+ - yuuji.yaginuma@gmail.com
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - ".gitignore"
77
+ - ".travis.yml"
78
+ - CODE_OF_CONDUCT.md
79
+ - Gemfile
80
+ - LICENSE.txt
81
+ - README.md
82
+ - Rakefile
83
+ - bin/console
84
+ - bin/setup
85
+ - lib/rake/guardian.rb
86
+ - lib/rake/guardian/config.rb
87
+ - lib/rake/guardian/version.rb
88
+ - rake-guardian.gemspec
89
+ homepage: https://github.com/y-yagi/rake-guardian
90
+ licenses:
91
+ - MIT
92
+ metadata:
93
+ allowed_push_host: https://rubygems.org
94
+ post_install_message:
95
+ rdoc_options: []
96
+ require_paths:
97
+ - lib
98
+ required_ruby_version: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - ">="
101
+ - !ruby/object:Gem::Version
102
+ version: '0'
103
+ required_rubygems_version: !ruby/object:Gem::Requirement
104
+ requirements:
105
+ - - ">="
106
+ - !ruby/object:Gem::Version
107
+ version: '0'
108
+ requirements: []
109
+ rubyforge_project:
110
+ rubygems_version: 2.4.5
111
+ signing_key:
112
+ specification_version: 4
113
+ summary: Prevent the Rake of execution in a particular environment
114
+ test_files: []