Sha256: af2d748362647cf8c000755a3d6e85453e05e1e8f586306dc9c70cc46aee86cc

Contents?: true

Size: 760 Bytes

Versions: 2

Compression:

Stored size: 760 Bytes

Contents

# c.f. https://github.com/thoughtbot/hound/blob/d2f3933/app/models/commit_file.rb
class RuboCop::Git::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 ||= unless removed?
                   @commit.file_content(filename)
                 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
    RuboCop::Git::Patch.new(@file.patch)
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rubocop-git2-0.1.6 lib/rubocop/git/commit_file.rb
rubocop-git2-0.1.5 lib/rubocop/git/commit_file.rb