Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixing an issue with the refactoring done earlier.

  • Loading branch information...
commit 86928fa4a2ca7a91e08571a46a98fdb42aee354d 1 parent 3965b70
Austin Ziegler authored

Showing 2 changed files with 26 additions and 26 deletions. Show diff stats Hide diff stats

  1. +1 1  lib/diff/lcs.rb
  2. +25 25 lib/diff/lcs/internals.rb
2  lib/diff/lcs.rb
@@ -729,7 +729,7 @@ def patch(src, patchset, direction = nil)
729 729 # Start with a new empty type of the source's class
730 730 res = src.class.new
731 731
732   - direction ||= Diff::LCS.__diff_direction(src, patchset)
  732 + direction ||= Diff::LCS::Internals.diff_direction(src, patchset)
733 733
734 734 ai = bj = 0
735 735
50 lib/diff/lcs/internals.rb
@@ -185,31 +185,6 @@ def diff_direction(src, patchset, limit = nil)
185 185 count += 1
186 186
187 187 case change
188   - when Diff::LCS::Change
189   - # With a simplistic change, we can't tell the difference between
190   - # the left and right on '!' actions, so we ignore those. On '='
191   - # actions, if there's a miss, we miss both left and right.
192   - element = string ? src[change.position, 1] : src[change.position]
193   -
194   - case change.action
195   - when '-'
196   - if element == change.element
197   - left_match += 1
198   - else
199   - left_miss += 1
200   - end
201   - when '+'
202   - if element == change.element
203   - right_match += 1
204   - else
205   - right_miss += 1
206   - end
207   - when '='
208   - if element != change.element
209   - left_miss += 1
210   - right_miss += 1
211   - end
212   - end
213 188 when Diff::LCS::ContextChange
214 189 case change.action
215 190 when '-' # Remove details from the old string
@@ -247,6 +222,31 @@ def diff_direction(src, patchset, limit = nil)
247 222 end
248 223 end
249 224 end
  225 + when Diff::LCS::Change
  226 + # With a simplistic change, we can't tell the difference between
  227 + # the left and right on '!' actions, so we ignore those. On '='
  228 + # actions, if there's a miss, we miss both left and right.
  229 + element = string ? src[change.position, 1] : src[change.position]
  230 +
  231 + case change.action
  232 + when '-'
  233 + if element == change.element
  234 + left_match += 1
  235 + else
  236 + left_miss += 1
  237 + end
  238 + when '+'
  239 + if element == change.element
  240 + right_match += 1
  241 + else
  242 + right_miss += 1
  243 + end
  244 + when '='
  245 + if element != change.element
  246 + left_miss += 1
  247 + right_miss += 1
  248 + end
  249 + end
250 250 end
251 251
252 252 break if (not limit.nil?) && (count > limit)

0 comments on commit 86928fa

Please sign in to comment.
Something went wrong with that request. Please try again.