From e.i at bluewin.ch Tue Jul 31 07:20:21 2007 From: e.i at bluewin.ch (Emanuel =?ISO-8859-1?Q?Inderm=FChle?=) Date: Tue, 31 Jul 2007 13:20:21 +0200 Subject: [Rake-devel] List of Files as prerequisits Message-ID: <1185880821.16157.19.camel@localhost> Hello I have a question concerning the use of rake. Sorry for using dhe developper mailing list, but there was no other. How do i make a task that has as prerequisit a list of files. As this is the nature of tasks their requisits may be missing. So i cant make a FileList of files that are missing. There is a list of these files, stored in a other file (its name ist letters.txt). But this file will be created by another task. How do i implement this problem in rake. My try: --------code ------------ def methodToGetFileListFromlettersFile (path,extension = "") hmms = [] File.open("system/system/letter.txt", "r") do |file| file.each_line do | line | hmms << path + line + extension end end return hmms end rule ".hmm" do | t | `touch #{t.name}` #is in reality more complex end file "letter.txt" do #generate "letter.txt" somehow end task :combineFiles=>["letter.txt"]+methodToGetFileListFromletterFile("systempath/","hmm") do #do something with the files end -----------/code------------- But then i realized that when the task are created the file letter.txt is not existing so methodToGetFileListFromlettersFile() will fail. What is a possible solution for my problem Thanks for every answer From zimbatm at oree.ch Tue Jul 31 10:51:31 2007 From: zimbatm at oree.ch (Jonas Pfenniger) Date: Tue, 31 Jul 2007 16:51:31 +0200 Subject: [Rake-devel] List of Files as prerequisits In-Reply-To: <1185880821.16157.19.camel@localhost> References: <1185880821.16157.19.camel@localhost> Message-ID: Hi Emanuel, your problem (I think) is that you are relying on the execution order of your task's dependencies. Here is a snippet that should work : file "letter.txt" do #generate "letter.txt" somehow end task :ensure_hmms => "letter.txt" do (File.read('letter.txt').split("\n") - FileList['*.hmm']).each do |missing_hmm| sh :touch, missing_hmm end end task :combineFiles=>:ensure_hmms do #do something with the files end -- Cheers, zimbatm -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rake-devel/attachments/20070731/de7647ec/attachment.html