class Pod::Specification::Set::Presenter
Provides support for presenting a Pod
described by a {Set} in a consistent way across clients of CocoaPods-Core.
Attributes
@return [Set] the set that should be presented.
Public Class Methods
@param [Set] set @see set
.
# File lib/cocoapods-core/specification/set/presenter.rb, line 16 def initialize(set) @set = set end
Public Instance Methods
@return [String] A string that describes the deprecation of the pod.
If the pod is deprecated in favor of another pod it will contain information about that. If the pod is not deprecated returns nil.
@example Output example
"[DEPRECATED]" "[DEPRECATED in favor of NewAwesomePod]"
# File lib/cocoapods-core/specification/set/presenter.rb, line 122 def deprecation_description if spec.deprecated? description = '[DEPRECATED' description += if spec.deprecated_in_favor_of.nil? ']' else " in favor of #{spec.deprecated_in_favor_of}]" end description end end
@return [String] the description of the Pod
, if no description is
available the summary is returned.
# File lib/cocoapods-core/specification/set/presenter.rb, line 109 def description spec.description || spec.summary end
# File lib/cocoapods-core/specification/set/presenter.rb, line 197 def github_metrics metrics['github'] || {} end
@return [String] the homepage of the pod.
# File lib/cocoapods-core/specification/set/presenter.rb, line 95 def homepage spec.homepage end
@return [String] the type of the license of the Pod
.
@example
"MIT"
# File lib/cocoapods-core/specification/set/presenter.rb, line 163 def license spec.license[:type] if spec.license end
@!group Private Helpers
# File lib/cocoapods-core/specification/set/presenter.rb, line 193 def metrics @metrics ||= Metrics.pod(name) || {} end
@return [String] the name of the Pod
.
# File lib/cocoapods-core/specification/set/presenter.rb, line 26 def name @set.name end
@return [String] the platforms supported by the Pod
.
@example
"iOS" "iOS - OS X"
# File lib/cocoapods-core/specification/set/presenter.rb, line 150 def platform sorted_platforms = spec.available_platforms.sort do |a, b| a.to_s.downcase <=> b.to_s.downcase end sorted_platforms.join(' - ') end
@return [String] the URL of the source of the Pod
.
# File lib/cocoapods-core/specification/set/presenter.rb, line 137 def source_url url_keys = [:git, :svn, :http, :hg, :path] key = spec.source.keys.find { |k| url_keys.include?(k) } key ? spec.source[key] : 'No source url' end
@return [Array<String>] The name of the sources that contain the Pod
sorted alphabetically.
# File lib/cocoapods-core/specification/set/presenter.rb, line 65 def sources @set.sources.map(&:name).sort end
@return [Specification] the specification of the {Set}. If no
versions requirements where passed to the set it returns the highest available version.
# File lib/cocoapods-core/specification/set/presenter.rb, line 77 def spec @spec ||= @set.specification end
@return [Array] an array containing all the subspecs of the Pod
.
# File lib/cocoapods-core/specification/set/presenter.rb, line 169 def subspecs (spec.recursive_subspecs.any? && spec.recursive_subspecs) || nil end
@return [String] a short description, expected to be 140 characters
long of the Pod.
# File lib/cocoapods-core/specification/set/presenter.rb, line 102 def summary spec.summary end
@return [Version] the highest version of available for the Pod
.
# File lib/cocoapods-core/specification/set/presenter.rb, line 32 def version @set.versions.first end
@return [Array<Version>] all the versions available ascending
order.
# File lib/cocoapods-core/specification/set/presenter.rb, line 39 def versions @set.versions end
@return [String] all the versions available sorted from the highest
to the lowest.
@example Return example
"1.5pre, 1.4 [master repo] - 1.4 [test_repo repo]"
@note This method orders the sources by name.
# File lib/cocoapods-core/specification/set/presenter.rb, line 52 def versions_by_source result = [] versions_by_source = @set.versions_by_source @set.sources.sort.each do |source| versions = versions_by_source[source] result << "#{versions.map(&:to_s) * ', '} [#{source.name} repo]" end result * ' - ' end