class Bow::ResponseFormatter

Constants

ERROR
INFO
SUCCESS

Public Class Methods

colorize(msg, color_pattern) click to toggle source
# File lib/bow/response_formatter.rb, line 40
def colorize(msg, color_pattern)
  color_pattern % msg
end
colorize_result(result) click to toggle source
# File lib/bow/response_formatter.rb, line 29
def colorize_result(result)
  out, err = result.map { |m| m.to_s.strip }
  err = err.empty? ? nil : colorize(err, ERROR)
  out = if !out.empty?
          colorize(out, SUCCESS)
        elsif err.nil?
          colorize('DONE', INFO)
        end
  [out, err]
end
multi_print(host, results) click to toggle source
# File lib/bow/response_formatter.rb, line 15
def multi_print(host, results)
  results.each do |r|
    puts "#{wrap(host, r)}\n"
  end
end
pretty_print(*args) click to toggle source
# File lib/bow/response_formatter.rb, line 11
def pretty_print(*args)
  puts "#{wrap(*args)}\n"
end
wrap(host, result) click to toggle source
# File lib/bow/response_formatter.rb, line 21
def wrap(host, result)
  host_group = colorize("[#{host.group}]", HEADER)
  host_addr = colorize(host.host, HEADER)
  host_header = "\n#{host_group} #{host_addr}:\n\n"
  response = colorize_result(result).compact.first
  "#{host_header}#{response}"
end