[Rake-devel] Custom Task

Charles F. I. Savage cfis at interserv.com
Mon Aug 8 03:02:23 EDT 2005

Hi everyone,

I've created a new custom task called DownloadTask (to help simply a
script that downloads about 10 products from the Internet, builds them,
and then installs them).  The point of a DownloadTask is to download a
file via http or ftp, plus the digest, and then verify the file.  I
realize I could skip the whole download task idea and do something like

    file '/usr/src/myfile.tar.gz' do |task|

However, the concept of a download task (with all the code behind it
wrapped up) seems to me a more elegant solution.  The problem is that I
don't see how to fit it into the rake architecture.

The simple case, which I've implemented, works fine:

download 'http://www.somesite.com/path/myfile.tar.gz'
file 'myfile.tar.gz' => 'http://www.somesite.com/path/myfile.tar.gz'

However, I run into problems if the file should be downloaded to a
different directory.  For example, say the rake file is in the directory
"build" and the file should be downloaded to "/usr/src".  Thus:

download 'http://www.somesite.com/path/myfile.tar.gz'
file '/usr/src/myfile.tar.gz' =>

The problem is that there is no way to add a "local_path" option to the
download task.  Basically, the file task is dependent on the download
task, but the download task needs to know from the file task where to
put the file.

I could do:

download 'http://www.somesite.com/path/myfile.tar.gz' do |task|
    move 'myfile.tar.gz' '/usr/src/'

file '/usr/src/myfile.tar.gz' =>

But then the download task will always run, because it will check for
the file 'myfile.tar.gz' in the local directory, not see it (because the
block moved it), then download the code again.  Not ideal.

Anybody have any advice on how to do this?

Thanks for the help,


-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 2781 bytes
Desc: S/MIME Cryptographic Signature
Url : http://rubyforge.org/pipermail/rake-devel/attachments/20050808/abcfe02a/smime.bin

More information about the Rake-devel mailing list