Class: Pod::Specification::Set::Presenter

Inherits:
Object
  • Object
show all
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 Information collapse

Specification Information collapse

Statistics collapse

Private Helpers collapse

Instance Method Summary collapse

Constructor Details

#initialize(set) ⇒ Presenter

Returns a new instance of Presenter

Parameters:

  • set (Set)

    @see #set.


16
17
18
# File 'lib/cocoapods-core/specification/set/presenter.rb', line 16

def initialize(set)
  @set = set
end

Instance Attribute Details

#setSet (readonly)

Returns the set that should be presented.

Returns:

  • (Set)

    the set that should be presented.


12
13
14
# File 'lib/cocoapods-core/specification/set/presenter.rb', line 12

def set
  @set
end

Instance Method Details

#authorsString

Returns the list of the authors of the Pod in sentence format.

Examples:

Output example


"Author 1, Author 2 and Author 3"

Returns:

  • (String)

    the list of the authors of the Pod in sentence format.


88
89
90
91
# File 'lib/cocoapods-core/specification/set/presenter.rb', line 88

def authors
  return '' unless spec.authors
  spec.authors.keys.to_sentence
end

#deprecation_descriptionString

Returns 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.

Examples:

Output example


"[DEPRECATED]"
"[DEPRECATED in favor of NewAwesomePod]"

Returns:

  • (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.


122
123
124
125
126
127
128
129
130
131
132
133
# File 'lib/cocoapods-core/specification/set/presenter.rb', line 122

def deprecation_description
  if spec.deprecated?
    description = '[DEPRECATED'
    if spec.deprecated_in_favor_of.nil?
      description += ']'
    else
      description += " in favor of #{spec.deprecated_in_favor_of}]"
    end

    description
  end
end

#descriptionString

Returns the description of the Pod, if no description is available the summary is returned.

Returns:

  • (String)

    the description of the Pod, if no description is available the summary is returned.


109
110
111
# File 'lib/cocoapods-core/specification/set/presenter.rb', line 109

def description
  spec.description || spec.summary
end

#github_forksInteger

Returns the GitHub forks of the repo of the Pod.

Returns:

  • (Integer)

    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
  github_metrics['forks']
end

#github_metricsObject


197
198
199
# File 'lib/cocoapods-core/specification/set/presenter.rb', line 197

def github_metrics
  metrics['github'] || {}
end

#github_stargazersInteger

Returns the GitHub likes of the repo of the Pod.

Returns:

  • (Integer)

    the GitHub likes of the repo of the Pod.


179
180
181
# File 'lib/cocoapods-core/specification/set/presenter.rb', line 179

def github_stargazers
  github_metrics['stargazers']
end

#homepageString

Returns the homepage of the pod.

Returns:

  • (String)

    the homepage of the pod.


95
96
97
# File 'lib/cocoapods-core/specification/set/presenter.rb', line 95

def homepage
  spec.homepage
end

#licenseString

Returns the type of the license of the Pod.

Examples:


"MIT"

Returns:

  • (String)

    the type of the license of the Pod.


163
164
165
# File 'lib/cocoapods-core/specification/set/presenter.rb', line 163

def license
  spec.license[:type] if spec.license
end

#metricsObject


193
194
195
# File 'lib/cocoapods-core/specification/set/presenter.rb', line 193

def metrics
  @metrics ||= Metrics.pod(name) || {}
end

#nameString

Returns the name of the Pod.

Returns:

  • (String)

    the name of the Pod.


26
27
28
# File 'lib/cocoapods-core/specification/set/presenter.rb', line 26

def name
  @set.name
end

#platformString

Returns the platforms supported by the Pod.

Examples:


"iOS"
"iOS - OS X"

Returns:

  • (String)

    the platforms supported by the Pod.


150
151
152
153
154
155
# 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

#source_urlString

Returns the URL of the source of the Pod.

Returns:

  • (String)

    the URL of the source of the Pod.


137
138
139
140
141
# 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

#sourcesArray<String>

Returns The name of the sources that contain the Pod sorted alphabetically.

Returns:

  • (Array<String>)

    The name of the sources that contain the Pod sorted alphabetically.


65
66
67
# File 'lib/cocoapods-core/specification/set/presenter.rb', line 65

def sources
  @set.sources.map(&:name).sort
end

#specSpecification

Returns the specification of the Pod::Specification::Set. If no versions requirements where passed to the set it returns the highest available version.

Returns:


77
78
79
# File 'lib/cocoapods-core/specification/set/presenter.rb', line 77

def spec
  @spec ||= @set.specification
end

#subspecsArray

Returns an array containing all the subspecs of the Pod.

Returns:

  • (Array)

    an array containing all the subspecs of the Pod.


169
170
171
# File 'lib/cocoapods-core/specification/set/presenter.rb', line 169

def subspecs
  (spec.recursive_subspecs.any? && spec.recursive_subspecs) || nil
end

#summaryString

Returns a short description, expected to be 140 characters long of the Pod.

Returns:

  • (String)

    a short description, expected to be 140 characters long of the Pod.


102
103
104
# File 'lib/cocoapods-core/specification/set/presenter.rb', line 102

def summary
  spec.summary
end

#versionVersion

Returns the highest version of available for the Pod.

Returns:

  • (Version)

    the highest version of available for the Pod.


32
33
34
# File 'lib/cocoapods-core/specification/set/presenter.rb', line 32

def version
  @set.versions.first
end

#versionsArray<Version>

Returns all the versions available ascending order.

Returns:

  • (Array<Version>)

    all the versions available ascending order.


39
40
41
# File 'lib/cocoapods-core/specification/set/presenter.rb', line 39

def versions
  @set.versions
end

#versions_by_sourceString

Note:

This method orders the sources by name.

Returns all the versions available sorted from the highest to the lowest.

Examples:

Return example


"1.5pre, 1.4 [master repo] - 1.4 [test_repo repo]"

Returns:

  • (String)

    all the versions available sorted from the highest to the lowest.


52
53
54
55
56
57
58
59
60
# 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