Class: Commit

Inherits:
Record show all
Defined in:
lib/record.rb

Instance Attribute Summary collapse

Attributes inherited from Record

#author, #date

Instance Method Summary collapse

Constructor Details

#initialize(commit = nil, date = nil, paths = nil) ⇒ Commit

Returns a new instance of Commit.



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/record.rb', line 13

def initialize(commit = nil, date = nil, paths = nil)
    @addition = 0
    @date = date
    if commit
        @author = commit.author[:email]
        @date = commit.time
        @message = commit.message.gsub("\n",' ')
        @sha = commit.oid
        @diffs = 0
        commit.diff(commit.parents[0]).each_patch do |patch|
            # Weight deletions half as much, since they are typically
            # faster to do & also are 1:1 with additions when changing a line
            @diffs += patch.stat[0] + patch.stat[1]/2
        end
    end
end

Instance Attribute Details

#additionObject

Time calc



9
10
11
# File 'lib/record.rb', line 9

def addition
  @addition
end

#clocked_inObject

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_outObject

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

#diffsObject

From Grit::Commit object



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

def diffs
  @diffs
end

#estimatedObject

Time calc



9
10
11
# File 'lib/record.rb', line 9

def estimated
  @estimated
end

#messageObject

From Grit::Commit object



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

def message
  @message
end

#minutesObject

Time calc



9
10
11
# File 'lib/record.rb', line 9

def minutes
  @minutes
end

#overridenObject

Time calc



9
10
11
# File 'lib/record.rb', line 9

def overriden
  @overriden
end

#shaObject

From Grit::Commit object



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

def sha
  @sha
end