From: Clifford Heath Date: 2010-12-17T10:35:29+09:00 Subject: Re: Effects of require tsuraan wrote: > In ruby, if I understand correctly, you can do > require some_string > and it parses that file and puts stuff into the global namespace. Is > there a sane way to determine exactly what was changed by that > require? No, there's not. Requiring a file *executes* that file, which often has the side-effect of defining some constants. If you only care about top-level constants, or know the namespace of the constants you care about, you can save the list before require, and subtract that from the list after require. > root//plugin//plugin.rb > and I want to load all the plugin.rb files, I can use > Dir["root/*/plugin/#{name}/plugin.rb"] and then use require_relative > on the resulting list of strings, but how do I know what modules are > being defined in those plugin.rb files? You don't, unless you can guarantee to always use a specific mapping between directory structures and namespaces - none is enforced (nor could be enforced) in Ruby, as it is in, say, Java class file loading. The code being run on require could change anything, through monkey patching, ObjectSpace, etc, even changing running object instances. Clifford Heath.