phinze/homebrew-cask — pull request #2822 by rolandwalker (2014-02-08 18:54:03+00:00)
Title: add Cask::SubversionDownloadStrategy

abstract out module `Cask::DownloadStrategy`, add some commentary

The interface is through new `url` keys: `:using`, `:trust_cert`, and `:revision`.

There's one oddity about this implementation, which is that I tarball the directory that SVN gives us. At first glance this sounds like a horrible hack, but I've decided that it is actually a solid way to go. Here are my comments on the subject from the code:

* A single file is tractable to the rest of the Cask toolchain,
* An alternative would be to create a Directory container type. However, some type of file-serialization trick would still be needed in order to enable calculating a single checksum over a directory. So, in that alternative implementation, the special cases would propagate outside this class, including the use of tar or equivalent.
* SubversionDownloadStrategy.cached_location is not versioned
* tarball_path provides a needed return value for our overridden fetch method.
* We can also take this private opportunity to strip files from the download which are protocol-specific.

And here is an example Cask that would use this functionality in the fonts repo, addressing caskroom/homebrew-fonts#29, where multiple Casks are required to supply a single font.
````ruby
class FontLekton < Cask
url 'https://github.com/w0ng/googlefontdirectory/trunk/fonts/lekton', :using => :svn, :trust_cert => true
homepage 'http://www.google.com/fonts/specimen/Lekton'
version 'latest'
no_checksum
font 'Lekton-Bold.ttf'
font 'Lekton-Italic.ttf'
font 'Lekton-Regular.ttf'
end
```