Class: Card::Content::Diff::LCS

Inherits:
Object
  • Object
show all
Defined in:
card/lib/card/content/diff/l_c_s.rb,
card/lib/card/content/diff/l_c_s/processor.rb

Overview

Use LCS algorithm to create a Result

Defined Under Namespace

Classes: ExcludeeIterator, Processor

Instance Method Summary collapse

Constructor Details

#initialize(opts) ⇒ LCS

Returns a new instance of LCS.



8
9
10
11
12
13
14
15
16
17
18
19
# File 'card/lib/card/content/diff/l_c_s.rb', line 8

def initialize opts
  # regex; remove matches completely from diff
  @reject_pattern = opts[:reject]
  # regex; put matches back to the result after diff
  @exclude_pattern = opts[:exclude]

  @preprocess   = opts[:preprocess]  # block; called with every word
  @postprocess  = opts[:postprocess] # block; called with complete diff

  @splitters = %w(<[^>]+> \[\[[^\]]+\]\] \{\{[^}]+\}\} \s+)
  @disjunction_pattern = /^\s/
end

Instance Method Details

#run(old_text, new_text, result) ⇒ Object



21
22
23
24
25
# File 'card/lib/card/content/diff/l_c_s.rb', line 21

def run old_text, new_text, result
  @result = result
  compare old_text, new_text
  @result.complete = postprocess @result.complete
end