Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
#!/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