Commit adb89ec5 authored by Eloy Duran's avatar Eloy Duran

Cleanup and make specs green.

parent 23626caa
require 'net/http'
module Pod
class Command
module SetPresent
def self.options
[
["--name-only", "Show only the names of the pods"],
["--stats", "Show additional stats (like GitHub watchers and forks)"],
]
end
def list
@list
end
def parse_set_options(argv)
@stats = argv.option('--stats')
@list = argv.option('--name-only')
end
def present_sets(array)
array.each do |set|
present_set(set)
end
end
def present_set(set)
if @list
puts set.name
else
puts "--> #{set.name} (#{set.versions.reverse.join(", ")})".green
puts_wrapped_text(set.specification.summary)
spec = set.specification.part_of_other_pod? ? set.specification.part_of_specification : set.specification
source = spec.source.reject {|k,_| k == :commit || k == :tag }.values.first
puts_detail('Homepage', spec.homepage)
puts_detail('Source', source)
if @stats
stats = stats(source)
puts_detail('Watchers', stats[:watchers])
puts_detail('Forks', stats[:forks])
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)
indent = ' ' * indentation
puts txt.strip.gsub(/(.{1,#{col}})( +|$)\n?|(.{#{col}})/, indent + "\\1\\3\n")
end
def puts_detail(title,string)
return if !string
# 8 is the length of homepage
number_of_spaces = ((8 - title.length) > 0) ? (8 - title.length) : 0
spaces = ' ' * number_of_spaces
puts " - #{title}: #{spaces + string}"
end
def stats(url)
original_url, username, reponame = *(url.match(/[:\/]([\w\-]+)\/([\w\-]+)\.git/).to_a)
result = {}
if original_url
gh_response = Net::HTTP.get('github.com', "/api/v2/json/repos/show/#{username}/#{reponame}")
result[:watchers] = gh_response.match(/\"watchers\"\W*:\W*([0-9]+)/).to_a[1]
result[:forks] = gh_response.match(/\"forks\"\W*:\W*([0-9]+)/).to_a[1]
end
result
end
end
end
end
......@@ -10,7 +10,11 @@ module Pod
@instance = instance
end
attr_accessor :repos_dir, :project_root, :project_pods_root, :clean, :verbose, :silent, :doc, :doc_install, :force_doc, :integrate_targets
attr_accessor :repos_dir, :project_root, :project_pods_root
attr_accessor :clean, :verbose, :silent
attr_accessor :doc, :doc_install, :force_doc
attr_accessor :integrate_targets
alias_method :clean?, :clean
alias_method :verbose?, :verbose
alias_method :silent?, :silent
......
......@@ -87,12 +87,8 @@ module Pod
raise "Appledoc encountered an error (exitstatus: #{$?.exitstatus})."
end
rescue Exception => e
if e.is_a?(Informative)
rescue Informative
puts "[!] Skipping documentation generation because appledoc can't be found." if config.verbose?
else
throw e
end
end
end
end
......
......@@ -32,11 +32,9 @@ module Pod
# TODO This is just to work around a MacRuby bug
def post_initialize
@define_for_platforms = [:osx, :ios]
#@dependencies, @source_files, @resources, @clean_paths, @subspecs = [], [], [], [], []
@clean_paths, @subspecs = [], []
@dependencies, @source_files, @resources = { :ios => [], :osx => [] }, { :ios => [], :osx => [] }, { :ios => [], :osx => [] }
@platform = Platform.new(nil)
#@xcconfig = Xcodeproj::Config.new
@xcconfig = { :ios => Xcodeproj::Config.new, :osx => Xcodeproj::Config.new }
@compiler_flags = { :ios => '', :osx => '' }
end
......@@ -332,10 +330,19 @@ module Pod
allowed = [nil, :ios, :osx]
incorrect << "platform - accepted values are (no value, :ios, :osx)" unless allowed.include?(platform.name)
[:source_files, :resources, :clean_paths].each do |m|
incorrect << "#{m} - paths cannot start with a slash" unless self.send(m) && self.send(m).reject{|f| !f.start_with?("/")}.empty?
{
:source_files => source_files.values,
:resources => resources.values,
:clean_paths => clean_paths
}.each do |name, paths|
if paths.flatten.any? { |path| path.start_with?("/") }
incorrect << "#{name} - paths cannot start with a slash"
end
end
if source && source[:local] && source[:local].start_with?("/")
incorrect << "source[:local] - paths cannot start with a slash"
end
incorrect << "source[:local] - paths cannot start with a slash" if source && source[:local] && source[:local].start_with?("/")
no_errors_found = missing.empty? && incorrect.empty?
......
......@@ -28,13 +28,14 @@ describe "Pod::Command::List" do
it "presents the known pods" do
list = command()
list.run
[ 'ZBarSDK',
'TouchJSON',
'SDURLCache',
'MagicalRecord',
'A2DynamicDelegate',
'75 pods were found'
].each {|s| list.output.should.include s }
[
/ZBarSDK/,
/TouchJSON/,
/SDURLCache/,
/MagicalRecord/,
/A2DynamicDelegate/,
/\d+ pods were found/
].each { |regex| list.output.should =~ regex }
end
it "returns the new pods" do
......
......@@ -173,7 +173,7 @@ else
should_xcodebuild(podfile.target_definitions[:osx_target])
end
if Pod::Generator::Documentation.appledoc_installed?
unless `which appledoc`.strip.empty?
it "generates documentation of all pods by default" do
create_config!
......
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