homebrew-cask-versions/lib/cask/source/uri.rb
Roland Walker 216444849e Add copious debugging with --debug
- add new file "cask/utils.rb" analogous to "utils.rb" in Homebrew
- define odebug and odumpcask, analogs of ohai and friends, but
  which only give output when --debug is in effect
- move the debug setting from an instance variable in Cask::CLI
  to a method Cask.debug, defined in "lib/cask/options.rb", which
  was added in #2276. (Perhaps options.rb should be merged back
  into Cask::CLI).
- sprinkle odebug statements liberally throughout the codebase
- update tests
2014-01-28 10:15:43 -05:00

22 lines
465 B
Ruby

class Cask::Source::URI
def self.me?(query)
!!(query =~ 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}"
curl(uri, '-o', path.to_s)
Cask::Source::Path.new(path).load
rescue ErrorDuringExecution
raise CaskUnavailableError, uri
end
end