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

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
F3b7b8756d0c7f71cc7460cc33aefaee?d=identicon&s=25 Daniel.Berger (Guest)
on 2005-11-22 18:30
(Received via mailing list)
> >> 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
Dd76a12d66f843de5c5f8782668e7127?d=identicon&s=25 mfp (Guest)
on 2005-11-22 19:47
(Received via mailing list)
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.
31ab75f7ddda241830659630746cdd3a?d=identicon&s=25 halostatue (Guest)
on 2005-11-22 19:55
(Received via mailing list)
On 11/22/05, Mauricio Fernández <mfp@acm.org> 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
This topic is locked and can not be replied to.