Class: GitWakaTime::Commit

Inherits:
Sequel::Model
  • Object
show all
Defined in:
lib/gitwakatime/commit.rb

Overview

Cache git commit and correlate it’s children

Instance Method Summary collapse

Instance Method Details

#after_createObject



7
8
9
# File 'lib/gitwakatime/commit.rb', line 7

def after_create
  extract_changed_files if GitWakaTime.config.git
end

#dateObject



28
29
30
# File 'lib/gitwakatime/commit.rb', line 28

def date
  self[:date].localtime
end

#oldest_dependentObject



20
21
22
# File 'lib/gitwakatime/commit.rb', line 20

def oldest_dependent
  @files.sort { |f| f.commit.date }.first
end

#time_in_secondsObject



24
25
26
# File 'lib/gitwakatime/commit.rb', line 24

def time_in_seconds
  commited_files.map(&:time_in_seconds).compact.inject(:+)
end

#to_sObject



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),
         message
        )
end