Class: Pod::SPM::Metadata
- Inherits:
-
Object
- Object
- Pod::SPM::Metadata
- Defined in:
- lib/cocoapods-spm/metadata.rb
Instance Attribute Summary collapse
-
#raw ⇒ Object
readonly
Returns the value of attribute raw.
Class Method Summary collapse
Instance Method Summary collapse
- #[](key) ⇒ Object
-
#initialize(raw) ⇒ Metadata
constructor
A new instance of Metadata.
- #macro_impl_name ⇒ Object
- #product_names_of_target(name) ⇒ Object
- #products ⇒ Object
- #targets ⇒ Object
- #targets_of_type(type) ⇒ Object
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
#raw ⇒ Object (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
#[](key) ⇒ Object
24 25 26 |
# File 'lib/cocoapods-spm/metadata.rb', line 24 def [](key) raw[key] end |
#macro_impl_name ⇒ Object
45 46 47 |
# File 'lib/cocoapods-spm/metadata.rb', line 45 def macro_impl_name targets_of_type("macro").first&.fetch("name") end |
#product_names_of_target(name) ⇒ Object
36 37 38 39 |
# File 'lib/cocoapods-spm/metadata.rb', line 36 def product_names_of_target(name) names = products.select { |h| h["targets"].include?(name) }.map { |h| h["name"] } names.empty? ? [name] : names end |
#products ⇒ Object
32 33 34 |
# File 'lib/cocoapods-spm/metadata.rb', line 32 def products raw["products"] end |
#targets ⇒ Object
28 29 30 |
# File 'lib/cocoapods-spm/metadata.rb', line 28 def targets raw["targets"] end |
#targets_of_type(type) ⇒ Object
41 42 43 |
# File 'lib/cocoapods-spm/metadata.rb', line 41 def targets_of_type(type) targets.select { |t| t["type"] == type } end |