class RuboCop::Git::CommitFile

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

Public Class Methods

new(file, commit) click to toggle source
# File lib/rubocop/git/commit_file.rb, line 4
def initialize(file, commit)
  @file = file
  @commit = commit
end

Public Instance Methods

absolute_path() click to toggle source
# File lib/rubocop/git/commit_file.rb, line 9
def absolute_path
  @file.absolute_path
end
content() click to toggle source
# File lib/rubocop/git/commit_file.rb, line 17
def content
  @content ||= begin
    unless removed?
      @commit.file_content(filename)
    end
  end
end
filename() click to toggle source
# File lib/rubocop/git/commit_file.rb, line 13
def filename
  @file.filename
end
modified_line_at(line_number) click to toggle source
# File lib/rubocop/git/commit_file.rb, line 43
def modified_line_at(line_number)
  modified_lines.detect do |modified_line|
    modified_line.line_number == line_number
  end
end
modified_lines() click to toggle source
# File lib/rubocop/git/commit_file.rb, line 39
def modified_lines
  @modified_lines ||= patch.additions
end
relevant_line?(line_number) click to toggle source
# File lib/rubocop/git/commit_file.rb, line 25
def relevant_line?(line_number)
  modified_lines.detect do |modified_line|
    modified_line.line_number == line_number
  end
end
removed?() click to toggle source
# File lib/rubocop/git/commit_file.rb, line 31
def removed?
  @file.status == 'removed'
end
ruby?() click to toggle source
# File lib/rubocop/git/commit_file.rb, line 35
def ruby?
  filename.match(/.*\.rb$/)
end

Private Instance Methods

patch() click to toggle source
# File lib/rubocop/git/commit_file.rb, line 51
def patch
  Patch.new(@file.patch)
end