module Coveralls::Output

def format(string, options = {})

Returns the formatted string.

# => "\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'
    if options[:color]
      options[:color].split(/\s/).reverse_each do |color|
        if Term::ANSIColor.respond_to?(color.to_sym)
          string = Term::ANSIColor.send(color.to_sym, string)
        end
      end
    end
  end
  string
end