|
|
|
@ -20,10 +20,26 @@ class CreateDiffRecordService < ApplicationService
|
|
|
|
|
|
|
|
|
|
def diff_content
|
|
|
|
|
content = ''
|
|
|
|
|
|
|
|
|
|
arr = []
|
|
|
|
|
index = 0
|
|
|
|
|
fragment_size = 1
|
|
|
|
|
Diffy::Diff.new(before, after).each do |line|
|
|
|
|
|
next unless line =~ /^[\+-]/
|
|
|
|
|
unless line =~ /^[\+-]/
|
|
|
|
|
if arr.empty? && index < fragment_size
|
|
|
|
|
content += line
|
|
|
|
|
index += 1
|
|
|
|
|
else
|
|
|
|
|
index = 0
|
|
|
|
|
arr << line
|
|
|
|
|
arr.shift if arr.size > fragment_size
|
|
|
|
|
end
|
|
|
|
|
next
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
content += arr.join('') if arr.present?
|
|
|
|
|
content += line
|
|
|
|
|
arr.clear
|
|
|
|
|
end
|
|
|
|
|
content
|
|
|
|
|
end
|
|
|
|
|