Skip to content

Commit

Permalink
Accept Pathname object as rule's prerequisite
Browse files Browse the repository at this point in the history
  • Loading branch information
gemmaro committed Dec 20, 2023
1 parent 6ed3a03 commit 4a63d6a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/rake/task_manager.rb
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,8 @@ 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)
Expand Down
10 changes: 10 additions & 0 deletions test/test_rake_rules.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 4a63d6a

Please sign in to comment.