Sha256: a4fbfc3bb4ae7e8c7b5b5b5fddbea79c8ab4c4360f14348d9721b8a7d14cf4d6

Contents?: true

Size: 611 Bytes

Versions: 1

Compression:

Stored size: 611 Bytes

Contents

class MDir
  def initialize(path)
    @path=path
    @files=[]
    @dirs=[]
  end
  def file(f)
    @files << f
  end
  def files(*f)
    @files += f
  end
  def dir(name,&p)
    dir = MDir.new(name)
    dir.instance_eval(&p)
    @dirs << dir
  end
  def dirs(*names,&p)
    names.each{|name|
      dir=MDir.new(name)
      dir.instance_eval(&p)
      @dirs << dir
    }
  end
  def gather(base="")
    a=[]
    @files.each{|f|
      a+=Dir[File.join(@path,f)]
    }
    @dirs.each{|dir|
      a+=dir.gather(@path)
    }
    a
  end
end

def dir(path,&p)
  d=MDir.new(path)
  d.instance_eval(&p)
  d.gather
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
appswarm-0.0.1 lib/appswarm/dir_tool.rb