Class: SSHKit::Formatter::Simple
- Inherits:
-
Abstract
- Object
- Abstract
- SSHKit::Formatter::Simple
- Defined in:
- lib/sshkit/formatter/simple.rb
Instance Method Summary collapse
- #error(message = 'X') ⇒ Object
- #info(message) ⇒ Object
-
#initialize(original_output) ⇒ Simple
constructor
A new instance of Simple.
- #result(message) ⇒ Object
- #start(message, &block) ⇒ Object
- #stop ⇒ Object
- #success(message = '✔') ⇒ Object
- #write(message) ⇒ Object (also: #<<)
Constructor Details
#initialize(original_output) ⇒ Simple
Returns a new instance of Simple.
8 9 10 11 12 13 |
# File 'lib/sshkit/formatter/simple.rb', line 8 def initialize(original_output) super(original_output) @spinner = CapistranoSimpleFormatter::Spinner.new @in_block = false end |
Instance Method Details
#error(message = 'X') ⇒ Object
55 56 57 |
# File 'lib/sshkit/formatter/simple.rb', line 55 def error( = 'X') result(.red) end |
#info(message) ⇒ Object
51 52 53 |
# File 'lib/sshkit/formatter/simple.rb', line 51 def info() result() end |
#result(message) ⇒ Object
40 41 42 43 44 45 46 47 48 49 |
# File 'lib/sshkit/formatter/simple.rb', line 40 def result() if @in_block print "\b" = " ├── #{}" else stop end puts() end |
#start(message, &block) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/sshkit/formatter/simple.rb', line 15 def start(, &block) @spinner.start begin if block_given? @in_block = true puts "\b#{}".yellow block.call() stop @in_block = false else print "\b#{} ".yellow end rescue Exception => e stop @in_block = false error("\n X ERROR: #{e.}\n") raise e end end |
#stop ⇒ Object
36 37 38 |
# File 'lib/sshkit/formatter/simple.rb', line 36 def stop @spinner.stop end |
#success(message = '✔') ⇒ Object
59 60 61 |
# File 'lib/sshkit/formatter/simple.rb', line 59 def success( = '✔') result(.green) end |
#write(message) ⇒ Object Also known as: <<
63 |
# File 'lib/sshkit/formatter/simple.rb', line 63 def write() end |