Module: Minitest::Utils
- Defined in:
- lib/minitest/utils.rb,
lib/minitest/utils/cli.rb,
lib/minitest/utils/rails.rb,
lib/minitest/utils/railtie.rb,
lib/minitest/utils/version.rb,
lib/minitest/utils/reporter.rb,
lib/minitest/utils/extension.rb,
lib/minitest/utils/rails/locale.rb
Defined Under Namespace
Modules: Assertions, Locale, UrlHelpers
Classes: CLI, Railtie, Reporter
Constant Summary
collapse
- COLOR =
{red: 31, green: 32, yellow: 33, blue: 34, gray: 37}.freeze
- BGCOLOR =
{red: 41, green: 42, yellow: 43, blue: 44, gray: 47}.freeze
- VERSION =
"0.7.0"
Class Method Summary
collapse
Class Method Details
.color(string, color = :default, bgcolor: nil) ⇒ Object
21
22
23
24
25
26
27
28
29
|
# File 'lib/minitest/utils.rb', line 21
def self.color(string, color = :default, bgcolor: nil)
return string unless color_enabled?
fg = COLOR.fetch(color, 0)
bg = BGCOLOR.fetch(bgcolor, nil)
code = [fg, bg].compact.join(";")
"\e[#{code}m#{string}\e[0m"
end
|
.color_enabled? ⇒ Boolean
31
32
33
|
# File 'lib/minitest/utils.rb', line 31
def self.color_enabled?
!ENV["NO_COLOR"] && !Minitest.options[:no_color]
end
|