Class: Pod::SPM::Metadata

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(raw) ⇒ Metadata

Returns a new instance of Metadata.



8
9
10
# File 'lib/cocoapods-spm/metadata.rb', line 8

def initialize(raw)
  @raw = raw
end

Instance Attribute Details

#rawObject (readonly)

Returns the value of attribute raw.



6
7
8
# File 'lib/cocoapods-spm/metadata.rb', line 6

def raw
  @raw
end

Class Method Details

.for_pod(name) ⇒ Object



20
21
22
# File 'lib/cocoapods-spm/metadata.rb', line 20

def self.for_pod(name)
  from_file(Config.instance.macro_root_dir / name / "metadata.json")
end

.from_file(path) ⇒ Object



16
17
18
# File 'lib/cocoapods-spm/metadata.rb', line 16

def self.from_file(path)
  from_s(File.read(path))
end

.from_s(str) ⇒ Object



12
13
14
# File 'lib/cocoapods-spm/metadata.rb', line 12

def self.from_s(str)
  new(JSON.parse(str))
end

Instance Method Details

#macro_impl_nameObject



32
33
34
# File 'lib/cocoapods-spm/metadata.rb', line 32

def macro_impl_name
  targets_of_type("macro").first&.fetch("name")
end

#targetsObject



24
25
26
# File 'lib/cocoapods-spm/metadata.rb', line 24

def targets
  raw["targets"]
end

#targets_of_type(type) ⇒ Object



28
29
30
# File 'lib/cocoapods-spm/metadata.rb', line 28

def targets_of_type(type)
  targets.select { |t| t["type"] == type }
end