Skip to content

Commit

Permalink
rule learns to accept Symbols as a prereq name
Browse files Browse the repository at this point in the history
rules presently expect string names as their prereqs (among others:
Procs/Methods, RegExp patterns, or pathmap specs)

This adds the conventional ability for a prereq task to be specified
using a Symbol as is common with non-file-based tasks.
  • Loading branch information
jasonkarns committed Apr 18, 2020
1 parent 4fe73ff commit 6a82435
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/rake/task_manager.rb
Expand Up @@ -300,8 +300,8 @@ def make_sources(task_name, task_pattern, extensions)
when /^\./
source = task_name.sub(task_pattern, ext)
source == ext ? task_name.ext(ext) : source
when String
ext
when String, Symbol
ext.to_s
when Proc, Method
if ext.arity == 1
ext.call(task_name)
Expand Down
11 changes: 11 additions & 0 deletions test/test_rake_rules.rb
Expand Up @@ -80,6 +80,17 @@ def test_rule_prereqs_can_be_created_by_string
assert_equal [OBJFILE], @runs
end

def test_rule_prereqs_can_be_created_by_symbol
task :nonfile do |t|
@runs << t.name
end
rule ".o" => :nonfile do |t|
@runs << t.name
end
Task[OBJFILE].invoke
assert_equal ["nonfile", OBJFILE], @runs
end

def test_plain_strings_as_dependents_refer_to_files
create_file(SRCFILE)
rule ".o" => SRCFILE do |t|
Expand Down

0 comments on commit 6a82435

Please sign in to comment.