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

set[R]

@return [Set] the set that should be presented.

Public Class Methods

new(set) click to toggle source

@param [Set] set @see set.

# File lib/cocoapods-core/specification/set/presenter.rb, line 16
def initialize(set)
  @set = set
end

Public Instance Methods

authors() click to toggle source

@return [String] the list of the authors of the Pod in sentence

format.

@example Output example

"Author 1, Author 2 and Author 3"
# File lib/cocoapods-core/specification/set/presenter.rb, line 88
def authors
  return '' unless spec.authors
  spec.authors.keys.to_sentence
end
deprecation_description() click to toggle source

@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
description() click to toggle source

@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
github_forks() click to toggle source

@return [Integer] the GitHub forks of the repo of the Pod.

# File lib/cocoapods-core/specification/set/presenter.rb, line 185
def github_forks
  github_metrics['forks']
end
github_metrics() click to toggle source
# File lib/cocoapods-core/specification/set/presenter.rb, line 197
def github_metrics
  metrics['github'] || {}
end
github_stargazers() click to toggle source

@return [Integer] the GitHub likes of the repo of the Pod.

# File lib/cocoapods-core/specification/set/presenter.rb, line 179
def github_stargazers
  github_metrics['stargazers']
end
homepage() click to toggle source

@return [String] the homepage of the pod.

# File lib/cocoapods-core/specification/set/presenter.rb, line 95
def homepage
  spec.homepage
end
license() click to toggle source

@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
metrics() click to toggle source

@!group Private Helpers

# File lib/cocoapods-core/specification/set/presenter.rb, line 193
def metrics
  @metrics ||= Metrics.pod(name) || {}
end
name() click to toggle source

@return [String] the name of the Pod.

# File lib/cocoapods-core/specification/set/presenter.rb, line 26
def name
  @set.name
end
platform() click to toggle source

@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
source_url() click to toggle source

@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
sources() click to toggle source

@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
spec() click to toggle source

@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
subspecs() click to toggle source

@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
summary() click to toggle source

@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
version() click to toggle source

@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
versions() click to toggle source

@return [Array<Version>] all the versions available ascending

order.
# File lib/cocoapods-core/specification/set/presenter.rb, line 39
def versions
  @set.versions
end
versions_by_source() click to toggle source

@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