Sha256: e32893867c79ff0b77ce8367ed94b1f7924b8825d0dfac4a07d73b9e7ac5540a
Contents?: true
Size: 968 Bytes
Versions: 14
Compression:
Stored size: 968 Bytes
Contents
# encoding: utf-8 # frozen_string_literal: true module RuboCop module Formatter # This mix-in module provides string coloring methods for terminals. # It automatically disables coloring if coloring is disabled in the process # globally or the formatter's output is not a terminal. module Colorizable def rainbow @rainbow ||= begin rainbow = Rainbow.new if options[:color] rainbow.enabled = true elsif options[:color] == false || !output.tty? rainbow.enabled = false end rainbow end end def colorize(string, *args) rainbow.wrap(string).color(*args) end [ :black, :red, :green, :yellow, :blue, :magenta, :cyan, :white ].each do |color| define_method(color) do |string| colorize(string, color) end end end end end
Version data entries
14 entries across 14 versions & 2 rubygems