Class | Dir
In: | lib/facets/core/dir/self/ascend.rb lib/facets/core/dir/self/ancestor.rb lib/facets/core/dir/self/ls_r.rb lib/facets/core/dir/self/descend.rb
Parent: | Object

CREDIT George Moschovitis

### Methods

ancestor? ascend descend ls_r multiglob multiglob_r multiglob_with_default

### External Aliases

ls_r | -> | recurse
| Alias for Dir#ls_r

### Public Class methods

ancestor?(parent_path, child_path)

Is a path parental to another?

ascend( dir, inclusive=true, &blk)

Ascend a directory path.

descend( path ) {|| ...}
ls_r(path='.', &block)

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

multiglob( *patterns )

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('**/*')

Multiglob also accepts ’+’ and ’-’ prefixes. Any entry that begins with a ’-’ is treated as an exclusion glob and will be removed from the final result. For example, to collect all files in the current directory, less ruby scripts:

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

This is very useful in collecting files as specificed by a configuration parameter.

multiglob_r( *patterns )

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/**/*' )

multiglob_with_default(default, *patterns)

This is just like multiglob but handles a base pattern such that if the `patterns` list starts with a ’+’ or ’-’ entry, then the base will be included in the result, otherwise it will be omitted.

      Dir.multiglob_with_default('*.yaml', '-*.rb')  #=> [ 'foo.yaml' ]
      Dir.multiglob_with_default('*.yaml', '+*.rb')  #=> [ 'foo.yaml', 'foo.rb' ]
      Dir.multiglob_with_default('*.yaml', '*.rb')   #=> [ 'foo.rb' ]

This is useful when a configuration option needs to supply a file list that may include files, exclude files or append files to a default list.

[Validate]