Module: Diffy::Format
- Defined in:
- lib/diffy/format.rb
Instance Method Summary collapse
-
#color ⇒ Object
ANSI color output suitable for terminal output.
-
#html ⇒ Object
Html output which does inline highlighting of changes between two lines.
-
#html_simple ⇒ Object
Basic html output which does not attempt to highlight the changes between lines, and is more performant.
-
#text ⇒ Object
Basic text output.
Instance Method Details
#color ⇒ Object
ANSI color output suitable for terminal output
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/diffy/format.rb', line 4 def color map do |line| case line when /^(---|\+\+\+|\\\\)/ "\033[90m#{line.chomp}\033[0m" when /^\+/ "\033[32m#{line.chomp}\033[0m" when /^-/ "\033[31m#{line.chomp}\033[0m" when /^@@/ "\033[36m#{line.chomp}\033[0m" else line.chomp end end.join("\n") + "\n" end |
#html ⇒ Object
Html output which does inline highlighting of changes between two lines.
33 34 35 |
# File 'lib/diffy/format.rb', line 33 def html HtmlFormatter.new(self, .merge(:highlight_words => true)).to_s end |
#html_simple ⇒ Object
Basic html output which does not attempt to highlight the changes between lines, and is more performant.
28 29 30 |
# File 'lib/diffy/format.rb', line 28 def html_simple HtmlFormatter.new(self, ).to_s end |
#text ⇒ Object
Basic text output
22 23 24 |
# File 'lib/diffy/format.rb', line 22 def text to_a.join end |