class Finder

Overview

Inspired by the find command, this helps you find files and folders recursively in Crystal

Defined in:

finder.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new(root : String, rules : Array(FinderRule)) #

[View source]
def self.new(root : String, rule : FinderRule) #

[View source]
def self.new(rules : Array(FinderRule)) #

[View source]
def self.new(rule : FinderRule) #

[View source]
def self.new(root = Dir.current) #

[View source]

Instance Method Detail

def dirs : Array(String) #

gives you all the directories that exist recursively as Array(String)


[View source]
def dirs(&block : String -> ) #

[View source]
def each(&block : String -> ) #

Iterates over each directory and file underneath the root that matches the FinderRules passed in or all of them if nothing was passed in.


[View source]
def files : Array(String) #

gives you all the files that exist recursively as Array(String)


[View source]
def files(&block : String -> ) #

allows you to iterate over the files with a block


[View source]
def find(fragment : String) : Array(String) #

Returns an array of paths recursively under root that include fragment in the path


[View source]
def find(fragment : Regex) : Array(String) #

Returns an array of paths recursively under root that match your regex fragment


[View source]
def passes_rules(f) #

[View source]
def root : String #

[View source]
def select(&block : String -> Bool) #

Returns an array of paths recursively under root that are truthy for the block


[View source]
def walk(d = @root, &block : String, Array(String), Array(String) -> ) #

Port of Python's os.walk. It recursively iterates through the root directory and at each level will give yield you the current directory, array of directories in the current directory, and the same thing for files.


[View source]