remove Pathname#find_formula

Closes Homebrew/homebrew#40486.

Signed-off-by: Xu Cheng <xucheng@me.com>
This commit is contained in:
Xu Cheng 2015-06-10 16:00:09 +08:00
parent d8876a9da4
commit f2d0a88292
3 changed files with 5 additions and 29 deletions

View File

@ -327,17 +327,6 @@ class Pathname
quiet_system "/usr/bin/install-info", "--delete", "--quiet", to_s, "#{dirname}/dir" quiet_system "/usr/bin/install-info", "--delete", "--quiet", to_s, "#{dirname}/dir"
end end
def find_formula
[join("Formula"), join("HomebrewFormula"), self].each do |d|
if d.exist?
d.children.each do |pn|
yield pn if pn.extname == ".rb"
end
break
end
end
end
# Writes an exec script in this folder for each target pathname # Writes an exec script in this folder for each target pathname
def write_exec_script *targets def write_exec_script *targets
targets.flatten! targets.flatten!

View File

@ -9,6 +9,7 @@ require 'formulary'
require 'software_spec' require 'software_spec'
require 'install_renamed' require 'install_renamed'
require 'pkg_version' require 'pkg_version'
require 'tap'
# A formula provides instructions and metadata for Homebrew to install a piece # A formula provides instructions and metadata for Homebrew to install a piece
# of software. Every Homebrew formula is a {Formula}. # of software. Every Homebrew formula is a {Formula}.
@ -627,14 +628,7 @@ class Formula
# an array of all tap {Formula} names # an array of all tap {Formula} names
def self.tap_names def self.tap_names
names = [] Tap.map(&:formula_names).flatten.sort
Pathname.glob("#{HOMEBREW_LIBRARY}/Taps/*/*/") do |tap|
tap.find_formula do |formula|
formula.to_s =~ HOMEBREW_TAP_PATH_REGEX
names << "#{$1}/#{$2.gsub(/^homebrew-/, "")}/#{formula.basename(".rb")}"
end
end
names.sort
end end
# an array of all {Formula} names # an array of all {Formula} names

View File

@ -136,16 +136,9 @@ class Formulary
def initialize tapped_name def initialize tapped_name
@tapped_name = tapped_name @tapped_name = tapped_name
user, repo, name = tapped_name.split("/", 3).map(&:downcase) user, repo, name = tapped_name.split("/", 3).map(&:downcase)
tap = Pathname.new("#{HOMEBREW_LIBRARY}/Taps/#{user}/homebrew-#{repo}") tap = Tap.new user, repo
path = tap.join("#{name}.rb") path = tap.formula_files.detect { |file| file.basename(".rb").to_s == name }
path ||= tap.path/"#{name}.rb"
if tap.directory?
tap.find_formula do |file|
if file.basename(".rb").to_s == name
path = file
end
end
end
super name, path super name, path
end end