Class: Card::Diff::DiffBuilder::LCS
Defined Under Namespace
Classes: ExcludeeIterator, Summary
Instance Attribute Summary collapse
-
#adds_cnt ⇒ Object
readonly
Returns the value of attribute adds_cnt.
-
#dels_cnt ⇒ Object
readonly
Returns the value of attribute dels_cnt.
Instance Method Summary collapse
- #complete ⇒ Object
-
#initialize(old_text, new_text, opts, summary = nil) ⇒ LCS
constructor
A new instance of LCS.
- #summary ⇒ Object
Constructor Details
#initialize(old_text, new_text, opts, summary = nil) ⇒ LCS
Returns a new instance of LCS.
100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 |
# File 'lib/card/diff.rb', line 100 def initialize old_text, new_text, opts, summary=nil @reject_pattern = opts[:reject] # regex; remove match completely from diff @exclude_pattern = opts[:exclude] # regex; put back to the result after diff @preprocess = opts[:preprocess] # block; called with every word @postprocess = opts[:postprocess] # block; called with complete diff @adds_cnt = 0 @dels_cnt = 0 @splitters = %w( <[^>]+> \[\[[^\]]+\]\] \{\{[^}]+\}\} \s+ ) @disjunction_pattern = /^\s/ @summary ||= Summary.new opts[:summary] if not old_text list = split_and_preprocess(new_text) if @exclude_pattern list = list.reject{ |word| word.match @exclude_pattern } end text = postprocess list.join @result = added_chunk text @summary.add text else init_diff old_text, new_text run_diff end end |
Instance Attribute Details
#adds_cnt ⇒ Object (readonly)
Returns the value of attribute adds_cnt.
99 100 101 |
# File 'lib/card/diff.rb', line 99 def adds_cnt @adds_cnt end |
#dels_cnt ⇒ Object (readonly)
Returns the value of attribute dels_cnt.
99 100 101 |
# File 'lib/card/diff.rb', line 99 def dels_cnt @dels_cnt end |