Sha256: 412015509eef131cbaa052a8c79f4fbd22ef2cccf0506bc622cdc02d226b1091

Contents?: true

Size: 881 Bytes

Versions: 11

Compression:

Stored size: 881 Bytes

Contents

module RuboCop::Git
# copy from https://github.com/thoughtbot/hound/blob/d2f3933/app/models/commit_file.rb
class CommitFile
  def initialize(file, commit)
    @file = file
    @commit = commit
  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_lines.detect do |modified_line|
      modified_line.line_number == line_number
    end
  end

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

  def ruby?
    filename.match(/.*\.rb$/)
  end

  def modified_lines
    @modified_lines ||= patch.additions
  end

  def modified_line_at(line_number)
    modified_lines.detect do |modified_line|
      modified_line.line_number == line_number
    end
  end

  private

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

Version data entries

11 entries across 11 versions & 2 rubygems

Version Path
rubocop-git-0.1.3 lib/rubocop/git/commit_file.rb
rubocop-git-kjanoudi-0.1.4 lib/rubocop/git/commit_file.rb
rubocop-git-kjanoudi-0.1.3 lib/rubocop/git/commit_file.rb
rubocop-git-kjanoudi-0.1.2 lib/rubocop/git/commit_file.rb
rubocop-git-0.1.2 lib/rubocop/git/commit_file.rb
rubocop-git-0.1.1 lib/rubocop/git/commit_file.rb
rubocop-git-0.1.0 lib/rubocop/git/commit_file.rb
rubocop-git-0.0.6 lib/rubocop/git/commit_file.rb
rubocop-git-0.0.5 lib/rubocop/git/commit_file.rb
rubocop-git-0.0.4 lib/rubocop/git/commit_file.rb
rubocop-git-0.0.3 lib/rubocop/git/commit_file.rb