class Giteaucrat::File

Attributes

name[RW]

@return [String]

repo[RW]

@return [Giteaucrat::Repo]

Public Instance Methods

authors() click to toggle source
# File lib/giteaucrat/file.rb, line 25
def authors
  @authors ||= begin
    blame = repo.git_repo.blame(name)
    lines = blame.lines
    commits = lines.map(&:commit).uniq.find_all do |commit|
      !repo.ignored_commit?(commit)
    end
    commits.each_with_object(Set.new) do |commit, authors|
      author = Author.find_by_git_person(commit.author)
      authors << author unless author.ignored?
    end
  end
end
formatter() click to toggle source
# File lib/giteaucrat/file.rb, line 56
def formatter
  @formatter ||= Formatters.formatter_for(self)
end
owner() click to toggle source
# File lib/giteaucrat/file.rb, line 39
def owner
  @owner ||= begin
    Author.find_by_git_person(repo.git_repo.log(name).last.author)
  rescue NoMethodError
    Author.new(name: repo.git_repo.config['user.name'],
               email: repo.git_repo.config['user.email'])
  end
end
read_contents() click to toggle source
# File lib/giteaucrat/file.rb, line 48
def read_contents
  ::File.read(name)
end
write_contents(contents) click to toggle source
# File lib/giteaucrat/file.rb, line 52
def write_contents(contents)
  ::File.write(name, contents)
end