# File lib/backports/tools.rb, line 42 def self.mark_as_loaded(feature) # Nothing to do, the full path will be OK end
Full paths are recorded in $LOADED_FEATURES.
# File lib/backports/tools.rb, line 27 def initialize # Assume backported features are Ruby libraries (i.e. not C) @loaded = $LOADED_FEATURES.group_by{|p| File.basename(p, ".rb")} end
Check loaded features for one that matches "#{any of the load path}/#{feature}"
# File lib/backports/tools.rb, line 33 def include?(feature) if fullpaths = @loaded[File.basename(feature, ".rb")] fullpaths.any?{|fullpath| base_dir, = fullpath.partition("/#{feature}") $LOAD_PATH.include?(base_dir) } end end