Sha256: 8b6fe00ccf0943ba4566206f95cd58601cbfd8616725e2bb9567f95255a20e46
Contents?: true
Size: 1.86 KB
Versions: 29
Compression:
Stored size: 1.86 KB
Contents
# frozen_string_literal: true module Mutant class Reporter class CLI # CLI runner status printer base class class Printer include AbstractType, Adamantium::Flat, Concord.new(:output, :object), Procto.call(:run) private_class_method :new # Create delegators to object # # @return [undefined] def self.delegate(*names) names.each(&method(:define_delegator)) end private_class_method :delegate # Create delegator to object # # @param [Symbol] name # # @return [undefined] def self.define_delegator(name) define_method(name) do object.public_send(name) end private(name) end private_class_method :define_delegator delegate :success? NL = "\n" # Run printer # # @return [self] abstract_method :run private def status_color success? ? Unparser::Color::GREEN : Unparser::Color::RED end def visit_collection(printer, collection) collection.each do |object| visit(printer, object) end end def visit(printer, object) printer.call(output, object) end def info(string, *arguments) puts(string % arguments) end def status(string, *arguments) puts(colorize(status_color, string % arguments)) end def puts(string) output.puts(string) end def colorize(color, message) color = Unparser::Color::NONE unless tty? color.format(message) end def tty? output.tty? end alias_method :color?, :tty? end # Printer end # CLI end # Reporter end # Mutant
Version data entries
29 entries across 29 versions & 1 rubygems