Created
October 25, 2011 23:43
-
-
Save mipearson/1314818 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
ROOT = '...' | |
EXTENSIONS = %w{html rb erb js css} | |
ignore = File.read(ROOT + '/.gitignore').split("\n").map {|a| "-not -path '#{a}'"}.join(' ') | |
if ARGV[0] == 'config' | |
puts "graph_title Code Metric - Line Count" | |
puts "graph_vlabel lines of code" | |
puts "graph_period line" | |
puts "graph_category codemetric" | |
puts "graph_info Lines of code per extension" | |
EXTENSIONS.each do |extension| | |
puts <<-EOF | |
#{extension}.label #{extension.upcase} loc | |
#{extension}.type GAUGE | |
#{extension}.min 0 | |
EOF | |
end | |
else | |
EXTENSIONS.each do |extension| | |
total = `cd #{ROOT}; find app lib public -mount -type f -name '*.#{extension}' #{ignore} | xargs wc -l | tail -1` | |
puts "#{extension}.value #{total.to_i}" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment