-
-
Save imme5150/6083600 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# thanks to railscasts: | |
# http://railscasts.com/episodes/48-console-tricks-revised?view=comments | |
# add this to your ~/.irbrc file | |
class Object | |
# look up source location of a method | |
def sl(method_name) | |
self.method(method_name).source_location | |
end | |
# macvim | |
def mvim(method_name) | |
file, line = sl(method_name) | |
`mvim #{file} +#{line}` | |
end | |
# sublime text | |
def subl(method_name) | |
file, line = sl(method_name) | |
`subl #{file}:#{line}` | |
end | |
# textmate | |
def mate(method_name) | |
file, line = sl(method_name) | |
`mate '#{file}' -l #{line}` | |
end | |
end | |
# examples: | |
# helper.sl(:link_to) # show file name and line number of the source code for the link_to helper method | |
# helper.mate(:link_to) # opens the link_to helper definition in textmate | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment