From fdf000ec62a4195f49841cc6b85d3a044e325578 Mon Sep 17 00:00:00 2001 From: Andy Grunwald Date: Tue, 30 Apr 2013 23:23:49 +0200 Subject: [PATCH] Add decimal places to statistic output If you analyze a project sometimes the statistic outputs a language with 0%. At first it seems that the language is not part of this project, but there are only some decimal places missing. --- bin/linguist | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/bin/linguist b/bin/linguist index d28aaf7b..c428fa67 100755 --- a/bin/linguist +++ b/bin/linguist @@ -12,8 +12,9 @@ path = ARGV[0] || Dir.pwd if File.directory?(path) repo = Linguist::Repository.from_directory(path) repo.languages.sort_by { |_, size| size }.reverse.each do |language, size| - percentage = ((size / repo.size.to_f) * 100).round - puts "%-4s %s" % ["#{percentage}%", language] + percentage = ((size / repo.size.to_f) * 100) + percentage = sprintf '%.2f' % percentage + puts "%-7s %s" % ["#{percentage}%", language] end elsif File.file?(path) blob = Linguist::FileBlob.new(path, Dir.pwd)