aboutsummaryrefslogtreecommitdiffstats
path: root/Library
diff options
context:
space:
mode:
authorXu Cheng2015-06-10 16:00:09 +0800
committerXu Cheng2015-06-11 15:28:30 +0800
commitf2d0a88292cf3cafb8696f0bd02d4a02d0498658 (patch)
treeffb36335f23bb1529cefb1b4069e2830fb1c3dc0 /Library
parentd8876a9da4cff0843e65bcbfba1b268235e7e2b6 (diff)
downloadbrew-f2d0a88292cf3cafb8696f0bd02d4a02d0498658.tar.bz2
remove Pathname#find_formula
Closes Homebrew/homebrew#40486. Signed-off-by: Xu Cheng <xucheng@me.com>
Diffstat (limited to 'Library')
-rw-r--r--Library/Homebrew/extend/pathname.rb11
-rw-r--r--Library/Homebrew/formula.rb10
-rw-r--r--Library/Homebrew/formulary.rb13
3 files changed, 5 insertions, 29 deletions
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