Sha256: 912aaac7d80719d1a5ee760a2abce528e0869aeb33f3c21a9425b287b9e6ebee
Contents?: true
Size: 1.5 KB
Versions: 2
Compression:
Stored size: 1.5 KB
Contents
# coding: utf-8 # frozen_string_literal: true ############################################## # © Alex Semyonov, 2013—2017, MIT License # # Authors: Alex Semyonov <alex@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(&: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 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.1.0 | lib/giteaucrat/file.rb |
giteaucrat-0.0.8 | lib/giteaucrat/file.rb |