Class: GitWakaTime::Commit
- Inherits:
-
Sequel::Model
- Object
- Sequel::Model
- GitWakaTime::Commit
- Defined in:
- lib/gitwakatime/commit.rb
Overview
Cache git commit and correlate it’s children
Instance Method Summary collapse
- #after_create ⇒ Object
- #date ⇒ Object
- #oldest_dependent ⇒ Object
- #time_in_seconds ⇒ Object
- #to_s ⇒ Object
Instance Method Details
#after_create ⇒ Object
7 8 9 |
# File 'lib/gitwakatime/commit.rb', line 7 def after_create extract_changed_files if GitWakaTime.config.git end |
#date ⇒ Object
28 29 30 |
# File 'lib/gitwakatime/commit.rb', line 28 def date self[:date].localtime end |
#oldest_dependent ⇒ Object
20 21 22 |
# File 'lib/gitwakatime/commit.rb', line 20 def oldest_dependent @files.sort { |f| f.commit.date }.first end |
#time_in_seconds ⇒ Object
24 25 26 |
# File 'lib/gitwakatime/commit.rb', line 24 def time_in_seconds commited_files.map(&:time_in_seconds).compact.inject(:+) end |
#to_s ⇒ Object
11 12 13 14 15 16 17 18 |
# File 'lib/gitwakatime/commit.rb', line 11 def to_s format(' %-8s %8s %-30s %-80s'.green, sha[0..8], date, ChronicDuration.output(time_in_seconds.to_i), ) end |