Class: Giteaucrat::File
- Inherits:
-
Object
show all
- Includes:
- Common
- Defined in:
- lib/giteaucrat/file.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods included from Common
#assign_attributes, #initialize
Instance Attribute Details
#name ⇒ String
20
21
22
|
# File 'lib/giteaucrat/file.rb', line 20
def name
@name
end
|
23
24
25
|
# File 'lib/giteaucrat/file.rb', line 23
def repo
@repo
end
|
Instance Method Details
#authors ⇒ Object
25
26
27
28
29
30
31
32
33
34
35
36
37
|
# 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
|
#owner ⇒ Object
39
40
41
42
43
44
45
46
|
# 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 ⇒ Object
48
49
50
|
# File 'lib/giteaucrat/file.rb', line 48
def read_contents
::File.read(name)
end
|
#write_contents(contents) ⇒ Object
52
53
54
|
# File 'lib/giteaucrat/file.rb', line 52
def write_contents(contents)
::File.write(name, contents)
end
|
#write_copyright! ⇒ Object
60
61
62
|
# File 'lib/giteaucrat/file.rb', line 60
def write_copyright!
formatter.write_copyright!
end
|