Method: Maid::Tools#dir
- Defined in:
- lib/maid/tools.rb
#dir(globs) ⇒ Object
Give all files matching the given glob.
Note that the globs are not regexps (they're closer to shell globs). However, some regexp-like notation can be
used, e.g. ?, [a-z], {tgz,zip}. For more details, see Ruby's documentation on Dir.glob.
The matches are sorted lexically to aid in readability when using --dry-run.
Examples
Single glob:
dir('~/Downloads/*.zip')
Specifying multiple extensions succinctly:
dir('~/Downloads/*.{exe,deb,dmg,pkg,rpm}')
Multiple glob (all are equivalent):
dir(['~/Downloads/*.zip', '~/Dropbox/*.zip'])
dir(%w(~/Downloads/*.zip ~/Dropbox/*.zip))
dir('~/{Downloads,Dropbox}/*.zip')
Recursing into subdirectories (see also: find):
dir('~/Music/**/*.m4a')
240 241 242 243 244 245 |
# File 'lib/maid/tools.rb', line 240 def dir(globs) (globs). map { |glob| Dir.glob(glob) }. flatten. sort end |