Module: DependenciesHelpers Private
- Extended by:
- T::Helpers
- Included in:
- Homebrew::Cmd::Deps, Homebrew::Cmd::Uses
- Defined in:
- dependencies_helpers.rb
Overview
This module is part of a private API. This module may only be used in the Homebrew/brew repository. Third parties should avoid using this module if possible, as it may be removed or changed without warning.
Helper functions for dependencies.
Class Method Summary collapse
Instance Method Summary collapse
- #args_includes_ignores(args) ⇒ Object private
- #recursive_includes(klass, root_dependent, includes, ignores) ⇒ Object private
- #select_includes(dependables, ignores, includes) ⇒ Object private
Class Method Details
.dependents(formulae_or_casks) ⇒ Object
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
53 54 55 56 57 58 59 60 61 |
# File 'dependencies_helpers.rb', line 53 def dependents(formulae_or_casks) formulae_or_casks.map do |formula_or_cask| if formula_or_cask.is_a?(Formula) formula_or_cask else CaskDependent.new(formula_or_cask) end end end |
Instance Method Details
#args_includes_ignores(args) ⇒ Object
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'dependencies_helpers.rb', line 12 def args_includes_ignores(args) includes = [:required?, :recommended?] # included by default includes << :build? if args.include_build? includes << :test? if args.include_test? includes << :optional? if args.include_optional? ignores = [] ignores << :recommended? if args.skip_recommended? ignores << :satisfied? if args.missing? [includes, ignores] end |
#recursive_includes(klass, root_dependent, includes, ignores) ⇒ Object
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'dependencies_helpers.rb', line 25 def recursive_includes(klass, root_dependent, includes, ignores) raise ArgumentError, "Invalid class argument: #{klass}" if klass != Dependency && klass != Requirement cache_key = "recursive_includes_#{includes}_#{ignores}" klass.(root_dependent, cache_key:) do |dependent, dep| klass.prune if ignores.any? { |ignore| dep.public_send(ignore) } klass.prune if includes.none? do |include| # Ignore indirect test dependencies next if include == :test? && dependent != root_dependent dep.public_send(include) end # If a tap isn't installed, we can't find the dependencies of one of # its formulae and an exception will be thrown if we try. Dependency.keep_but_prune_recursive_deps if klass == Dependency && dep.tap && !dep.tap.installed? end end |
#select_includes(dependables, ignores, includes) ⇒ Object
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
45 46 47 48 49 50 51 |
# File 'dependencies_helpers.rb', line 45 def select_includes(dependables, ignores, includes) dependables.select do |dep| next false if ignores.any? { |ignore| dep.public_send(ignore) } includes.any? { |include| dep.public_send(include) } end end |