module Diffy::Format

Public Instance Methods

minitest() click to toggle source

ANSI color output suitable for terminal, customized for minitest.

# File lib/asciidoctor/doctest/minitest_diffy.rb, line 55
def minitest
  padding = ' ' * 2
  ary = map do |line|
    case line
    when /^(---|\+\+\+|\\\\)/
      # ignore
    when /^\\\s*No newline at end of file/
      # ignore
    when /^\+/
      line.chomp.sub(/^\+/, 'A' + padding).color(:red)
    when /^-/
      line.chomp.sub(/^\-/, 'E' + padding).color(:green)
    else
      padding + line.chomp
    end
  end
  "\n" + ary.compact.join("\n")
end