Commit 51e74ff3 authored by Fabio Pelosin's avatar Fabio Pelosin

Add Pod lib command #850

Tests are still missing.
parent efdedaa6
......@@ -17,7 +17,7 @@ GIT
GIT
remote: https://github.com/CocoaPods/Xcodeproj.git
revision: 0571050275fa11c7bb0ad50bd7945624c1d45111
revision: fd27b6217686358aea5250f006b10ed73d4726e5
branch: master
specs:
xcodeproj (0.6.0)
......
......@@ -8,17 +8,18 @@ module Pod
class Command < CLAide::Command
require 'cocoapods/command/help'
require 'cocoapods/command/inter_process_communication'
require 'cocoapods/command/lib'
require 'cocoapods/command/list'
require 'cocoapods/command/outdated'
require 'cocoapods/command/podfile_info'
require 'cocoapods/command/project'
require 'cocoapods/command/push'
require 'cocoapods/command/repo'
require 'cocoapods/command/search'
require 'cocoapods/command/setup'
require 'cocoapods/command/spec'
require 'cocoapods/command/help'
require 'cocoapods/command/inter_process_communication'
require 'cocoapods/command/podfile_info'
self.abstract_command = true
self.default_subcommand = 'install'
......
module Pod
class Command
class Lib < Command
self.abstract_command = true
self.summary = 'Develop pods'
#-----------------------------------------------------------------------#
class Create < Lib
self.summary = 'Creates a new Pod'
self.description = <<-DESC
Creates a new Pod with the given name from the template in the working directory.
DESC
self.arguments = '[NAME]'
def initialize(argv)
@name = argv.shift_argument
super
end
def validate!
super
help! "A name for the Pod is required." unless @name
end
def run
clone_template
configure_template
print_info
end
private
#----------------------------------------#
# !@group Private helpers
extend Executable
executable :git
executable :ruby
TEMPLATE_REPO = "/Users/fabio/Projects/CP/pod-template"
TEMPLATE_INFO_URL = "/Users/fabio/Projects/CP/pod-template"
# Clones the template from the remote in the working directory using
# the name of the Pod.
#
# @return [void]
#
def clone_template
UI.section("Creating `#{@name}` Pod") do
git!"clone '#{TEMPLATE_REPO}' #{@name}"
end
end
# Runs the template configuration utilities.
#
# @return [void]
#
def configure_template
UI.section("Configuring template") do
Dir.chdir(@name) do
ruby! "_CONFIGURE.rb #{@name}"
end
end
end
# Runs the template configuration utilities.
#
# @return [void]
#
def print_info
UI.puts "\nTo learn more about the template see `#{TEMPLATE_INFO_URL}`."
end
end
#-----------------------------------------------------------------------#
class Lint < Lib
self.summary = 'Validates a Pod'
self.description = <<-DESC
Validates the Pod using the files in the working directory.
DESC
def self.options
[ ["--quick", "Lint skips checks that would require to download and build the spec"],
["--only-errors", "Lint validates even if warnings are present"],
["--no-clean", "Lint leaves the build directory intact for inspection"] ].concat(super)
end
def initialize(argv)
@quick = argv.flag?('quick')
@only_errors = argv.flag?('only-errors')
@clean = argv.flag?('clean', true)
super
end
def validate!
super
end
def run
UI.puts
validator = Validator.new(podspec_to_lint)
validator.local = true
validator.quick = @quick
validator.no_clean = !@clean
validator.only_errors = @only_errors
validator.validate
if validator.validated?
UI.puts "#{validator.spec.name} passed validation.".green
else
raise Informative, "#{validator.spec.name} did not pass validation."
end
unless @clean
UI.puts "Pods project available at `#{validator.validation_dir}/Pods/Pods.xcodeproj` for inspection."
UI.puts
end
end
private
#----------------------------------------#
# !@group Private helpers
# @return [Pathname] The path of the podspec found in the current
# working directory.
#
# @raise If no podspec is found.
# @raise If multiple podspecs are found.
#
def podspec_to_lint
podspecs = Pathname.glob(Pathname.pwd + '*.podspec{.yaml,}')
raise Informative, "Unable to find a podspec in the working directory" if podspecs.count.zero?
raise Informative, "Multiple podspecs detected in the working directory" if podspecs.count > 1
podspecs.first
end
end
#-----------------------------------------------------------------------#
end
end
end
module Pod
class Command
class Search < Command
self.summary = 'Search pods'
self.summary = 'Searches for pods'
self.description = <<-DESC
Searches for pods, ignoring case, whose name matches `QUERY'. If the
......
......@@ -60,14 +60,12 @@ module Pod
def self.options
[ ["--quick", "Lint skips checks that would require to download and build the spec"],
["--local", "Lint a podspec against the local files contained in its directory"],
["--only-errors", "Lint validates even if warnings are present"],
["--no-clean", "Lint leaves the build directory intact for inspection"] ].concat(super)
end
def initialize(argv)
@quick = argv.flag?('quick')
@local = argv.flag?('local')
@only_errors = argv.flag?('only-errors')
@clean = argv.flag?('clean', true)
@podspecs_paths = argv.arguments!
......@@ -80,7 +78,6 @@ module Pod
podspecs_to_lint.each do |podspec|
validator = Validator.new(podspec)
validator.quick = @quick
validator.local = @local
validator.no_clean = !@clean
validator.only_errors = @only_errors
validator.validate
......
......@@ -305,7 +305,7 @@ module Pod
podfile = Pod::Podfile.new do
platform(platform_name, deployment_target)
if (local)
pod name, :local => podspec.dirname.to_s
pod name, :path => podspec.dirname.to_s
else
pod name, :podspec => podspec.to_s
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