Alex Young
1/20/2007 9:42:00 AM
Gregory Brown wrote:
<snip>
> == Structure ==
>
> bin/ : any scripts or executables
>
> lib/ : source files.
>
> conventionally,
>
> Ruport::Data::Table is in
>
> lib/ruport/data/table.rb
>
> alternatively, the class could be included in any file lower down the
> chain:
> (e.g. lib/ruport.rb or lib/ruport/data.rb)
>
> ext/ : C sources for extensions
>
> doc/: documentation
>
> test/: All tests and test data. Tests should begin with
> test_class_name, however an older convention is tc_class_name with
> ts_all.rb loading all your tests.
>
> main directory:
> Rakefile, main documentation files such as README
>
It may be a bad habit I've picked up from Rails, but for a lot of my
apps (typically small, sqlite-backed XMLRPC services) I also have
db/: Database storage (should be in var/, I know, but what the hell) and
migrations
tmp/: Temporary file storage.
conf/: Configuration files. Usually config/config.default.yaml in svn,
and the app looks for config/config.yaml (which is ignored by svn).
Also, if it's appropriate, I use lib/models and lib/controllers the same
way Rails uses app/models and app/controllers.
This has been steadily evolving over the past couple of months, and the
logical conclusion will probably be something which looks an awful lot
like Rails, but without the view side or needing to bother with the HTTP
handling.
> There are of course exceptions to this...
>
> == Tests ==
>
> One test per method, ideally, mapping method name to test.
> Additional tests for bug reports, edge cases, etc.
> ( I usually use a name like test_ensure_table_append_accepts_arrays)
>
> or some really long name describing the problem I'm checking for
If the app is small enough, I go for test_models.rb,
test_controllers.rb, test_xmlrpc.rb, and controller_test_modules.rb.
test_controllers.rb and test_xmlrpc.rb have test cases which mix in the
same modules from controller_test_modules.rb, the difference being that
the tests in test_xmlrpc.rb actually fire up the executables in bin/ and
perform the tests over XMLRPC to the localhost interface.
Of course, these are things that are quite specific to my niche, but
they may be useful.
--
Alex