Skip to content

Instantly share code, notes, and snippets.

@mgamba
Last active December 18, 2015 21:59
Show Gist options
  • Save mgamba/5851652 to your computer and use it in GitHub Desktop.
Save mgamba/5851652 to your computer and use it in GitHub Desktop.
Quick and dirty method finder for ruby scripts

bash call

find app/ | grep ".rb$" | ./find_methods.rb

find_methods.rb

#!/usr/bin/env ruby -n

file_name = $_.chomp

puts file_name
IO.readlines(file_name).each do |line|
  puts "   #{line.lstrip}" if line =~ /^\ *def|private|public|protected/ || line =~ /^\ *class *<< *self/
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment