Class: CapistranoBanner::Base
- Inherits:
-
Object
- Object
- CapistranoBanner::Base
- Defined in:
- lib/capistrano_banner/base.rb
Instance Method Summary collapse
- #banner ⇒ Object
- #color(overwrite = nil) ⇒ Object
- #color_banner(color) ⇒ Object
-
#initialize(stage, path) ⇒ Base
constructor
A new instance of Base.
- #pause ⇒ Object
- #print_banner(options) ⇒ Object
- #prompt ⇒ Object
- #warning_color?(color) ⇒ Boolean
Constructor Details
#initialize(stage, path) ⇒ Base
Returns a new instance of Base.
6 7 8 9 10 |
# File 'lib/capistrano_banner/base.rb', line 6 def initialize(stage, path) @stage = stage @path = path @ui = HighLine.new end |
Instance Method Details
#banner ⇒ Object
12 13 14 15 16 17 18 19 20 |
# File 'lib/capistrano_banner/base.rb', line 12 def if @path.end_with? ".erb" require 'erb' template = File.read(@path) ERB.new(template).result else File.read(@path) end end |
#color(overwrite = nil) ⇒ Object
34 35 36 37 38 39 40 41 42 |
# File 'lib/capistrano_banner/base.rb', line 34 def color(overwrite = nil) return overwrite if overwrite case @stage when :production ; :red when :staging ; :yellow else :green ; :green end end |
#color_banner(color) ⇒ Object
22 23 24 |
# File 'lib/capistrano_banner/base.rb', line 22 def (color) Term::ANSIColor.send(color, Term::ANSIColor.bold()) end |
#pause ⇒ Object
26 27 28 |
# File 'lib/capistrano_banner/base.rb', line 26 def pause exit unless @ui.agree(prompt) end |
#print_banner(options) ⇒ Object
48 49 50 51 52 53 54 55 |
# File 'lib/capistrano_banner/base.rb', line 48 def () c = color([:color]) puts (c) if ![:force] && (warning_color?(c) || [:pause]) pause end end |
#prompt ⇒ Object
30 31 32 |
# File 'lib/capistrano_banner/base.rb', line 30 def prompt "This is #{Term::ANSIColor.send(color, @stage.to_s)} stage. Are you ready? (y/N) >" end |
#warning_color?(color) ⇒ Boolean
44 45 46 |
# File 'lib/capistrano_banner/base.rb', line 44 def warning_color?(color) color == :red end |