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

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



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

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

Instance Attribute Details

#depsObject (readonly)

Returns the value of attribute deps



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

def deps
  @deps
end

#requirementsObject (readonly)

Returns the value of attribute requirements



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

def requirements
  @requirements
end

Class Method Details

.tar_needs_xz_dependency?Boolean

Returns:

  • (Boolean)


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

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

Instance Method Details

#add(spec) ⇒ Object



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

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

#build(spec) ⇒ Object



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

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

#cache_key(spec) ⇒ Object



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

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



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

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

#fetch(spec) ⇒ Object



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

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

#git_dep_if_needed(tags) ⇒ Object



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

def git_dep_if_needed(tags)
  return if Utils.git_available?
  Dependency.new("git", tags)
end

#ld64_dep_if_neededObject



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

def ld64_dep_if_needed(*); end

#subversion_dep_if_needed(tags) ⇒ Object



60
61
62
63
# File 'Library/Homebrew/dependency_collector.rb', line 60

def subversion_dep_if_needed(tags)
  return if Utils.svn_available?
  Dependency.new("subversion", tags)
end

#xz_dep_if_needed(tags) ⇒ Object



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

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