Class | Backports::StdLib::LoadedFeatures |
In: |
lib/backports/tools.rb
|
Parent: | Object |
# File lib/backports/tools.rb, line 53 53: def self.mark_as_loaded(feature) 54: $LOADED_FEATURES << "#{File.basename(feature, '.rb')}.rb" 55: end
# File lib/backports/tools.rb, line 42 42: def self.mark_as_loaded(feature) 43: # Nothing to do, the full path will be OK 44: end
Full paths are recorded in $LOADED_FEATURES.
# File lib/backports/tools.rb, line 27 27: def initialize 28: # Assume backported features are Ruby libraries (i.e. not C) 29: @loaded = $LOADED_FEATURES.group_by{|p| File.basename(p, ".rb")} 30: end
Requested features are recorded in $LOADED_FEATURES
# File lib/backports/tools.rb, line 48 48: def include?(feature) 49: # Assume backported features are Ruby libraries (i.e. not C) 50: $LOADED_FEATURES.include?("#{File.basename(feature, '.rb')}.rb") 51: end
Check loaded features for one that matches "#{any of the load path}/#{feature}"
# File lib/backports/tools.rb, line 33 33: def include?(feature) 34: if fullpaths = @loaded[File.basename(feature, ".rb")] 35: fullpaths.any?{|fullpath| 36: base_dir, = fullpath.partition("/#{feature}") 37: $LOAD_PATH.include?(base_dir) 38: } 39: end 40: end