8 Commits

Author SHA1 Message Date
Jack Nagel
45bdeadd94 Set bottle download strategy directly
We know what strategy we want, so going through DownloadStrategyDetector
is wasted work. Now we can remove those patterns from the detector and
have two fewer branches each time through.
2014-03-18 21:28:33 -05:00
Jack Nagel
ed7f8faed2 VCSDownloadStrategy: rename checkout_name to cache_filename 2013-10-11 00:21:23 -05:00
Jack Nagel
6c5a9ae0fb Extract a new superclass for VCS-based download strategies 2013-10-09 21:41:15 -05:00
Jack Nagel
57560c03e6 Handle invalid names in download strategies
When subformulae are initialized without a name parameter, Homebrew
assigns the name "__UNKNOWN__". This may cause collisions in the cache.

Currently CurlDownloadStrategy and its descendants handles this by
extracting the basename form the URL and using that as the cached
filename. However, other strategies simply raise an exception.

We can improve the other strategies by URL-encoding the URL string and
using that as the cached directory name.

Note that this happens very rarely, especially now that resources (which
always have a name) are preferred to subformulae. The most common case
is a subformula that specifies a head download.

Closes Homebrew/homebrew#22949.
2013-09-30 22:56:02 -05:00
Jack Nagel
d1ce5bafc9 Raise when given an invalid download strategy spec
When DownloadStrategyDetector.detect is given a second argument, and
that argument is not a symbol or an AbstractDownloadStrategy subclass,
it is silently ignored, and we fall back to guessing the strategy based
on the URL.

This means I can do

  url 'http://foo.com/bar.tar.gz', :using => Class.new

and things will appear to work, even though I have clearly passed an
invalid value for :using.

A more useful behavior is to raise an exception for unknown strategy
specifications.
2013-09-26 17:00:00 -05:00
Jack Nagel
41af459205 Require hardware where it is needed 2013-06-01 19:38:48 -05:00
Jack Nagel
2288f63197 Tests for AbstractDownloadStrategy 2013-04-07 20:59:50 -05:00
Jack Nagel
39ec66614b Test coverage for DownloadStrategyDetector
While at it, make it use class methods instead; no reason to instantiate
an object for this.

Eventually there should be some functional tests for the individual
strategies as well.

Signed-off-by: Jack Nagel <jacknagel@gmail.com>
2012-10-15 17:45:48 -05:00