Class: MetricFu::Churn
Defined Under Namespace
Classes: Git, SourceControl, Svn
Instance Attribute Summary
Attributes inherited from Generator
#report, #template
Instance Method Summary
collapse
Methods inherited from Generator
class_name, #create_metric_dir_if_missing, #create_output_dir_if_missing, generate_report, #generate_report, metric_directory, #metric_directory, #round_to_tenths
Constructor Details
#initialize(options = {}) ⇒ Churn
7
8
9
10
11
12
13
14
15
16
17
|
# File 'lib/generators/churn.rb', line 7
def initialize(options={})
super
if File.exist?(".git")
@source_control = Git.new(MetricFu.churn[:start_date])
elsif File.exist?(".svn")
@source_control = Svn.new(MetricFu.churn[:start_date])
else
raise "Churning requires a subversion or git repo"
end
@minimum_churn_count = MetricFu.churn[:minimum_churn_count] || 5
end
|
Instance Method Details
#analyze ⇒ Object
23
24
25
26
|
# File 'lib/generators/churn.rb', line 23
def analyze
@changes = @changes.to_a.sort {|x,y| y[1] <=> x[1]}
@changes = @changes.map {|change| {:file_path => change[0], :times_changed => change[1] }}
end
|
#emit ⇒ Object
19
20
21
|
# File 'lib/generators/churn.rb', line 19
def emit
@changes = parse_log_for_changes.reject {|file, change_count| change_count < @minimum_churn_count}
end
|
#to_h ⇒ Object
28
29
30
|
# File 'lib/generators/churn.rb', line 28
def to_h
{:churn => {:changes => @changes}}
end
|