Move deprecated Formula class methods to compat

These have all been moved to Formulary.
This commit is contained in:
Jack Nagel 2014-06-22 15:00:15 -05:00
parent 90183877ff
commit 4d9d01893e
22 changed files with 39 additions and 40 deletions

View File

@ -304,7 +304,7 @@ class Test
test "brew", "uses", formula
dependencies = `brew deps #{formula}`.split("\n")
dependencies -= `brew list`.split("\n")
formula_object = Formula.factory(formula)
formula_object = Formulary.factory(formula)
return unless satisfied_requirements? formula_object
installed_gcc = false

View File

@ -229,7 +229,7 @@ module Homebrew
puts output
if ARGV.include? '--write'
f = Formula.factory formula_name
f = Formulary.factory(formula_name)
update_or_add = nil
Utils::Inreplace.inreplace(f.path) do |s|

View File

@ -39,7 +39,7 @@ module Homebrew
def cleanup_cellar
HOMEBREW_CELLAR.subdirs.each do |rack|
begin
cleanup_formula Formula.factory(rack.basename.to_s)
cleanup_formula Formulary.factory(rack.basename.to_s)
rescue FormulaUnavailableError
# Don't complain about directories from DIY installs
end
@ -80,7 +80,7 @@ module Homebrew
next unless (name = file.basename.to_s[/(.*)-(?:#{Regexp.escape(version)})/, 1])
begin
f = Formula.factory(name)
f = Formulary.factory(name)
rescue FormulaUnavailableError
next
end

View File

@ -51,7 +51,7 @@ module Homebrew
end
if Formula.aliases.include? fc.name
realname = Formula.canonical_name fc.name
realname = Formulary.canonical_name(fc.name)
raise <<-EOS.undent
The formula #{realname} is already aliased to #{fc.name}
Please check that you are not creating a duplicate.

View File

@ -37,7 +37,7 @@ module Homebrew
def detected_name(path, version)
basename = path.basename.to_s
detected_name = basename[/(.*?)-?#{Regexp.escape(version)}/, 1] || basename
canonical_name = Formula.canonical_name(detected_name)
canonical_name = Formulary.canonical_name(detected_name)
odie <<-EOS.undent if detected_name != canonical_name
The detected name #{detected_name.inspect} exists in Homebrew as an alias

View File

@ -570,7 +570,7 @@ def check_for_gettext
return if @found.empty?
# Our gettext formula will be caught by check_linked_keg_only_brews
f = Formula.factory("gettext") rescue nil
f = Formulary.factory("gettext") rescue nil
return if f and f.linked_keg.directory? and @found.all? do |path|
Pathname.new(path).realpath.to_s.start_with? "#{HOMEBREW_CELLAR}/gettext"
end
@ -585,7 +585,7 @@ end
def check_for_iconv
unless find_relative_paths("lib/libiconv.dylib", "include/iconv.h").empty?
if (f = Formula.factory("libiconv") rescue nil) and f.linked_keg.directory?
if (f = Formulary.factory("libiconv") rescue nil) and f.linked_keg.directory?
if not f.keg_only? then <<-EOS.undent
A libiconv formula is installed and linked
This will break stuff. For serious. Unlink it.
@ -993,7 +993,7 @@ def check_for_bad_python_symlink
end
def check_for_non_prefixed_coreutils
gnubin = "#{Formula.factory('coreutils').prefix}/libexec/gnubin"
gnubin = "#{Formulary.factory('coreutils').prefix}/libexec/gnubin"
if paths.include? gnubin then <<-EOS.undent
Putting non-prefixed coreutils in your path can cause gmp builds to fail.
EOS
@ -1051,7 +1051,7 @@ def check_for_unlinked_but_not_keg_only
true
elsif not (HOMEBREW_REPOSITORY/"Library/LinkedKegs"/rack.basename).directory?
begin
Formula.factory(rack.basename.to_s).keg_only?
Formulary.factory(rack.basename.to_s).keg_only?
rescue FormulaUnavailableError
false
end

View File

@ -26,7 +26,7 @@ module Homebrew
else
# Don't use ARGV.formulae as that will throw if the file doesn't parse
paths = ARGV.named.map do |name|
name = Formula.canonical_name name
name = Formulary.canonical_name(name)
Formula.path(name)
end
unless ARGV.force?

View File

@ -28,7 +28,7 @@ module Homebrew
ARGV.named.each_with_index do |f,i|
puts unless i == 0
begin
info_formula Formula.factory(f)
info_formula Formulary.factory(f)
rescue FormulaUnavailableError
# No formula with this name, try a blacklist lookup
if (blacklist = blacklisted?(f))

View File

@ -4,12 +4,12 @@ require 'irb'
class Symbol
def f
Formula.factory(self.to_s)
Formulary.factory(to_s)
end
end
class String
def f
Formula.factory(self)
Formulary.factory(self)
end
end

View File

@ -49,7 +49,7 @@ module Homebrew
private
def keg_only?(name)
Formula.factory(name).keg_only?
Formulary.factory(name).keg_only?
rescue FormulaUnavailableError
false
end

View File

@ -22,7 +22,7 @@ module Homebrew
formulae.sort.each do |n|
begin
Formula.factory(n)
Formulary.factory(n)
rescue Exception => e
onoe "problem in #{Formula.path(n)}"
puts e

View File

@ -17,7 +17,7 @@ module Homebrew
end
else
ARGV.named.each do |name|
name = Formula.canonical_name(name)
name = Formulary.canonical_name(name)
rack = HOMEBREW_CELLAR/name
if rack.directory?
@ -41,6 +41,6 @@ module Homebrew
end
def rm_pin name
Formula.factory(name).unpin rescue nil
Formulary.factory(name).unpin rescue nil
end
end

View File

@ -31,6 +31,18 @@ class Formula
opoo "Formula.all is deprecated, use Formula.map instead"
map
end
def self.canonical_name(name)
Formulary.canonical_name(name)
end
def self.class_s(name)
Formulary.class_s(name)
end
def self.factory(name)
Formulary.factory(name)
end
end
class UnidentifiedFormula < Formula

View File

@ -29,7 +29,7 @@ class Dependency
end
def to_formula
f = Formula.factory(name)
f = Formulary.factory(name)
# Add this dependency's options to the formula's build args
f.build.args = f.build.args.concat(options)
f

View File

@ -17,7 +17,7 @@ module HomebrewArgvExtension
require 'keg'
require 'formula'
@kegs ||= downcased_unique_named.collect do |name|
canonical_name = Formula.canonical_name(name)
canonical_name = Formulary.canonical_name(name)
rack = HOMEBREW_CELLAR/canonical_name
dirs = rack.directory? ? rack.subdirs : []
@ -32,7 +32,7 @@ module HomebrewArgvExtension
Keg.new(linked_keg_ref.resolved_path)
elsif dirs.length == 1
Keg.new(dirs.first)
elsif (prefix = Formula.factory(canonical_name).prefix).directory?
elsif (prefix = Formulary.factory(canonical_name).prefix).directory?
Keg.new(prefix)
else
raise MultipleVersionsInstalledError.new(name)

View File

@ -171,7 +171,7 @@ module SharedEnvExtension
# ld64 is a newer linker provided for Xcode 2.5
def ld64
ld64 = Formula.factory('ld64')
ld64 = Formulary.factory('ld64')
self['LD'] = ld64.bin/'ld'
append "LDFLAGS", "-B#{ld64.bin}/"
end

View File

@ -338,10 +338,6 @@ class Formula
alias_method :python2, :python
alias_method :python3, :python
def self.class_s name
Formulary.class_s(name)
end
# an array of all Formula names
def self.names
Dir["#{HOMEBREW_LIBRARY}/Formula/*.rb"].map{ |f| File.basename f, '.rb' }.sort
@ -376,19 +372,10 @@ class Formula
Dir["#{HOMEBREW_LIBRARY}/Aliases/*"].map{ |f| File.basename f }.sort
end
def self.canonical_name name
Formulary.canonical_name(name)
end
def self.[](name)
Formulary.factory(name)
end
# deprecated
def self.factory name
Formulary.factory name
end
def tap?
HOMEBREW_TAP_DIR_REGEX === path
end

View File

@ -211,7 +211,7 @@ class FormulaInstaller
return if ARGV.force?
conflicts = f.conflicts.reject do |c|
keg = Formula.factory(c.name).prefix
keg = Formulary.factory(c.name).prefix
not keg.directory? && Keg.new(keg).linked?
end

View File

@ -60,7 +60,7 @@ class FormulaVersions
begin
old_const = Formulary.unload_formula(f.name)
nostdout { yield Formula.factory(path.to_s) }
nostdout { yield Formulary.factory(path.to_s) }
rescue *IGNORED_EXCEPTIONS => e
# We rescue these so that we can skip bad versions and
# continue walking the history

View File

@ -13,7 +13,7 @@ module Language
["python", "python3"].each do |python|
next if build.without? python
version = self.major_minor_version python
ENV["PYTHONPATH"] = if Formula.factory(python).installed?
ENV["PYTHONPATH"] = if Formulary.factory(python).installed?
nil
else
"#{HOMEBREW_PREFIX}/lib/python#{version}/site-packages"

View File

@ -47,7 +47,7 @@ class Tab < OpenStruct
end
def self.for_name name
for_formula(Formula.factory(name))
for_formula(Formulary.factory(name))
end
def self.for_formula f

View File

@ -195,7 +195,7 @@ class FormulaTests < Homebrew::TestCase
end
}
end
assert_kind_of Formula, Formula.factory(name)
assert_kind_of Formula, Formulary.factory(name)
ensure
path.unlink
end