Sha256: c0d8db1f7c824f8ed58df2e7fb3ae5074c7b7abed23cc68f3010565e9b512c86

Contents?: true

Size: 910 Bytes

Versions: 1

Compression:

Stored size: 910 Bytes

Contents

module VirtualBox
  # Eases the processes of loading specific files then globbing
  # the rest from a specified directory.
  module GlobLoader
    # Glob requires all ruby files in a directory, optionally loading select
    # files initially (since others may depend on them).
    #
    # @param [String] dir The directory to glob
    # @param [Array<String>] initial_files Initial files (relative to `dir`)
    #   to load
    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.

      initial_files.each do |file|
        require File.expand_path(file, dir).downcase
      end

      # Glob require the rest
      Dir[File.join(dir, "**", "*.rb")].each do |f|
        require File.expand_path(f).downcase
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
virtualbox-0.7.8 lib/virtualbox/ext/glob_loader.rb