Sha256: 5ebdca2a855c3f9d6bdf6808655f2c6fe92eca4043308f6092b15df01cd75ee8

Contents?: true

Size: 937 Bytes

Versions: 1

Compression:

Stored size: 937 Bytes

Contents

module Minitest
  module RedGreen
    class Plugin
      attr_accessor :sync

      ESC = "\e["

      def initialize io
        @io = io
      end

      def external_encoding
        @io.external_encoding
      end

      def puts *strings
        if not strings.grep(%r{\d+\) (?:Failure|Error)}).empty?
          strings.map! &method(:red)
        end
        @io.puts *strings
      end

      def print str
        @io.print filter_test_output_chars str
      end

      def filter_test_output_chars str
        case str
        when '.' then green str
        when 'E', 'F' then red str
        when 'S' then yellow str
        else str
        end
      end

      def green str
        colorize str, 32
      end

      def red str
        colorize str, 31
      end

      def yellow str
        colorize str, 33
      end

      def colorize str, col_code
        "#{ESC}#{col_code}m#{str}#{ESC}0m"
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
minitest-red_green-0.9.3 lib/minitest/red_green/plugin.rb