Skip to content

Instantly share code, notes, and snippets.

@aaron
Created November 8, 2012 16:51
Show Gist options
  • Save aaron/4040018 to your computer and use it in GitHub Desktop.
Save aaron/4040018 to your computer and use it in GitHub Desktop.
List duplicate rails helper methods
h = Hash.new(0)
Dir.glob(Rails.root.join('app','helpers','*.rb')).each do |file|
File.read(file).lines.each do |line|
if line[/^[ ]+def ([a-zA-Z0-9!_]+)/]
h[$1] += 1
end
end
end
h.each {|key, value| puts key if value > 1}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment