Module: DependenciesHelpers Private

Included in:
Homebrew
Defined in:
Library/Homebrew/dependencies_helpers.rb

Overview

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

Helper functions for dependencies.

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.dependents(formulae_or_casks) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.


75
76
77
78
79
80
81
82
83
# File 'Library/Homebrew/dependencies_helpers.rb', line 75

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. You should avoid using this method if possible, as it may be removed or be changed in the future.


9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'Library/Homebrew/dependencies_helpers.rb', line 9

def args_includes_ignores(args)
  includes = []
  ignores = []

  if args.include_build?
    includes << "build?"
  else
    ignores << "build?"
  end

  if args.include_test?
    includes << "test?"
  else
    ignores << "test?"
  end

  if args.include_optional?
    includes << "optional?"
  else
    ignores << "optional?"
  end

  ignores << "recommended?" if args.skip_recommended?

  [includes, ignores]
end

#recursive_includes(klass, root_dependent, includes, ignores) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.


36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'Library/Homebrew/dependencies_helpers.rb', line 36

def recursive_includes(klass, root_dependent, includes, ignores)
  type = if klass == Dependency
    :dependencies
  elsif klass == Requirement
    :requirements
  else
    raise ArgumentError, "Invalid class argument: #{klass}"
  end

  root_dependent.send("recursive_#{type}") do |dependent, dep|
    if dep.recommended?
      klass.prune if ignores.include?("recommended?") || dependent.build.without?(dep)
    elsif dep.optional?
      klass.prune if !includes.include?("optional?") && !dependent.build.with?(dep)
    elsif dep.build? || dep.test?
      keep = false
      keep ||= dep.test? && includes.include?("test?") && dependent == root_dependent
      keep ||= dep.build? && includes.include?("build?")
      klass.prune unless keep
    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.
    if type == :dependencies &&
       dep.is_a?(TapDependency) &&
       !dep.tap.installed?
      Dependency.keep_but_prune_recursive_deps
    end
  end
end

#reject_ignores(dependables, ignores, includes) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.


67
68
69
70
71
72
73
# File 'Library/Homebrew/dependencies_helpers.rb', line 67

def reject_ignores(dependables, ignores, includes)
  dependables.reject do |dep|
    next false unless ignores.any? { |ignore| dep.send(ignore) }

    includes.none? { |include| dep.send(include) }
  end
end