Formatting

This commit is contained in:
Arfon Smith
2014-07-09 09:50:47 -05:00
parent 7802030a53
commit 3a797e2583

View File

@@ -114,17 +114,26 @@ namespace :benchmark do
puts "Changes between #{reference}...#{compare}"
changes = reference_classifications.deep_diff(compare_classifications)
# Are there any differences in the linguist classification?
if changes.any?
changes.each do |lang, files|
previous_count = reference_classifications[lang].size
# Count the number of changed classifications (language and number)
summary = changes[lang].inject(Hash.new(0)) do |result, (key, val)|
new_lang = val.last
result[new_lang] += 1
result
end
end
puts summary
puts "#{lang}"
# Work out the percentage change
summary.each do |new_lang, count|
percent = count / previous_count.to_f
puts " #{sprintf("%.2f", percent)}% change to #{new_lang} (count files)"
end
end
else
puts "No changes"
end