Class: DependencyCollector Private

Inherits:
Object show all
Extended by:
Cachable
Includes:
OS::Linux::DependencyCollector, OS::Mac::DependencyCollector
Defined in:
dependency_collector.rb

Overview

This class is part of a private API. This class may only be used in the Homebrew/brew repository. Third parties should avoid using this class if possible, as it may be removed or changed without warning.

This class is used by depends_on in the formula DSL to turn dependency specifications into the proper kinds of dependencies and requirements.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Cachable

cache, clear_cache

Constructor Details

#initializevoid

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.



26
27
28
29
30
31
32
# File 'dependency_collector.rb', line 26

def initialize
  # Ensure this is synced with `initialize_dup` and `freeze` (excluding simple objects like integers and booleans)
  @deps = Dependencies.new
  @requirements = Requirements.new

  init_global_dep_tree_if_needed!
end

Instance Attribute Details

#depsObject (readonly)

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.



23
24
25
# File 'dependency_collector.rb', line 23

def deps
  @deps
end

#requirementsObject (readonly)

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.



23
24
25
# File 'dependency_collector.rb', line 23

def requirements
  @requirements
end

Class Method Details

.tar_needs_xz_dependency?Boolean

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.

Returns:

  • (Boolean)


127
128
129
# File 'dependency_collector.rb', line 127

def self.tar_needs_xz_dependency?
  !new.xz_dep_if_needed([]).nil?
end

Instance Method Details

#add(spec) ⇒ 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.



46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'dependency_collector.rb', line 46

def add(spec)
  case dep = fetch(spec)
  when Array
    dep.compact.each { |dep| @deps << dep }
  when Dependency
    @deps << dep
  when Requirement
    @requirements << dep
  when nil
    # no-op when we have a nil value
    nil
  else
    raise ArgumentError, "DependencyCollector#add passed something that isn't a Dependency or Requirement!"
  end
  dep
end

#build(spec) ⇒ 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.



78
79
80
81
# File 'dependency_collector.rb', line 78

def build(spec)
  spec, tags = spec.is_a?(Hash) ? spec.first : spec
  parse_spec(spec, Array(tags))
end

#bzip2_dep_if_needed(tags) ⇒ 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.



123
124
125
# File 'dependency_collector.rb', line 123

def bzip2_dep_if_needed(tags)
  Dependency.new("bzip2", [*tags, :implicit]) unless which("bzip2")
end

#cache_key(spec) ⇒ 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.



67
68
69
70
71
72
73
74
75
76
# File 'dependency_collector.rb', line 67

def cache_key(spec)
  if spec.is_a?(Resource)
    if spec.download_strategy <= CurlDownloadStrategy
      return "#{spec.download_strategy}#{File.extname(spec.url).split("?").first}"
    end

    return spec.download_strategy
  end
  spec
end

#curl_dep_if_needed(tags) ⇒ 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.



96
97
98
# File 'dependency_collector.rb', line 96

def curl_dep_if_needed(tags)
  Dependency.new("curl", [*tags, :implicit])
end

#cvs_dep_if_needed(tags) ⇒ 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.



107
108
109
# File 'dependency_collector.rb', line 107

def cvs_dep_if_needed(tags)
  Dependency.new("cvs", [*tags, :implicit]) unless which("cvs")
end

#fetch(spec) ⇒ 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.



63
64
65
# File 'dependency_collector.rb', line 63

def fetch(spec)
  self.class.cache.fetch(cache_key(spec)) { |key| self.class.cache[key] = build(spec) }
end

#freezeObject

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.



40
41
42
43
44
# File 'dependency_collector.rb', line 40

def freeze
  @deps.freeze
  @requirements.freeze
  super
end

#gcc_dep_if_needed(related_formula_names) ⇒ Dependency?

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.

Parameters:

Returns:



84
# File 'dependency_collector.rb', line 84

def gcc_dep_if_needed(related_formula_names); end

#git_dep_if_needed(tags) ⇒ 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.



89
90
91
92
93
94
# File 'dependency_collector.rb', line 89

def git_dep_if_needed(tags)
  require "utils/git"
  return if Utils::Git.available?

  Dependency.new("git", [*tags, :implicit])
end

#glibc_dep_if_needed(related_formula_names) ⇒ Dependency?

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.

Parameters:

Returns:



87
# File 'dependency_collector.rb', line 87

def glibc_dep_if_needed(related_formula_names); end

#initialize_dup(other) ⇒ 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.



34
35
36
37
38
# File 'dependency_collector.rb', line 34

def initialize_dup(other)
  super
  @deps = @deps.dup
  @requirements = @requirements.dup
end

#subversion_dep_if_needed(tags) ⇒ 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.



100
101
102
103
104
105
# File 'dependency_collector.rb', line 100

def subversion_dep_if_needed(tags)
  require "utils/svn"
  return if Utils::Svn.available?

  Dependency.new("subversion", [*tags, :implicit])
end

#unzip_dep_if_needed(tags) ⇒ 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.



119
120
121
# File 'dependency_collector.rb', line 119

def unzip_dep_if_needed(tags)
  Dependency.new("unzip", [*tags, :implicit]) unless which("unzip")
end

#xz_dep_if_needed(tags) ⇒ 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.



111
112
113
# File 'dependency_collector.rb', line 111

def xz_dep_if_needed(tags)
  Dependency.new("xz", [*tags, :implicit]) unless which("xz")
end

#zstd_dep_if_needed(tags) ⇒ 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.



115
116
117
# File 'dependency_collector.rb', line 115

def zstd_dep_if_needed(tags)
  Dependency.new("zstd", [*tags, :implicit]) unless which("zstd")
end