diff options
author | Austin Ziegler <austin@zieglers.ca> | 2017-01-18 18:33:59 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-01-18 18:33:59 -0500 |
commit | 972ae416205ea8dd630d9cc32ab18aae2c577b14 (patch) | |
tree | 7325cd8e3279b71e5bc18302112e47cad3000a40 /lib/diff/lcs/internals.rb | |
parent | ff796c262db5a22f14b4765c09655b4faccc132a (diff) | |
parent | 06ee20e929656d41c301f61fd447105c3840e410 (diff) | |
download | diff-lcs-972ae416205ea8dd630d9cc32ab18aae2c577b14.tar.gz |
Merge pull request #39 from halostatue/spec-cleanup
Various diff-lcs Fixes
Diffstat (limited to 'lib/diff/lcs/internals.rb')
-rw-r--r-- | lib/diff/lcs/internals.rb | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/lib/diff/lcs/internals.rb b/lib/diff/lcs/internals.rb index 9d9e3f3..17d1d06 100644 --- a/lib/diff/lcs/internals.rb +++ b/lib/diff/lcs/internals.rb @@ -142,8 +142,6 @@ class << Diff::LCS::Internals # some time. This also works better with Diff::LCS::ContextChange or # Diff::LCS::Change as its source, as an array will cause the creation # of one of the above. - # - # Note: This will be deprecated as a public function in a future release. def intuit_diff_direction(src, patchset, limit = nil) string = src.kind_of?(String) count = left_match = left_miss = right_match = right_miss = 0 @@ -217,19 +215,27 @@ class << Diff::LCS::Internals no_left = (left_match == 0) && (left_miss > 0) no_right = (right_match == 0) && (right_miss > 0) - case [no_left, no_right] - when [false, true] + case [ no_left, no_right ] + when [ false, true ] :patch - when [true, false] + when [ true, false ] :unpatch else case left_match <=> right_match when 1 - :patch + if left_miss.zero? + :patch + else + :unpatch + end when -1 - :unpatch + if right_miss.zero? + :unpatch + else + :patch + end else - raise "The provided patchset does not appear to apply to the provided value as either source or destination value." + raise "The provided patchset does not appear to apply to the provided enumerable as either source or destination value." end end end |