From damphyr at freemail.gr Wed Oct 5 11:25:40 2005 From: damphyr at freemail.gr (Damphyr) Date: Wed, 05 Oct 2005 17:25:40 +0200 Subject: [Rake-devel] Changing task dependencies from another task Message-ID: <4343F074.3080603@freemail.gr> I thought this is a question better directed at the source instead of ruby-talk :). Now, I have a script that generates HTML from XML for part of a site. I use tasks to get the files from the source control repository, copy them to a directory that mirrors the structure of the actual site and then I scp the files over. Now, I'm using the following code to find the files to copy: #a file task for each target file def to_target src,target_dir,trim=nil tgt=File.join(target_dir,src) tgt=File.join(target_dir,src.sub(trim,"")) if trim file tgt=>[src] do mkdir_p(File.dirname(tgt)) cp(src,tgt) unless File.directory?(src) end return tgt end #lots of file tasks as prerequisites to :copy_generated def create_list sitelist=FileList["/publish/generated/**/*"] sitelist.each{|src| targeted=to_target(src,PUBLISH,/htdocs\//) task :copy_generated=>[targeted] @changed_files<[:generate] do create_list end task :copy_generated=>[:post_generate] Now, the problem is that :copy_generated does not cause the file tasks added as requisites in :post_generate to be executed although the Task#lookup(..).needed? call returns true and gives me the proper task name. This at the moment forces me to generate that part of the site everytime. The other workaround I have is rewrite the generator to use Rake filetasks, but that is not done in 10 minutes. Obviously at the moment :copy_generated is called the prerequisites are evaluated and when we come back from any other tasks it is assumed that prerequisites have not changed. Is this a reasonable feature request (re-evaluating the list of prerequisites when all prerequisite tasks are done)? Do I miss something? Cheers, V.- -- http://www.braveworld.net/riva ____________________________________________________________________ http://www.freemail.gr - ?????? ???????? ???????????? ????????????. http://www.freemail.gr - free email service for the Greek-speaking. From jim at weirichhouse.org Thu Oct 6 08:02:07 2005 From: jim at weirichhouse.org (Jim Weirich) Date: Thu, 6 Oct 2005 08:02:07 -0400 Subject: [Rake-devel] Changing task dependencies from another task In-Reply-To: <4343F074.3080603@freemail.gr> References: <4343F074.3080603@freemail.gr> Message-ID: <200510060802.08236.jim@weirichhouse.org> On Wednesday 05 October 2005 11:25 am, Damphyr wrote: > I thought this is a question better directed at the source instead of > ruby-talk :). > Now, I have a script that generates HTML from XML for part of a site. > I use tasks to get the files from the source control repository, copy > them to a directory that mirrors the structure of the actual site and > then I scp the files over. Hi, I took a quick look at your rakefile, but had trouble reproducing the problem. If you would like to send a small tar file with just enough files to allow me to run the system, I would be glad to look into it further. You don't have to perform to real transform you are doing, just enough dependencies to illustrate the problem. Thanks. -- -- Jim Weirich jim at weirichhouse.org http://onestepback.org ----------------------------------------------------------------- "Beware of bugs in the above code; I have only proved it correct, not tried it." -- Donald Knuth (in a memo to Peter van Emde Boas) From damphyr at freemail.gr Thu Oct 6 08:24:32 2005 From: damphyr at freemail.gr (Damphyr) Date: Thu, 06 Oct 2005 14:24:32 +0200 Subject: [Rake-devel] Changing task dependencies from another task In-Reply-To: <200510060802.08236.jim@weirichhouse.org> References: <4343F074.3080603@freemail.gr> <200510060802.08236.jim@weirichhouse.org> Message-ID: <43451780.6000106@freemail.gr> Jim Weirich wrote: > On Wednesday 05 October 2005 11:25 am, Damphyr wrote: > >>I thought this is a question better directed at the source instead of >>ruby-talk :). >>Now, I have a script that generates HTML from XML for part of a site. >>I use tasks to get the files from the source control repository, copy >>them to a directory that mirrors the structure of the actual site and >>then I scp the files over. > > > Hi, > > I took a quick look at your rakefile, but had trouble reproducing the problem. > If you would like to send a small tar file with just enough files to allow me > to run the system, I would be glad to look into it further. You don't have > to perform to real transform you are doing, just enough dependencies to > illustrate the problem. > > Thanks. > Well this is something I discussed with Stefan Lang (of Rant fame - I know, I'm shameless ;) ) on ruby-talk and he provided this: $ cat Rakefile @print = lambda { |t| puts t.name } task :A => :B, &@print task :B do |t| file :A => [:C, :D] @print[t] end task :C, &@print task :D, &@print $ rake A (in /home/stefan/tmp/rant-dyn-dep.t) B A The desired result would be B C D A Cheers, V.- -- http://www.braveworld.net/riva ____________________________________________________________________ http://www.freemail.gr - ?????? ???????? ???????????? ????????????. http://www.freemail.gr - free email service for the Greek-speaking. From jim at weirichhouse.org Thu Oct 6 10:21:06 2005 From: jim at weirichhouse.org (Jim Weirich) Date: Thu, 6 Oct 2005 14:21:06 -0000 (UTC) Subject: [Rake-devel] Changing task dependencies from another task In-Reply-To: <43451780.6000106@freemail.gr> References: <4343F074.3080603@freemail.gr><200510060802.08236.jim@weirichhouse.org> <43451780.6000106@freemail.gr> Message-ID: <63596.192.223.163.6.1128608466.squirrel@weirichhouse.org> Damphyr said: > Well this is something I discussed with Stefan Lang (of Rant fame - I > know, I'm shameless ;) ) on ruby-talk and he provided this: > > $ cat Rakefile > @print = lambda { |t| puts t.name } > > task :A => :B, &@print > task :B do |t| > file :A => [:C, :D] > @print[t] > end > task :C, &@print > task :D, &@print > $ rake A > (in /home/stefan/tmp/rant-dyn-dep.t) > B > A > > The desired result would be > B > C > D > A > Stefan keeps me on my toes and makes sure I don't let rake rest on its laurels :) I actually saw the ruby-talk exchange and am investigating what it would take to have rake do that. Essentially, it would be a second pass over the prerequisites to make sure that all of them were invoked. However, I am trying to understand the kind of problem that needs this kind of solution. I would like to see a simplified version of your original problem, with just enough data files to cause the problem. Just a simple "cp" command for the transform would be enough. Thanks. -- -- Jim Weirich jim at weirichhouse.org http://onestepback.org ----------------------------------------------------------------- "Beware of bugs in the above code; I have only proved it correct, not tried it." -- Donald Knuth (in a memo to Peter van Emde Boas) From damphyr at freemail.gr Thu Oct 6 12:18:02 2005 From: damphyr at freemail.gr (Damphyr) Date: Thu, 06 Oct 2005 18:18:02 +0200 Subject: [Rake-devel] Changing task dependencies from another task In-Reply-To: <63596.192.223.163.6.1128608466.squirrel@weirichhouse.org> References: <4343F074.3080603@freemail.gr><200510060802.08236.jim@weirichhouse.org> <43451780.6000106@freemail.gr> <63596.192.223.163.6.1128608466.squirrel@weirichhouse.org> Message-ID: <43454E3A.3090404@freemail.gr> Jim Weirich wrote: > Damphyr said: > However, I am trying to understand the kind of problem that needs this > kind of solution. I would like to see a simplified version of your > original problem, with just enough data files to cause the problem. Just > a simple "cp" command for the transform would be enough. Well, check the attached rar file. It has a test rakefile with directories and files that duplicates the problem. Cheers, V.- -- http://www.braveworld.net/riva ____________________________________________________________________ http://www.freemail.gr - ?????? ???????? ???????????? ????????????. http://www.freemail.gr - free email service for the Greek-speaking. -------------- next part -------------- A non-text attachment was scrubbed... Name: rake_prob.rar Type: application/octet-stream Size: 2694 bytes Desc: not available Url : http://rubyforge.org/pipermail/rake-devel/attachments/20051006/bdf18b9e/rake_prob.obj From damphyr at freemail.gr Tue Oct 11 10:07:12 2005 From: damphyr at freemail.gr (Damphyr) Date: Tue, 11 Oct 2005 16:07:12 +0200 Subject: [Rake-devel] Changing task dependencies from another task In-Reply-To: <43454E3A.3090404@freemail.gr> References: <4343F074.3080603@freemail.gr><200510060802.08236.jim@weirichhouse.org> <43451780.6000106@freemail.gr> <63596.192.223.163.6.1128608466.squirrel@weirichhouse.org> <43454E3A.3090404@freemail.gr> Message-ID: <434BC710.6020609@freemail.gr> Damphyr wrote: > Jim Weirich wrote: > >> Damphyr said: However, I am trying to understand the kind of problem >> that needs this >> kind of solution. I would like to see a simplified version of your >> original problem, with just enough data files to cause the problem. Just >> a simple "cp" command for the transform would be enough. Any news on this subject? Cheers, V.- -- http://www.braveworld.net/riva ____________________________________________________________________ http://www.freemail.gr - ?????? ???????? ???????????? ????????????. http://www.freemail.gr - free email service for the Greek-speaking. From jim at weirichhouse.org Tue Oct 11 22:11:47 2005 From: jim at weirichhouse.org (Jim Weirich) Date: Tue, 11 Oct 2005 22:11:47 -0400 Subject: [Rake-devel] Changing task dependencies from another task In-Reply-To: <434BC710.6020609@freemail.gr> References: <4343F074.3080603@freemail.gr> <43454E3A.3090404@freemail.gr> <434BC710.6020609@freemail.gr> Message-ID: <200510112211.47872.jim@weirichhouse.org> On Tuesday 11 October 2005 10:07 am, Damphyr wrote: > Damphyr wrote: > > Jim Weirich wrote: > >> Damphyr said: However, I am trying to understand the kind of problem > >> that needs this > >> kind of solution. I would like to see a simplified version of your > >> original problem, with just enough data files to cause the problem. > >> Just a simple "cp" command for the transform would be enough. > > Any news on this subject? > Cheers, > V.- Sorry ... I've been "off the net" since last Friday dealing with a family emergency. I will get back to this soon. -- -- Jim Weirich jim at weirichhouse.org http://onestepback.org ----------------------------------------------------------------- "Beware of bugs in the above code; I have only proved it correct, not tried it." -- Donald Knuth (in a memo to Peter van Emde Boas) From philipp.neubeck at gmx.de Wed Oct 19 12:40:48 2005 From: philipp.neubeck at gmx.de (philipp.neubeck@gmx.de) Date: Wed, 19 Oct 2005 18:40:48 +0200 Subject: [Rake-devel] FileTask#needed? and FileTask#timestamp "bug" In-Reply-To: <20050906112730.25b9e77c@alpha.lan> References: <20050904111950.772d0832@alpha.lan> <20050905123751.5675561f@alpha.lan> <431CF95C.2060202@inin.com> <200509060041.38287.jim@weirichhouse.org> <20050906112730.25b9e77c@alpha.lan> Message-ID: <20051019184048.1afffbc4@alpha.lan> On Tue, 6 Sep 2005 11:27:30 +0200 I wrote: > On Tue, 6 Sep 2005 00:41:38 -0400 > Jim Weirich wrote: > > > Regarding the behavior of timestamp when the file doesn't exist: > > > > I went with the time stamp of a non-existing file should be a time stamp that > > is earlier than any existing file. The biggest reason is that using a late > > time stamp for non-existing files would cause the target to be continually > > rebuilt, and that just doesn't make sense. > > > > Anyways, the change is in the 0.6.0 just out today. > > first, before any one gets angry because i don't just say 'you're right' :-), i rate this problem (if it's any) as minor. > > > sorry if i'm a a bit (or very) blind, but let me explain why i think you're both wrong: > > the normal user of Rake, should tell Rake the truth about his dependencies, i.e. if you insert a dependency the target should only be correctly invokable if the prerequisite is fullfilled. (any other behaviour is special and can be changed by each user) > > so the behaviour Patrick mentions is IMO not the general behaviour a Rake user (should :-) wants, because he inserts dependencies which aren't any (he does not tell the Rake system everything he knows!) > > so in this "normal" case, what you say Jim (...the target would be continually rebuilt...) is not right: > the file thats missing would be relevant to rebuilt the target, but since it's non-existant, the target-rebuilt would fail, so the user would see it failed and has to correct the problem. > > example: > main.exe needs main.cpp needs main.hpp. you correctly built with rake. then you rename main.hpp and reinvoke rake, but rake would just do nothing. or say you changed some pieces of your dependency generator wrongly and it produces filenames of non-existant files, then rake would not complain, never, not even a warning. > > > i hope the behaviour i described is understandable. the only question is what should be the standard, the one you describe or i describe. > i don't know if it would be better to make both behaviours accessable. hm.. i'm waiting for an anwser. at least it would be nice if you would tell your state: are you still thinking about what the correct solution should be or did you solve this problem in silence? bye Phil -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 189 bytes Desc: not available Url : http://rubyforge.org/pipermail/rake-devel/attachments/20051019/56726b7f/attachment-0001.bin From blair at orcaware.com Fri Oct 21 01:56:39 2005 From: blair at orcaware.com (Blair Zajac) Date: Thu, 20 Oct 2005 22:56:39 -0700 Subject: [Rake-devel] Redefine tasks Message-ID: <43588317.9050304@orcaware.com> Hello, The new Ruby on Rails 0.14.1 release supports a lib/tasks/ directory where you place *.rake files that get imported after RoR's rake definitions. In 0.13.1, I needed to override some of the targets, such as :clone_structure_to_test, with my own specific code, and I would just edit the Rakefile. After doing the 0.14.1 and merging in a ton of changes, I thought, there has to be a better way, so I can leave a vanilla RoR Rakefile alone and still have my own custom targets. I first tried just defining the same clone_structure_to_test task, but when I ran it, it ran the original RoR task and my new version, not what I wanted :) What I came up was this code, which clears out the original task and creates a brand new one. # Rake allows the same task name to be specified multiple times, where # each successive task definition appends to a list of actions to # perform. Therefore, an application specific task cannot redefine a # previously defined task. These methods here allow tasks to be # redefined and renamed. module Rake class Task # Clear all existing actions for the given task and then set the # action for the task to the given block. def self.redefine_task(args, &block) task_name, deps = resolve_args(args) TASKS.delete(task_name.to_s) define_task(args, &block) end end end # Clear all existing actions for the given task and then set the # action for the task to the given block. def redefine_task(args, &block) Rake::Task.redefine_task(args, &block) end # Alias one task name to another task name. This let's a following # task rename the original task and still depend upon it. def alias_task(new_name, old_name) Rake::Task::TASKS[new_name.to_s] = Rake::Task::TASKS.delete(old_name.to_s) end This way, in a new lib/tasks/clone_structure_to_test.rake, I can use this: # Delete the original clone_structure_to_test task and create a new # one that uses the SQL DDL files to set up the database. desc "Faster replacement for the original :clone_structure_to_test" redefine_task :clone_structure_to_test => :environment do abcs = ActiveRecord::Base.configurations `psql --quiet -U "#{abcs["test"]["username"]}" -f db/create.sql #{abcs["test"]["database"]}` end It would be great if something like this made it into the next Rake release. Regards, Blair -- Blair Zajac, Ph.D. Subversion and Orca training and consulting http://www.orcaware.com/svn/