lib/churn/churn_calculator.rb in churn-0.0.10 vs lib/churn/churn_calculator.rb in churn-0.0.11
- old
+ new
@@ -44,18 +44,18 @@
@revisions = parse_log_for_revision_changes
end
# Analyze the source control data, filter, sort, and find more information on the editted files
def analyze
- @changes = @changes.to_a.sort {|x,y| y[1] <=> x[1]}
+ @changes = sort_changes(@changes)
@changes = @changes.map {|file_path, times_changed| {:file_path => file_path, :times_changed => times_changed }}
calculate_revision_changes
- @method_changes = @method_changes.to_a.sort {|x,y| y[1] <=> x[1]}
+ @method_changes = sort_changes(@method_changes)
@method_changes = @method_changes.map {|method, times_changed| {'method' => method, 'times_changed' => times_changed }}
- @class_changes = @class_changes.to_a.sort {|x,y| y[1] <=> x[1]}
+ @class_changes = sort_changes(@class_changes)
@class_changes = @class_changes.map {|klass, times_changed| {'klass' => klass, 'times_changed' => times_changed }}
end
# collect all the data into a single hash data structure.
def to_h
@@ -98,9 +98,13 @@
method_churn = hash[:churn][:method_churn].map {|e| (e.delete('method') || {}).merge(e) }
result += display_array(method_churn)
end
private
+
+ def sort_changes(changes)
+ changes.to_a.sort! {|x,y| y[1] <=> x[1]}
+ end
def filters
/.*\.rb/
end