Sha256: f33c4961067d240c4be9ef03401fc738f9e9f9ade31351cc42fd5d91b0d17261

Contents?: true

Size: 608 Bytes

Versions: 2

Compression:

Stored size: 608 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
      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

  class << self
    # Alias for Dir#recurse.
    alias_method :ls_r, :recurse
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
facets-2.2.1 lib/core/facets/dir/recurse.rb
facets-2.3.0 lib/core/facets/dir/recurse.rb