From: Paul van Delst Date: 2007-03-12T23:25:06+09:00 Subject: Re: Code organisation "template" interference(?) with RUBYLIB envar Brian Candler wrote: > On Sat, Mar 10, 2007 at 08:25:09AM +0900, Paul van Delst wrote: >> ---project1 (module Proj1) >> | |--lib >> | | |---project1.rb (class Proj1::Runner) >> | | |---config >> | | | | >> | | | `--config.rb (class Proj1::Config) > .. >> require 'base/base' >> module Proj2 >> module Runner1 > > I'd suggest putting a single entry in your load path, for the very top level > of your directory structure, and then use > > require 'project1/lib/base/base' > > instead of > > require 'base/base' > > This is the simplest way of easily distinguishing project1 from project2 if > the subdirectories and files contained by both have the same names > (especially if project1 needs to use files within project2) Hi Brian, Your suggestion is how I first thought about "fixing" my problem. But when other folks check out my code from the repository, they may not have the same directory structure as I do. Then I get calls about files not found etc. > If all projects are independent, then clearly when you run an application > from project1 you only need to put project1's lib directory into the RUBYLIB > environment. > > If you want to automate this, then create a bunch of files at the top level > of your lib tree > > [project1.rb] > $:.unshift "/path/to/project1/lib" > > [project2.rb] > $:.unshift "/path/to/project2/lib" > > Then your programs can say: > > require 'project1' > require 'base/base' > > or whatever. (That means you only need to put one extra line at the top of > each source file) Thanks for the tip. I think I'll look into this... I do something like this for my test cases. cheers, paulv -- Paul van Delst Ride lots. CIMSS @ NOAA/NCEP/EMC Eddy Merckx