Class: Hashira::Churn

Inherits:
Object
  • Object
show all
Defined in:
lib/hashira/churn.rb

Constant Summary collapse

SITES_THAT_DRIFT_APART =
2

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(counts) ⇒ Churn

Returns a new instance of Churn.



8
9
10
# File 'lib/hashira/churn.rb', line 8

def initialize(counts)
  @counts = counts
end

Class Method Details

.build(directory) ⇒ Object



6
# File 'lib/hashira/churn.rb', line 6

def self.build(directory) = new(Hashira::GitLog.new(directory).counts)

Instance Method Details

#changing(members) ⇒ Object



18
# File 'lib/hashira/churn.rb', line 18

def changing(members) = members.count { |member| hits(member.file).positive? }

#history?Boolean

Returns:

  • (Boolean)


12
# File 'lib/hashira/churn.rb', line 12

def history? = @counts.any?

#hits(file) ⇒ Object



14
# File 'lib/hashira/churn.rb', line 14

def hits(file) = @counts.select { |path, _| path.end_with?(file) }.values.max || 0

#hot?(members) ⇒ Boolean

Returns:

  • (Boolean)


16
# File 'lib/hashira/churn.rb', line 16

def hot?(members) = changing(members) >= SITES_THAT_DRIFT_APART