Module: Cucumber::Gherkin::Formatter::AnsiEscapes

Extended by:
AnsiEscapes
Included in:
AnsiEscapes, Rake::Task
Defined in:
lib/cucumber/gherkin/formatter/ansi_escapes.rb

Overview

Defines aliases for ANSI coloured output. Default colours can be overridden by defining a GHERKIN_COLORS variable in your shell, very much like how you can tweak the familiar POSIX command ls with $LSCOLORS: linux-sxs.org/housekeeping/lscolors.html

The colours that you can change are:

undefined

defaults to yellow

pending

defaults to yellow

pending_arg

defaults to yellow,bold

executing

defaults to grey

executing_arg

defaults to grey,bold

failed

defaults to red

failed_arg

defaults to red,bold

passed

defaults to green

passed_arg

defaults to green,bold

outline

defaults to cyan

outline_arg

defaults to cyan,bold

skipped

defaults to cyan

skipped_arg

defaults to cyan,bold

comment

defaults to grey

tag

defaults to cyan

For instance, if your shell has a black background and a green font (like the “Homebrew” settings for OS X' Terminal.app), you may want to override passed steps to be white instead of green. Examples:

export GHERKIN_COLORS="passed=white"
export GHERKIN_COLORS="passed=white,bold:passed_arg=white,bold,underline"

(If you're on Windows, use SET instead of export). To see what colours and effects are available, just run this in your shell:

ruby -e "require 'rubygems'; require 'term/ansicolor'; puts Term::ANSIColor.attributes"

Although not listed, you can also use grey

Constant Summary collapse

COLORS =
{
  'black'   => "\e[30m",
  'red'     => "\e[31m",
  'green'   => "\e[32m",
  'yellow'  => "\e[33m",
  'blue'    => "\e[34m",
  'magenta' => "\e[35m",
  'cyan'    => "\e[36m",
  'white'   => "\e[37m",
  'grey'    => "\e[90m",
  'bold'    => "\e[1m"
}
ALIASES =
Hash.new do |h, k|
          if k.to_s =~ /(.*)_arg/
            h[$1] + ',bold'
          end
        end.merge({
  'undefined' => 'yellow',
  'pending'   => 'yellow',
  'executing' => 'grey',
  'failed'    => 'red',
  'passed'    => 'green',
  'outline'   => 'cyan',
  'skipped'   => 'cyan',
  'comments'  => 'grey',
  'tag'       => 'cyan'
})

Instance Method Summary collapse

Instance Method Details

#resetObject


89
90
91
# File 'lib/cucumber/gherkin/formatter/ansi_escapes.rb', line 89

def reset
  "\e[0m"
end

#up(n) ⇒ Object


93
94
95
# File 'lib/cucumber/gherkin/formatter/ansi_escapes.rb', line 93

def up(n)
  "\e[#{n}A"
end