Class: SSHKit::Formatter::Pretty
- Defined in:
- lib/sshkit/formatters/pretty.rb
Instance Attribute Summary
Attributes inherited from Abstract
Instance Method Summary collapse
- #write(obj) ⇒ Object (also: #<<)
Methods inherited from Abstract
Constructor Details
This class inherits a constructor from SSHKit::Formatter::Abstract
Instance Method Details
#write(obj) ⇒ Object Also known as: <<
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/sshkit/formatters/pretty.rb', line 9 def write(obj) if obj.is_a? SSHKit::Command return if obj.verbosity < SSHKit.config.output_verbosity unless obj.started? original_output << "[#{c.green(obj.uuid)}] Running #{c.yellow(c.bold(String(obj)))} on #{c.yellow(obj.host.to_s)}\n" end if obj.complete? && !obj.stdout.empty? obj.stdout.lines.each do |line| original_output << c.green("\t" + line) end end if obj.complete? && !obj.stderr.empty? obj.stderr.lines.each do |line| original_output << c.red("\t" + line) end end if obj.finished? original_output << "[#{c.green(obj.uuid)}] Finished in #{sprintf('%5.3f seconds', obj.runtime)} command #{c.bold { obj.failure? ? c.red('failed') : c.green('successful') }}.\n" end else original_output << c.black(c.on_yellow("Output formatter doesn't know how to handle #{obj.inspect}\n")) end end |