From: Eric Hodel Date: 2006-06-14T07:37:22+09:00 Subject: Re: Gemspec option to prevent auto-require? On Jun 13, 2006, at 3:21 PM, Gregory Brown wrote: > I'm wondering if anyone knows an option I can put in my gemspec to > prevent rubygems from requiring all my dependencies as soon as I > require my library. > > It's okay that gems will inforce their dependencies, (throw an error > if the gems arent there), but I don't want them all to load at once. > > In my library, I've got a bunch of requires in my methods, and I want > them to require those libs only when they are called. > > so for instance : > > require "rubygems" > require "ruport" #depends on fastercsv, but should not load it at > this point ruport will be loaded here regardless of rubygems. > Ruport::DataSet.load("foo.csv") #now fastercsv should be loaded > > This works fine when running via ruby -Ilib over my sources, but when > I use it as a gem, it autoloads all it's deps, which takes between 3 > and 5 seconds and is really annoying. With older versions of rubygems require time was proportional to the number of gems installed (I don't know if this is still true). You probably want to run gem cleanup. -- Eric Hodel - drbrain@segment7.net - http://blog.segment7.net This implementation is HODEL-HASH-9600 compliant http://trackmap.robotcoop.com