Skip to content

Instantly share code, notes, and snippets.

@mipearson
Created October 25, 2011 23:43
Show Gist options
  • Save mipearson/1314818 to your computer and use it in GitHub Desktop.
Save mipearson/1314818 to your computer and use it in GitHub Desktop.
#!/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