Class: Pod::Specification::Set
- Inherits:
-
Object
- Object
- Pod::Specification::Set
- Defined in:
- lib/cocoapods-core/specification/set.rb,
lib/cocoapods-core/specification/set/presenter.rb
Overview
The order in which the sets are provided is used to select a specification if multiple are available for a given version.
The set class is not and should be not aware of the backing store of a Source.
A Specification::Set is responsible of handling all the specifications of a Pod. This class stores the information of the dependencies that required a Pod in the resolution process.
Direct Known Subclasses
Defined Under Namespace
Classes: External, Head, Presenter
Instance Attribute Summary collapse
-
#name ⇒ String
readonly
The name of the Pod.
-
#sources ⇒ Array<Source>
readonly
The sources that contain the specifications for the available versions of a Pod.
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#highest_version ⇒ Version
The highest version known of the specification.
-
#highest_version_spec_path ⇒ Pathname
The path of the highest version.
-
#initialize(name, sources = []) ⇒ Set
constructor
A new instance of Set.
-
#specification ⇒ Specification
The top level specification of the Pod for the #required_version.
-
#specification_paths_for_version(version) ⇒ Array<String>
The paths to specifications for the given version.
-
#to_hash ⇒ Hash
Returns a hash representation of the set composed by dumb data types.
- #to_s ⇒ Object (also: #inspect)
-
#versions ⇒ Array<Version>
All the available versions for the Pod, sorted from highest to lowest.
-
#versions_by_source ⇒ Hash{Source => Version}
All the available versions for the Pod grouped by source.
Constructor Details
#initialize(name, sources = []) ⇒ Set
Returns a new instance of Set.
32 33 34 35 |
# File 'lib/cocoapods-core/specification/set.rb', line 32 def initialize(name, sources = []) @name = name @sources = Array(sources) end |
Instance Attribute Details
#name ⇒ String (readonly)
Returns the name of the Pod.
19 20 21 |
# File 'lib/cocoapods-core/specification/set.rb', line 19 def name @name end |
#sources ⇒ Array<Source> (readonly)
Returns the sources that contain the specifications for the available versions of a Pod.
24 25 26 |
# File 'lib/cocoapods-core/specification/set.rb', line 24 def sources @sources end |
Instance Method Details
#==(other) ⇒ Object
90 91 92 93 94 |
# File 'lib/cocoapods-core/specification/set.rb', line 90 def ==(other) self.class == other.class && @name == other.name && @sources.map(&:name) == other.sources.map(&:name) end |
#highest_version ⇒ Version
Returns The highest version known of the specification.
65 66 67 |
# File 'lib/cocoapods-core/specification/set.rb', line 65 def highest_version versions.first end |
#highest_version_spec_path ⇒ Pathname
If multiple sources have a specification for the #required_version, the order in which they are provided is used to disambiguate.
Returns The path of the highest version.
75 76 77 |
# File 'lib/cocoapods-core/specification/set.rb', line 75 def highest_version_spec_path specification_paths_for_version(highest_version).first end |
#specification ⇒ Specification
If multiple sources have a specification for the #required_version, the order in which they are provided is used to disambiguate.
Returns the top level specification of the Pod for the #required_version.
44 45 46 |
# File 'lib/cocoapods-core/specification/set.rb', line 44 def specification Specification.from_file(highest_version_spec_path) end |
#specification_paths_for_version(version) ⇒ Array<String>
Returns the paths to specifications for the given version.
51 52 53 54 |
# File 'lib/cocoapods-core/specification/set.rb', line 51 def specification_paths_for_version(version) sources = @sources.select { |source| versions_by_source[source].include?(version) } sources.map { |source| source.specification_path(name, version) } end |
#to_hash ⇒ Hash
Returns a hash representation of the set composed by dumb data types.
112 113 114 115 116 117 118 119 120 121 122 123 |
# File 'lib/cocoapods-core/specification/set.rb', line 112 def to_hash versions = versions_by_source.reduce({}) do |memo, (source, version)| memo[source.name] = version.map(&:to_s) memo end { 'name' => name, 'versions' => versions, 'highest_version' => highest_version.to_s, 'highest_version_spec' => highest_version_spec_path.to_s, } end |
#to_s ⇒ Object Also known as: inspect
96 97 98 |
# File 'lib/cocoapods-core/specification/set.rb', line 96 def to_s "#<#{self.class.name} for `#{name}' available at `#{sources.map(&:name).join(', ')}'>" end |
#versions ⇒ Array<Version>
Returns all the available versions for the Pod, sorted from highest to lowest.
59 60 61 |
# File 'lib/cocoapods-core/specification/set.rb', line 59 def versions versions_by_source.values.flatten.uniq.sort.reverse end |
#versions_by_source ⇒ Hash{Source => Version}
Returns all the available versions for the Pod grouped by source.
82 83 84 85 86 87 88 |
# File 'lib/cocoapods-core/specification/set.rb', line 82 def versions_by_source result = {} sources.each do |source| result[source] = source.versions(name) end result end |