From: Tom Pollard Date: 2006-12-16T07:24:28+09:00 Subject: Re: gems cleverness? On Dec 15, 2006, at 3:15 PM, Eric Hodel wrote: > On Dec 15, 2006, at 12:56, Giles Bowkett wrote: >>> I don't see how you could possibly expect to know what files >>> would be >>> loaded by your program in the future. >> >> Well, that's the challenge, isn't it? It's only when you start to >> hack >> time-travel knowledge discovery problems that you discover how truly >> astounding Ruby's dynamicity is. >> >> Seriously a human can do it just by looking at the source. > > Not accurately. Load path manipulation or require order may cause > files to be loaded or not loaded contrary to your expectations. > Files may have been orphaned by the author, or your code may not > need certain files, so they won't be required. Granted, but that's not a good reason to not to do what you can. Based on a static analysis of the code, you can figure out what most of the module dependencies are, or even all of the module dependencies in most cases. Being able to identify the modules a script loads automatically is a necessary step for tools like PerlApp, perl2exe, PAR/pp, py2app, py2exe, etc. which produce executables from Perl and Python scripts by bundling the script, the interpreter and the dependent modules in a self-extracting, executable archive. I don't remember what the OP here wanted this for, but what they're asking for is not impractical or silly, and the problems people are citing with it are not unique to ruby. If you're not familiar with the Perl and Python products I mentioned, here are some references: PAR http://par.perl.org/wiki/Main_Page Module::ScanDeps http://search.cpan.org/dist/Module-ScanDeps/ py2app http://svn.pythonmac.org/py2app/py2app/trunk/doc/index.html PerlApp http://aspn.activestate.com/ASPN/docs/PDK/6.0/ PerlApp_overview.html py2exe http://www.py2exe.org/ I noticed (while Googling) that there is a similar Ruby project already. Presumably it already does this sort of dependency analysis in one form or another. rubyscript2exe http://www.erikveen.dds.nl/rubyscript2exe/index.html Cheers, Tom