I’ve written a test harness (in Perl, but I may convert it to Ruby, if
I’m happy with the language after this step), and I’d like to replace
the part that displays the results in a web browser with a Ruby-based
CGI program. Currently I’m modeling it in a MVC pattern, with the
Model (which varies, depending on what sort of results you’re after)
containing the interface to my test database, and the View asking the
Model for the data to display in HTML.
The actual writing of classes is going well, though I’m torn on
whether to have one monolithic Model class, or have several smaller
ones for each View they’re meant to support. My question is on code
organization.
Initially, I tried to just put a class definition (or two) in each
file, and use “require ‘filename’” to fetch it, but that wouldn’t work
until I surrounded the class definition with a "module TestHarness/end"
pair. Later, I figured out it must’ve been a typo of some sort, but
by then, I’d started defining module-level globals, and didn’t want to
give up the namespace.
Okay, that’s not a problem. But I can’t figure out how to
export classes from my module into the global namespace. In Perl, I’d
just add the functions to @EXPORT, and be done with it. Can this be
done in Ruby as well, or am I just thinking about it the wrong way?
Should I be creating my CGI executable in that same module as well?
Or am I just over-organizing here?
Comments welcome.
-=Eric
···
–
Come to think of it, there are already a million monkeys on a million
typewriters, and Usenet is NOTHING like Shakespeare.
– Blair Houghton