Reimplement specs in terms of resources

This is groundwork for implementing #20276. The goal is to make SoftwareSpec more formula-like, so that dependencies and build options can be tracked on a per-spec basis without using conditionals in the class body.

The first four patches are largely code movement, which inverts the Resource -> SoftwareSpec dependency. Resource is now the fundamental representation of a download.

The other four patches move tracking of resources into SoftwareSpec, so that you can do something along these things:

```rb
class Thing < Formula
  # ...

  resource 'man' do
    url '...'
    sha1 '...'
  end

  head do
    url '...'

    resource 'man' do
      url '...'
      sha1 '...'
    end
  end
 
  # ...
```

The set of resources for a particular install is the combination of those declared at the top level and those declared in the block that corresponds to the build type (stable, devel, head). The order is not important; resources with identical names inside a head or devel block override those declared at the top-level.