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.
12 13 14 |
# File 'lib/hashira/churn.rb', line 12 def initialize(counts) @counts = counts end |
Class Method Details
.from_git ⇒ Object
8 |
# File 'lib/hashira/churn.rb', line 8 def self.from_git = new(tally(`#{LOG}`)) |
.tally(output) ⇒ Object
10 |
# File 'lib/hashira/churn.rb', line 10 def self.tally(output) = output.split("\n").map(&:strip).reject(&:empty?).tally |
Instance Method Details
#changing(members) ⇒ Object
20 |
# File 'lib/hashira/churn.rb', line 20 def changing(members) = members.count { |member| hits(member.file).positive? } |
#hits(file) ⇒ Object
16 |
# File 'lib/hashira/churn.rb', line 16 def hits(file) = @counts.select { |path, _| path.end_with?(file) }.values.max || 0 |
#hot?(members) ⇒ Boolean
18 |
# File 'lib/hashira/churn.rb', line 18 def hot?(members) = changing(members) >= SITES_THAT_DRIFT_APART |