From f2d0a88292cf3cafb8696f0bd02d4a02d0498658 Mon Sep 17 00:00:00 2001 From: Xu Cheng Date: Wed, 10 Jun 2015 16:00:09 +0800 Subject: remove Pathname#find_formula Closes Homebrew/homebrew#40486. Signed-off-by: Xu Cheng --- Library/Homebrew/extend/pathname.rb | 11 ----------- Library/Homebrew/formula.rb | 10 ++-------- Library/Homebrew/formulary.rb | 13 +++---------- 3 files changed, 5 insertions(+), 29 deletions(-) (limited to 'Library') diff --git a/Library/Homebrew/extend/pathname.rb b/Library/Homebrew/extend/pathname.rb index ee8d8c9f4..a0c24e981 100644 --- a/Library/Homebrew/extend/pathname.rb +++ b/Library/Homebrew/extend/pathname.rb @@ -327,17 +327,6 @@ class Pathname quiet_system "/usr/bin/install-info", "--delete", "--quiet", to_s, "#{dirname}/dir" 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 def write_exec_script *targets targets.flatten! diff --git a/Library/Homebrew/formula.rb b/Library/Homebrew/formula.rb index 72c8bdff0..979ef3721 100644 --- a/Library/Homebrew/formula.rb +++ b/Library/Homebrew/formula.rb @@ -9,6 +9,7 @@ require 'formulary' require 'software_spec' require 'install_renamed' require 'pkg_version' +require 'tap' # A formula provides instructions and metadata for Homebrew to install a piece # of software. Every Homebrew formula is a {Formula}. @@ -627,14 +628,7 @@ class Formula # an array of all tap {Formula} names def self.tap_names - names = [] - 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 + Tap.map(&:formula_names).flatten.sort end # an array of all {Formula} names diff --git a/Library/Homebrew/formulary.rb b/Library/Homebrew/formulary.rb index 9ed79db07..cc59b3472 100644 --- a/Library/Homebrew/formulary.rb +++ b/Library/Homebrew/formulary.rb @@ -136,16 +136,9 @@ class Formulary def initialize tapped_name @tapped_name = tapped_name user, repo, name = tapped_name.split("/", 3).map(&:downcase) - tap = Pathname.new("#{HOMEBREW_LIBRARY}/Taps/#{user}/homebrew-#{repo}") - path = tap.join("#{name}.rb") - - if tap.directory? - tap.find_formula do |file| - if file.basename(".rb").to_s == name - path = file - end - end - end + tap = Tap.new user, repo + path = tap.formula_files.detect { |file| file.basename(".rb").to_s == name } + path ||= tap.path/"#{name}.rb" super name, path end -- cgit v1.2.3