Class: Loadable::OriginalLoader
- Inherits:
-
Object
- Object
- Loadable::OriginalLoader
- Includes:
- Loadable
- Defined in:
- lib/loadable/loaders/original_loader.rb
Overview
The original loader is simply an encpsulation of the Ruby’s built-in #require and #load functionality. This load wedge is thus the first placed of the $LOADER list and the final fallback if no other loader succeeds.
Constant Summary
Constants included from Loadable
Instance Method Summary collapse
- #call(fname, options = {}) ⇒ Object
-
#each(options = {}, &block) ⇒ Object
Iterate over each requirable file.
- #each_loadpath(options = {}, &block) ⇒ Object private
- #each_rubygems(options = {}, &block) ⇒ Object private
Methods included from Loadable
call, #default_file_extensions, each, #lookup, #name, #raise_load_error, register, search, #traverse, vendor
Instance Method Details
#call(fname, options = {}) ⇒ Object
19 20 21 22 23 24 25 |
# File 'lib/loadable/loaders/original_loader.rb', line 19 def call(fname, ={}) if [:load] original_load(fname, [:wrap]) else original_require(fname) end end |
#each(options = {}, &block) ⇒ Object
Iterate over each requirable file. Since RubyGems has become a standard part of Ruby as of 1.9, this includes active and latest versions of inactive gems.
NOTE: in older versions of RubyGems, activated gem versions are in the $LOAD_PATH too. This may cause some duplicate iterations.
34 35 36 37 38 |
# File 'lib/loadable/loaders/original_loader.rb', line 34 def each(={}, &block) each_loadpath(&block) each_rubygems(&block) self end |
#each_loadpath(options = {}, &block) ⇒ Object (private)
43 44 45 46 47 48 |
# File 'lib/loadable/loaders/original_loader.rb', line 43 def each_loadpath(={}, &block) $LOAD_PATH.uniq.each do |path| path = File.(path) traverse(path, &block) end end |
#each_rubygems(options = {}, &block) ⇒ Object (private)
51 52 53 54 55 56 57 58 59 |
# File 'lib/loadable/loaders/original_loader.rb', line 51 def each_rubygems(={}, &block) return unless defined?(::Gem) Gem::Specification.current_specs.each do |spec| spec.require_paths.each do |require_path| path = File.join(spec.full_gem_path, require_path) traverse(path, &block) end end end |