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.
92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 |
# File 'lib/card/diff.rb', line 92 def initialize old_text, new_text, opts, _summary=nil # regex; remove match completely from diff @reject_pattern = opts[:reject] # regex; put 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 @adds_cnt = 0 @dels_cnt = 0 @splitters = %w( <[^>]+> \[\[[^\]]+\]\] \{\{[^}]+\}\} \s+ ) @disjunction_pattern = /^\s/ @summary ||= Summary.new opts[:summary] if !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.
91 92 93 |
# File 'lib/card/diff.rb', line 91 def adds_cnt @adds_cnt end |
#dels_cnt ⇒ Object (readonly)
Returns the value of attribute dels_cnt.
91 92 93 |
# File 'lib/card/diff.rb', line 91 def dels_cnt @dels_cnt end |