Joel VanderWerf
3/31/2006 10:05:00 PM
Stephen Tashiro wrote:
> I see, by experiment, that one can maipulate $LOAD_PATH within a Ruby
> program. The second edition of the Pixaxe book indicates that using
> rubygems is a good way.
>
> What are some examples of "best practices" for $LOAD_PATH management?
One idea: have a directory called ruby/prj/lib or some such, put it in
your $RUBYLIB env var so that it gets into $LOAD_PATH, and populate it
with symlinks to your development directories. This lets you code
against your development versions of your libraries without installing
them locally.
For example, I have a lib project called "wl". The lib files live in
ruby/prj/wl/lib/wl/ and there is also ruby/prj/wl/lib/wl.rb. My lib dir
has these symlinks:
ruby/prj/lib/wl -> ../wl/lib/wl/
ruby/prj/lib/wl.rb -> ../wl/lib/wl.rb
Then, since ruby/prj/lib is on my $LOAD_PATH, I can simply do
require 'wl'
require 'wl/something'
as I develop against this library. These two lines work the same when
the library is truly installed on a user's computer. (I'm using the
standard setup.rb for this one.)
If I want to try installing locally to make sure my code works against
installed versions of the library, I can just clear RUBYLIB in a subshell.
--
vjoel : Joel VanderWerf : path berkeley edu : 510 665 3407