diff options
| author | Shaun Jackman | 2016-07-13 13:51:44 -0500 | 
|---|---|---|
| committer | Shaun Jackman | 2017-05-01 10:58:26 -0700 | 
| commit | ffe1ee1636bba266b2d8180300375dc1a86794cd (patch) | |
| tree | c56ceae0a6289d32532a9f10b5541d295621d1cb /Library/Homebrew/formulary.rb | |
| parent | 8cba0352e0be94263e2ed96c98bf93d8f2fce8ef (diff) | |
| download | brew-ffe1ee1636bba266b2d8180300375dc1a86794cd.tar.bz2 | |
Install a bottle from an URL
Diffstat (limited to 'Library/Homebrew/formulary.rb')
| -rw-r--r-- | Library/Homebrew/formulary.rb | 17 | 
1 files changed, 14 insertions, 3 deletions
diff --git a/Library/Homebrew/formulary.rb b/Library/Homebrew/formulary.rb index f5e6a2eb9..446d5dc10 100644 --- a/Library/Homebrew/formulary.rb +++ b/Library/Homebrew/formulary.rb @@ -105,7 +105,18 @@ module Formulary    # Loads formulae from bottles.    class BottleLoader < FormulaLoader      def initialize(bottle_name) -      @bottle_filename = Pathname(bottle_name).realpath +      case bottle_name +      when %r{(https?|ftp|file)://} +        # The name of the formula is found between the last slash and the last hyphen. +        resource = Resource.new bottle_name[%r{([^/]+)-}, 1] { url bottle_name } +        downloader = CurlBottleDownloadStrategy.new resource.name, resource +        @bottle_filename = downloader.cached_location +        cached = @bottle_filename.exist? +        downloader.fetch +        ohai "Pouring the cached bottle" if cached +      else +        @bottle_filename = Pathname(bottle_name).realpath +      end        name, full_name = Utils::Bottles.resolve_formula_names @bottle_filename        super name, Formulary.path(full_name)      end @@ -335,10 +346,10 @@ module Formulary    def self.loader_for(ref, from: nil)      case ref -    when %r{(https?|ftp|file)://} -      return FromUrlLoader.new(ref)      when Pathname::BOTTLE_EXTNAME_RX        return BottleLoader.new(ref) +    when %r{(https?|ftp|file)://} +      return FromUrlLoader.new(ref)      when HOMEBREW_TAP_FORMULA_REGEX        return TapLoader.new(ref, from: from)      end  | 
