lib/emaildiff.rb in diff-0.3.4.4 vs lib/emaildiff.rb in diff-0.3.5

- old
+ new

@@ -26,16 +26,16 @@ def striplines(ary) newary= ary.dup newary.each_with_index { |item,index| if item.class == String item = item.dup - item.strip - while item[0] == GREATER + item = item.strip + while item[0,1] == ">" item.slice!(0) - item.strip - newary[index] = item + item = item.strip end + newary[index] = item end } return newary end end @@ -43,11 +43,11 @@ module HTMLCollapsable def diff(b) Diff.new(self, b) end - def patch_email(diff,starttoken,endtoken) + def patch_email(diff,starttoken = nil,endtoken = nil) newary = nil if diff.difftype == String newary = diff.difftype.new('') else newary = diff.difftype.new @@ -60,29 +60,29 @@ case mod[0] when '-' if ai < mod[1] quoted = 1 end - newary << starttoken if quoted == 1 + newary << starttoken if quoted == 1 && !starttoken.nil? while ai < mod[1] - newary << diff.orig_b[bi] + newary << diff.orig_b[bi] if !starttoken.nil? ai += 1 bi += 1 end - newary << endtoken if quoted == 1 + newary << endtoken if quoted == 1 && !starttoken.nil? ai += 1 when '+' if bi < mod[1] quoted = 1 end - newary << starttoken if quoted == 1 + newary << starttoken if quoted == 1 && !starttoken.nil? while bi < mod[1] - newary << diff.orig_b[bi] + newary << diff.orig_b[bi] if !starttoken.nil? ai += 1 bi += 1 end - newary << endtoken if quoted == 1 + newary << endtoken if quoted == 1 && !starttoken.nil? newary << diff.orig_b[mod[1]] bi += 1 else raise "Unknown diff action" end @@ -90,16 +90,16 @@ } quoted = 0 if ai < self.length quoted = 1 end - newary << starttoken if quoted == 1 + newary << starttoken if quoted == 1 && !starttoken.nil? while ai < self.length - newary << diff.orig_b[bi] + newary << diff.orig_b[bi] if !starttoken.nil? ai += 1 bi += 1 end - newary << endtoken if quoted == 1 + newary << endtoken if quoted == 1 && !starttoken.nil? return newary end end class Array