Class: CommitStats
- Inherits:
-
Object
- Object
- CommitStats
- Defined in:
- lib/gitstats/stats/commit.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#commits ⇒ Object
readonly
Returns the value of attribute commits.
-
#files ⇒ Object
readonly
Returns the value of attribute files.
-
#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 ⇒ Object
readonly
Returns the value of attribute lines.
-
#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
- #days ⇒ Object
-
#initialize ⇒ CommitStats
constructor
A new instance of CommitStats.
- #update(commit) ⇒ Object
Constructor Details
#initialize ⇒ CommitStats
Returns a new instance of CommitStats.
16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/gitstats/stats/commit.rb', line 16 def initialize @commits = 0 @files_added = 0 @files_deleted = 0 @lines_added = 0 @lines_deleted = 0 @files = 0 @lines = 0 @first_commit = nil @last_commit = nil @days = Array.new 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 ⇒ Object (readonly)
Returns the value of attribute files.
7 8 9 |
# File 'lib/gitstats/stats/commit.rb', line 7 def files @files 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.
9 10 11 |
# File 'lib/gitstats/stats/commit.rb', line 9 def first_commit @first_commit end |
#last_commit ⇒ Object (readonly)
Returns the value of attribute last_commit.
10 11 12 |
# File 'lib/gitstats/stats/commit.rb', line 10 def last_commit @last_commit end |
#lines ⇒ Object (readonly)
Returns the value of attribute lines.
8 9 10 |
# File 'lib/gitstats/stats/commit.rb', line 8 def lines @lines 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
#days ⇒ Object
12 13 14 |
# File 'lib/gitstats/stats/commit.rb', line 12 def days @days.size end |
#update(commit) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/gitstats/stats/commit.rb', line 29 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] @files = @files_added - @files_deleted @lines = @lines_added - @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 day = commit[:time].year * 10000 + commit[:time].month * 100 + commit[:time].day @days << day unless @days.include? day end |