capistrano-banner 0.2.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 +7 -0
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +90 -0
- data/Rakefile +1 -0
- data/capistrano-banner.gemspec +23 -0
- data/lib/capistrano-banner.rb +3 -0
- data/lib/capistrano-banner/base.rb +64 -0
- data/lib/capistrano-banner/version.rb +3 -0
- data/lib/capistrano/banner.rb +3 -0
- data/lib/capistrano/tasks/banner.rake +16 -0
- metadata +98 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 60c45ab3385c15e9b925e9f3346787da0da37571
|
4
|
+
data.tar.gz: 46d62436e27375c14f49e3d18fe96c95fd9b1bd6
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 683287d3c5ac3b17d6f40dd40dbb5dce14566ded8d16239cb2cb2b822dec5cfbb4724f4398c846e0d34454892e91e64237d8bf093ca9e08e216f69b3f9d2e489
|
7
|
+
data.tar.gz: b7ed2b1195185fe9699b69fbf002010da714c85bd310c998475b7ed7a13835192e06c458e1a95056149f8cea426d6dc399d4f4d83a517ef960399d326b7e6c82
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2012 HORII Keima
|
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,90 @@
|
|
1
|
+
# capistrano-banner
|
2
|
+
|
3
|
+
`capistrano-banner` displays application banner, and pause in production stage
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Gemfile:
|
8
|
+
|
9
|
+
gem 'capistrano-banner'
|
10
|
+
|
11
|
+
Then:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
### Note
|
16
|
+
|
17
|
+
After version 0.1.0, `capistrano-banner` works well just with capistrano >= 3.
|
18
|
+
|
19
|
+
If you're using capistrano =< 2, please use this gem versioned 0.0.x
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
First, create your application banner in config/banner.txt.
|
24
|
+
|
25
|
+
Like this:
|
26
|
+
|
27
|
+
```zsh
|
28
|
+
$ gem install artii
|
29
|
+
$ artii --font=banner3-D yourapp > config/banner.txt
|
30
|
+
```
|
31
|
+
|
32
|
+
(about artii: https://github.com/miketierney/artii )
|
33
|
+
|
34
|
+
Then enable in Capfile:
|
35
|
+
|
36
|
+
require 'capistrano/banner'
|
37
|
+
|
38
|
+
This line hooks `deploy:banner` task just before `deploy:starting`.
|
39
|
+
|
40
|
+
See also [capistrano(3) flow](http://capistranorb.com/documentation/getting-started/flow/).
|
41
|
+
|
42
|
+
After all, let's execute cap!
|
43
|
+
|
44
|
+
```
|
45
|
+
$ cap production deploy
|
46
|
+
'##:::'##::'#######::'##::::'##:'########:::::'###::::'########::'########::
|
47
|
+
. ##:'##::'##.... ##: ##:::: ##: ##.... ##:::'## ##::: ##.... ##: ##.... ##:
|
48
|
+
:. ####::: ##:::: ##: ##:::: ##: ##:::: ##::'##:. ##:: ##:::: ##: ##:::: ##:
|
49
|
+
::. ##:::: ##:::: ##: ##:::: ##: ########::'##:::. ##: ########:: ########::
|
50
|
+
::: ##:::: ##:::: ##: ##:::: ##: ##.. ##::: #########: ##.....::: ##.....:::
|
51
|
+
::: ##:::: ##:::: ##: ##:::: ##: ##::. ##:: ##.... ##: ##:::::::: ##::::::::
|
52
|
+
::: ##::::. #######::. #######:: ##:::. ##: ##:::: ##: ##:::::::: ##::::::::
|
53
|
+
:::..::::::.......::::.......:::..:::::..::..:::::..::..:::::::::..:::::::::
|
54
|
+
|
55
|
+
This is production stage. Are you ready? (y/N) >
|
56
|
+
```
|
57
|
+
|
58
|
+
In production stage, capistarano pauses and waits your input.
|
59
|
+
|
60
|
+
### Custom banner hook
|
61
|
+
|
62
|
+
In another way, you can call banner method in your task:
|
63
|
+
|
64
|
+
```
|
65
|
+
task :foobar do
|
66
|
+
CapistranoBanner.banner("./config/custom.txt")
|
67
|
+
end
|
68
|
+
```
|
69
|
+
|
70
|
+
## Options
|
71
|
+
|
72
|
+
`capistrano-banner` respects some capistrano settings:
|
73
|
+
|
74
|
+
- `:banner_path` : A path to banner source file. Default to `"./config/banner.txt"`
|
75
|
+
- `:banner_options` : Set specifc banner options with Hash:
|
76
|
+
- `:color => :colorname'` banner color (e.g. :red, :green and :blue ... see https://github.com/flori/term-ansicolor )
|
77
|
+
- `:pause => true` anyway pause
|
78
|
+
- `:force => true` don't pause even if production env
|
79
|
+
|
80
|
+
## LICENSE
|
81
|
+
|
82
|
+
See LICENSE.txt.
|
83
|
+
|
84
|
+
## Contributing
|
85
|
+
|
86
|
+
1. Fork it
|
87
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
88
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
89
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
90
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'capistrano-banner/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |gem|
|
7
|
+
gem.name = "capistrano-banner"
|
8
|
+
gem.version = CapistranoBanner::VERSION
|
9
|
+
gem.authors = ["HORII Keima", "KONDO Uchio"]
|
10
|
+
gem.email = ["holysugar@gmail.com", "udzura@udzura.jp"]
|
11
|
+
gem.description = %q{capistrano application banner}
|
12
|
+
gem.summary = %q{provides a task to display application banner}
|
13
|
+
gem.homepage = "https://github.com/holysugar/capistrano-banner"
|
14
|
+
|
15
|
+
gem.files = `git ls-files`.split($/)
|
16
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
17
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
18
|
+
gem.require_paths = ["lib"]
|
19
|
+
|
20
|
+
gem.add_runtime_dependency 'capistrano', '>= 3.0.0'
|
21
|
+
gem.add_runtime_dependency 'term-ansicolor'
|
22
|
+
gem.add_runtime_dependency 'highline'
|
23
|
+
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
require 'term/ansicolor'
|
2
|
+
require 'highline'
|
3
|
+
|
4
|
+
module CapistranoBanner
|
5
|
+
class Base
|
6
|
+
def initialize(stage, path)
|
7
|
+
@stage = stage
|
8
|
+
@path = path
|
9
|
+
@ui = HighLine.new
|
10
|
+
end
|
11
|
+
|
12
|
+
def banner
|
13
|
+
if @path.end_with? ".erb"
|
14
|
+
require 'erb'
|
15
|
+
template = File.read(@path)
|
16
|
+
ERB.new(template).result
|
17
|
+
else
|
18
|
+
File.read(@path)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def color_banner(color)
|
23
|
+
Term::ANSIColor.send(color, Term::ANSIColor.bold(banner))
|
24
|
+
end
|
25
|
+
|
26
|
+
def pause
|
27
|
+
exit unless @ui.agree(prompt)
|
28
|
+
end
|
29
|
+
|
30
|
+
def prompt
|
31
|
+
"This is #{Term::ANSIColor.send(color, @stage.to_s)} stage. Are you ready? (y/N) >"
|
32
|
+
end
|
33
|
+
|
34
|
+
def color(overwrite = nil)
|
35
|
+
return overwrite if overwrite
|
36
|
+
|
37
|
+
case @stage
|
38
|
+
when :production ; :red
|
39
|
+
when :staging ; :yellow
|
40
|
+
else :green ; :green
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def warning_color?(color)
|
45
|
+
color == :red
|
46
|
+
end
|
47
|
+
|
48
|
+
def print_banner(options)
|
49
|
+
c = color(options[:color])
|
50
|
+
puts color_banner(c)
|
51
|
+
|
52
|
+
if !options[:force] && (warning_color?(c) || options[:pause])
|
53
|
+
pause
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
def self.banner(banner_path = nil, stage = fetch(:stage), options = {})
|
59
|
+
banner_path ||= (
|
60
|
+
File.exist?("./config/banner.txt.erb") ? "./config/banner.txt.erb" : "./config/banner.txt"
|
61
|
+
)
|
62
|
+
Base.new(stage, banner_path).print_banner(options)
|
63
|
+
end
|
64
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'capistrano-banner/base'
|
2
|
+
|
3
|
+
namespace :deploy do
|
4
|
+
desc 'Show banner of service'
|
5
|
+
task :banner do
|
6
|
+
path = fetch(:banner_path, lambda {
|
7
|
+
File.exist?("./config/banner.txt.erb") ? "./config/banner.txt.erb" : "./config/banner.txt"
|
8
|
+
})
|
9
|
+
stage = fetch(:stage, :development)
|
10
|
+
options = fetch(:banner_options, {})
|
11
|
+
|
12
|
+
CapistranoBanner::Base.new(stage, path).print_banner(options)
|
13
|
+
end
|
14
|
+
|
15
|
+
before :starting, :banner
|
16
|
+
end
|
metadata
ADDED
@@ -0,0 +1,98 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: capistrano-banner
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.2.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- HORII Keima
|
8
|
+
- KONDO Uchio
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2014-11-25 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: capistrano
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
18
|
+
- - '>='
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: 3.0.0
|
21
|
+
type: :runtime
|
22
|
+
prerelease: false
|
23
|
+
version_requirements: !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - '>='
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
version: 3.0.0
|
28
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: term-ansicolor
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - '>='
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: '0'
|
35
|
+
type: :runtime
|
36
|
+
prerelease: false
|
37
|
+
version_requirements: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - '>='
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: '0'
|
42
|
+
- !ruby/object:Gem::Dependency
|
43
|
+
name: highline
|
44
|
+
requirement: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - '>='
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: '0'
|
49
|
+
type: :runtime
|
50
|
+
prerelease: false
|
51
|
+
version_requirements: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - '>='
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '0'
|
56
|
+
description: capistrano application banner
|
57
|
+
email:
|
58
|
+
- holysugar@gmail.com
|
59
|
+
- udzura@udzura.jp
|
60
|
+
executables: []
|
61
|
+
extensions: []
|
62
|
+
extra_rdoc_files: []
|
63
|
+
files:
|
64
|
+
- .gitignore
|
65
|
+
- Gemfile
|
66
|
+
- LICENSE.txt
|
67
|
+
- README.md
|
68
|
+
- Rakefile
|
69
|
+
- capistrano-banner.gemspec
|
70
|
+
- lib/capistrano-banner.rb
|
71
|
+
- lib/capistrano-banner/base.rb
|
72
|
+
- lib/capistrano-banner/version.rb
|
73
|
+
- lib/capistrano/banner.rb
|
74
|
+
- lib/capistrano/tasks/banner.rake
|
75
|
+
homepage: https://github.com/holysugar/capistrano-banner
|
76
|
+
licenses: []
|
77
|
+
metadata: {}
|
78
|
+
post_install_message:
|
79
|
+
rdoc_options: []
|
80
|
+
require_paths:
|
81
|
+
- lib
|
82
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
83
|
+
requirements:
|
84
|
+
- - '>='
|
85
|
+
- !ruby/object:Gem::Version
|
86
|
+
version: '0'
|
87
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
88
|
+
requirements:
|
89
|
+
- - '>='
|
90
|
+
- !ruby/object:Gem::Version
|
91
|
+
version: '0'
|
92
|
+
requirements: []
|
93
|
+
rubyforge_project:
|
94
|
+
rubygems_version: 2.0.14
|
95
|
+
signing_key:
|
96
|
+
specification_version: 4
|
97
|
+
summary: provides a task to display application banner
|
98
|
+
test_files: []
|