Module: Palmister

Extended by:
Erubis::XmlHelper
Defined in:
lib/palmister/simple_correction_diff.rb,
lib/palmister.rb,
lib/palmister/vc_diff.rb,
lib/palmister/version.rb,
lib/palmister/simple_html_diff.rb,
lib/palmister/simple_line_diff.rb

Overview

require ‘action_view/template_handlers/erb’

Defined Under Namespace

Classes: SimpleCorrectionDiff, SimpleHtmlDiff, SimpleLineDiff, StringSimpleCorrectionDiff, VcDiff

Constant Summary collapse

VERSION =
"0.0.3"

Class Method Summary collapse

Class Method Details

.diff(old, new, output = Palmister::SimpleHtmlDiff) ⇒ Object



12
13
14
15
16
17
18
19
# File 'lib/palmister.rb', line 12

def self.diff(old, new, output = Palmister::SimpleHtmlDiff)
  # html_escape code for display and split strings into lines array
  a = html_escape(old).split(/\015?\012/)
  b = html_escape(new).split(/\015?\012/)
  out = output.new
  Diff::LCS.traverse_balanced(a, b, out)
  out.content
end