diff options
| author | Alyssa Ross | 2016-10-05 20:56:07 +0100 |
|---|---|---|
| committer | Alyssa Ross | 2016-10-25 22:34:35 +0100 |
| commit | 0cd983487c97ff373ccd0a73631ff57ae1b3baa0 (patch) | |
| tree | e82c715faf11369dbebd94bfe1cdcf2f95b0cf84 /Library/Homebrew | |
| parent | 99a7fb8cb4c68fa3d7821fb2d164fbd1211437c1 (diff) | |
| download | brew-0cd983487c97ff373ccd0a73631ff57ae1b3baa0.tar.bz2 | |
missing_deps: extract formula instance method
Diffstat (limited to 'Library/Homebrew')
| -rw-r--r-- | Library/Homebrew/diagnostic.rb | 22 | ||||
| -rw-r--r-- | Library/Homebrew/formula.rb | 20 |
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 = { |
