Module: Cucumber::Formatter::ANSIColor
- Includes:
- Term::ANSIColor
- Included in:
- Console
- Defined in:
- lib/cucumber/formatter/ansicolor.rb
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 CUCUMBER_COLORS variable in your shell, very much like how you can tweak the familiar POSIX command ls with <a href="$LSCOLORS/$LS_COLORSmipsisrisc.com/rambling/2008/06/27/lscolorsls_colors-now-with-linux-support/">$LSCOLORS/$LS_COLORS>
The colours that you can change are:
-
undefined - defaults to yellow
-
pending - defaults to yellow
-
pending_param - defaults to yellow,bold
-
failed - defaults to red
-
failed_param - defaults to red,bold
-
passed - defaults to green
-
passed_param - defaults to green,bold
-
outline - defaults to cyan
-
outline_param - defaults to cyan,bold
-
skipped - defaults to cyan
-
skipped_param - 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 CUCUMBER_COLORS="passed=white"
export CUCUMBER_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 Cucumber::Term::ANSIColor.attributes"
Although not listed, you can also use grey
Constant Summary
- 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', 'comment' => 'grey', 'tag' => 'cyan' })
Constants included from Term::ANSIColor
Term::ANSIColor::ATTRIBUTES, Term::ANSIColor::ATTRIBUTE_NAMES, Term::ANSIColor::COLORED_REGEXP
Class Method Summary (collapse)
-
+ (Object) define_grey
:nodoc:.
-
+ (Object) define_real_grey
:nodoc:.
Instance Method Summary (collapse)
- - (Object) cukes(n)
- - (Object) green_cukes(n)
-
- (Object) grey(m)
:nodoc:.
- - (Object) red_cukes(n)
- - (Object) yellow_cukes(n)
Methods included from Term::ANSIColor
attributes, coloring=, coloring?, included, #uncolored
Class Method Details
+ (Object) define_grey
:nodoc:
98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 |
# File 'lib/cucumber/formatter/ansicolor.rb', line 98 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 ::Cucumber::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 |
+ (Object) define_real_grey
:nodoc:
126 127 128 129 130 131 132 133 134 |
# File 'lib/cucumber/formatter/ansicolor.rb', line 126 def self.define_real_grey #:nodoc: def grey(m) #:nodoc: if ::Cucumber::Term::ANSIColor.coloring? "\e[90m#{m}\e[0m" else m end end end |
Instance Method Details
- (Object) cukes(n)
138 139 140 |
# File 'lib/cucumber/formatter/ansicolor.rb', line 138 def cukes(n) ("(::) " * n).strip end |
- (Object) green_cukes(n)
142 143 144 |
# File 'lib/cucumber/formatter/ansicolor.rb', line 142 def green_cukes(n) blink(green(cukes(n))) end |
- (Object) grey(m)
:nodoc:
127 128 129 130 131 132 133 |
# File 'lib/cucumber/formatter/ansicolor.rb', line 127 def grey(m) #:nodoc: if ::Cucumber::Term::ANSIColor.coloring? "\e[90m#{m}\e[0m" else m end end |
- (Object) red_cukes(n)
146 147 148 |
# File 'lib/cucumber/formatter/ansicolor.rb', line 146 def red_cukes(n) blink(red(cukes(n))) end |
- (Object) yellow_cukes(n)
150 151 152 |
# File 'lib/cucumber/formatter/ansicolor.rb', line 150 def yellow_cukes(n) blink(yellow(cukes(n))) end |