Class: DependencyCollector

Inherits:
Object
  • Object
show all
Extended by:
Cachable
Defined in:
brew/Library/Homebrew/dependency_collector.rb,
brew/Library/Homebrew/extend/os/mac/dependency_collector.rb,
brew/Library/Homebrew/extend/os/linux/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

#initializeDependencyCollector

Returns a new instance of DependencyCollector



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

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

Instance Attribute Details

#depsObject (readonly)

Returns the value of attribute deps



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

def deps
  @deps
end

#requirementsObject (readonly)

Returns the value of attribute requirements



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

def requirements
  @requirements
end

Class Method Details

.tar_needs_xz_dependency?Boolean

Returns:

  • (Boolean)


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

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

Instance Method Details

#add(spec) ⇒ Object



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

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

#build(spec) ⇒ Object



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

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

#bzip2_dep_if_needed(tags) ⇒ Object



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

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

#cache_key(spec) ⇒ Object



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

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



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

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

#fetch(spec) ⇒ Object



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

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

#git_dep_if_needed(tags) ⇒ Object



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

def git_dep_if_needed(tags)
  return if Utils.git_available?

  Dependency.new("git", tags)
end

#java_dep_if_needed(tags) ⇒ Object



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

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

#subversion_dep_if_needed(tags) ⇒ Object



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

def subversion_dep_if_needed(tags)
  return if Utils.svn_available?

  Dependency.new("subversion", tags)
end

#unzip_dep_if_needed(tags) ⇒ Object



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

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

#xz_dep_if_needed(tags) ⇒ Object



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

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