Commit 6ae76658 authored by Fabio Pelosin's avatar Fabio Pelosin

[refactor] moved spec_present module to presenter class

parent 31b6da64
......@@ -3,13 +3,13 @@ require 'colored'
module Pod
class Command
autoload :ErrorReport, 'cocoapods/command/error_report'
autoload :SetPresent, 'cocoapods/command/set_present'
autoload :Install, 'cocoapods/command/install'
autoload :List, 'cocoapods/command/list'
autoload :Repo, 'cocoapods/command/repo'
autoload :Search, 'cocoapods/command/search'
autoload :Setup, 'cocoapods/command/setup'
autoload :Spec, 'cocoapods/command/spec'
autoload :Presenter, 'cocoapods/command/presenter'
class Help < Informative
def initialize(command_class, argv)
......
......@@ -15,22 +15,20 @@ module Pod
end
def self.options
SetPresent.set_present_options +
super
SetPresent.options + super
end
include SetPresent
extend Executable
executable :git
def initialize(argv)
parse_set_options(argv)
@new = argv.option('new')
@presenter = Presenter.new(argv)
super unless argv.empty?
end
def list_all
present_sets(all = Source.all_sets)
@presenter.present_sets(all = Source.all_sets)
puts "#{all.count} pods were found"
puts
end
......@@ -53,15 +51,15 @@ module Pod
days.reverse.each do |d|
sets = groups[d]
next unless sets
puts "Pods added in the last #{d == 1 ? '1 day' : "#{d} days"}\n".yellow
present_sets(sets)
puts "Pods added in the last #{d == 1 ? '1 day' : "#{d} days"}".yellow
@presenter.present_sets(sets)
end
end
def run
if @new
puts "\nUpdating Spec Repositories\n".yellow if config.verbose?
Repo.new(ARGV.new(["update"])).run
#Repo.new(ARGV.new(["update"])).run
list_new
else
list_all
......
......@@ -2,29 +2,21 @@ require 'net/http'
module Pod
class Command
module SetPresent
def self.set_present_options
" --name-only Show only the names of the pods\n" +
class Presenter
def self.options
" --stats Show additional stats (like GitHub watchers and forks)\n"
end
def list
@list
end
def parse_set_options(argv)
def initialize(argv)
@stats = argv.option('--stats')
@list = argv.option('--name-only')
end
def present_sets(array)
puts
array.each {|set| present_set(set)}
end
def present_set(set)
if @list
puts set.name
else
puts "--> #{set.name} (#{set.versions.reverse.join(", ")})".green
puts_wrapped_text(set.summary)
spec = set.specification.part_of_other_pod? ? set.specification.part_of_specification : set.specification
......@@ -37,7 +29,6 @@ module Pod
end
puts
end
end
# adapted from http://blog.macromates.com/2006/wrapping-text-with-regular-expressions/
def puts_wrapped_text(txt, col = 80, indentation = 4)
......
......@@ -13,23 +13,19 @@ module Pod
def self.options
" --full Search by name, summary, and description\n" +
SetPresent.set_present_options +
super
Presenter.options + super
end
include SetPresent
def initialize(argv)
parse_set_options(argv)
@full_text_search = argv.option('--full')
unless @query = argv.arguments.first
super
end
@presenter = Presenter.new(argv)
@query = argv.shift_argument
super unless argv.empty? && @query
end
def run
sets = Source.search_by_name(@query.strip, @full_text_search)
present_sets(sets)
@presenter.present_sets(sets)
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