From fe0b1bac13e7e628b16ef40dcb4037e4b08149cd Mon Sep 17 00:00:00 2001 From: gemmaro Date: Fri, 15 Dec 2023 21:13:10 +0900 Subject: [PATCH] Accept Pathname-like object as rule's prerequisite --- lib/rake/task_manager.rb | 6 +++++- test/test_rake_rules.rb | 10 ++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/lib/rake/task_manager.rb b/lib/rake/task_manager.rb index 0db5c241e..5e5096799 100644 --- a/lib/rake/task_manager.rb +++ b/lib/rake/task_manager.rb @@ -309,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 = Rake.from_pathname(ext)).is_a?(String) + ext + else + fail "Don't know how to handle rule dependent: #{ext.inspect}" + end end } result.flatten diff --git a/test/test_rake_rules.rb b/test/test_rake_rules.rb index e20df9350..48fab0bad 100644 --- a/test/test_rake_rules.rb +++ b/test/test_rake_rules.rb @@ -80,6 +80,16 @@ def test_rule_prereqs_can_be_created_by_string assert_equal [OBJFILE], @runs end + def test_rule_prereqs_can_be_created_by_pathname + create_file(SRCFILE) + create_file(FOOFILE) + rule ".o" => [".c", Pathname(FOOFILE)] do |t| + @runs << t.name + end + Task[OBJFILE].invoke + assert_equal [OBJFILE], @runs + end + def test_rule_prereqs_can_be_created_by_symbol task :nonfile do |t| @runs << t.name