class Mutest::Reporter::CLI::Printer

CLI runner status printer base class

Constants

NL

Private Class Methods

define_delegator(name) click to toggle source

Create delegator to object

@param [Symbol] name

@return [undefined]

# File lib/mutest/reporter/cli/printer.rb, line 26
def self.define_delegator(name)
  define_method(name) do
    object.public_send(name)
  end
  private(name)
end
delegate(*names) click to toggle source

Create delegators to object

@return [undefined]

# File lib/mutest/reporter/cli/printer.rb, line 16
def self.delegate(*names)
  names.each(&method(:define_delegator))
end

Private Instance Methods

color?()

Test if output can be colored

@return [Boolean]

@api private

Alias for: tty?
colorize(color, message) click to toggle source

Colorize message

@param [Color] color @param [String] message

@return [String]

if color is enabled
unmodified message otherwise
# File lib/mutest/reporter/cli/printer.rb, line 103
def colorize(color, message)
  color = Color::NONE unless tty?
  color.format(message)
end
info(string, *arguments) click to toggle source

Print an info line to output

@return [undefined]

# File lib/mutest/reporter/cli/printer.rb, line 77
def info(string, *arguments)
  puts(string % arguments)
end
puts(string) click to toggle source

Print a line to output

@return [undefined]

# File lib/mutest/reporter/cli/printer.rb, line 91
def puts(string)
  output.puts(string)
end
status(string, *arguments) click to toggle source

Print a status line to output

@return [undefined]

# File lib/mutest/reporter/cli/printer.rb, line 84
def status(string, *arguments)
  puts(colorize(status_color, string % arguments))
end
status_color() click to toggle source

Status color

@return [Color]

# File lib/mutest/reporter/cli/printer.rb, line 48
def status_color
  success? ? Color::GREEN : Color::RED
end
tty?() click to toggle source

Test if output is a tty

@return [Boolean]

# File lib/mutest/reporter/cli/printer.rb, line 111
def tty?
  output.tty?
end
Also aliased as: color?
visit(printer, object) click to toggle source

Visit object

@param [Class] Printer @param [Object] object

@return [undefined]

# File lib/mutest/reporter/cli/printer.rb, line 70
def visit(printer, object)
  printer.call(output, object)
end
visit_collection(printer, collection) click to toggle source

Visit a collection of objects

@return [Class] Printer @return [Enumerable<Object>] collection

@return [undefined]

# File lib/mutest/reporter/cli/printer.rb, line 58
def visit_collection(printer, collection)
  collection.each do |object|
    visit(printer, object)
  end
end