What ruble are you using? With ruby ββ1.9 you can use require_relative .
require_relative 'subdirectory/file1.rb' require_relative 'subdirectory/file2.rb'
But you must know the files. require_relative will not work with all files in a subdirectory. But I would not recommend using such a general reading in a gem. You need to know what you are downloading.
If you really want this, you can use something like this:
Dir.chdir(File.dirname(__FILE__)){ Dir["**/*.rb"].each { |f| require_relative f } }
With ruby ββ1.8 this should work:
Dir.chdir(File.dirname(__FILE__)){ Dir["./**/*.rb"].each { |f| require f } }
As for File.join, there are some things for Windows: File.join creates a path, so the OS can use it. On unix, the path separator is / , in windows \ . But, as you already wrote: ruby ββunderstands / , so this does not matter in windows. But what happens if you work with Classic Mac OS? There it is : (see Wikipedia Path_ (calculations) ). So it's better to use join, (or you are using my version of Dir.chdir)
source share