Add basic linguist bin

This commit is contained in:
Joshua Peek
2011-05-25 12:52:29 -05:00
parent 5a780fbdc1
commit ed9888cf9c
2 changed files with 18 additions and 0 deletions

16
bin/linguist Executable file
View File

@@ -0,0 +1,16 @@
#!/usr/bin/env ruby
require 'linguist/blob'
require 'linguist/repository'
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]
end
else
abort "usage: linguist <path>"
end