Commit 16b4d95e authored by Fabio Pelosin's avatar Fabio Pelosin

[presenter] present output to per set so it doesn't wait for all the sets to be…

[presenter] present output to per set so it doesn't wait for all the sets to be ready on lenghty operations
parent 50749fbe
...@@ -30,9 +30,8 @@ module Pod ...@@ -30,9 +30,8 @@ module Pod
def list_all def list_all
sets = Source.all_sets sets = Source.all_sets
puts @presenter.render(sets) sets.each {|s| puts @presenter.describe(s)}
puts "#{sets.count} pods were found" puts "\n#{sets.count} pods were found"
puts
end end
def list_new def list_new
...@@ -52,12 +51,11 @@ module Pod ...@@ -52,12 +51,11 @@ module Pod
end end
end end
end end
puts
days.reverse.each do |d| days.reverse.each do |d|
sets = groups[d] sets = groups[d]
next unless sets next unless sets
puts "Pods added in the last #{d == 1 ? 'day' : "#{d} days"}".yellow puts "\nPods added in the last #{d == 1 ? 'day' : "#{d} days"}".yellow
puts @presenter.render(sets.sort_by {|set| creation_dates[set.name]}) sets.sort_by {|s| creation_dates[s.name]}.each {|s| puts @presenter.describe(s)}
end end
end end
...@@ -65,6 +63,7 @@ module Pod ...@@ -65,6 +63,7 @@ module Pod
puts "\nUpdating Spec Repositories\n".yellow if @update && config.verbose? puts "\nUpdating Spec Repositories\n".yellow if @update && config.verbose?
Repo.new(ARGV.new(["update"])).run if @update Repo.new(ARGV.new(["update"])).run if @update
@new ? list_new : list_all @new ? list_new : list_all
puts
end end
end end
end end
......
...@@ -13,13 +13,13 @@ module Pod ...@@ -13,13 +13,13 @@ module Pod
def render(array) def render(array)
result = "\n" result = "\n"
array.each {|set| result << render_set(set)} seats.each {|s| puts describe(s)}
result result
end end
def render_set(set) def describe(set)
pod = CocoaPod.new(set) pod = CocoaPod.new(set)
result = "--> #{pod.name} (#{pod.versions})\n".green result = "\n--> #{pod.name} (#{pod.versions})\n".green
result << wrap_string(pod.summary) result << wrap_string(pod.summary)
result << detail('Homepage', pod.homepage) result << detail('Homepage', pod.homepage)
result << detail('Source', pod.source_url) result << detail('Source', pod.source_url)
...@@ -29,7 +29,7 @@ module Pod ...@@ -29,7 +29,7 @@ module Pod
result << detail('License', pod.license) if @stats result << detail('License', pod.license) if @stats
result << detail('Watchers', pod.github_watchers) if @stats result << detail('Watchers', pod.github_watchers) if @stats
result << detail('Forks', pod.github_forks) if @stats result << detail('Forks', pod.github_forks) if @stats
result << "\n" result
end end
private private
......
...@@ -25,7 +25,8 @@ module Pod ...@@ -25,7 +25,8 @@ module Pod
def run def run
sets = Source.search_by_name(@query.strip, @full_text_search) sets = Source.search_by_name(@query.strip, @full_text_search)
puts @presenter.render(sets) sets.each {|s| puts @presenter.describe(s)}
puts
end end
end end
end end
......
...@@ -12,7 +12,7 @@ describe Pod::Command::Presenter do ...@@ -12,7 +12,7 @@ describe Pod::Command::Presenter do
it "presents the name, version, description, homepage and source of a specification set" do it "presents the name, version, description, homepage and source of a specification set" do
presenter = Presenter.new(argv()) presenter = Presenter.new(argv())
output = presenter.render_set(@set) output = presenter.describe(@set)
output.should.include? 'CocoaLumberjack' output.should.include? 'CocoaLumberjack'
output.should.include? '1.0' output.should.include? '1.0'
output.should.include? '1.1' output.should.include? '1.1'
...@@ -25,13 +25,12 @@ describe Pod::Command::Presenter do ...@@ -25,13 +25,12 @@ describe Pod::Command::Presenter do
response = '{"repository":{"homepage":"","url":"https://github.com/robbiehanson/CocoaLumberjack","has_downloads":true,"has_issues":true,"language":"Objective-C","master_branch":"master","forks":42,"fork":false,"created_at":"2011/03/30 19:38:39 -0700","has_wiki":true,"description":"A fast & simple, yet powerful & flexible logging framework for Mac and iOS","size":416,"private":false,"name":"CocoaLumberjack","owner":"robbiehanson","open_issues":4,"watchers":318,"pushed_at":"2012/03/26 12:39:36 -0700"}}% ' response = '{"repository":{"homepage":"","url":"https://github.com/robbiehanson/CocoaLumberjack","has_downloads":true,"has_issues":true,"language":"Objective-C","master_branch":"master","forks":42,"fork":false,"created_at":"2011/03/30 19:38:39 -0700","has_wiki":true,"description":"A fast & simple, yet powerful & flexible logging framework for Mac and iOS","size":416,"private":false,"name":"CocoaLumberjack","owner":"robbiehanson","open_issues":4,"watchers":318,"pushed_at":"2012/03/26 12:39:36 -0700"}}% '
Pod::Specification::Statistics.instance.expects(:fetch_stats).with("robbiehanson", "CocoaLumberjack").returns(response) Pod::Specification::Statistics.instance.expects(:fetch_stats).with("robbiehanson", "CocoaLumberjack").returns(response)
presenter = Presenter.new(argv('--stats')) presenter = Presenter.new(argv('--stats'))
output = presenter.render_set(@set) output = presenter.describe(@set)
output.should.include? 'Author: Robbie Hanson' output.should.include? 'Author: Robbie Hanson'
output.should.include? 'License: BSD' output.should.include? 'License: BSD'
output.should.include? 'Platform: iOS - OS X' output.should.include? 'Platform: iOS - OS X'
output.should.include? 'Watchers: 318' output.should.include? 'Watchers: 318'
output.should.include? 'Forks: 42' output.should.include? 'Forks: 42'
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