Class: Pod::SPM::Resolver::Result

Inherits:
Object
  • Object
show all
Defined in:
lib/cocoapods-spm/resolver/result.rb

Direct Known Subclasses

WritableResult

Defined Under Namespace

Classes: WritableResult

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Result

Returns a new instance of Result.



20
21
22
23
24
25
# File 'lib/cocoapods-spm/resolver/result.rb', line 20

def initialize(options = {})
  @spm_pkgs = options[:spm_pkgs] || []
  @spm_dependencies_by_target = options[:spm_dependencies_by_target] || {}
  @spm_products = options[:spm_products] || {}
   = options[:metadata_cache] || {}
end

Instance Attribute Details

#metadata_cacheObject (readonly)

Returns the value of attribute metadata_cache.



18
19
20
# File 'lib/cocoapods-spm/resolver/result.rb', line 18

def 
  
end

#spm_dependencies_by_targetObject (readonly)

Returns the value of attribute spm_dependencies_by_target.



18
19
20
# File 'lib/cocoapods-spm/resolver/result.rb', line 18

def spm_dependencies_by_target
  @spm_dependencies_by_target
end

#spm_pkgsObject (readonly)

Returns the value of attribute spm_pkgs.



18
19
20
# File 'lib/cocoapods-spm/resolver/result.rb', line 18

def spm_pkgs
  @spm_pkgs
end

#spm_productsObject (readonly)

Returns the value of attribute spm_products.



18
19
20
# File 'lib/cocoapods-spm/resolver/result.rb', line 18

def spm_products
  @spm_products
end

Instance Method Details

#linker_flags_for(target) ⇒ Object



41
42
43
44
45
46
47
# File 'lib/cocoapods-spm/resolver/result.rb', line 41

def linker_flags_for(target)
  flags = spm_dependencies_for(target).flat_map { |d| d.pkg.linker_flags }
  flags += spm_products_for(target).map do |p|
    p.linked_as_framework? ? "-framework \"#{p.name}\"" : "-l\"#{p.name}.o\""
  end
  flags.uniq
end

#metadata_of(name) ⇒ Object

Raises:

  • (Informative)


27
28
29
30
31
# File 'lib/cocoapods-spm/resolver/result.rb', line 27

def (name)
  return [name] if .key?(name)

  raise Informative, "Metadata of `#{name}` does not exist"
end

#spm_dependencies_for(target) ⇒ Object



33
34
35
# File 'lib/cocoapods-spm/resolver/result.rb', line 33

def spm_dependencies_for(target)
  @spm_dependencies_by_target[target.to_s].to_a
end

#spm_products_for(target) ⇒ Object



37
38
39
# File 'lib/cocoapods-spm/resolver/result.rb', line 37

def spm_products_for(target)
  spm_dependencies_for(target).flat_map { |d| @spm_products[d.product].to_a }.uniq(&:name)
end