From: ruby@... Date: 2016-10-23T08:05:41+00:00 Subject: [ruby-core:77723] [Ruby trunk Feature#12858] Supporting batch-requiring of files in ruby Issue #12858 has been updated by Herwin W. You realize [this gem](https://rubygems.org/gems/require_all/) does exactly that? ---------------------------------------- Feature #12858: Supporting batch-requiring of files in ruby https://bugs.ruby-lang.org/issues/12858#change-61004 * Author: Robert A. Heiler * Status: Open * Priority: Normal * Assignee: ---------------------------------------- Hello. This is a very short proposal, unlike some of my previous ones; and it also is hopefully possibly better than some of my other proposals before. Could we have a way to batch-require .rb files from a directory? Right now we can do: require 'foo/bar.rb' require 'foo/boo.rb' require 'foo/bii.rb' But this is a bit cumbersome, especially if you have lots of files to manually specify here. We can do first grab these via Dir[] which works fine and then invoke require() on each entry. This also works fine and I am doing this in some of my gems, but it is a cumbersome nonetheless. I was thinking of either of the following two changes perhaps: require_directory 'foo' # This would be similar to: require_directory 'foo/' This new method would then attempt a Dir[] before batch-requiring the specified files via require(). Alternatively, or additionally, perhaps require() itself could support '*'? Then we could have this for require itself like: require 'foo/*.rb' I am not sure if this has been suggested before; there are a few gems that try to solve this but I was wondering if it could be added to ruby as a core functionality itself. Note that while my examples above center primarily around .rb files, it could of course work for .so files too, just following require() policy anyway - my main point was about batch-requiring files more easily in ruby. Thanks for reading! PS: It could work for load() too but I personally seem to use require() like +98% of the time so I don't care that much about load() really. -- https://bugs.ruby-lang.org/ Unsubscribe: