mxcl/homebrew — pull request #20276 by jacknagel (2013-09-19 21:52:43+00:00)
Title: Eliminate spec-conditional dependencies

(previously, #20274)

When installing the `devel` or `HEAD` version of a formula, `--devel` or `--HEAD` is present in ARGV, which means it is present in the `build` object of any dependencies when their classes are loaded. This becomes problematic when dependencies are conditional upon `build.devel?` or `build.head?` because these conditionals are evaluated when the class is loaded and not when the actual object is instantiated (at which point we *do* select the correct spec by using `ARGV.filter_for_dependencies`.

So instead of

```rb
if build.devel?
depends_on 'foo'
depends_on 'bar'
end
```

we need some way to scope these dependencies without using a language-level conditional in the class body.

One way would be to teach SoftwareSpec about dependencies, and use `depends_on` inside the devel block; I like the however this would mean adding a block-style `head` and I'm not convinced that it is the right place for the information (SoftwareSpec doesn't know about `build`, options, etc., so a lot of indirection would be required).

Another would be a new syntax:

```rb
group :devel do
depends_on 'foo'
depends_on 'bar'
end

group :head do
depends_on 'baz' => :build
depends_on 'qux'
end
```

(not sold on the name "group", but it is what e.g. bundler uses).

dependencies declared at the top level would apply to all specs.