Vladimir Dozen <Vladimir.Dozen / osw.com.ru> writes:

> ehlo.
ESMTP :) 

>    that most of them will duplicate each other with slightly

Actually this is the reason why putting them into one single file
makes more sense. But let's entertain the idea that you have hundreds
of dissimilar classes each in its own file.

>    The problem is that directory with all these files looks a bit
>    messy; in Java, I would create JAR-archive and put all files there;
>    thus, I could distribute single file. Java can load classes directly
>    from JAR.

No set standard to package files for Ruby. But, there are always
alternatives:

1. Put them into directories. Each time your program runs, iterate
   over all the files in that directory and require'd each one. This
   is a 3-line code (OK, I lied, it's short enough to be a 1-liner).

2. If directory is too mesy, use zip or tar.gz. Same approach as
   directory, but you can package them in one neat file.

Approach 1 is the simplest and the easiest. Even easier than dealing
with JAR. No need to go to special length to create a package. Just
dump them in a directory, and use this 1-liner:
Dir["#{dirname}/*.rb"].each { |fn| require fn }
^^^^^
may not adjustment (not tested).


YS.