module Coveralls::Output
def format(string, options = {})
# => "\e[36mHello World\e[0m"
Coveralls::Output.format("Hello World!", :color => "cyan")
Examples
Term::ANSIColor
:color - The color to be passed as a method to
options - The hash of options used for formatting the text:
string - the text to be formatted
through Term::ANSIColor
Public: Formats the given string with the specified color
def format(string, options = {}) unless no_color? require 'term/ansicolor' options[:color]&.split(/\s/)&.reverse_each do |color| next unless Term::ANSIColor.respond_to?(color.to_sym) string = Term::ANSIColor.send(color.to_sym, string) end end string end
def no_color?
def no_color? defined?(@no_color) && @no_color end
def output
def output (defined?(@output) && @output) || $stdout end
def print(string, options = {})
Coveralls::Output.print("Hello World!", :color => "underline")
Example
Term::ANSIColor
:color - The color to be passed as a method to
options - The hash of options used for formatting the text:
string - the text to be formatted
Public: Passes .format to Kernel#print
def print(string, options = {}) return if silent? (options[:output] || output).print format(string, options) end
def puts(string, options = {})
Coveralls::Output.puts("Hello World", :color => "cyan")
Example
Term::ANSIColor
:color - The color to be passed as a method to
options - The hash of options used for formatting the text:
string - the text to be formatted
Public: Passes .format to Kernel#puts
def puts(string, options = {}) return if silent? (options[:output] || output).puts format(string, options) end
def silent?
def silent? ENV['COVERALLS_SILENT'] || (defined?(@silent) && @silent) end