From: Joel VanderWerf Date: 2006-03-21T15:04:14+09:00 Subject: Re: rake rules with multiple prerequisites Joel VanderWerf wrote: > Joel VanderWerf wrote: >> Jim Weirich wrote: >>> The problem is that a plain string in the *rule* dependency list already >>> has a meaning: it is the file extension to be used in the name of the >>> source file for the target. >> That's what I was guessing. I'll stick with procs, as you suggest below: >> >>> You can do this: >>> >>> generic_files = FileList["foo", "bar", "baz"].collect { |fn| lambda { fn >>> } } >> Thanks! >> > > On second thought... would it be possible for the proc to *return* a > FileList? It doesn't seem to work now, but it would be a nice feature, > wouldn't it? > > $ cat rakefile > generic_files = proc {FileList["foo", "bar", "baz"]} > > rule /^site_\w+/ => [ > proc {|fn| "__#{fn}"}, > generic_files > ] do |t| > p t.name > end > > task :__site_stuff > > file "foo" do touch "foo"; end > file "bar" do touch "bar"; end > file "baz" do touch "baz"; end > > $ rake site_stuff > (in /home/vjoel/ruby/misc/rake) > rake aborted! > can't convert Rake::FileList into String > > (See full trace by running task with --trace) > $ > I found a small patch to make this example work, but of course it could break something else. It seems like a natural thing to do: just flatten the result of Rake::TaskManager#make_sources. Normally, the result would be an array of strings, but this patch allows the translation procs to return an array of filenames (or a FileList), rather than just one. --- rake.rb.bck 2006-03-20 22:00:12.000000000 -0800 +++ rake.rb 2006-03-20 22:00:12.000000000 -0800 @@ -1427,7 +1427,7 @@ else fail "Don't know how to handle rule dependent: #{ext.inspect}" end - } + }.flatten end end -- vjoel : Joel VanderWerf : path berkeley edu : 510 665 3407