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

Instance Method Summary collapse

Constructor Details

#initialize(set, statistics_provider = nil) ⇒ Presenter

Returns a new instance of Presenter.

Parameters:

  • set (Set)

    @see #set.



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

#setSet (readonly)

Returns the set that should be presented.

Returns:

  • (Set)

    the set that should be presented.



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

def set
  @set
end

#statistics_providerStatistics (readonly)

Returns The statistics provider.

Returns:



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

def statistics_provider
  @statistics_provider
end

Instance Method Details

#authorsString

Note:

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.

Examples:

Output example


"Author 1, Author 2 and Author 3"

Returns:

  • (String)

    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 authors
  return '' unless spec.authors
  if RUBY_VERSION == '1.8.7'
    spec.authors.keys.sort.to_sentence
  else
    spec.authors.keys.to_sentence
  end
end

#creation_dateTime

Returns the creation date of the first known ‘podspec` of the Pod.

Returns:

  • (Time)

    the creation date of the first known ‘podspec` of the Pod.



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

def creation_date
  statistics_provider.creation_date(@set)
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.



124
125
126
# File 'lib/cocoapods-core/specification/set/presenter.rb', line 124

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.



182
183
184
# File 'lib/cocoapods-core/specification/set/presenter.rb', line 182

def github_forks
  statistics_provider.github_forks(@set)
end

#github_last_activityString

Returns the relative time of the last push of the repo the Pod.

Returns:

  • (String)

    the relative time of the last push of the repo the Pod.



188
189
190
# File 'lib/cocoapods-core/specification/set/presenter.rb', line 188

def github_last_activity
  distance_from_now_in_words(statistics_provider.github_pushed_at(@set))
end

#github_watchersInteger

Returns the GitHub likes of the repo of the Pod.

Returns:

  • (Integer)

    the GitHub likes of the repo of the Pod.



176
177
178
# File 'lib/cocoapods-core/specification/set/presenter.rb', line 176

def github_watchers
  statistics_provider.github_watchers(@set)
end

#homepageString

Returns the homepage of the pod.

Returns:

  • (String)

    the homepage of the pod.



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

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.



153
154
155
# File 'lib/cocoapods-core/specification/set/presenter.rb', line 153

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

#nameString

Returns the name of the Pod.

Returns:

  • (String)

    the name of the Pod.



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

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.



143
144
145
# File 'lib/cocoapods-core/specification/set/presenter.rb', line 143

def platform
  spec.available_platforms.sort { |a,b| a.to_s.downcase <=> b.to_s.downcase }.join(' - ')
end

#source_urlString

Returns the URL of the source of the Pod.

Returns:

  • (String)

    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

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



72
73
74
# File 'lib/cocoapods-core/specification/set/presenter.rb', line 72

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:



84
85
86
# File 'lib/cocoapods-core/specification/set/presenter.rb', line 84

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



159
160
161
# File 'lib/cocoapods-core/specification/set/presenter.rb', line 159

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.



117
118
119
# File 'lib/cocoapods-core/specification/set/presenter.rb', line 117

def summary
  spec.summary
end

#verions_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.



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

#versionVersion

Returns the highest version of available for the Pod.

Returns:

  • (Version)

    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

#versionsArray<Version>

Returns all the versions available ascending order.

Returns:

  • (Array<Version>)

    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