Homebrew/homebrew — pull request #27361 by jacknagel (2014-03-09 21:49:26+00:00)
Title: Generalize bottle implementation and eliminate load-time shenanigans

This pull request moves all logic that decides whether or not a bottle should be installed into the installer and decouples this logic from global state.

To facilitate this, I have split the existing Bottle class into two classes.

The first is a `BottleSpecification` class: this is just a container for bottle information collected from the formula DSL. It is an attribute of `SoftwareSpec`, i.e. every spec object can have a bottle specification attached to it.

The second is called `Bottle`, and it is only instantiated on-demand at runtime. This class has all the behavior (fetching, checksumming, etc) that the existing bottle class does.

Further, decisions about bottles are no longer made in the formula constructor.

This allows us to make some really nice simplifications and remove some ugly hacks from the installer.

As a bonus, the bottle DSL works for any spec. Since it is implemented on SoftwareSpec, it can be nested inside `stable` and `devel` blocks. That is, this falls out as a natural consequence of the implementation and works exactly how you would expect it to, for free, without any extra code or hacks:

```rb
devel do
url "..."
sha1 "..."

bottle do
sha1 "..." => :mavericks
end
end
```

This is just the first part of a larger reworking of some problem areas so that we can eliminate use of `ARGV.filter_for_dependencies` and also get rid of coupling to `ARGV` deep inside the constituent objects of `Formula`.