Skip to content

Commit fe0b1ba

Browse files
committed
Accept Pathname-like object as rule's prerequisite
1 parent b29fb4e commit fe0b1ba

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

lib/rake/task_manager.rb

+5-1
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,11 @@ def make_sources(task_name, task_pattern, extensions)
309309
ext.call
310310
end
311311
else
312-
fail "Don't know how to handle rule dependent: #{ext.inspect}"
312+
if (ext = Rake.from_pathname(ext)).is_a?(String)
313+
ext
314+
else
315+
fail "Don't know how to handle rule dependent: #{ext.inspect}"
316+
end
313317
end
314318
}
315319
result.flatten

test/test_rake_rules.rb

+10
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,16 @@ def test_rule_prereqs_can_be_created_by_string
8080
assert_equal [OBJFILE], @runs
8181
end
8282

83+
def test_rule_prereqs_can_be_created_by_pathname
84+
create_file(SRCFILE)
85+
create_file(FOOFILE)
86+
rule ".o" => [".c", Pathname(FOOFILE)] do |t|
87+
@runs << t.name
88+
end
89+
Task[OBJFILE].invoke
90+
assert_equal [OBJFILE], @runs
91+
end
92+
8393
def test_rule_prereqs_can_be_created_by_symbol
8494
task :nonfile do |t|
8595
@runs << t.name

0 commit comments

Comments
 (0)