jimweirich/rake — pull request #215 by avdi (2013-08-02 15:09:09+00:00)
Title: Make Task#source default to the first prerequisite in non-rule tasks.

In GNU Make, The `$<` macro always expands to the *first* prerequisite of the current rule. This supports a common idiom wherein the primary "source file" for the target is listed first in the dependency list.

The Rake analog of this macro seems to be `Task#source`, but unlike in Make it is only available in tasks declared with `rule`.

Making `Task#source` return the first prerequisite in non-rule tasks aids code malleability. Let's say I start with a file task:

```ruby
file "ch1.html" => ["ch1.md"] do |t|
sh "pandoc -o #{t.name} #{t.source}"
end
```

I can then generalize it into a rule without changing the body at all:

```ruby
rule ".html" => [".md"] do |t|
sh "pandoc -o #{t.name} #{t.source}"
end
```

What do you think?