Sha256: d295d06ee193f9b243d0d4280b3e51a60616ce28ed166c5f2de7f5162f7624af
Contents?: true
Size: 1.5 KB
Versions: 2
Compression:
Stored size: 1.5 KB
Contents
# coding: utf-8 ################################################ # © Alexander Semyonov, 2013—2013, MIT License # # Authors: Alexander Semyonov <al@semyonov.us> # # Sergey Ukustov <sergey@ukstv.me> # ################################################ require 'giteaucrat' require 'grit' require 'core_ext/grit/blame' require 'giteaucrat/formatters' module Giteaucrat class File include Common # @return [String] attr_accessor :name # @return [Giteaucrat::Repo] attr_accessor :repo def authors @authors ||= begin blame = repo.git_repo.blame(name) lines = blame.lines commits = lines.map { |line| line.commit }.uniq.find_all do |commit| !repo.ignored_commit?(commit) end commits.inject(Set.new) do |authors, commit| author = Author.find_by_git_person(commit.author) authors << author unless author.ignored? authors end end end 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 def read_contents ::File.read(name) end def write_contents(contents) ::File.write(name, contents) end def formatter @formatter ||= Formatters.formatter_for(self) end def write_copyright! formatter.write_copyright! end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
giteaucrat-0.0.7 | lib/giteaucrat/file.rb |
giteaucrat-0.0.6 | lib/giteaucrat/file.rb |