aboutsummaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorJoshua Peek <josh@joshpeek.com>2011-05-25 12:52:29 -0500
committerJoshua Peek <josh@joshpeek.com>2011-05-25 12:52:29 -0500
commited9888cf9ca838bc027898d1cf49d92c0681e256 (patch)
treef9f627de1c990a780006a7fd9414e98773008004 /bin
parent5a780fbdc187f79edc6a4b3ce8796466dfa52f30 (diff)
Add basic linguist bin
Diffstat (limited to 'bin')
-rwxr-xr-xbin/linguist16
1 files changed, 16 insertions, 0 deletions
diff --git a/bin/linguist b/bin/linguist
new file mode 100755
index 0000000..ba31f7b
--- /dev/null
+++ b/bin/linguist
@@ -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