module Kernel

Public Instance Methods

load(path, wrap = false) click to toggle source
# File lib/bootsnap/load_path_cache/core_ext/kernel_require.rb, line 45
def load(path, wrap = false)
  if (resolved = Bootsnap::LoadPathCache.load_path_cache.find(path, try_extensions: false))
    load_without_bootsnap(resolved, wrap)
  else
    load_without_bootsnap(path, wrap)
  end
end
Also aliased as: load_without_bootsnap
load_without_bootsnap(path, wrap = false)
Alias for: load
require(path) click to toggle source
# File lib/bootsnap/load_path_cache/core_ext/kernel_require.rb, line 7
def require(path)
  string_path = path.to_s
  return false if Bootsnap::LoadPathCache.loaded_features_index.key?(string_path)

  resolved = Bootsnap::LoadPathCache.load_path_cache.find(string_path)
  if Bootsnap::LoadPathCache::FALLBACK_SCAN.equal?(resolved)
    if (cursor = Bootsnap::LoadPathCache.loaded_features_index.cursor(string_path))
      ret = require_without_bootsnap(path)
      resolved = Bootsnap::LoadPathCache.loaded_features_index.identify(string_path, cursor)
      Bootsnap::LoadPathCache.loaded_features_index.register(string_path, resolved)
      return ret
    else
      return require_without_bootsnap(path)
    end
  elsif false == resolved
    return false
  elsif resolved.nil?
    error = LoadError.new(+"cannot load such file -- #{path}")
    error.instance_variable_set(:@path, path)
    raise error
  else
    # Note that require registers to $LOADED_FEATURES while load does not.
    ret = require_without_bootsnap(resolved)
    Bootsnap::LoadPathCache.loaded_features_index.register(string_path, resolved)
    return ret
  end
end
Also aliased as: require_without_bootsnap
require_relative(path) click to toggle source
# File lib/bootsnap/load_path_cache/core_ext/kernel_require.rb, line 36
def require_relative(path)
  location = caller_locations(1..1).first
  realpath = Bootsnap::LoadPathCache.realpath_cache.call(
    location.absolute_path || location.path, path
  )
  require(realpath)
end
require_relative_without_bootsnap(path)
Alias for: require_relative
require_without_bootsnap(path)
Alias for: require