aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/cask/lib/hbc/source.rb
diff options
context:
space:
mode:
authorAnastasiaSulyagina2016-08-18 22:11:42 +0300
committerAnastasiaSulyagina2016-08-19 14:50:14 +0300
commite81f4ab7deeb40308f240be5ea00091fc8786d7a (patch)
treeb5418f9149de71c0f05f90cb2b39ab47f46e27b4 /Library/Homebrew/cask/lib/hbc/source.rb
parent5c7c9de669025bbe4cad9829be39c5cf3b31ad25 (diff)
downloadbrew-e81f4ab7deeb40308f240be5ea00091fc8786d7a.tar.bz2
init
Diffstat (limited to 'Library/Homebrew/cask/lib/hbc/source.rb')
-rw-r--r--Library/Homebrew/cask/lib/hbc/source.rb37
1 files changed, 37 insertions, 0 deletions
diff --git a/Library/Homebrew/cask/lib/hbc/source.rb b/Library/Homebrew/cask/lib/hbc/source.rb
new file mode 100644
index 000000000..af298108a
--- /dev/null
+++ b/Library/Homebrew/cask/lib/hbc/source.rb
@@ -0,0 +1,37 @@
+module Hbc::Source; end
+
+require "hbc/source/gone"
+require "hbc/source/path_slash_required"
+require "hbc/source/path_slash_optional"
+require "hbc/source/tapped_qualified"
+require "hbc/source/untapped_qualified"
+require "hbc/source/tapped"
+require "hbc/source/uri"
+
+module Hbc::Source
+ def self.sources
+ [
+ Hbc::Source::URI,
+ Hbc::Source::PathSlashRequired,
+ Hbc::Source::TappedQualified,
+ Hbc::Source::UntappedQualified,
+ Hbc::Source::Tapped,
+ Hbc::Source::PathSlashOptional,
+ Hbc::Source::Gone,
+ ]
+ end
+
+ def self.for_query(query)
+ odebug "Translating '#{query}' into a valid Cask source"
+ raise Hbc::CaskUnavailableError, query if query.to_s =~ %r{^\s*$}
+ source = sources.find { |s|
+ odebug "Testing source class #{s}"
+ s.me?(query)
+ }
+ raise Hbc::CaskUnavailableError, query unless source
+ odebug "Success! Using source class #{source}"
+ resolved_cask_source = source.new(query)
+ odebug "Resolved Cask URI or file source to '#{resolved_cask_source}'"
+ resolved_cask_source
+ end
+end