class Policial::CommitFile

Public: A file in a commit.

Attributes

commit[R]

Public Class Methods

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

Public Instance Methods

content() click to toggle source
# File lib/policial/commit_file.rb, line 17
def content
  @content ||= begin
    @commit.file_content(filename) unless removed?
  end
end
filename() click to toggle source
# File lib/policial/commit_file.rb, line 13
def filename
  @file.filename
end
line_at(line_number) click to toggle source
# File lib/policial/commit_file.rb, line 27
def line_at(line_number)
  changed_lines.detect { |line| line.number == line_number } ||
    UnchangedLine.new
end
removed?() click to toggle source
# File lib/policial/commit_file.rb, line 23
def removed?
  @file.status == 'removed'
end

Private Instance Methods

changed_lines() click to toggle source
# File lib/policial/commit_file.rb, line 34
def changed_lines
  @changed_lines ||= patch.changed_lines
end
patch() click to toggle source
# File lib/policial/commit_file.rb, line 38
def patch
  Patch.new(@file.patch)
end