[Rake-devel] Hello and a little patch for task initialisation
Jim Weirich
jim at weirichhouse.org
Fri Jul 9 21:11:02 EDT 2004
Link, Claudius wrote:
> Hello,
>
> as it is my first post to the list
> some information on me (to keep it short only about rake and ruby :-)
Thanks for your feedback. It is always interesting to hear how people
are using rake in the real world.
I have a couple of questions ...
First regarding your name patch. Could you demonstrate how you intend
to use change. It looks relatively harmless. Task object can be
instantiated with non-string names, but the "name" accessor does a
"to_s" before returning the value. Also the "@name" variable isn't used
within the task class body. But I'm a little uncomfortable with letting
go of the concept of string-like names for tasks. Help me understand.
Second, regarding the delay of dependency calculation, perhaps the
following will help.
Task actions and dependencies can be declared separately, for example:
task :a do ... actions go here ... end
task :a => [... dependencies go here ...]
This opens up some interesting possibilities. What if we used one task
to calculate the dependencies of other tasks. Consider the following
Rakefile:
task :default => [:deps, :x]
def calculate_deps(who)
puts "SLEEPING ----------------"
sleep(10)
puts "AWAKE ----------------"
[:y]
end
desc "Main Target"
task :x do
puts "DOING X"
end
desc "Secondary Task"
task :y do
puts "DOING Y"
end
desc "Calculate the dependencies"
task :deps do
task :x => calculate_deps(:x)
end
Task x has no dependencies declared in the file. Task y adds some
dependencies to x via a long calculation (artificially made long through
the use of sleep).
With this Rakefile, the rake -T command executes quickly. E.g.
$ rake -T
(in /home/jim/pgm/ruby/rakemisc)
rake deps # Calculate the dependencies
rake x # Main Target
rake y # Secondary Task
If we need to perform task x, then we can explicitly calculate its
dependencies ...
$ rake deps x
(in /home/jim/pgm/ruby/rakemisc)
SLEEPING ----------------
AWAKE ----------------
DOING Y
DOING X
$
Does this help?
--
-- 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)
More information about the Rake-devel
mailing list