capistrano-confirm 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +4 -0
- data/Gemfile +4 -0
- data/LICENSE +18 -0
- data/README +22 -0
- data/Rakefile +1 -0
- data/capistrano-confirm.gemspec +18 -0
- data/lib/capistrano-confirm/version.rb +5 -0
- data/lib/capistrano-confirm.rb +37 -0
- metadata +75 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
2
|
+
a copy of this software and associated documentation files (the
|
3
|
+
'Software'), to deal in the Software without restriction, including
|
4
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
5
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
6
|
+
permit persons to whom the Software is furnished to do so, subject to
|
7
|
+
the following conditions:
|
8
|
+
|
9
|
+
The above copyright notice and this permission notice shall be
|
10
|
+
included in all copies or substantial portions of the Software.
|
11
|
+
|
12
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
13
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
14
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
15
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
16
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
17
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
18
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
= Capistrano Confirm
|
2
|
+
|
3
|
+
Confirm before deploy.
|
4
|
+
|
5
|
+
Make sure you are not deploying the wrong branch, or remind you should deploy it after code review!
|
6
|
+
|
7
|
+
== Usage:
|
8
|
+
|
9
|
+
1, Add it to your Gemfile:
|
10
|
+
|
11
|
+
gem 'capistrano-confirm'
|
12
|
+
|
13
|
+
2, Require it in your deploy config file, it should be `config/deploy.rb` for rails
|
14
|
+
|
15
|
+
require "bundler/setup"
|
16
|
+
require 'capistrano-confirm'
|
17
|
+
|
18
|
+
|
19
|
+
== Author
|
20
|
+
Jinzhu Zhang
|
21
|
+
wosmvp@gmail.com
|
22
|
+
http://github.com/jinzhu
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
Gem::Specification.new do |s|
|
4
|
+
s.name = "capistrano-confirm"
|
5
|
+
s.version = "0.0.1" #Capistrano::Confirm::VERSION
|
6
|
+
s.authors = ["Jinzhu"]
|
7
|
+
s.email = ["wosmvp@gmail.com"]
|
8
|
+
s.homepage = "https://github.com/jinzhu/capistrano-confirm"
|
9
|
+
s.summary = %q{Confirm before deploy}
|
10
|
+
s.description = %q{Confirm before deploy}
|
11
|
+
|
12
|
+
s.rubyforge_project = "capistrano-confirm"
|
13
|
+
|
14
|
+
s.files = `git ls-files`.split("\n")
|
15
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
16
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
17
|
+
s.require_paths = ["lib"]
|
18
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
def colorful(str, code="31")
|
2
|
+
"\e[#{code}m#{str.upcase}\e[0m"
|
3
|
+
end
|
4
|
+
|
5
|
+
Capistrano::Configuration.instance.load do
|
6
|
+
namespace :deploy do
|
7
|
+
task :confirm do
|
8
|
+
first_num, sencond_num = rand(10), rand(10)
|
9
|
+
|
10
|
+
result = first_num + sencond_num
|
11
|
+
stage_info = " #{colorful(stage)}" rescue ''
|
12
|
+
branch_info = " with branch #{colorful(branch)}" rescue ''
|
13
|
+
|
14
|
+
Capistrano::CLI.ui.say %Q(
|
15
|
+
#{colorful("="*80, 33)}
|
16
|
+
|
17
|
+
You are deploying#{stage_info}#{branch_info}, Are you sure?
|
18
|
+
Please make sure you did #{colorful("code review")}, and are not deploying the #{colorful("wrong branch")},
|
19
|
+
Answer the bellow question to make sure you are not drunk!
|
20
|
+
#{first_num} + #{sencond_num} = ?
|
21
|
+
|
22
|
+
#{colorful("="*80, 33)}
|
23
|
+
)
|
24
|
+
|
25
|
+
answer = Capistrano::CLI.ui.ask("Your answer here (answer `NO` to stop the deploy):").strip
|
26
|
+
if (answer =~ /^\s*\d+\s*$/) && (answer.to_i == result)
|
27
|
+
Capistrano::CLI.ui.say colorful("Deploying#{"."*71}", 33)
|
28
|
+
else
|
29
|
+
Capistrano::CLI.ui.say colorful("Stoping#{"."*73}", 33)
|
30
|
+
Capistrano::CLI.ui.say colorful("Difficult question for you? Your math must be taught by National Bureau of Statistics!") if (answer =~ /^\s*\d+\s*$/)
|
31
|
+
abort
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
before "deploy:update_code", "deploy:confirm"
|
36
|
+
end
|
37
|
+
end
|
metadata
ADDED
@@ -0,0 +1,75 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: capistrano-confirm
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 29
|
5
|
+
prerelease:
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 0
|
9
|
+
- 1
|
10
|
+
version: 0.0.1
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Jinzhu
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2011-12-15 00:00:00 +08:00
|
19
|
+
default_executable:
|
20
|
+
dependencies: []
|
21
|
+
|
22
|
+
description: Confirm before deploy
|
23
|
+
email:
|
24
|
+
- wosmvp@gmail.com
|
25
|
+
executables: []
|
26
|
+
|
27
|
+
extensions: []
|
28
|
+
|
29
|
+
extra_rdoc_files: []
|
30
|
+
|
31
|
+
files:
|
32
|
+
- .gitignore
|
33
|
+
- Gemfile
|
34
|
+
- LICENSE
|
35
|
+
- README
|
36
|
+
- Rakefile
|
37
|
+
- capistrano-confirm.gemspec
|
38
|
+
- lib/capistrano-confirm.rb
|
39
|
+
- lib/capistrano-confirm/version.rb
|
40
|
+
has_rdoc: true
|
41
|
+
homepage: https://github.com/jinzhu/capistrano-confirm
|
42
|
+
licenses: []
|
43
|
+
|
44
|
+
post_install_message:
|
45
|
+
rdoc_options: []
|
46
|
+
|
47
|
+
require_paths:
|
48
|
+
- lib
|
49
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
hash: 3
|
55
|
+
segments:
|
56
|
+
- 0
|
57
|
+
version: "0"
|
58
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
59
|
+
none: false
|
60
|
+
requirements:
|
61
|
+
- - ">="
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
hash: 3
|
64
|
+
segments:
|
65
|
+
- 0
|
66
|
+
version: "0"
|
67
|
+
requirements: []
|
68
|
+
|
69
|
+
rubyforge_project: capistrano-confirm
|
70
|
+
rubygems_version: 1.6.2
|
71
|
+
signing_key:
|
72
|
+
specification_version: 3
|
73
|
+
summary: Confirm before deploy
|
74
|
+
test_files: []
|
75
|
+
|