mirror of
https://github.com/KevinMidboe/linguist.git
synced 2025-12-29 21:31:01 +00:00
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.
This commit is contained in:
@@ -12,8 +12,9 @@ path = ARGV[0] || Dir.pwd
|
|||||||
if File.directory?(path)
|
if File.directory?(path)
|
||||||
repo = Linguist::Repository.from_directory(path)
|
repo = Linguist::Repository.from_directory(path)
|
||||||
repo.languages.sort_by { |_, size| size }.reverse.each do |language, size|
|
repo.languages.sort_by { |_, size| size }.reverse.each do |language, size|
|
||||||
percentage = ((size / repo.size.to_f) * 100).round
|
percentage = ((size / repo.size.to_f) * 100)
|
||||||
puts "%-4s %s" % ["#{percentage}%", language]
|
percentage = sprintf '%.2f' % percentage
|
||||||
|
puts "%-7s %s" % ["#{percentage}%", language]
|
||||||
end
|
end
|
||||||
elsif File.file?(path)
|
elsif File.file?(path)
|
||||||
blob = Linguist::FileBlob.new(path, Dir.pwd)
|
blob = Linguist::FileBlob.new(path, Dir.pwd)
|
||||||
|
|||||||
Reference in New Issue
Block a user