Class: Formulary::FromUrlLoader

Inherits:
FormulaLoader show all
Defined in:
brew/Library/Homebrew/formulary.rb

Overview

Loads formulae from URLs.

Instance Attribute Summary collapse

Attributes inherited from FormulaLoader

#alias_path, #name, #path

Instance Method Summary collapse

Methods inherited from FormulaLoader

#get_formula, #klass

Constructor Details

#initialize(url) ⇒ FromUrlLoader

Returns a new instance of FromUrlLoader



190
191
192
193
194
195
# File 'brew/Library/Homebrew/formulary.rb', line 190

def initialize(url)
  @url = url
  uri = URI(url)
  formula = File.basename(uri.path, ".rb")
  super formula, HOMEBREW_CACHE_FORMULA/File.basename(uri.path)
end

Instance Attribute Details

#urlObject (readonly)

Returns the value of attribute url



188
189
190
# File 'brew/Library/Homebrew/formulary.rb', line 188

def url
  @url
end

Instance Method Details

#load_fileObject



197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
# File 'brew/Library/Homebrew/formulary.rb', line 197

def load_file
  if url =~ %r{githubusercontent.com/[\w-]+/[\w-]+/[a-f0-9]{40}(/Formula)?/([\w+-.@]+).rb}
    formula_name = Regexp.last_match(2)
    ohai "Consider using `brew extract #{formula_name} ...`!"
    puts <<~EOS
      This will extract your desired #{formula_name} version to a stable tap instead of
      installing from an unstable URL!

    EOS
  end
  HOMEBREW_CACHE_FORMULA.mkpath
  FileUtils.rm_f(path)
  curl_download url, to: path
  super
rescue MethodDeprecatedError => e
  if url =~ %r{github.com/([\w-]+)/homebrew-([\w-]+)/}
    e.issues_url = "https://github.com/#{Regexp.last_match(1)}/homebrew-#{Regexp.last_match(2)}/issues/new"
  end
  raise
end