Module: FasterPath

Defined in:
lib/faster_path.rb,
lib/faster_path/version.rb,
lib/faster_path/optional/refinements.rb,
lib/faster_path/optional/monkeypatches.rb

Overview

:nodoc:

Defined Under Namespace

Modules: RefineFile, RefinePathname

Constant Summary collapse

FFI_LIBRARY =
begin
  toplevel_dir = File.dirname(__dir__)
  config = Thermite::Config.new(cargo_project_path: toplevel_dir,
                                ruby_project_path: toplevel_dir)
  config.ruby_extension_path
end
VERSION =
"0.3.10"

Class Method Summary collapse

Class Method Details

.basename(pth, ext = "") ⇒ String

Rust implementation of File.basename

Parameters:

  • pth (String)

    the path to evaluate

  • ext (String) (defaults to: "")

    any extension to remove

Returns:

  • (String)


57
58
59
# File 'lib/faster_path.rb', line 57

def self.basename(pth, ext="")
  Public.send(:basename, pth, ext)
end

.blank?(str) ⇒ true, false

A very fast way to check if a string is blank

Parameters:

  • str (#to_s)

Returns:

  • (true, false)


49
50
51
# File 'lib/faster_path.rb', line 49

def self.blank?(str)
  "#{str}".strip.empty?
end

.children(pth, with_directory = true) ⇒ Array<String>

Rust implementation of Pathname.children

Parameters:

  • pth (String)

    the path to evaluate

  • with_directory (true, false) (defaults to: true)

    whether to include directory in results

Returns:

  • (Array<String>)


65
66
67
# File 'lib/faster_path.rb', line 65

def self.children(pth, with_directory=true)
  Public.send(:children, pth, with_directory)
end

.children_compat(pth, with_directory = true) ⇒ Array<Pathname>

Rust implementation of Pathname.children

Parameters:

  • pth (String)

    the path to evaluate

  • with_directory (true, false) (defaults to: true)

    whether to include directory in results

Returns:

  • (Array<Pathname>)


73
74
75
# File 'lib/faster_path.rb', line 73

def self.children_compat(pth, with_directory=true)
  Public.send(:children_compat, pth, with_directory)
end

.ruby_arch_bitsInteger

The Ruby architecture bit width: 64bits or 32bits

Returns:

  • (Integer)


42
43
44
# File 'lib/faster_path.rb', line 42

def self.ruby_arch_bits
  1.size * 8
end

.rust_arch_bitsInteger

The Rust architecture bit width: 64bits or 32bits

Returns:

  • (Integer)


36
37
38
# File 'lib/faster_path.rb', line 36

def self.rust_arch_bits
  Rust.rust_arch_bits
end

.sledgehammer_everything!Object

Applies all performant monkeypatches to both ‘Pathname` and `File`



121
122
123
124
# File 'lib/faster_path/optional/monkeypatches.rb', line 121

def self.sledgehammer_everything!
  MonkeyPatches._ruby_core_file!
  MonkeyPatches._ruby_library_pathname!
end