Class: MDir

Inherits:
Object
  • Object
show all
Defined in:
lib/appswarm/dir_tool.rb

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ MDir

Returns a new instance of MDir.



2
3
4
5
6
# File 'lib/appswarm/dir_tool.rb', line 2

def initialize(path)
  @path=path
  @files=[]
  @dirs=[]
end

Instance Method Details

#dir(name, &p) ⇒ Object



13
14
15
16
17
# File 'lib/appswarm/dir_tool.rb', line 13

def dir(name,&p)
  dir = MDir.new(name)
  dir.instance_eval(&p)
  @dirs << dir
end

#dirs(*names, &p) ⇒ Object



18
19
20
21
22
23
24
# File 'lib/appswarm/dir_tool.rb', line 18

def dirs(*names,&p)
  names.each{|name|
    dir=MDir.new(name)
    dir.instance_eval(&p)
    @dirs << dir
  }
end

#file(f) ⇒ Object



7
8
9
# File 'lib/appswarm/dir_tool.rb', line 7

def file(f)
  @files << f
end

#files(*f) ⇒ Object



10
11
12
# File 'lib/appswarm/dir_tool.rb', line 10

def files(*f)
  @files += f
end

#gather(base = "") ⇒ Object



25
26
27
28
29
30
31
32
33
34
# File 'lib/appswarm/dir_tool.rb', line 25

def gather(base="")
  a=[]
  @files.each{|f|
    a+=Dir[File.join(@path,f)]
  }
  @dirs.each{|dir|
    a+=dir.gather(@path)
  }
  a
end