Class: Formulary::FromUrlLoader

Inherits:
FormulaLoader show all
Defined in:
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



163
164
165
166
167
168
# File 'Library/Homebrew/formulary.rb', line 163

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



161
162
163
# File 'Library/Homebrew/formulary.rb', line 161

def url
  @url
end

Instance Method Details

#load_fileObject



170
171
172
173
174
175
176
177
178
179
180
# File 'Library/Homebrew/formulary.rb', line 170

def load_file
  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