diff --git a/lib/rake/task_manager.rb b/lib/rake/task_manager.rb index 90bc0d0d1..25011723d 100644 --- a/lib/rake/task_manager.rb +++ b/lib/rake/task_manager.rb @@ -302,8 +302,6 @@ def make_sources(task_name, task_pattern, extensions) source == ext ? task_name.ext(ext) : source when String, Symbol ext.to_s - when Pathname - Rake.from_pathname(ext) when Proc, Method if ext.arity == 1 ext.call(task_name) @@ -311,7 +309,11 @@ def make_sources(task_name, task_pattern, extensions) ext.call end else - fail "Don't know how to handle rule dependent: #{ext.inspect}" + if ext.respond_to?(:to_path) + Rake.from_pathname(ext) + else + fail "Don't know how to handle rule dependent: #{ext.inspect}" + end end } result.flatten diff --git a/test/support/rakefile_definitions.rb b/test/support/rakefile_definitions.rb index d1c9afdd1..6e0baaa59 100644 --- a/test/support/rakefile_definitions.rb +++ b/test/support/rakefile_definitions.rb @@ -78,6 +78,20 @@ def rakefile_chains DEFAULT end + def rakefile_rule_with_proc + rakefile <<~RAKEFILE + task :default => "play.app" + + rule ".app" => [->(name) { name.ext(".scpt") }] do |t| + cp t.source, t.name + end + + file 'play.scpt' do + touch 'play.scpt' + end + RAKEFILE + end + def rakefile_file_chains rakefile <<~RAKEFILE file "fileA" do |t| diff --git a/test/test_rake_functional.rb b/test/test_rake_functional.rb index 1298a3235..be7ffd675 100644 --- a/test/test_rake_functional.rb +++ b/test/test_rake_functional.rb @@ -294,6 +294,15 @@ def test_rules_chaining_to_file_task "'play.app' file should exist" end + def test_rule_with_proc_prerequisite + rakefile_rule_with_proc + + rake + + assert File.exist?(File.join(@tempdir, "play.app")), + "'play.app' file should exist" + end + def dryrun_tasks @err.split("\n").select { |line| line.match(/^\*\* Execute/)