Module: Evilution::Reporter::HTML::DiffFormatter
- Defined in:
- lib/evilution/reporter/html/diff_formatter.rb
Class Method Summary collapse
Class Method Details
.call(diff) ⇒ Object
9 10 11 |
# File 'lib/evilution/reporter/html/diff_formatter.rb', line 9 def call(diff) diff.split("\n").map { |line| format_line(line) }.join("\n") end |
.format_line(line) ⇒ Object
13 14 15 16 |
# File 'lib/evilution/reporter/html/diff_formatter.rb', line 13 def format_line(line) css_class = line_class(line) %(<span class="#{css_class}">#{Evilution::Reporter::HTML::Escape.call(line)}</span>) end |
.line_class(line) ⇒ Object
18 19 20 21 22 23 24 25 26 |
# File 'lib/evilution/reporter/html/diff_formatter.rb', line 18 def line_class(line) if line.start_with?("- ") "diff-removed" elsif line.start_with?("+ ") "diff-added" else "" end end |