homebrew-cask-versions/lib/cask/source/uri.rb
Roland Walker 787b471618 isolate ErrorDuringExecution rescue
it only should be rescued for the `curl` invocation
2014-06-03 11:39:58 -04:00

28 lines
541 B
Ruby

class Cask::Source::URI
def self.me?(query)
!!(query.to_s =~ URI.regexp)
end
attr_reader :uri
def initialize(uri)
@uri = uri
end
def load
HOMEBREW_CACHE_CASKS.mkpath
path = HOMEBREW_CACHE_CASKS.join(File.basename(uri))
ohai "Downloading #{uri}"
odebug "Download target -> #{path.to_s}"
begin
curl(uri, '-o', path.to_s)
rescue ErrorDuringExecution
raise CaskUnavailableError.new uri
end
Cask::Source::PathSlashOptional.new(path).load
end
def to_s
uri.to_s
end
end