class Ivar::ProjectRoot

def find(caller_location = nil)

Returns:
  • (String) - The absolute path to the project root directory

Parameters:
  • caller_location (String, nil) -- Optional file path to start from (defaults to caller's location)
def find(caller_location = nil)
  file_path = caller_location || caller_locations(2, 1).first&.path
  return Dir.pwd unless file_path
  @mutex.synchronize do
    return @cache[file_path] if @cache.key?(file_path)
  end
  dir = File.dirname(File.expand_path(file_path))
  root = find_project_root(dir)
  @mutex.synchronize do
    @cache[file_path] = root
  end
  root
end