aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew
diff options
context:
space:
mode:
authorAlyssa Ross2016-10-05 20:56:07 +0100
committerAlyssa Ross2016-10-25 22:34:35 +0100
commit0cd983487c97ff373ccd0a73631ff57ae1b3baa0 (patch)
treee82c715faf11369dbebd94bfe1cdcf2f95b0cf84 /Library/Homebrew
parent99a7fb8cb4c68fa3d7821fb2d164fbd1211437c1 (diff)
downloadbrew-0cd983487c97ff373ccd0a73631ff57ae1b3baa0.tar.bz2
missing_deps: extract formula instance method
Diffstat (limited to 'Library/Homebrew')
-rw-r--r--Library/Homebrew/diagnostic.rb22
-rw-r--r--Library/Homebrew/formula.rb20
2 files changed, 24 insertions, 18 deletions
diff --git a/Library/Homebrew/diagnostic.rb b/Library/Homebrew/diagnostic.rb
index a5b1302bd..b434c394b 100644
--- a/Library/Homebrew/diagnostic.rb
+++ b/Library/Homebrew/diagnostic.rb
@@ -8,27 +8,13 @@ require "utils/shell"
module Homebrew
module Diagnostic
def self.missing_deps(ff, hide = nil)
- hide ||= []
-
missing = {}
ff.each do |f|
- missing_deps = f.recursive_dependencies do |dependent, dep|
- if dep.optional? || dep.recommended?
- tab = Tab.for_formula(dependent)
- Dependency.prune unless tab.with?(dep)
- elsif dep.build?
- Dependency.prune
- end
- end
-
- missing_deps.map!(&:to_formula)
- missing_deps.reject! do |d|
- !hide.include?(d.name) && d.installed_prefixes.any?
- end
+ missing_dependencies = f.missing_dependencies(hide: hide)
- unless missing_deps.empty?
- yield f.full_name, missing_deps if block_given?
- missing[f.full_name] = missing_deps
+ unless missing_dependencies.empty?
+ yield f.full_name, missing_dependencies if block_given?
+ missing[f.full_name] = missing_dependencies
end
end
missing
diff --git a/Library/Homebrew/formula.rb b/Library/Homebrew/formula.rb
index c2467b7bc..947313047 100644
--- a/Library/Homebrew/formula.rb
+++ b/Library/Homebrew/formula.rb
@@ -1466,6 +1466,26 @@ class Formula
recursive_dependencies.reject(&:build?)
end
+ # Returns a list of formulae depended on by this formula that aren't
+ # installed
+ def missing_dependencies(hide: nil)
+ hide ||= []
+ missing_dependencies = recursive_dependencies do |dependent, dep|
+ if dep.optional? || dep.recommended?
+ tab = Tab.for_formula(dependent)
+ Dependency.prune unless tab.with?(dep)
+ elsif dep.build?
+ Dependency.prune
+ end
+ end
+
+ missing_dependencies.map!(&:to_formula)
+ missing_dependencies.select! do |d|
+ hide.include?(d.name) || d.installed_prefixes.empty?
+ end
+ missing_dependencies
+ end
+
# @private
def to_hash
hsh = {