| 1 |
module Minitest |
| 2 |
module Reporters |
| 3 |
module ANSI |
| 4 |
module Code |
| 5 |
def self.color? |
| 6 |
return false if ENV['MINITEST_REPORTERS_MONO'] |
| 7 |
color_terminal = ENV['TERM'].to_s.downcase.include?("color") |
| 8 |
$stdout.tty? || color_terminal |
| 9 |
end |
| 10 |
|
| 11 |
if color? |
| 12 |
require 'ansi/code' |
| 13 |
|
| 14 |
include ::ANSI::Code |
| 15 |
extend ::ANSI::Code |
| 16 |
else |
| 17 |
def black(s = nil) |
| 18 |
block_given? ? yield : s |
| 19 |
end |
| 20 |
|
| 21 |
%w[red green yellow blue magenta cyan white].each do |color| |
| 22 |
alias_method color, :black |
| 23 |
end |
| 24 |
|
| 25 |
extend self |
| 26 |
end |
| 27 |
end |
| 28 |
end |
| 29 |
end |
| 30 |
end |