Method: Cucumber::Formatter::ANSIColor.define_grey

Defined in:
lib/cucumber/formatter/ansicolor.rb

.define_greyObject

:nodoc:



103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
# File 'lib/cucumber/formatter/ansicolor.rb', line 103

def self.define_grey #:nodoc:
  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_method :grey, :white
  when 2..8
    alias_method :grey, :white # rubocop:disable Lint/DuplicateMethods
  else
    define_real_grey
  end
rescue Exception => e # rubocop:disable Lint/RescueException
  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_method :grey, :white
  else
    define_real_grey
  end
end