From: Joel VanderWerf Date: 2004-06-15T04:21:18+09:00 Subject: Re: require && what has happened? This might be a good question to ask on ruby-talk. Michal Rokos wrote: > in python i found that i can very easily do "plugins" by doing > execString = "import myModule as p" > eval(execString) > # now I have module MyModule as "variable" p > that as easy in ruby.?.? > EOQ > > I know that it isn't possible in ruby.... So he asked whether there is > some way to find out what has happened when he require something.... > > IFAIK there no way to find out what has happended.... Am I right? I suggested a way to do something like this at http://ruby-talk.org/100429 Briefly, the Script.load method loads a file and returns a module which you can use to access the top-level constants and methods defined in the file. Script also defines #load and #require methods so that calling load and require from your script file first tries to find files relative to the script file, and, if found, wraps their top level constants and methods in the same module. If the files are not found, it falls back to Kernel#load and #require. It's a trivial little piece of code, but I gave it a home at: http://redshift.sourceforge.net/script/