Re: There must be a better way -- requiring multiple files


#1

Dir[File.join(FILE, “…”, “…”, “lib”, “**”,

Others more familiar with the Ruby source already said
Yep, guess so.

Interesting points raised nevertheless.

Kind regards

robert

Could Kernel#require be modified to understand ‘*’ (non-recursive) and
‘**’ (recursive)? Then you could do:

require “net/*” # require all .rb files under the net directory
require “net/**” # Same, but recursive

I seem to recall this being proposed in the past, but I can’t remember
the arguments against it.

Regards,

Dan


#2

On Wed, Nov 23, 2005 at 02:29:16AM +0900, Berger, Daniel wrote:

Could Kernel#require be modified to understand ‘*’ (non-recursive) and
‘**’ (recursive)? Then you could do:

require “net/*” # require all .rb files under the net directory
require “net/**” # Same, but recursive

I seem to recall this being proposed in the past, but I can’t remember
the arguments against it.

You could add to them that it’d pose some problems with RubyGems’ new
definition of Kernel#require.


#3

On 11/22/05, Mauricio Fernández removed_email_address@domain.invalid wrote:

definition of Kernel#require.
Yeah, but I think that there are enough potential problems with the
idea that one wouldn’t even have to reach that far down the list to
kill it.

  1. The search time would be high, since Ruby would have to look in all
    of $LOAD_PATH.
  2. It would be massively insecure. Even what I do in Ruwiki isn’t
    safe from that perspective.

It would be better to have a single file that you load that contains
the names of the files you want to load.

-austin