finder
Helps you find files and folders recursively from a root directory
Installation
Add this to your application's shard.yml:
dependencies:
finder:
github: mlobl/finder
Usage
You can look at spec and docs for a few examples, but here are some quickies
require "finder"
# Uses CWD as the root dir by default
finder = Finder.new
# or set it like this
Finder.new "/tmp"
# substring match
finder.find(".txt") # ==> ["a.txt", "dir/path/b.txt", ..]
# or regex
Finder.new.find(/\.txt/) # ==> ["a.txt", "dir/path/b.txt", ..]
# filter with a select method
finder.select &.includes? "substring"
# array of all files (can pass in block as well)
Finder.new.files # ==> ["dir_a/x.txt", "dir_b/y.txt", ..]
# same for dirs
Finder.new.dirs # ==> ["dir_a", "dir_b", ..]
# iterate across both dirs and files with each
Finder.new.each do |path|
puts path
end
# walk the directory (port of Python's os.walk)
Finder.new.walk do |current_dir, folder, files|
....
end
Contributing
- Fork it ( https://github.com/mlobl/finder/fork )
- Create your feature branch (git checkout -b my-new-feature)
- Commit your changes (git commit -am 'Add some feature')
- Push to the branch (git push origin my-new-feature)
- Create a new Pull Request
Contributors
- mlobl Meyer Lobl - creator, maintainer