Module: Gherkin::Tools::Colors
Overview
Defines aliases for coloured output. You don’t invoke any methods from this module directly, but you can change the output colours by defining a GHERKIN_COLORS
variable in your shell, very much like how you can tweak the familiar POSIX command ls
with <a href=“mipsisrisc.com/rambling/2008/06/27/lscolorsls_colors-now-with-linux-support/”>$LSCOLORS/$LS_COLORS</a>
The colours that you can change are:
-
undefined
- defaults toyellow
-
pending
- defaults toyellow
-
pending_param
- defaults toyellow,bold
-
failed
- defaults tored
-
failed_param
- defaults tored,bold
-
passed
- defaults togreen
-
passed_param
- defaults togreen,bold
-
outline
- defaults tocyan
-
outline_param
- defaults tocyan,bold
-
skipped
- defaults tocyan
-
skipped_param
- defaults tocyan,bold
-
comment
- defaults togrey
-
tag
- defaults tocyan
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_param=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
- ALIASES =
Hash.new do |h,k| if k.to_s =~ /(.*)_param/ h[$1] + ',bold' end end.merge({ 'undefined' => 'yellow', 'pending' => 'yellow', 'failed' => 'red', 'passed' => 'green', 'outline' => 'cyan', 'skipped' => 'cyan', 'comments' => 'grey', 'tag' => 'cyan' })
Class Method Summary collapse
-
.define_grey ⇒ Object
:nodoc:.
-
.define_real_grey ⇒ Object
:nodoc:.
Instance Method Summary collapse
-
#grey(m) ⇒ Object
:nodoc:.
Class Method Details
.define_grey ⇒ Object
:nodoc:
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 |
# File 'lib/gherkin/tools/colors.rb', line 82 def self.define_grey #:nodoc: begin gem 'genki-ruby-terminfo' require 'terminfo' case TermInfo.default_object.tigetnum("colors") when 0 raise "Your terminal doesn't support colours" when 1 ::Term::ANSIColor.coloring = false alias grey white when 2..8 alias grey white else define_real_grey end rescue Exception => e if e.class.name == 'TermInfo::TermInfoError' STDERR.puts "*** WARNING ***" STDERR.puts "You have the genki-ruby-terminfo gem installed, but you haven't set your TERM variable." STDERR.puts "Try setting it to TERM=xterm-256color to get grey colour in output" STDERR.puts "\n" alias grey white else define_real_grey end end end |
.define_real_grey ⇒ Object
:nodoc:
110 111 112 113 114 |
# File 'lib/gherkin/tools/colors.rb', line 110 def self.define_real_grey #:nodoc: def grey(m) #:nodoc: "\e[90m#{m}\e[0m" end end |
Instance Method Details
#grey(m) ⇒ Object
:nodoc:
111 112 113 |
# File 'lib/gherkin/tools/colors.rb', line 111 def grey(m) #:nodoc: "\e[90m#{m}\e[0m" end |