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

Version Path
fluent-plugin-detect-memb-exceptions-0.0.2 vendor/bundle/ruby/2.0.0/gems/rubocop-0.42.0/lib/rubocop/formatter/colorizable.rb
fluent-plugin-detect-memb-exceptions-0.0.1 vendor/bundle/ruby/2.0.0/gems/rubocop-0.42.0/lib/rubocop/formatter/colorizable.rb
rubocop-0.43.0 lib/rubocop/formatter/colorizable.rb
rubocop-0.42.0 lib/rubocop/formatter/colorizable.rb
rubocop-0.41.2 lib/rubocop/formatter/colorizable.rb
rubocop-0.41.1 lib/rubocop/formatter/colorizable.rb
rubocop-0.41.0 lib/rubocop/formatter/colorizable.rb
rubocop-0.40.0 lib/rubocop/formatter/colorizable.rb
rubocop-0.39.0 lib/rubocop/formatter/colorizable.rb
rubocop-0.38.0 lib/rubocop/formatter/colorizable.rb
rubocop-0.37.2 lib/rubocop/formatter/colorizable.rb
rubocop-0.37.1 lib/rubocop/formatter/colorizable.rb
rubocop-0.37.0 lib/rubocop/formatter/colorizable.rb
rubocop-0.36.0 lib/rubocop/formatter/colorizable.rb