From a569261a9bdc16c76ef8b2b709c4a311206bbfdf Mon Sep 17 00:00:00 2001 From: Jack Nagel Date: Wed, 23 Jan 2013 00:26:24 -0600 Subject: Formula#recursive_dependencies This behaves like recursive_deps, but the resulting list consists of Dependency objects instead of Formula objects. The list maintains the installable order property of recursive_deps. While in the area, add some comments clarifying the purpose of related methods. --- Library/Homebrew/formula.rb | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) (limited to 'Library') diff --git a/Library/Homebrew/formula.rb b/Library/Homebrew/formula.rb index e3d199718..453a06ef7 100644 --- a/Library/Homebrew/formula.rb +++ b/Library/Homebrew/formula.rb @@ -444,19 +444,35 @@ 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 - def self.expand_deps f - f.deps.map do |dep| - f_dep = Formula.factory dep.to_s - expand_deps(f_dep) << f_dep - end + # Like recursive_deps, but returns a list of Dependency objects instead + # of Formula objects. + def recursive_dependencies + Formula.expand_dependencies(self).flatten.uniq end + # The full set of Requirements for this formula's dependency tree. def recursive_requirements reqs = ComparableSet.new recursive_deps.each { |dep| reqs.merge dep.requirements } -- cgit v1.2.3