`#stage` takes an optional `target` argument, which specifies the
location in which to unpack the `resource`.
Passing relative paths to `#stage`, as in
resource("foo").stage "bar"
does not work, because this calls `Pathname("bar").install` inside the
temporary directory that the contents of the resource are unpacked to.
This means that passing a relative path to `#stage` has the unintended
effect of moving files around inside a temporary directory the formula
has no access to.
Let's fix that by keeping track of the original working directory before
`#stage` was called and prepending this to `target` whenever `target` is
a relative path.
The main class you should look at is the {Formula} class (and classes linked from there). That's the class that's used to create Homebrew formulae (i.e. package descriptions). Assume anything else you stumble upon is private.