Sha256: da02940f164c4eb56b469cdce8c64051ce8ff7cbb623716a4f77d1f929f62308

Contents?: true

Size: 868 Bytes

Versions: 1

Compression:

Stored size: 868 Bytes

Contents

module Minitest
  module RedGreen
    class Plugin
      attr_accessor :sync

      ESC = "\e["

      def initialize io
        @io = io
      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.2 lib/minitest/red_green/plugin.rb