class Rcov::TextCoverageDiff

def process_unified_diff(filename, diff)

def process_unified_diff(filename, diff)
  current_hunk = []
  current_hunk_start = 0
  keep_current_hunk = false
  state = :init
  interesting_hunks = []
  diff.each_with_index do |line, i|
    #puts "#{state} %5d #{line}" % i
    case state
    when :init
      if md = HUNK_HEADER.match(line)
        current_hunk = []
        current_hunk_start = md[1].to_i
        state = :body
      end
    when :body
      case line
      when HUNK_HEADER
        new_start = $1.to_i
        if keep_current_hunk
          interesting_hunks << [current_hunk_start, current_hunk]
        end
        current_hunk_start = new_start
        current_hunk = []
        keep_current_hunk = false
      when /^-/
        # ignore
      when /^\+!! /
        keep_current_hunk = true
        current_hunk << line[1..-1]
      else
        current_hunk << line[1..-1]
      end
    end
  end
  if keep_current_hunk
    interesting_hunks << [current_hunk_start, current_hunk]
  end
  interesting_hunks
end