Sha256: 7019c1d15c66549c2b751e125e4dbadb2c93f41f051445d7d7125e6594d41f7c

Contents?: true

Size: 754 Bytes

Versions: 1

Compression:

Stored size: 754 Bytes

Contents

module RuboCop::Git
# c.f. https://github.com/thoughtbot/hound/blob/d2f3933/app/models/commit_file.rb
class CommitFile
  def initialize(file, commit)
    @file = file
    @commit = commit
  end

  def absolute_path
    @file.absolute_path
  end

  def filename
    @file.filename
  end

  def content
    @content ||= begin
      unless removed?
        @commit.file_content(filename)
      end
    end
  end

  def relevant_line?(line_number)
    !modified_line_at(line_number).nil?
  end

  def removed?
    @file.status == 'removed'
  end

  def modified_lines
    @modified_lines ||= patch.changed_lines
  end

  def modified_line_at(line_number)
    modified_lines[line_number]
  end

  private

  def patch
    Patch.new(@file.patch)
  end
end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rubocop-git2-0.1.4 lib/rubocop/git/commit_file.rb