module Kernel

Public Class Methods

load(path, wrap = false) click to toggle source
# File lib/bootsnap/load_path_cache/core_ext/kernel_require.rb, line 98
def load(path, wrap = false)
  if resolved = Bootsnap::LoadPathCache.load_path_cache.find(path)
    return load_without_bootsnap(resolved, wrap)
  end

  # load also allows relative paths from pwd even when not in $:
  if File.exist?(relative = File.expand_path(path))
    return load_without_bootsnap(relative, wrap)
  end

  raise Bootsnap::LoadPathCache::CoreExt.make_load_error(path)
rescue Bootsnap::LoadPathCache::ReturnFalse
  return false
rescue Bootsnap::LoadPathCache::FallbackScan
  load_without_bootsnap(path, wrap)
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 75
def require(path)
  return false if Bootsnap::LoadPathCache.loaded_features_index.key?(path)

  if resolved = Bootsnap::LoadPathCache.load_path_cache.find(path)
    return require_with_bootsnap_lfi(path, resolved)
  end

  raise Bootsnap::LoadPathCache::CoreExt.make_load_error(path)
rescue Bootsnap::LoadPathCache::ReturnFalse
  return false
rescue Bootsnap::LoadPathCache::FallbackScan
  require_with_bootsnap_lfi(path)
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 90
def require_relative(path)
  realpath = Bootsnap::LoadPathCache.realpath_cache.call(
    caller_locations(1..1).first.absolute_path, path
  )
  require(realpath)
end
require_relative_without_bootsnap(path)
Alias for: require_relative
require_with_bootsnap_lfi(path, resolved = nil) click to toggle source
# File lib/bootsnap/load_path_cache/core_ext/kernel_require.rb, line 69
def require_with_bootsnap_lfi(path, resolved = nil)
  Bootsnap::LoadPathCache.loaded_features_index.register(path, resolved) do
    require_without_bootsnap(resolved || path)
  end
end
require_without_bootsnap(path)
Alias for: require

Private Instance Methods

load(path, wrap = false) click to toggle source
# File lib/bootsnap/load_path_cache/core_ext/kernel_require.rb, line 48
def load(path, wrap = false)
  if resolved = Bootsnap::LoadPathCache.load_path_cache.find(path)
    return load_without_bootsnap(resolved, wrap)
  end

  # load also allows relative paths from pwd even when not in $:
  if File.exist?(relative = File.expand_path(path))
    return load_without_bootsnap(relative, wrap)
  end

  raise Bootsnap::LoadPathCache::CoreExt.make_load_error(path)
rescue Bootsnap::LoadPathCache::ReturnFalse
  return false
rescue Bootsnap::LoadPathCache::FallbackScan
  load_without_bootsnap(path, wrap)
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 25
def require(path)
  return false if Bootsnap::LoadPathCache.loaded_features_index.key?(path)

  if resolved = Bootsnap::LoadPathCache.load_path_cache.find(path)
    return require_with_bootsnap_lfi(path, resolved)
  end

  raise Bootsnap::LoadPathCache::CoreExt.make_load_error(path)
rescue Bootsnap::LoadPathCache::ReturnFalse
  return false
rescue Bootsnap::LoadPathCache::FallbackScan
  require_with_bootsnap_lfi(path)
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 40
def require_relative(path)
  realpath = Bootsnap::LoadPathCache.realpath_cache.call(
    caller_locations(1..1).first.absolute_path, path
  )
  require(realpath)
end
require_relative_without_bootsnap(path)
Alias for: require_relative
require_with_bootsnap_lfi(path, resolved = nil) click to toggle source

Note that require registers to $LOADED_FEATURES while load does not.

# File lib/bootsnap/load_path_cache/core_ext/kernel_require.rb, line 19
def require_with_bootsnap_lfi(path, resolved = nil)
  Bootsnap::LoadPathCache.loaded_features_index.register(path, resolved) do
    require_without_bootsnap(resolved || path)
  end
end
require_without_bootsnap(path)
Alias for: require