Class Dir
In: lib/core/facets/dir/ascend.rb
lib/core/facets/dir/multiglob.rb
lib/core/facets/dir/parent.rb
lib/core/facets/dir/recurse.rb
Parent: Object

Methods

ascend   descend   ls_r   multiglob   multiglob_r   parent?   recurse  

Public Class methods

TODO: make it work with windows too use FileTest.root?

Descend a directory path.

  Dir.descend("/var/log") do |path|
    p path
  end

produces

  /
  /var
  /var/log

CREDIT: Daniel Berger, Jeffrey Schwab

Like glob but can take multiple patterns.

  Dir.multiglob( '*.rb', '*.py' )

Rather then constants for options multiglob accepts a trailing options hash of symbol keys.

  :noescape    File::FNM_NOESCAPE
  :casefold    File::FNM_CASEFOLD
  :pathname    File::FNM_PATHNAME
  :dotmatch    File::FNM_DOTMATCH
  :strict      File::FNM_PATHNAME && File::FNM_DOTMATCH

It also has an option for recurse.

  :recurse     Recurively include contents of directories.

For example

  Dir.multiglob( '*', :recurse => true )

would have the same result as

  Dir.multiglob('**/*')

The same as multiglob, but recusively includes directories.

  Dir.multiglob_r( 'folder' )

is equivalent to

  Dir.multiglob( 'folder', :recurse=>true )

The effect of which is

  Dir.multiglob( 'folder', 'folder/**/**' )

Is a path parental to another?

TODO: Needs improvement. TODO: Instance version?

Recursively scan a directory and pass each file to the given block.

CREDIT: George Moschovitis

TODO: If fully compatible, reimplement as alias of Find.find, or just copy and paste Find.find code here if it looks more robust.

[Validate]