Class: Pod::Swift::ProjectPackages

Inherits:
Object
  • Object
show all
Defined in:
lib/cocoapods-spm/swift/package/project_packages.rb

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ ProjectPackages

Returns a new instance of ProjectPackages.

Raises:

  • (Informative)


6
7
8
9
10
11
12
13
# File 'lib/cocoapods-spm/swift/package/project_packages.rb', line 6

def initialize(options = {})
  @src_dir = options[:src_dir]
  raise Informative, "src_dir must not be nil" if @src_dir.nil?

  @json_dir = options[:write_json_to_dir]
  @pkg_desc_cache = {}
  load
end

Instance Method Details

#pkg_desc_of(name) ⇒ Object

Raises:

  • (Informative)


29
30
31
32
33
# File 'lib/cocoapods-spm/swift/package/project_packages.rb', line 29

def pkg_desc_of(name)
  return @pkg_desc_cache[name] if @pkg_desc_cache.key?(name)

  raise Informative, "Package description of `#{name}` does not exist!"
end

#resolve_recursive_targets_of(pkg_name, product_name) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/cocoapods-spm/swift/package/project_packages.rb', line 15

def resolve_recursive_targets_of(pkg_name, product_name)
  @recursive_targets_cache ||= {}
  return @recursive_targets_cache[product_name] if @recursive_targets_cache.key(product_name)

  res = []
  to_visit = pkg_desc_of(pkg_name).targets_of_product(product_name)
  until to_visit.empty?
    target = to_visit.pop
    res << target
    to_visit += target.resolve_dependencies(@pkg_desc_cache)
  end
  @recursive_targets_cache[product_name] = res.uniq(&:name)
end