Class: DependencyCollector

Inherits:
Object
  • Object
show all
Extended by:
Cachable
Defined in:
Library/Homebrew/dependency_collector.rb,
Library/Homebrew/extend/os/mac/dependency_collector.rb,
Library/Homebrew/extend/os/linux/dependency_collector.rb

Overview

typed: true frozen_string_literal: true

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Cachable

cache, clear_cache

Constructor Details

#initializeDependencyCollector

Returns a new instance of DependencyCollector.


25
26
27
28
# File 'Library/Homebrew/dependency_collector.rb', line 25

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

Instance Attribute Details

#depsObject (readonly)

Returns the value of attribute deps


23
24
25
# File 'Library/Homebrew/dependency_collector.rb', line 23

def deps
  @deps
end

#requirementsObject (readonly)

Returns the value of attribute requirements


23
24
25
# File 'Library/Homebrew/dependency_collector.rb', line 23

def requirements
  @requirements
end

Class Method Details

.tar_needs_xz_dependency?Boolean

Returns:

  • (Boolean)

89
90
91
# File 'Library/Homebrew/dependency_collector.rb', line 89

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

Instance Method Details

#add(spec) ⇒ Object


30
31
32
33
34
35
36
37
38
# File 'Library/Homebrew/dependency_collector.rb', line 30

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

#build(spec) ⇒ Object


52
53
54
55
# File 'Library/Homebrew/dependency_collector.rb', line 52

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

#bzip2_dep_if_needed(tags) ⇒ Object


81
82
83
# File 'Library/Homebrew/dependency_collector.rb', line 81

def bzip2_dep_if_needed(tags)
  Dependency.new("bzip2", tags) unless which("bzip2")
end

#cache_key(spec) ⇒ Object


44
45
46
47
48
49
50
# File 'Library/Homebrew/dependency_collector.rb', line 44

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


69
70
71
# File 'Library/Homebrew/dependency_collector.rb', line 69

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

#fetch(spec) ⇒ Object


40
41
42
# File 'Library/Homebrew/dependency_collector.rb', line 40

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

#git_dep_if_needed(tags) ⇒ Object


57
58
59
60
61
# File 'Library/Homebrew/dependency_collector.rb', line 57

def git_dep_if_needed(tags)
  return if Utils::Git.available?

  Dependency.new("git", tags)
end

#java_dep_if_needed(tags) ⇒ Object


85
86
87
# File 'Library/Homebrew/dependency_collector.rb', line 85

def java_dep_if_needed(tags)
  JavaRequirement.new(tags)
end

#subversion_dep_if_needed(tags) ⇒ Object


63
64
65
66
67
# File 'Library/Homebrew/dependency_collector.rb', line 63

def subversion_dep_if_needed(tags)
  return if Utils::Svn.available?

  Dependency.new("subversion", tags)
end

#unzip_dep_if_needed(tags) ⇒ Object


77
78
79
# File 'Library/Homebrew/dependency_collector.rb', line 77

def unzip_dep_if_needed(tags)
  Dependency.new("unzip", tags) unless which("unzip")
end

#xz_dep_if_needed(tags) ⇒ Object


73
74
75
# File 'Library/Homebrew/dependency_collector.rb', line 73

def xz_dep_if_needed(tags)
  Dependency.new("xz", tags) unless which("xz")
end