Class: CommitAccumulator
- Inherits:
-
Object
- Object
- CommitAccumulator
- Defined in:
- lib/gitstats/stats/commit.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#commits ⇒ Object
readonly
Returns the value of attribute commits.
-
#files_added ⇒ Object
readonly
Returns the value of attribute files_added.
-
#files_deleted ⇒ Object
readonly
Returns the value of attribute files_deleted.
-
#first_commit ⇒ Object
readonly
Returns the value of attribute first_commit.
-
#last_commit ⇒ Object
readonly
Returns the value of attribute last_commit.
-
#lines_added ⇒ Object
readonly
Returns the value of attribute lines_added.
-
#lines_deleted ⇒ Object
readonly
Returns the value of attribute lines_deleted.
Instance Method Summary collapse
- #files ⇒ Object
-
#initialize ⇒ CommitAccumulator
constructor
A new instance of CommitAccumulator.
- #lines ⇒ Object
- #update(commit) ⇒ Object
Constructor Details
#initialize ⇒ CommitAccumulator
Returns a new instance of CommitAccumulator.
18 19 20 21 22 23 24 25 26 |
# File 'lib/gitstats/stats/commit.rb', line 18 def initialize @commits = 0 @files_added = 0 @files_deleted = 0 @lines_added = 0 @lines_deleted = 0 @first_commit = nil @last_commit = nil end |
Instance Attribute Details
#commits ⇒ Object (readonly)
Returns the value of attribute commits.
2 3 4 |
# File 'lib/gitstats/stats/commit.rb', line 2 def commits @commits end |
#files_added ⇒ Object (readonly)
Returns the value of attribute files_added.
3 4 5 |
# File 'lib/gitstats/stats/commit.rb', line 3 def files_added @files_added end |
#files_deleted ⇒ Object (readonly)
Returns the value of attribute files_deleted.
4 5 6 |
# File 'lib/gitstats/stats/commit.rb', line 4 def files_deleted @files_deleted end |
#first_commit ⇒ Object (readonly)
Returns the value of attribute first_commit.
7 8 9 |
# File 'lib/gitstats/stats/commit.rb', line 7 def first_commit @first_commit end |
#last_commit ⇒ Object (readonly)
Returns the value of attribute last_commit.
8 9 10 |
# File 'lib/gitstats/stats/commit.rb', line 8 def last_commit @last_commit end |
#lines_added ⇒ Object (readonly)
Returns the value of attribute lines_added.
5 6 7 |
# File 'lib/gitstats/stats/commit.rb', line 5 def lines_added @lines_added end |
#lines_deleted ⇒ Object (readonly)
Returns the value of attribute lines_deleted.
6 7 8 |
# File 'lib/gitstats/stats/commit.rb', line 6 def lines_deleted @lines_deleted end |
Instance Method Details
#files ⇒ Object
10 11 12 |
# File 'lib/gitstats/stats/commit.rb', line 10 def files @files_added - @files_deleted end |
#lines ⇒ Object
14 15 16 |
# File 'lib/gitstats/stats/commit.rb', line 14 def lines @lines_added - @lines_deleted end |
#update(commit) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/gitstats/stats/commit.rb', line 28 def update(commit) @commits += 1 @files_added += commit[:files_added] @files_deleted += commit[:files_deleted] @lines_added += commit[:lines_added] @lines_deleted += commit[:lines_deleted] @first_commit ||= commit[:time] @last_commit ||= commit[:time] @first_commit = commit[:time] if commit[:time] < @first_commit @last_commit = commit[:time] if commit[:time] > @last_commit end |