Module: Diffy::Format

Defined in:
lib/asciidoctor/doctest/minitest_diffy.rb

Instance Method Summary collapse

Instance Method Details

#minitestvoid

ANSI color output suitable for terminal, customized for minitest.


56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/asciidoctor/doctest/minitest_diffy.rb', line 56

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