Module: Sourcerer::Util::Pathifier

Defined in:
lib/sourcerer/util/pathifier.rb

Overview

Classify an input string as file/dir/glob/missing and yield matching paths lazily.

Not required internally; callers must require this file explicitly.

Defined Under Namespace

Classes: Result

Constant Summary collapse

GLOB_METACHARACTERS =
/[*?\[\]{}]/

Class Method Summary collapse

Class Method Details

.match(input, recursive: true, include_dirs: false, follow_symlinks: false) ⇒ Result

Classify input and return a Result with a lazy path enumerator.

Parameters:

  • input (String)

    file path, directory path, or glob pattern

  • recursive (Boolean) (defaults to: true)

    if dir, traverse recursively (default: true)

  • include_dirs (Boolean) (defaults to: false)

    if dir traversal, also yield directory paths (default: false)

  • follow_symlinks (Boolean) (defaults to: false)

    follow symlink directories during recursal (default: false)

Returns:



23
24
25
26
27
28
29
30
31
# File 'lib/sourcerer/util/pathifier.rb', line 23

def self.match input, recursive: true, include_dirs: false, follow_symlinks: false
  type = classify(input)
  Result.new(
    type:  type,
    input: input,
    enum:  build_enum(
      type, input, recursive: recursive, include_dirs: include_dirs,
                                    follow_symlinks: follow_symlinks))
end