From: Josh Cheek Date: 2011-07-30T05:11:07+09:00 Subject: Re: ruby 'require' --20cf307d06fea3b11d04a93ae12b Content-Type: text/plain; charset=ISO-8859-1 On Fri, Jul 29, 2011 at 3:00 PM, Rick Tan 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 > > 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. > > -- > 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 } --20cf307d06fea3b11d04a93ae12b--