[Rake-devel] Multi-part extensions in rules?...

Stuart Hungerford stuart.hungerford at anu.edu.au
Mon Apr 2 23:30:01 EDT 2007

Jim Weirich wrote:

> [...]
>  > rule(/\.50\.png$/ => [".tiff"]) do |r|
>  >      # do stuff with r
>  > end
> The problem is that (by default), rake doesn't recognize ".50.png" as a 
> file extension.  The second rule using a regexp addresses part of the 
> problem, but it doesn't go far enough.  You also have to tell rake how 
> to find the source file a match for the rule.  Given that it's trying to 
> build 'xxx.50.png', it will try to find a 'xxx.50.tiff'.  If you want to 
> drop the 50 part, you have to give rake a proc that convert from the 
> .50.png to just .tiff.  Something like this:
>   rule(/\.50\.png$/ => proc { |fn| fn.sub(/\.\d+\.png$/, '.tiff') }) do |r|
>     cp r.source, r.name
>   end
> I hope I understood your problem correctly.  Does that help?

    I think I see now -- many thanks!



Stuart Hungerford
ANUSF Data Intensive Projects

More information about the Rake-devel mailing list