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 |
# File 'lib/capistrano_banner/base.rb', line 12 def File.read(@path) end |
#color(overwrite = nil) ⇒ Object
28 29 30 31 32 33 34 35 36 |
# File 'lib/capistrano_banner/base.rb', line 28 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
16 17 18 |
# File 'lib/capistrano_banner/base.rb', line 16 def (color) Term::ANSIColor.send(color, Term::ANSIColor.bold()) end |
#pause ⇒ Object
20 21 22 |
# File 'lib/capistrano_banner/base.rb', line 20 def pause exit unless @ui.agree(prompt) end |
#print_banner(options) ⇒ Object
42 43 44 45 46 47 48 49 |
# File 'lib/capistrano_banner/base.rb', line 42 def () c = color([:color]) puts (c) if ![:force] && (warning_color?(c) || [:pause]) pause end end |
#prompt ⇒ Object
24 25 26 |
# File 'lib/capistrano_banner/base.rb', line 24 def prompt "This is #{Term::ANSIColor.send(color, @stage.to_s)} stage. Are you ready? (y/N) >" end |
#warning_color?(color) ⇒ Boolean
38 39 40 |
# File 'lib/capistrano_banner/base.rb', line 38 def warning_color?(color) color == :red end |