I've got some input files which I want to encode using Ruby. The output from the encoding should match some pattern based on the filename of the input file. In order to not do this by hand, I want to use Rake as help for automation. Further I'd like to not specify a single task for every input file.
I've tried some FileList "magic" but it didn't work out. Here's the code:
desc 'Create all output from specified input'
task :encode do
FileList['input/*.txt'].each {|input| file "output/output_#{input}" => input}
end
Anyone can help? I didn't find find anything on the web about multiple output files as dependency.
I would look into using Rake's
rule
tasks, which allow tasks to be dynamically defined based on regex rules. See the rakefile rdoc page for details, but here's an example:And then you should be able to run
rake encode
in a directory with files matchinginput/*
, and have the output files be placed inoutput/output_*
.