Sha256: e3c1883589c54578004f18394886ec3ac8924cd61f6442c4c5182e5342b69290
Contents?: true
Size: 781 Bytes
Versions: 10
Compression:
Stored size: 781 Bytes
Contents
module RuboCop::Git # copy from https://github.com/thoughtbot/hound/blob/d2f3933/app/models/patch.rb class Patch RANGE_INFORMATION_LINE = /^@@ .+\+(?<line_number>\d+),/ MODIFIED_LINE = /^\+(?!\+|\+)/ NOT_REMOVED_LINE = /^[^-]/ def initialize(body) @body = body || '' end def additions line_number = 0 lines.each_with_index.inject([]) do |additions, (content, patch_position)| case content when RANGE_INFORMATION_LINE line_number = Regexp.last_match[:line_number].to_i when MODIFIED_LINE additions << Line.new(content, line_number, patch_position) line_number += 1 when NOT_REMOVED_LINE line_number += 1 end additions end end private def lines @body.lines end end end
Version data entries
10 entries across 10 versions & 3 rubygems