Class: Commit
Instance Attribute Summary collapse
-
#addition ⇒ Object
Time calc.
-
#clocked_in ⇒ Object
Whether it’s been padded by a clock in/out.
-
#clocked_out ⇒ Object
Whether it’s been padded by a clock in/out.
-
#diffs ⇒ Object
From Grit::Commit object.
-
#estimated ⇒ Object
Time calc.
-
#message ⇒ Object
From Grit::Commit object.
-
#minutes ⇒ Object
Time calc.
-
#overriden ⇒ Object
Time calc.
-
#sha ⇒ Object
From Grit::Commit object.
-
#stats ⇒ Object
From Grit::Commit object.
Attributes inherited from Record
Instance Method Summary collapse
- #calculate_diffs(my_files, not_my_files) ⇒ Object
-
#initialize(commit = nil, date = nil) ⇒ Commit
constructor
A new instance of Commit.
Constructor Details
#initialize(commit = nil, date = nil) ⇒ Commit
Returns a new instance of Commit.
13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/record.rb', line 13 def initialize(commit = nil, date = nil) @addition = 0 @date = date if commit @author = commit..email @date = commit.committed_date @message = commit..gsub("\n",' ') @sha = commit.id @stats = commit.stats end end |
Instance Attribute Details
#addition ⇒ Object
Time calc
9 10 11 |
# File 'lib/record.rb', line 9 def addition @addition end |
#clocked_in ⇒ Object
Whether it’s been padded by a clock in/out
11 12 13 |
# File 'lib/record.rb', line 11 def clocked_in @clocked_in end |
#clocked_out ⇒ Object
Whether it’s been padded by a clock in/out
11 12 13 |
# File 'lib/record.rb', line 11 def clocked_out @clocked_out end |
#diffs ⇒ Object
From Grit::Commit object
7 8 9 |
# File 'lib/record.rb', line 7 def diffs @diffs end |
#estimated ⇒ Object
Time calc
9 10 11 |
# File 'lib/record.rb', line 9 def estimated @estimated end |
#message ⇒ Object
From Grit::Commit object
7 8 9 |
# File 'lib/record.rb', line 7 def @message end |
#minutes ⇒ Object
Time calc
9 10 11 |
# File 'lib/record.rb', line 9 def minutes @minutes end |
#overriden ⇒ Object
Time calc
9 10 11 |
# File 'lib/record.rb', line 9 def overriden @overriden end |
#sha ⇒ Object
From Grit::Commit object
7 8 9 |
# File 'lib/record.rb', line 7 def sha @sha end |
#stats ⇒ Object
From Grit::Commit object
7 8 9 |
# File 'lib/record.rb', line 7 def stats @stats end |
Instance Method Details
#calculate_diffs(my_files, not_my_files) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/record.rb', line 25 def calculate_diffs(my_files, not_my_files) return @diffs if @diffs plus, minus = 0, 0 @stats.to_diffstat.each do |diff_stat| should_include = (diff_stat.filename =~ my_files) should_ignore = not_my_files && (diff_stat.filename =~ not_my_files) if should_include && !should_ignore plus += diff_stat.additions minus += diff_stat.deletions end end # Weight deletions half as much, since they are typically # faster to do & also are 1:1 with additions when changing a line @diffs = plus+minus/2 end |