class Bootsnap::LoadPathCache::Path

Experimental RBS support (using type sampling data from the type_fusion project).

# sig/bootsnap/load_path_cache/path.rbs

class Bootsnap::LoadPathCache::Path
  
  type Bootsnap__LoadPathCache__Path_entries_and_dirs_return_value = Array[Array, String] | Array[Array, String, String] | Array[Array, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String] | Array[Array, String, String, String, String, String, String, String, String, String] | Array[Array, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String] | Array[Array, String, String, String, String, String] | Array[Array, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String] | Array[Array, String, String, String, String, String, String, String, String, String, String, String, String, String, String] | Array[Array, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String]
  
  def entries_and_dirs: (Bootsnap::LoadPathCache::Store store) -> Bootsnap__LoadPathCache__Path_entries_and_dirs_return_value
  def expanded_path: () -> String
  def initialize: (String path, real: false) -> void
  def latest_mtime: (String path, Array[String] dirs) -> Integer
  def non_directory?: () -> false
  def relative?: () -> false
  def stability: () -> Symbol
  def stable?: () -> bool
  def to_realpath: () -> Bootsnap::LoadPathCache::Path
end

def entries_and_dirs(store)

Experimental RBS support (using type sampling data from the type_fusion project).

type Bootsnap__LoadPathCache__Path_entries_and_dirs_return_value = Array[Array, String] | Array[Array, String, String] | Array[Array, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String] | Array[Array, String, String, String, String, String, String, String, String, String] | Array[Array, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String] | Array[Array, String, String, String, String, String] | Array[Array, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String] | Array[Array, String, String, String, String, String, String, String, String, String, String, String, String, String, String] | Array[Array, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String]
type Bootsnap__LoadPathCache__Path_entries_and_dirs_return_value = Array |  | Array | String | Array | String | String | String | String | String | String | String | String | Array | String | String | String | String | String | String | String | String | String | Array | String | String | Array | String | String | String | String | Array | String | String | String | String | String | String | String | String | String | String | String

def entries_and_dirs: (Bootsnap::LoadPathCache::Store store) -> Bootsnap__LoadPathCache__Path_entries_and_dirs_return_value

This signature was generated using 38 samples from 3 applications.

of this +Path+.
Return a list of all the requirable files and all of the subdirectories
def entries_and_dirs(store)
  if stable?
    # the cached_mtime field is unused for 'stable' paths, but is
    # set to zero anyway, just in case we change the stability heuristics.
    _, entries, dirs = store.get(expanded_path)
    return [entries, dirs] if entries # cache hit
    entries, dirs = scan!
    store.set(expanded_path, [0, entries, dirs])
    return [entries, dirs]
  end
  cached_mtime, entries, dirs = store.get(expanded_path)
  current_mtime = latest_mtime(expanded_path, dirs || [])
  return [[], []]        if current_mtime == -1 # path does not exist
  return [entries, dirs] if cached_mtime == current_mtime
  entries, dirs = scan!
  store.set(expanded_path, [current_mtime, entries, dirs])
  [entries, dirs]
end

def expanded_path

Experimental RBS support (using type sampling data from the type_fusion project).

def expanded_path: () -> String

This signature was generated using 111 samples from 2 applications.

def expanded_path
  if @real
    path
  else
    @expanded_path ||= File.expand_path(path).freeze
  end
end

def initialize(path, real: false)

Experimental RBS support (using type sampling data from the type_fusion project).

def initialize: (String path, real: false) -> void

This signature was generated using 35 samples from 4 applications.

def initialize(path, real: false)
  @path = path.to_s.freeze
  @real = real
end

def latest_mtime(path, dirs)

Experimental RBS support (using type sampling data from the type_fusion project).

def latest_mtime: (String path, ( | String | String | String | String) dirs) -> Integer

This signature was generated using 3 samples from 1 application.

/a/b/c, pass ('/a/b', ['c'])
list of relative paths to directories under +path+. e.g. for /a/b and
last time a directory was modified in this subtree. +dirs+ should be a
def latest_mtime(path, dirs)
  max = -1
  ["", *dirs].each do |dir|
    curr = begin
      File.mtime("#{path}/#{dir}").to_i
           rescue Errno::ENOENT, Errno::ENOTDIR, Errno::EINVAL
             -1
    end
    max = curr if curr > max
  end
  max
end

def non_directory?

Experimental RBS support (using type sampling data from the type_fusion project).

def non_directory?: () -> false

This signature was generated using 19 samples from 2 applications.

True if the path exists, but represents a non-directory object
def non_directory?
  !File.stat(path).directory?
rescue Errno::ENOENT, Errno::ENOTDIR, Errno::EINVAL
  false
end

def relative?

Experimental RBS support (using type sampling data from the type_fusion project).

def relative?: () -> false

This signature was generated using 20 samples from 2 applications.

def relative?
  !path.start_with?(SLASH)
end

def scan! # (expensive) returns [entries, dirs]

(expensive) returns [entries, dirs]
def scan! # (expensive) returns [entries, dirs]
  PathScanner.call(expanded_path)
end

def stability

Experimental RBS support (using type sampling data from the type_fusion project).

def stability: () -> Symbol

This signature was generated using 23 samples from 2 applications.

def stability
  @stability ||= if Gem.path.detect { |p| expanded_path.start_with?(p.to_s) }
    STABLE
  elsif Bootsnap.bundler? && expanded_path.start_with?(Bundler.bundle_path.to_s)
    STABLE
  elsif expanded_path.start_with?(RUBY_LIBDIR) && !expanded_path.start_with?(RUBY_SITEDIR)
    STABLE
  else
    VOLATILE
  end
end

def stable?

Experimental RBS support (using type sampling data from the type_fusion project).

def stable?: () -> bool

This signature was generated using 25 samples from 2 applications.

must be cleared before the change will be noticed.
distribution. When adding or removing files in these paths, the cache
A path is considered 'stable' if it is part of a Gem.path or the ruby
def stable?
  stability == STABLE
end

def to_realpath

Experimental RBS support (using type sampling data from the type_fusion project).

def to_realpath: () -> Bootsnap::LoadPathCache::Path

This signature was generated using 18 samples from 3 applications.

def to_realpath
  return self if @real
  realpath = begin
    File.realpath(path)
  rescue Errno::ENOENT
    return self
  end
  if realpath == path
    @real = true
    self
  else
    Path.new(realpath, real: true)
  end
end

def volatile?

more frequently.
the ruby distribution root. These paths are scanned for new additions
A path is considered volatile if it doesn't live under a Gem.path or
def volatile?
  stability == VOLATILE
end