walk
Version, currently master branch1 version
- master branchlatestJul 15, 2021
github.com/alexherbo2/walk.cr
A Crystal library for walking a directory recursively
Installation
# Add this to your shard.yml
dependencies:
walk:
github: alexherbo2/walk.cr
branch: mastermaster is a branch, not a release, so this tracks it rather than pinning a version.
Then run:
shards installshard.yml
- Crystal
1.0.0- License
- Unlicense
Dependencies
This version declares no dependencies.
README
walk.cr
walk.cr is a Crystal library for walking a directory recursively. Comes with support for top-down and bottom-up traversal, and mechanisms for pruning the entries in the directory tree.
Dependencies
Installation
- Add the dependency to your
shard.yml:
dependencies:
walk:
github: alexherbo2/walk.cr
- Run
shards install.
Usage
Example โ Recursively iterate over the given directory and print the path for each entry:
require "walk"
Walk::Down.new("src").each do |path|
puts path
end
Output example:
src
src/walk
src/walk/down.cr
src/walk/up.cr
src/walk.cr
Example โ Skip hidden files and directories:
require "walk"
def hidden_file?(path)
path.expand.basename.starts_with?('.')
end
Walk::Down.new(".")
.filter do |path|
!hidden_file?(path)
end
.each do |path|
puts path
end
Output example:
.
README.md
shard.yml
spec
spec/walk_spec.cr
src
src/walk.cr
Example โ Find Git root:
require "walk"
def git_root?(path)
Dir.exists?(path / ".git")
end
Walk::Up.new("src/walk.cr").find do |path|
git_root?(path)
end
Result example:
Path["."]
See the source for a complete reference.
Credits
Documentation
Built from the current release. The first visit to a release nobody has asked for starts its build.
Links
This branch
- Branch
master- Seen
- Jul 15, 2021
- Crystal
1.0.0- Indexed
- yes
Dependents
Repository
github.com/alexherbo2/walk.cr
Metadata
- Created
- Aug 12, 2026
- Updated
- Aug 15, 2026
- Synced
- Aug 15, 2026
- Versions
- 1