Class: Git::Heatmap::Aggregate
- Inherits:
-
Object
- Object
- Git::Heatmap::Aggregate
- Defined in:
- lib/git/heatmap/commits.rb
Instance Attribute Summary collapse
-
#additions ⇒ Object
readonly
Returns the value of attribute additions.
-
#churn ⇒ Object
readonly
Returns the value of attribute churn.
-
#commits ⇒ Object
readonly
Returns the value of attribute commits.
-
#deletions ⇒ Object
readonly
Returns the value of attribute deletions.
-
#earliest_commit_at ⇒ Object
readonly
Returns the value of attribute earliest_commit_at.
-
#latest_commit_at ⇒ Object
readonly
Returns the value of attribute latest_commit_at.
-
#maximum ⇒ Object
readonly
Returns the value of attribute maximum.
-
#periods ⇒ Object
readonly
Returns the value of attribute periods.
Instance Method Summary collapse
- #add(commit, patch) ⇒ Object
-
#initialize(filter) ⇒ Aggregate
constructor
A new instance of Aggregate.
- #size ⇒ Object
Constructor Details
#initialize(filter) ⇒ Aggregate
Returns a new instance of Aggregate.
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/git/heatmap/commits.rb', line 26 def initialize(filter) @filter = filter @commits = {} @periods = {} @earliest_commit_at = nil @latest_commit_at = nil @maximum = 0 @additions = Hash.new{|h,k| h[k] = 0} @deletions = Hash.new{|h,k| h[k] = 0} @churn = Hash.new{|h,k| h[k] = 0} end |
Instance Attribute Details
#additions ⇒ Object (readonly)
Returns the value of attribute additions.
48 49 50 |
# File 'lib/git/heatmap/commits.rb', line 48 def additions @additions end |
#churn ⇒ Object (readonly)
Returns the value of attribute churn.
50 51 52 |
# File 'lib/git/heatmap/commits.rb', line 50 def churn @churn end |
#commits ⇒ Object (readonly)
Returns the value of attribute commits.
42 43 44 |
# File 'lib/git/heatmap/commits.rb', line 42 def commits @commits end |
#deletions ⇒ Object (readonly)
Returns the value of attribute deletions.
49 50 51 |
# File 'lib/git/heatmap/commits.rb', line 49 def deletions @deletions end |
#earliest_commit_at ⇒ Object (readonly)
Returns the value of attribute earliest_commit_at.
45 46 47 |
# File 'lib/git/heatmap/commits.rb', line 45 def earliest_commit_at @earliest_commit_at end |
#latest_commit_at ⇒ Object (readonly)
Returns the value of attribute latest_commit_at.
46 47 48 |
# File 'lib/git/heatmap/commits.rb', line 46 def latest_commit_at @latest_commit_at end |
#maximum ⇒ Object (readonly)
Returns the value of attribute maximum.
56 57 58 |
# File 'lib/git/heatmap/commits.rb', line 56 def maximum @maximum end |
#periods ⇒ Object (readonly)
Returns the value of attribute periods.
43 44 45 |
# File 'lib/git/heatmap/commits.rb', line 43 def periods @periods end |
Instance Method Details
#add(commit, patch) ⇒ Object
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/git/heatmap/commits.rb', line 58 def add(commit, patch) = commit. time = [:time] key = @filter.key(time) unless @commits.include?(commit.oid) @commits[commit.oid] = commit commits = (@periods[key] ||= []) commits << commit end @additions[key] += patch.additions @deletions[key] += patch.deletions churn = patch.additions + patch.deletions.abs @churn[key] += churn total_churn = @churn[key] if total_churn > @maximum @maximum = total_churn end if @earliest_commit_at.nil? or time < @earliest_commit_at @earliest_commit_at = time end if @latest_commit_at.nil? or time > @latest_commit_at @latest_commit_at = time end end |
#size ⇒ Object
52 53 54 |
# File 'lib/git/heatmap/commits.rb', line 52 def size @commits.size end |