Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Enable rules to accept Method object as prerequisites.

  • Loading branch information...
commit f6ba31ff86a3cf88da708bcfc2120bd0da1af7cc 1 parent 885b44c
@avdi avdi authored
Showing with 27 additions and 1 deletion.
  1. +1 −1  lib/rake/task_manager.rb
  2. +26 −0 test/test_rake_rules.rb
View
2  lib/rake/task_manager.rb
@@ -265,7 +265,7 @@ def make_sources(task_name, extensions)
task_name.ext(ext)
when String
ext
- when Proc
+ when Proc, Method
if ext.arity == 1
ext.call(task_name)
else
View
26 test/test_rake_rules.rb
@@ -359,4 +359,30 @@ def test_regex_rule_with_args_and_lambda_prereq
Task[OBJFILE].invoke('arg')
end
+ def test_rule_with_method_prereq
+ create_file(".foo")
+ obj = Object.new
+ def obj.find_prereq
+ ".foo"
+ end
+ rule '.o' => obj.method(:find_prereq) do |t|
+ @runs << "#{t.name} - #{t.source}"
+ end
+ Task[OBJFILE].invoke
+ assert_equal ["#{OBJFILE} - .foo"], @runs
+ end
+
+ def test_rule_with_one_arg_method_prereq
+ create_file(SRCFILE)
+ obj = Object.new
+ def obj.find_prereq(task_name)
+ task_name.ext(".c")
+ end
+ rule '.o' => obj.method(:find_prereq) do |t|
+ @runs << "#{t.name} - #{t.source}"
+ end
+ Task[OBJFILE].invoke
+ assert_equal ["#{OBJFILE} - abc.c"], @runs
+ end
+
end
Please sign in to comment.
Something went wrong with that request. Please try again.