From: Francis Hwang Date: 2005-08-13T06:21:11+09:00 Subject: Re: LibInject 0.1.0: Small Pieces Smooshed Together Jim Weirich wrote: > Francis Hwang said: > > Jim Weirich wrote: > >> Cool! Does it handle things like this: > >> > >> class Command > >> def create_option_parser > >> require 'optparse' > >> @parser = OptionParser.new > >> ... > >> end > >> end > > > > Nope. It really only handles the simplest, most common case, of the > > require statement being on its own line outside of any class/method > > definitions. I could try to make it smart enough to pull require > > statements out of class & method definitions, but I'm not certain if > > it'd be worth the effort. Are there actually many libs out there that > > use requires this way? I personally try to avoid just 'cause I think it > > makes the code look messier, but obviously that's sort of just a > > personal style thing. > > My personal style (in general) is to put all the requires at the top level > at the beginning. However in RubyGems we use the above idiom often to > avoid requiring things that are not needed. The optparse is a bad example > because it is always (eventually) needed, but things like the compression > libraries or the network http libraries are only required for certain > variations of the gem command. By requiring them inline at the place they > are used means they are not loaded when they are not needed. Thanks for the input, Jim & Austin. Okay, I'll put a fix for this in my queue. f.