Skip to content

Instantly share code, notes, and snippets.

@tobias
Created June 22, 2009 01:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tobias/133750 to your computer and use it in GitHub Desktop.
Save tobias/133750 to your computer and use it in GitHub Desktop.
#!/opt/local/bin/ruby
KEY_PAIRS = %w{`~ 1! 2@ 3# 4$ 5% 6^ 7& 8* 9( 0) -_ [{ ]} \| ;: =+ '" ,< .> /?}.collect { |kp| kp.split('') }
KEYS = KEY_PAIRS.flatten
counts = { }
%w{ app lib test }.each do |dir|
Dir.glob("#{dir}/**/*.{rb,sass}").each do |filename|
File.open(filename) do |file|
file.each do |line|
KEYS.each do |key|
counts[key] ||= 0
counts[key] += line.count(key)
end
end
end
end
end
KEY_PAIRS.each do |kp|
puts "#{kp[0]} #{kp[1]} = #{counts[kp[0]]} #{counts[kp[1]]} " + (counts[kp[1]].to_f / counts[kp[0]]).to_s[0,5]
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment