Module: VirtualBox::GlobLoader
- Defined in:
- lib/virtualbox/ext/glob_loader.rb
Overview
Eases the processes of loading specific files then globbing the rest from a specified directory.
Class Method Summary collapse
-
.glob_require(dir, initial_files = []) ⇒ Object
Glob requires all ruby files in a directory, optionally loading select files initially (since others may depend on them).
Class Method Details
.glob_require(dir, initial_files = []) ⇒ Object
Glob requires all ruby files in a directory, optionally loading select files initially (since others may depend on them).
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/virtualbox/ext/glob_loader.rb', line 13 def self.glob_require(dir, initial_files=[]) # Note: The paths below both are "downcased" because on Windows, some # expand to "c:\" and some expand to "C:\" and cause the same file to # be loaded twice. Uck. require_files = [] initial_files.each do |file| require_files << File.(file, dir) end # Glob require the rest Dir[File.join(dir, "**", "*.rb")].each do |f| require_files << File.(f) end # Iterate over the files to require, manipulating them if necessary require_files.each do |file| file = file.downcase if Platform.windows? require file end end |