Class: DocHealth::Git
- Inherits:
-
Object
- Object
- DocHealth::Git
- Defined in:
- lib/doc_health/git.rb
Instance Attribute Summary collapse
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
- #file_commit_author ⇒ Object
-
#initialize(path) ⇒ Git
constructor
A new instance of Git.
- #last_commit_author(file) ⇒ Object
- #last_commit_date(file) ⇒ Object
Constructor Details
#initialize(path) ⇒ Git
Returns a new instance of Git.
9 10 11 12 |
# File 'lib/doc_health/git.rb', line 9 def initialize(path) @git = ::Git.open(path) @path = path end |
Instance Attribute Details
#path ⇒ Object (readonly)
Returns the value of attribute path.
7 8 9 |
# File 'lib/doc_health/git.rb', line 7 def path @path end |
Instance Method Details
#file_commit_author ⇒ Object
14 15 16 17 18 19 20 |
# File 'lib/doc_health/git.rb', line 14 def Dir.glob("#{path}**/*.md").map do |file| est_time = last_commit_date(file) = (file) [file, est_time, ] end end |
#last_commit_author(file) ⇒ Object
30 31 32 33 34 35 |
# File 'lib/doc_health/git.rb', line 30 def (file) gitlog = @git.log(1).object(file).first return "N/A" unless gitlog @git.log(1).object(file).first..name end |
#last_commit_date(file) ⇒ Object
22 23 24 25 26 27 28 |
# File 'lib/doc_health/git.rb', line 22 def last_commit_date(file) # handle new files not in the git history gitlog = @git.log(1).object(file).first return "N/A" unless gitlog gitlog.date.getlocal("-05:00").strftime("%Y-%m-%d %I:%M %p") end |