fedzor
4/25/2008 2:47:00 AM
check out the "need" gem! makes these things simple.
On Apr 22, 2008, at 6:45 AM, Christoffer Lern=F6 wrote:
> I'm writing a server for a networked game using ruby, but I keep =20
> running into issues when organizing them.
>
> Basically I have a structure looking a bit like this:
>
> lib/
> testclient/
> gamemodel/
> gamecommands/
> server/
> utils/
> test/
> gamemodel/
> gamecommands/
> server/
> utils/
>
>
> The problem is the paths for the requires.
>
> For a test in say test/gamemodel, I need to require something =20
> like ../../lib/gamemodel/<file>
> But when running the same test from some test_all.rb in /test, the =20
> correct require is of course ../lib/gamemodel/<file>
> (The natural way would have been to simply write require <file>)
>
> It is possible to fix this problem by appending to the load path, =20
> but this means rows of duplicate code in every test file.
>
> The problem naturally extends to the lib where you also have to =20
> decide where the code supposedly is run from.
>
> Any suggestions on neat ways of solving this problem or are there =20
> perhaps packages available to make this work automatically?
>
>
> /Christoffer
>
>
>
~ Ira Rizdal
Go hang a salami, I'm a lasagna hog