Class: DependencyCollector

Inherits:
Object
  • Object
show all
Extended by:
Cachable, T::Sig
Defined in:
extend/os/mac/dependency_collector.rb,
dependency_collector.rb

Overview

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



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

def initialize
  @deps = Dependencies.new
  @requirements = Requirements.new
end

Instance Attribute Details

#depsObject (readonly)

Returns the value of attribute deps.



25
26
27
# File 'dependency_collector.rb', line 25

def deps
  @deps
end

#requirementsObject (readonly)

Returns the value of attribute requirements.



25
26
27
# File 'dependency_collector.rb', line 25

def requirements
  @requirements
end

Class Method Details

.tar_needs_xz_dependency?Boolean

Returns:

  • (Boolean)


88
89
90
# File 'dependency_collector.rb', line 88

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

Instance Method Details

#add(spec) ⇒ Object



33
34
35
36
37
38
39
40
41
# File 'dependency_collector.rb', line 33

def add(spec)
  case dep = fetch(spec)
  when Dependency
    @deps << dep
  when Requirement
    @requirements << dep
  end
  dep
end

#build(spec) ⇒ Object



55
56
57
58
# File 'dependency_collector.rb', line 55

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

#bzip2_dep_if_needed(tags) ⇒ Object



22
# File 'extend/os/mac/dependency_collector.rb', line 22

def bzip2_dep_if_needed(tags); end

#cache_key(spec) ⇒ Object



47
48
49
50
51
52
53
# File 'dependency_collector.rb', line 47

def cache_key(spec)
  if spec.is_a?(Resource) && spec.download_strategy == CurlDownloadStrategy
    File.extname(spec.url)
  else
    spec
  end
end

#cvs_dep_if_needed(tags) ⇒ Object



14
15
16
# File 'extend/os/mac/dependency_collector.rb', line 14

def cvs_dep_if_needed(tags)
  Dependency.new("cvs", tags)
end

#fetch(spec) ⇒ Object



43
44
45
# File 'dependency_collector.rb', line 43

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

#git_dep_if_needed(tags) ⇒ Object



8
# File 'extend/os/mac/dependency_collector.rb', line 8

def git_dep_if_needed(tags); end

#subversion_dep_if_needed(tags) ⇒ Object



10
11
12
# File 'extend/os/mac/dependency_collector.rb', line 10

def subversion_dep_if_needed(tags)
  Dependency.new("subversion", tags) if MacOS.version >= :catalina
end

#unzip_dep_if_needed(tags) ⇒ Object



20
# File 'extend/os/mac/dependency_collector.rb', line 20

def unzip_dep_if_needed(tags); end

#xz_dep_if_needed(tags) ⇒ Object



18
# File 'extend/os/mac/dependency_collector.rb', line 18

def xz_dep_if_needed(tags); end