Module: Bootsnap::LoadPathCache

Defined in:
lib/bootsnap/load_path_cache.rb,
lib/bootsnap/load_path_cache/path.rb,
lib/bootsnap/load_path_cache/cache.rb,
lib/bootsnap/load_path_cache/store.rb,
lib/bootsnap/load_path_cache/path_scanner.rb,
lib/bootsnap/load_path_cache/change_observer.rb,
lib/bootsnap/load_path_cache/core_ext/active_support.rb,
lib/bootsnap/load_path_cache/core_ext/kernel_require.rb

Defined Under Namespace

Modules: ChangeObserver, CoreExt, PathScanner Classes: Cache, Path, Store

Constant Summary collapse

ReturnFalse =
Class.new(StandardError)
FallbackScan =
Class.new(StandardError)
DOT_RB =
'.rb'
DOT_SO =
'.so'
SLASH =
'/'
DL_EXTENSIONS =
::RbConfig::CONFIG
.values_at('DLEXT', 'DLEXT2')
.reject { |ext| !ext || ext.empty? }
.map    { |ext| ".#{ext}" }
.freeze
DLEXT =
DL_EXTENSIONS[0]
DLEXT2 =

This is nil on linux and darwin, but I think it’s ‘.o’ on some other platform. I’m not really sure which, but it seems better to replicate ruby’s semantics as faithfully as possible.

DL_EXTENSIONS[1]
CACHED_EXTENSIONS =
DLEXT2 ? [DOT_RB, DLEXT, DLEXT2] : [DOT_RB, DLEXT]

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.autoload_paths_cacheObject (readonly)

Returns the value of attribute autoload_paths_cache.



24
25
26
# File 'lib/bootsnap/load_path_cache.rb', line 24

def autoload_paths_cache
  @autoload_paths_cache
end

.load_path_cacheObject (readonly)

Returns the value of attribute load_path_cache.



24
25
26
# File 'lib/bootsnap/load_path_cache.rb', line 24

def load_path_cache
  @load_path_cache
end

Class Method Details

.setup(cache_path:, development_mode:, active_support: true) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/bootsnap/load_path_cache.rb', line 26

def setup(cache_path:, development_mode:, active_support: true)
  store = Store.new(cache_path)

  @load_path_cache = Cache.new(store, $LOAD_PATH, development_mode: development_mode)
  require_relative 'load_path_cache/core_ext/kernel_require'

  if active_support
    # this should happen after setting up the initial cache because it
    # loads a lot of code. It's better to do after +require+ is optimized.
    require 'active_support/dependencies'
    @autoload_paths_cache = Cache.new(
      store,
      ::ActiveSupport::Dependencies.autoload_paths,
      development_mode: development_mode
    )
    require_relative 'load_path_cache/core_ext/active_support'
  end
end