On Fri, 16 Mar 2001, Nathaniel Talbott wrote:

> I have a project that I'm working on that needs to live two different lives,
> and I'm not sure how to get it to do it. Of course, as Dave Thomas would
> say, this is Ruby, so there's always a way :-) I just need a little help
> finding it. Here's the exact problem:
> 
> I've written a unit testing framework called Lapidary, and it's made up of a
> reasonable number of files in a fairly simple directory structure. Those
> files have a lot of interdependencies on one another, so they need to be
> able to require one another. Now, Lapidary is generally used as a library,
> so it'll usually be installed in site_ruby/x.x/Lapidary/ and its parts will
> be accessed in a script using:
> 
> 	require 'Lapidary/TestCase'
> 	require 'Lapidary/UI/Console/TestRunner'
> 
> Thus the parts of Lapidary can reference each other in the same way. Fine,
> no problem there: everybody's happy.
> 
> The problem comes in when you want don't want to install Lapidary as a
> library, say to just look at it and run its internal unit tests. Suddenly,
> Lapidary doesn't work anymore, because it can't find itself! Aach! What to
> do? If it uses relative references, then it can't find its parts when run as
> a library; if it uses library references, then it can't find its parts when
> it's run standalone.
> 
FWIW: I used to have the same problem. No I fix this at install time; the
install script changes "require 'my1'" to "require 'myproject/my1'" etc.

Dave's solution is probably nicer.

/Robert