Class: Pod::Specification::Set::Presenter
- Inherits:
-
Object
- Object
- Pod::Specification::Set::Presenter
- Defined in:
- lib/cocoapods-core/specification/set/presenter.rb
Overview
Provides support for presenting a Pod described by a Pod::Specification::Set in a consistent way across clients of CocoaPods-Core.
Instance Attribute Summary collapse
-
#set ⇒ Set
readonly
The set that should be presented.
-
#statistics_provider ⇒ Statistics
readonly
The statistics provider.
Set Information collapse
-
#name ⇒ String
The name of the Pod.
-
#sources ⇒ Array<String>
The name of the sources that contain the Pod sorted alphabetically.
-
#verions_by_source ⇒ String
All the versions available sorted from the highest to the lowest.
-
#version ⇒ Version
The highest version of available for the Pod.
-
#versions ⇒ Array<Version>
All the versions available ascending order.
Specification Information collapse
-
#authors ⇒ String
The list of the authors of the Pod in sentence format.
-
#description ⇒ String
The description of the Pod, if no description is available the summary is returned.
-
#homepage ⇒ String
The homepage of the pod.
-
#license ⇒ String
The type of the license of the Pod.
-
#platform ⇒ String
The platforms supported by the Pod.
-
#source_url ⇒ String
The URL of the source of the Pod.
-
#spec ⇒ Specification
The specification of the Pod::Specification::Set.
-
#subspecs ⇒ Array
An array containing all the subspecs of the Pod.
-
#summary ⇒ String
A short description, expected to be 140 characters long of the Pod.
Statistics collapse
-
#creation_date ⇒ Time
The creation date of the first known ‘podspec` of the Pod.
-
#github_forks ⇒ Integer
The GitHub forks of the repo of the Pod.
-
#github_last_activity ⇒ String
The relative time of the last push of the repo the Pod.
-
#github_watchers ⇒ Integer
The GitHub likes of the repo of the Pod.
Instance Method Summary collapse
-
#initialize(set, statistics_provider = nil) ⇒ Presenter
constructor
A new instance of Presenter.
Constructor Details
#initialize(set, statistics_provider = nil) ⇒ Presenter
Returns a new instance of Presenter.
22 23 24 25 |
# File 'lib/cocoapods-core/specification/set/presenter.rb', line 22 def initialize(set, statistics_provider = nil) @set = set @statistics_provider = statistics_provider || Statistics.instance end |
Instance Attribute Details
#set ⇒ Set (readonly)
Returns the set that should be presented.
14 15 16 |
# File 'lib/cocoapods-core/specification/set/presenter.rb', line 14 def set @set end |
#statistics_provider ⇒ Statistics (readonly)
Returns The statistics provider.
18 19 20 |
# File 'lib/cocoapods-core/specification/set/presenter.rb', line 18 def statistics_provider @statistics_provider end |
Instance Method Details
#authors ⇒ String
In ruby 1.8.7 the authors are sorted by name because the hash doesn’t preserve the order in which they are defined in the podspec.
Returns the list of the authors of the Pod in sentence format.
99 100 101 102 103 104 105 106 |
# File 'lib/cocoapods-core/specification/set/presenter.rb', line 99 def return '' unless spec. if RUBY_VERSION == '1.8.7' spec..keys.sort.to_sentence else spec..keys.to_sentence end end |
#creation_date ⇒ Time
Returns the creation date of the first known ‘podspec` of the Pod.
173 174 175 |
# File 'lib/cocoapods-core/specification/set/presenter.rb', line 173 def creation_date statistics_provider.creation_date(@set) end |
#description ⇒ String
Returns the description of the Pod, if no description is available the summary is returned.
124 125 126 |
# File 'lib/cocoapods-core/specification/set/presenter.rb', line 124 def description spec.description || spec.summary end |
#github_forks ⇒ Integer
Returns the GitHub forks of the repo of the Pod.
185 186 187 |
# File 'lib/cocoapods-core/specification/set/presenter.rb', line 185 def github_forks statistics_provider.github_forks(@set) end |
#github_last_activity ⇒ String
Returns the relative time of the last push of the repo the Pod.
191 192 193 |
# File 'lib/cocoapods-core/specification/set/presenter.rb', line 191 def github_last_activity distance_from_now_in_words(statistics_provider.github_pushed_at(@set)) end |
#github_watchers ⇒ Integer
Returns the GitHub likes of the repo of the Pod.
179 180 181 |
# File 'lib/cocoapods-core/specification/set/presenter.rb', line 179 def github_watchers statistics_provider.github_watchers(@set) end |
#homepage ⇒ String
Returns the homepage of the pod.
110 111 112 |
# File 'lib/cocoapods-core/specification/set/presenter.rb', line 110 def homepage spec.homepage end |
#license ⇒ String
Returns the type of the license of the Pod.
156 157 158 |
# File 'lib/cocoapods-core/specification/set/presenter.rb', line 156 def license spec.license[:type] if spec.license end |
#name ⇒ String
Returns the name of the Pod.
33 34 35 |
# File 'lib/cocoapods-core/specification/set/presenter.rb', line 33 def name @set.name end |
#platform ⇒ String
Returns the platforms supported by the Pod.
143 144 145 146 147 148 |
# File 'lib/cocoapods-core/specification/set/presenter.rb', line 143 def platform sorted_platforms = spec.available_platforms.sort do |a, b| a.to_s.downcase <=> b.to_s.downcase end sorted_platforms.join(' - ') end |
#source_url ⇒ String
Returns the URL of the source of the Pod.
130 131 132 133 134 |
# File 'lib/cocoapods-core/specification/set/presenter.rb', line 130 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 |
#sources ⇒ Array<String>
Returns The name of the sources that contain the Pod sorted alphabetically.
72 73 74 |
# File 'lib/cocoapods-core/specification/set/presenter.rb', line 72 def sources @set.sources.map(&:name).sort end |
#spec ⇒ Specification
Returns the specification of the Pod::Specification::Set. If no versions requirements where passed to the set it returns the highest available version.
84 85 86 |
# File 'lib/cocoapods-core/specification/set/presenter.rb', line 84 def spec @spec ||= @set.specification end |
#subspecs ⇒ Array
Returns an array containing all the subspecs of the Pod.
162 163 164 |
# File 'lib/cocoapods-core/specification/set/presenter.rb', line 162 def subspecs (spec.recursive_subspecs.any? && spec.recursive_subspecs) || nil end |
#summary ⇒ String
Returns a short description, expected to be 140 characters long of the Pod.
117 118 119 |
# File 'lib/cocoapods-core/specification/set/presenter.rb', line 117 def summary spec.summary end |
#verions_by_source ⇒ String
This method orders the sources by name.
Returns all the versions available sorted from the highest to the lowest.
59 60 61 62 63 64 65 66 67 |
# File 'lib/cocoapods-core/specification/set/presenter.rb', line 59 def verions_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 |
#version ⇒ Version
Returns the highest version of available for the Pod.
39 40 41 |
# File 'lib/cocoapods-core/specification/set/presenter.rb', line 39 def version @set.versions.first end |
#versions ⇒ Array<Version>
Returns all the versions available ascending order.
46 47 48 |
# File 'lib/cocoapods-core/specification/set/presenter.rb', line 46 def versions @set.versions.sort.reverse end |