diff options
| author | Jack Nagel | 2013-01-23 00:26:26 -0600 |
|---|---|---|
| committer | Jack Nagel | 2013-01-26 12:14:46 -0600 |
| commit | 55681ca2019a5d52dc4982c64f65fca5a4bc974d (patch) | |
| tree | da89af3d2b818e11ad51cb459d6a55d02add394d /Library/Homebrew/formula.rb | |
| parent | d0161091d8a020652f046fc92db06570cf017376 (diff) | |
| download | brew-55681ca2019a5d52dc4982c64f65fca5a4bc974d.tar.bz2 | |
Dependency.expand_dependencies
Move Formula.expand_dependencies into the Dependency class, and extend
it to allow arbitrary filters to be applied when enumerating deps.
When supplied with a block, expand_dependencies will yield a [dependent,
dependency] pair for each dependency, allowing callers to filter out
dependencies that may not be applicable or useful in a given situation.
Deps can be skipped by simple calling Dependency.prune in the block,
e.g.:
Dependency.expand_dependencies do |f, dep|
Dependency.prune if dep.to_formula.installed?
end
The return value of the method is the filtered list.
If no block is supplied, a default filter that omits optional or
recommended deps based on what the dependent formula has requested is
applied.
Formula#recursive_dependencies is now implemented on top of this,
allowing FormulaInstaller to exact detailed control over what deps are
installed. `brew missing` and `brew upgrade` can learn to use this to
apply the installed options set when expanding dependencies.
Move Formula.expand_deps and Formula#recursive_deps into compat, because
these methods do not respect the new optional and recommended tags and
thus should no longer be used.
Diffstat (limited to 'Library/Homebrew/formula.rb')
| -rw-r--r-- | Library/Homebrew/formula.rb | 30 |
1 files changed, 4 insertions, 26 deletions
diff --git a/Library/Homebrew/formula.rb b/Library/Homebrew/formula.rb index 9801e0c47..e5b5d58fc 100644 --- a/Library/Homebrew/formula.rb +++ b/Library/Homebrew/formula.rb @@ -457,32 +457,10 @@ class Formula requirements.select { |r| r.is_a? ConflictRequirement } end - # for Formula objects - def self.expand_deps f - f.deps.map do |dep| - f_dep = Formula.factory dep.to_s - expand_deps(f_dep) << f_dep - end - end - - # for Dependency objects - def self.expand_dependencies f - f.deps.map do |dep| - f_dep = Formula.factory dep.to_s - expand_dependencies(f_dep) << dep - end - end - - # deps are in an installable order - # which means if a depends on b then b will be ordered before a in this list - def recursive_deps - Formula.expand_deps(self).flatten.uniq - end - - # Like recursive_deps, but returns a list of Dependency objects instead - # of Formula objects. - def recursive_dependencies - Formula.expand_dependencies(self).flatten.uniq + # Returns a list of Dependency objects in an installable order, which + # means if a depends on b then b will be ordered before a in this list + def recursive_dependencies(&block) + Dependency.expand(self, &block) end # The full set of Requirements for this formula's dependency tree. |
