class RuboCop::Git::Patch

copy from github.com/thoughtbot/hound/blob/d2f3933/app/models/patch.rb

Constants

MODIFIED_LINE
NOT_REMOVED_LINE
RANGE_INFORMATION_LINE

Public Class Methods

new(body) click to toggle source
# File lib/rubocop/git/patch.rb, line 8
def initialize(body)
  @body = body || ''
end

Public Instance Methods

additions() click to toggle source
# File lib/rubocop/git/patch.rb, line 12
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 Instance Methods

lines() click to toggle source
# File lib/rubocop/git/patch.rb, line 32
def lines
  @body.lines
end