Commit 295f8ddc authored by Fabio Pelosin's avatar Fabio Pelosin

[pod-list] introduced Pod::Command::Presenter::CocoaPod class that encapsulates…

[pod-list] introduced Pod::Command::Presenter::CocoaPod class that encapsulates pod presentation logic
parent 8593dcbe
module Pod
class Specification
class Set
def main_specification
specification.part_of_other_pod? ? specification.part_of_specification : specification
end
def homepage
main_specification.homepage
end
def description
main_specification.description
end
def summary
main_specification.summary
end
def source_url
main_specification.source.reject {|k,_| k == :commit || k == :tag }.values.first
end
def github_watchers
Pod::Specification::Statistics.instance.github_watchers(self)
end
def github_forks
Pod::Specification::Statistics.instance.github_watchers(self)
end
end
end
end
module Pod module Pod
class Command class Command
class Presenter class Presenter
...@@ -39,6 +5,8 @@ module Pod ...@@ -39,6 +5,8 @@ module Pod
" --stats Show additional stats (like GitHub watchers and forks)\n" " --stats Show additional stats (like GitHub watchers and forks)\n"
end end
autoload :CocoaPod, 'cocoapods/command/presenter/cocoa_pod'
def initialize(argv) def initialize(argv)
@stats = argv.option('--stats') @stats = argv.option('--stats')
end end
...@@ -49,12 +17,13 @@ module Pod ...@@ -49,12 +17,13 @@ module Pod
end end
def present_set(set) def present_set(set)
puts "--> #{set.name} (#{set.versions.reverse.join(", ")})".green pod = CocoaPod.new(set)
puts wrap_string(set.summary) puts "--> #{pod.name} (#{pod.versions})".green
puts_detail('Homepage', set.homepage) puts wrap_string(pod.summary)
puts_detail('Source', set.source_url) puts_detail('Homepage', pod.homepage)
puts_detail('Watchers', set.github_watchers) if @stats puts_detail('Source', pod.source_url)
puts_detail('Forks', set.github_forks) if @stats puts_detail('Watchers', pod.github_watchers) if @stats
puts_detail('Forks', pod.github_forks) if @stats
puts puts
end end
......
module Pod
class Command
class Presenter
class CocoaPod
def initialize(set)
@set = set
end
def spec
@spec ||= @set.specification.part_of_other_pod? ? @set.specification.part_of_specification : @set.specification
end
def name
@set.name
end
def version
@set.version.last
end
def versions
@set.versions.reverse.join(", ")
end
def homepage
spec.homepage
end
def description
spec.description
end
def summary
spec.summary
end
def source_url
spec.source.reject {|k,_| k == :commit || k == :tag }.values.first
end
def github_watchers
Pod::Specification::Statistics.instance.github_watchers(@set)
end
def github_forks
Pod::Specification::Statistics.instance.github_watchers(@set)
end
end
end
end
end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment