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.



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

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



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

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