Ruby 'require'

working on a ruby project with several files all lumped into a single
subdirectory. I would like to organize it more logically by grouping
files that share the same functionality. For example instead of

main.rb
allfiles << subdir
afile
bfile
cfile
dfile

would like reorganize these into

main.rb
allfiles << subdir
func1 << subdir
afile
bfile
func2 << subdir
cfile
dfile

Any trick i can use to simply pulling these files into main.rb. So
instead of

require ‘allfiles/func1/afile’
.
.
.
require ‘allfiles/func2/dfile’

i would like to use a more simplified require instead of enumerating
each of the files.

On Fri, Jul 29, 2011 at 1:00 PM, Rick T. [email protected] wrote:

working on a ruby project with several files all lumped into a single
subdirectory. I would like to organize it more logically by grouping
files that share the same functionality. For example instead of

John

On Fri, Jul 29, 2011 at 3:00 PM, Rick T. [email protected] wrote:

each of the files.


Posted via http://www.ruby-forum.com/.

Personally, I’ve grown to like explicit requiring, but if you’re sure
you
want to require all the files in the subdirs into main, you could use a
glob.

Dir[“#{File.dirname FILE}/**/*.rb”].each { |filename| require
filename }

Use аutomatic Class Loader and forget about the :require :wink: