Class: Hashira::Churn
- Inherits:
-
Object
- Object
- Hashira::Churn
- Defined in:
- lib/hashira/churn.rb
Constant Summary collapse
- LOG =
"git log --name-only --format= 2>/dev/null"- SITES_THAT_DRIFT_APART =
2
Class Method Summary collapse
Instance Method Summary collapse
- #changing(members) ⇒ Object
- #hits(file) ⇒ Object
- #hot?(members) ⇒ Boolean
-
#initialize(counts) ⇒ Churn
constructor
A new instance of Churn.
Constructor Details
#initialize(counts) ⇒ Churn
Returns a new instance of Churn.
11 12 13 |
# File 'lib/hashira/churn.rb', line 11 def initialize(counts) @counts = counts end |
Class Method Details
.scan ⇒ Object
7 |
# File 'lib/hashira/churn.rb', line 7 def self.scan = new(tally(`#{LOG}`)) |
.tally(output) ⇒ Object
9 |
# File 'lib/hashira/churn.rb', line 9 def self.tally(output) = output.split("\n").map(&:strip).reject(&:empty?).tally |
Instance Method Details
#changing(members) ⇒ Object
19 |
# File 'lib/hashira/churn.rb', line 19 def changing(members) = members.count { |member| hits(member.file).positive? } |
#hits(file) ⇒ Object
15 |
# File 'lib/hashira/churn.rb', line 15 def hits(file) = @counts.select { |path, _| path.end_with?(file) }.values.max || 0 |
#hot?(members) ⇒ Boolean
17 |
# File 'lib/hashira/churn.rb', line 17 def hot?(members) = changing(members) >= SITES_THAT_DRIFT_APART |