Monday, November 22, 2010

Rake duplicate task descriptions

Using Rake I can define tasks that get added to a collection of tasks for execution.  For example:
  1. desc "one"  
  2. task :one do  
  3.   puts "one"  
  4. end  
  5.   
  6. desc "all"  
  7. task :all => [:one]  
  8.   
  9. desc "two"  
  10. task :two do  
  11.   puts "two"  
  12. end  
  13.   
  14. desc "all"  
  15. task :all => [:two]  

Now, if I look at rake --tasks I will see:
> rake --tasks
rake one     # one
rake two     # two
rake all     # all / all

Rake has duplicated the description for the :all task. Looking at the code for Rake I discovered that this can be avoided by terminating the :all task description with a period:
  1. desc "one"  
  2. desc "all."  
  3. task :all => [:one]  
  4.   
  5. desc "one"  
  6. desc "all."  
  7. task :all => [:one]  

> rake --tasks
rake one     # one
rake two     # two
rake all     # all.

No comments :

Post a Comment