Skip to content

Commit 4a63d6a

Browse files
committed
Accept Pathname object as rule's prerequisite
1 parent 6ed3a03 commit 4a63d6a

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

lib/rake/task_manager.rb

+2
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,8 @@ def make_sources(task_name, task_pattern, extensions)
302302
source == ext ? task_name.ext(ext) : source
303303
when String, Symbol
304304
ext.to_s
305+
when Pathname
306+
Rake.from_pathname(ext)
305307
when Proc, Method
306308
if ext.arity == 1
307309
ext.call(task_name)

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)