Created
January 11, 2011 13:56
-
-
Save vjt/774431 to your computer and use it in GitHub Desktop.
ruby require tree
This file contains 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
# Wanna debug who the hell is requiring that damn gem | |
# you don't wanna see on earth? Here we go! :-) | |
# | |
# debugger rescue nil is required (ha ha) because, if | |
# you require ruby-debug, the debugger method will be | |
# defined *before* all debugger components are loaded | |
# | |
# Please note that, because this method is defined in | |
# Object, caller(0) will contain [$0,$0], thus you'll | |
# have to step inside the original require method and | |
# then call caller(0). | |
# | |
$require_level = [] | |
def self.require(file) | |
$require_level << '=' | |
debugger rescue nil if file.to_s == 'rake' || file.to_s == 'tsort' | |
puts "#{$require_level.join} #{file.inspect} from #{caller(0)[1]}" | |
ret = super(file) | |
$require_level.pop | |
return ret | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment