homebrew-cask-versions/lib/cask/source.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

32 lines
775 B
Ruby

module Cask::Source; end
require 'cask/source/gone'
require 'cask/source/path'
require 'cask/source/tapped_qualified'
require 'cask/source/untapped_qualified'
require 'cask/source/tapped'
require 'cask/source/uri'
module Cask::Source
def self.sources
[
Cask::Source::URI,
Cask::Source::Path,
Cask::Source::TappedQualified,
Cask::Source::UntappedQualified,
Cask::Source::Tapped,
Cask::Source::Gone,
]
end
def self.for_query(query)
odebug "Translating '#{query}' into a valid Cask source"
source = sources.find do |s|
odebug "Testing source class #{s}"
s.me?(query)
end
raise CaskUnavailableError.new(query) unless source
odebug "Using source class #{source}"
source.new(query)
end
end