When reading source code, I always want to know the full path of the file when it is loaded, is there any callback method in ruby to accomplish this, or any other way to do this? thanks in advance.
EDIT Clarification from the comments:
I want to know where the loaded ‘somefile’ is located while I execute this line: ‘load somefile’
The best way I can think of is to patch the
Kernelmodule. According to the docsKernel::loadsearches$:for the filename. We can do the same thing and print the path if we find it.We use
alias_methodto store the originalloadmethod, which we call at the end of ours.