lib/mutant/reporter/cli/printer.rb in mutant-0.8.0 vs lib/mutant/reporter/cli/printer.rb in mutant-0.8.1
- old
+ new
@@ -14,21 +14,19 @@
# Run printer
#
# @return [self]
#
# @api private
- #
abstract_method :run
private
- # Return status color
+ # Status color
#
# @return [Color]
#
# @api private
- #
def status_color
success? ? Color::GREEN : Color::RED
end
# Visit a collection of objects
@@ -37,11 +35,10 @@
# @return [Enumerable<Object>] collection
#
# @return [undefined]
#
# @api private
- #
def visit_collection(printer, collection)
collection.each do |object|
visit(printer, object)
end
end
@@ -52,76 +49,69 @@
# @param [Object] object
#
# @return [undefined]
#
# @api private
- #
def visit(printer, object)
printer.call(output, object)
end
# Print an info line to output
#
# @return [undefined]
#
# @api private
- #
def info(string, *arguments)
puts(format(string, *arguments))
end
# Print a status line to output
#
# @return [undefined]
#
# @api private
- #
def status(string, *arguments)
puts(colorize(status_color, format(string, *arguments)))
end
# Print a line to output
#
# @return [undefined]
#
# @api private
- #
def puts(string)
output.puts(string)
end
# Colorize message
#
# @param [Color] color
# @param [String] message
#
- # @api private
- #
# @return [String]
# if color is enabled
# unmodified message otherwise
#
+ # @api private
def colorize(color, message)
color = Color::NONE unless tty?
color.format(message)
end
# Test if output is a tty
#
# @return [Boolean]
#
# @api private
- #
def tty?
output.tty?
end
# Test if output can be colored
#
# @return [Boolean]
#
# @api private
- #
alias_method :color?, :tty?
end # Printer
end # CLI
end # Reporter
end # Mutant