Sha256: 1bfcdd1c1307150fc91f5d4e3b4bc1adf877546532e46bc805b2983ed4726e1d

Contents?: true

Size: 637 Bytes

Versions: 7

Compression:

Stored size: 637 Bytes

Contents

class Dir

  # Recursively scan a directory and pass each file
  # to the given block.
  #
  #   CREDIT: George Moschovitis

  def self.recurse(path='.', &block)
    list = []
    stoplist = ['.', '..']
    Dir.foreach(path) do |f|
      next if stoplist.include?(f)
      filename = (path == '.' ? f : 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

  # Same as Dir#recurse.
  def self.ls_r(path='.', &block)
    recurse(path, &block)
  end

end

Version data entries

7 entries across 7 versions & 2 rubygems

Version Path
facets-2.4.0 lib/facets/dir/recurse.rb
facets-2.4.1 lib/facets/dir/recurse.rb
facets-2.4.2 lib/core/facets/dir/recurse.rb
facets-2.4.4 lib/core/facets/dir/recurse.rb
facets-2.4.3 lib/core/facets/dir/recurse.rb
facets-2.4.5 lib/core/facets/dir/recurse.rb
mack-facets-0.8.2 lib/gems/facets-2.4.5/lib/core/facets/dir/recurse.rb