Class: DependencyCollector
- Inherits:
-
Object
- Object
- DependencyCollector
- 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
-
#deps ⇒ Object
readonly
Returns the value of attribute deps.
-
#requirements ⇒ Object
readonly
Returns the value of attribute requirements.
Class Method Summary collapse
Instance Method Summary collapse
- #add(spec) ⇒ Object
- #build(spec) ⇒ Object
- #bzip2_dep_if_needed(tags) ⇒ Object
- #cache_key(spec) ⇒ Object
- #cvs_dep_if_needed(tags) ⇒ Object
- #fetch(spec) ⇒ Object
- #git_dep_if_needed(tags) ⇒ Object
-
#initialize ⇒ DependencyCollector
constructor
A new instance of DependencyCollector.
- #java_dep_if_needed(tags) ⇒ Object
- #subversion_dep_if_needed(tags) ⇒ Object
- #unzip_dep_if_needed(tags) ⇒ Object
- #xz_dep_if_needed(tags) ⇒ Object
Methods included from Cachable
Constructor Details
#initialize ⇒ DependencyCollector
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
#deps ⇒ Object (readonly)
Returns the value of attribute deps
23 24 25 |
# File 'Library/Homebrew/dependency_collector.rb', line 23 def deps @deps end |
#requirements ⇒ Object (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
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, = spec.is_a?(Hash) ? spec.first : spec parse_spec(spec, Array()) end |
#bzip2_dep_if_needed(tags) ⇒ Object
81 82 83 |
# File 'Library/Homebrew/dependency_collector.rb', line 81 def bzip2_dep_if_needed() Dependency.new("bzip2", ) 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() Dependency.new("cvs", ) 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() return if Utils::Git.available? Dependency.new("git", ) end |
#java_dep_if_needed(tags) ⇒ Object
85 86 87 |
# File 'Library/Homebrew/dependency_collector.rb', line 85 def java_dep_if_needed() JavaRequirement.new() 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() return if Utils::Svn.available? Dependency.new("subversion", ) end |
#unzip_dep_if_needed(tags) ⇒ Object
77 78 79 |
# File 'Library/Homebrew/dependency_collector.rb', line 77 def unzip_dep_if_needed() Dependency.new("unzip", ) 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() Dependency.new("xz", ) unless which("xz") end |