My require namspaces idea worked pretty well. It allows one to free the
organization of your libs from how the end-user will interface with
them. For example:
The other thing it does is that scriptA.rb and scriptB.rb (or any other
scipt within the same namespace) can require another withput specifying
the location, ie.
scriptA.rb:
require 'scriptB.rb'
No need for 'myspace/script2.rb'. This works as long as scriptA.rb is
required with a defined namespace.
So all was well and wonderful, but then a nastye problem crept up -- I
couldn't run one of these scripts on its own (like for testing
purposes) b/c require's wouldn't be found. (i.e. the namespace isn't
setup) Ugh! Back to the drawing board....
Well it took me awhile, but arrived at a solution. Next post...
Okay, so I wanted a complete solution. A better solution. So I came up
with the idea of adding a namespace file into my lib path that is
"aquisitioned" (zope term), that will put into place the namespaces.
mylib/
_ns.rb
foo/
scriptA.rb
bar/
scriptB.rb
In "_ns.rb" I have:
mylib/foo myspace
mylib/bar myspace
Yes, I know it's not really a ruby script, but setup.rb won't install
it unless it ends in .rb --also I may change it to an actual ruby
script in the future --then it will more like an "autorequire" file.
Anyway. This solves all problems. Except for one thing: it's very
tricky to code.
I've managed a semi-working implemenation, but it's lack luster and
fails under certain cases. So I wondering if anyone has any insight on
how this can be coded?