diff options
| author | Markus Reiter | 2016-09-24 13:52:43 +0200 |
|---|---|---|
| committer | Markus Reiter | 2016-09-24 16:00:58 +0200 |
| commit | b86c8efb79b3ed835d552c4d7416640ef10caf21 (patch) | |
| tree | 7e1edc8a8f339e4d2781f43576d40c9c79aebcdc /Library/Homebrew/cask/lib/hbc/source/uri.rb | |
| parent | 687f0fcf721c8e36f32570ed72d0988a6eaf986f (diff) | |
| download | brew-b86c8efb79b3ed835d552c4d7416640ef10caf21.tar.bz2 | |
Cask: Use nested classes and modules.
Diffstat (limited to 'Library/Homebrew/cask/lib/hbc/source/uri.rb')
| -rw-r--r-- | Library/Homebrew/cask/lib/hbc/source/uri.rb | 48 |
1 files changed, 26 insertions, 22 deletions
diff --git a/Library/Homebrew/cask/lib/hbc/source/uri.rb b/Library/Homebrew/cask/lib/hbc/source/uri.rb index 99bc50688..09fab4bd0 100644 --- a/Library/Homebrew/cask/lib/hbc/source/uri.rb +++ b/Library/Homebrew/cask/lib/hbc/source/uri.rb @@ -1,28 +1,32 @@ -class Hbc::Source::URI - def self.me?(query) - !(query.to_s =~ URI.regexp).nil? - end +module Hbc + module Source + class URI + def self.me?(query) + !(query.to_s =~ ::URI.regexp).nil? + end - attr_reader :uri + attr_reader :uri - def initialize(uri) - @uri = uri - end + def initialize(uri) + @uri = uri + end - def load - Hbc.cache.mkpath - path = Hbc.cache.join(File.basename(uri)) - ohai "Downloading #{uri}" - odebug "Download target -> #{path}" - begin - curl(uri, "-o", path.to_s) - rescue ErrorDuringExecution - raise Hbc::CaskUnavailableError, uri - end - Hbc::Source::PathSlashOptional.new(path).load - end + def load + Hbc.cache.mkpath + path = Hbc.cache.join(File.basename(uri)) + ohai "Downloading #{uri}" + odebug "Download target -> #{path}" + begin + curl(uri, "-o", path.to_s) + rescue ErrorDuringExecution + raise CaskUnavailableError, uri + end + PathSlashOptional.new(path).load + end - def to_s - uri.to_s + def to_s + uri.to_s + end + end end end |
