[Rake-devel] Lambda for multiple prerequisite rules

miki mikisvaz at yahoo.com
Wed Aug 6 08:43:43 EDT 2008


Hi all, I just came across what I think is a bug.

The following Rakefile

-----
rule (/a-b-c/) => lambda{|t| [[t.split('-')]]} do |t|
end

rule (/^[^-]*$/) do |t|
  puts t.name
end
-----

When invoked should render:

$ rake a-b-c-d-e
a
b
c
d
e

but instead renders:

$ rake a-b-c-d-e
a
a
a
a
a


Apparently  the rake.rb file reads:   

def attempt_rule(task_name, extensions, block, level)
      sources = make_sources(task_name, extensions)
      prereqs = sources.collect { |source|
        if File.exist?(source) || Rake::Task.task_defined?(source)
          source
        elsif parent = enhance_with_matching_rule(sources.first, level+1)
          parent.name
        else
          return nil
        end
      }
      task = FileTask.define_task({task_name => prereqs}, &block)
      task.sources = prereqs
      task
 end

I belive line:

        elsif parent = enhance_with_matching_rule(sources.first, level+1)

should be:

        elsif parent = enhance_with_matching_rule(source, level+1)

As this fixes the problem.


Kind regards

Miguel


      


More information about the Rake-devel mailing list