9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
# File 'lib/rant/import/clean.rb', line 9
def self.rant_gen(rac, ch, args, &block)
if args.size > 1
rac.abort_at(ch, "Clean doesn't take more than one argument.")
end
tname = args.first || "clean"
case rac.var[tname]
when nil
rac.var[tname] = Rant::MultiFileList.new(rac)
when Rant::RacFileList
ml = Rant::MultiFileList.new(rac)
rac.var[tname] = ml.add(rac.var[tname])
when Rant::MultiFileList
else
rac.abort_at(ch,
"var `#{tname}' already exists.",
"Clean uses var with the same name as the task name.")
end
rac.task :__caller__ => ch, tname => [] do |t|
rac.var[tname].each_entry { |entry|
if test ?e, entry
if test ?f, entry
rac.cx.sys.rm_f entry
else
rac.cx.sys.rm_rf entry
end
end
}
end
end
|