Class: Giteaucrat::Repo
- Inherits:
-
Object
show all
- Includes:
- Common
- Defined in:
- lib/giteaucrat/repo.rb
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from Common
#assign_attributes, #initialize
Instance Attribute Details
#commit_keyword ⇒ Object
Returns the value of attribute commit_keyword.
28
29
30
|
# File 'lib/giteaucrat/repo.rb', line 28
def commit_keyword
@commit_keyword
end
|
Returns the value of attribute copyright_format.
31
32
33
|
# File 'lib/giteaucrat/repo.rb', line 31
def copyright_format
@copyright_format
end
|
#copyright_owner ⇒ Object
Returns the value of attribute copyright_owner.
30
31
32
|
# File 'lib/giteaucrat/repo.rb', line 30
def copyright_owner
@copyright_owner
end
|
#copyright_year ⇒ Number
90
91
92
|
# File 'lib/giteaucrat/repo.rb', line 90
def copyright_year
@copyright_year || first_commit.authored_date.year
end
|
#include_encoding ⇒ Object
Returns the value of attribute include_encoding.
33
34
35
|
# File 'lib/giteaucrat/repo.rb', line 33
def include_encoding
@include_encoding
end
|
#license ⇒ Object
Returns the value of attribute license.
32
33
34
|
# File 'lib/giteaucrat/repo.rb', line 32
def license
@license
end
|
#path ⇒ String
27
28
29
|
# File 'lib/giteaucrat/repo.rb', line 27
def path
@path
end
|
#patterns ⇒ <String>
57
58
59
|
# File 'lib/giteaucrat/repo.rb', line 57
def patterns
@patterns || %w[app/**/*.rb lib/**/*.rb script/**/*.rb spec/**/*.rb test/**/*.rb]
end
|
Class Method Details
.defaults=(options = {}) ⇒ Object
17
18
19
20
|
# File 'lib/giteaucrat/repo.rb', line 17
def self.defaults=(options = {})
Grit::Git.git_binary = options[:git] if options[:git]
Grit::Git.git_timeout = options[:git_timeout] if options[:git_timeout]
end
|
Instance Method Details
#authors=(authors) ⇒ Object
81
82
83
84
85
|
# File 'lib/giteaucrat/repo.rb', line 81
def authors=(authors)
authors.each do |author_attributes|
Author.new(author_attributes)
end
end
|
#commit!(message) ⇒ Object
36
37
38
|
# File 'lib/giteaucrat/repo.rb', line 36
def commit!(message)
git_repo.commit_all(message)
end
|
#config= ⇒ Object
87
|
# File 'lib/giteaucrat/repo.rb', line 87
def config=(*); end
|
#copyright_label ⇒ String
103
104
105
106
107
108
|
# File 'lib/giteaucrat/repo.rb', line 103
def copyright_label
@copyright_label ||= copyright_format
.gsub('%{years}', [copyright_year, Time.now.year].compact.join('—'))
.gsub('%{owner}', copyright_owner)
.gsub('%{license}', license || '')
end
|
#files ⇒ Object
40
41
42
43
44
45
46
47
48
49
50
|
# File 'lib/giteaucrat/repo.rb', line 40
def files
@files ||= begin
Dir.chdir(path) do
patterns.inject([]) do |files, pattern|
files + Dir[pattern]
end.map do |file_name|
File.new(name: file_name, repo: self)
end
end
end
end
|
#first_commit ⇒ Grit::Commit
95
96
97
98
99
100
|
# File 'lib/giteaucrat/repo.rb', line 95
def first_commit
@first_commit ||= begin
count = git_repo.commit_count
git_repo.commits(git_repo.head.name, 1, count - 1).first
end
end
|
#git ⇒ Object
73
74
75
|
# File 'lib/giteaucrat/repo.rb', line 73
def git
Grit::Git.git_binary
end
|
#git=(executable) ⇒ Object
77
78
79
|
# File 'lib/giteaucrat/repo.rb', line 77
def git=(executable)
Grit::Git.git_binary = executable
end
|
#git_repo ⇒ Object
22
23
24
|
# File 'lib/giteaucrat/repo.rb', line 22
def git_repo
@git_repo ||= find_git_repo(path)
end
|
#ignored_commit?(commit) ⇒ Boolean
117
118
119
|
# File 'lib/giteaucrat/repo.rb', line 117
def ignored_commit?(commit)
!commit || commit.message.match(ignored_commit_message)
end
|
#ignored_commit_message ⇒ Regexp
111
112
113
|
# File 'lib/giteaucrat/repo.rb', line 111
def ignored_commit_message
@ignored_commit_message ||= /^#{Regexp.escape(commit_keyword)}/
end
|
#include_encoding? ⇒ Boolean
121
122
123
|
# File 'lib/giteaucrat/repo.rb', line 121
def include_encoding?
!!include_encoding
end
|
#timeout ⇒ Object
65
66
67
|
# File 'lib/giteaucrat/repo.rb', line 65
def timeout
Grit::Git.git_timeout
end
|
#timeout=(timeout) ⇒ Object
69
70
71
|
# File 'lib/giteaucrat/repo.rb', line 69
def timeout=(timeout)
Grit::Git.git_timeout = timeout
end
|
#write_copyrights! ⇒ Object
52
53
54
|
# File 'lib/giteaucrat/repo.rb', line 52
def write_copyrights!
files.each(&:write_copyright!)
end
|