Module: Turn::Colorize

Included in:
IsoRunner, Reporter
Defined in:
lib/turn/colorize.rb

Constant Summary collapse

COLORIZE =
defined?(::ANSI::Code) && ENV.has_key?('TERM')
PASS =
pass('PASS')
FAIL =
fail('FAIL')
ERROR =
error('ERROR')
SKIP =
skip('SKIP')

Class Method Summary collapse

Class Method Details

.blue(string) ⇒ Object



25
26
27
# File 'lib/turn/colorize.rb', line 25

def self.blue(string)
  COLORIZE ? ::ANSI::Code.blue{ string } : string
end

.bold(string) ⇒ Object



33
34
35
# File 'lib/turn/colorize.rb', line 33

def self.bold(string)
  COLORIZE ? ::ANSI::Code.bold{ string } : string
end

.error(string) ⇒ Object

def self.error(string)

COLORIZE ? ::ANSI::Code.white{ ::ANSI::Code.on_red{ string } } : string

end



49
50
51
# File 'lib/turn/colorize.rb', line 49

def self.error(string)
  COLORIZE ? ::ANSI::Code.yellow{ string } : string
end

.fail(string) ⇒ Object



41
42
43
# File 'lib/turn/colorize.rb', line 41

def self.fail(string)
  COLORIZE ? ::ANSI::Code.red{ string } : string
end

.green(string) ⇒ Object



21
22
23
# File 'lib/turn/colorize.rb', line 21

def self.green(string)
  COLORIZE ? ::ANSI::Code.green{ string } : string
end

.magenta(string) ⇒ Object



29
30
31
# File 'lib/turn/colorize.rb', line 29

def self.magenta(string)
  COLORIZE ? ::ANSI::Code.magenta{ string } : string
end

.pass(string) ⇒ Object



37
38
39
# File 'lib/turn/colorize.rb', line 37

def self.pass(string)
  COLORIZE ? ::ANSI::Code.green{ string } : string
end

.red(string) ⇒ Object



17
18
19
# File 'lib/turn/colorize.rb', line 17

def self.red(string)
  COLORIZE ? ::ANSI::Code.red{ string } : string
end

.skip(string) ⇒ Object



53
54
55
# File 'lib/turn/colorize.rb', line 53

def self.skip(string)
  COLORIZE ? ::ANSI::Code.cyan{ string } : string
end