Methods
Public Class methods
ancestor?(parent_path, child_path)

Is a path parental to another?

# File lib/facets/core/dir/self/ancestor.rb, line 8
  def self.ancestor?(parent_path, child_path)
    %r|^#{Regexp.escape(parent_path)}| =~ child_path
  end
ascend( dir, inclusive=true, &blk)

Ascend a directory path.

# File lib/facets/core/dir/self/ascend.rb, line 6
  def self.ascend( dir, inclusive=true, &blk)
    dir = dir.dup
    blk.call( dir ) if inclusive
    ri = dir.rindex('/')
    while ri
      dir = dir.slice(0...ri)
      if dir == ""
        blk.call( '/' ) ; break
      end
      blk.call( dir )
      ri = dir.rindex('/')
    end
  end
descend( path ) {|| ...}
# File lib/facets/core/dir/self/descend.rb, line 4
  def self.descend( path ) #:yield:
    paths = path.split('/')
    paths.size.times do |n|
      yield File.join( *paths[0..n] )
    end
  end
ls_r(path='.', &block)

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

# File lib/facets/core/dir/self/ls_r.rb, line 8
  def self.ls_r(path='.', &block)
    list = []
    stoplist = ['.', '..']
    Dir.foreach(path) do |f|
      next if stoplist.include?(f)
      filename = path + '/' + f
      list << filename
      block.call(filename) if block
      if FileTest.directory?(filename) and not FileTest.symlink?(filename)
        list.concat( Dir.recurse(filename, &block) )
      end
    end
    list
  end