Commit 440b0dd1 authored by Eloy Durán's avatar Eloy Durán

Merge branch 'claide' into 0.17

parents 750dfe2a 124df8a9
GIT GIT
remote: git://github.com/CocoaPods/Xcodeproj.git remote: git://github.com/CocoaPods/Xcodeproj.git
revision: cc71c669a05934886c56169bbe209014a7a1af8e revision: eaab002f308e2641232630b1b5d4ab3c2f10a10a
specs: specs:
xcodeproj (0.4.0.rc1) xcodeproj (0.4.0.rc3)
activesupport (~> 3.2.6) activesupport (~> 3.2.6)
colored (~> 1.2) colored (~> 1.2)
...@@ -20,6 +20,7 @@ PATH ...@@ -20,6 +20,7 @@ PATH
specs: specs:
cocoapods (0.16.0.rc2) cocoapods (0.16.0.rc2)
activesupport (~> 3.2.6) activesupport (~> 3.2.6)
claide (~> 0.1)
colored (~> 1.2) colored (~> 1.2)
escape (~> 0.0.4) escape (~> 0.0.4)
faraday (~> 0.8.1) faraday (~> 0.8.1)
...@@ -38,13 +39,14 @@ GEM ...@@ -38,13 +39,14 @@ GEM
addressable (2.3.2) addressable (2.3.2)
awesome_print (1.1.0) awesome_print (1.1.0)
bacon (1.1.0) bacon (1.1.0)
claide (0.2.0)
coderay (1.0.8) coderay (1.0.8)
colored (1.2) colored (1.2)
crack (0.3.1) crack (0.3.1)
escape (0.0.4) escape (0.0.4)
faraday (0.8.4) faraday (0.8.4)
multipart-post (~> 1.1) multipart-post (~> 1.1)
faraday_middleware (0.8.8) faraday_middleware (0.9.0)
faraday (>= 0.7.4, < 0.9) faraday (>= 0.7.4, < 0.9)
github-markup (0.7.4) github-markup (0.7.4)
hashie (1.2.0) hashie (1.2.0)
......
...@@ -13,4 +13,4 @@ end ...@@ -13,4 +13,4 @@ end
require 'cocoapods' require 'cocoapods'
Pod::Command.run(*ARGV) Pod::Command.run(ARGV)
# -*- encoding: utf-8 -*- # -*- encoding: utf-8 -*-
$:.unshift File.expand_path('../lib', __FILE__) $:.unshift File.expand_path('../lib', __FILE__)
require 'cocoapods' require 'cocoapods/version'
Gem::Specification.new do |s| Gem::Specification.new do |s|
s.name = "cocoapods" s.name = "cocoapods"
...@@ -26,6 +26,7 @@ Gem::Specification.new do |s| ...@@ -26,6 +26,7 @@ Gem::Specification.new do |s|
s.executables = %w{ pod } s.executables = %w{ pod }
s.require_paths = %w{ lib } s.require_paths = %w{ lib }
s.add_runtime_dependency 'claide', '~> 0.1'
s.add_runtime_dependency 'xcodeproj', '~> 0.4.0.rc1' s.add_runtime_dependency 'xcodeproj', '~> 0.4.0.rc1'
s.add_runtime_dependency 'faraday', '~> 0.8.1' s.add_runtime_dependency 'faraday', '~> 0.8.1'
......
COCOAPODS: 0.15.1
PODS: PODS:
- AFNetworking (0.7.0): - AFNetworking (0.7.0):
- JSONKit - JSONKit
...@@ -19,17 +17,19 @@ PODS: ...@@ -19,17 +17,19 @@ PODS:
- FormatterKit/UnitOfInformationFormatter (1.0.0) - FormatterKit/UnitOfInformationFormatter (1.0.0)
- JSONKit (1.5pre) - JSONKit (1.5pre)
DEPENDENCIES:
- AFNetworking (~> 0.7.0)
- FormatterKit
SPEC CHECKSUMS: SPEC CHECKSUMS:
FormatterKit/UnitOfInformationFormatter: 12dea999a2df19e389f7b821962fc4088de8b821
FormatterKit/TimeIntervalFormatter: 12dea999a2df19e389f7b821962fc4088de8b821
AFNetworking: 7bf22b0ed1d9068909cd67206db78204eb63dd2c AFNetworking: 7bf22b0ed1d9068909cd67206db78204eb63dd2c
JSONKit: a01a22c75f27eae76b4badd55a91c20fe6e86477 FormatterKit: 12dea999a2df19e389f7b821962fc4088de8b821
FormatterKit/OrdinalNumberFormatter: 12dea999a2df19e389f7b821962fc4088de8b821 FormatterKit/ArrayFormatter: 12dea999a2df19e389f7b821962fc4088de8b821
FormatterKit/LocationFormatter: 12dea999a2df19e389f7b821962fc4088de8b821 FormatterKit/LocationFormatter: 12dea999a2df19e389f7b821962fc4088de8b821
FormatterKit/OrdinalNumberFormatter: 12dea999a2df19e389f7b821962fc4088de8b821
FormatterKit/TimeIntervalFormatter: 12dea999a2df19e389f7b821962fc4088de8b821
FormatterKit/URLRequestFormatter: 12dea999a2df19e389f7b821962fc4088de8b821 FormatterKit/URLRequestFormatter: 12dea999a2df19e389f7b821962fc4088de8b821
FormatterKit/ArrayFormatter: 12dea999a2df19e389f7b821962fc4088de8b821 FormatterKit/UnitOfInformationFormatter: 12dea999a2df19e389f7b821962fc4088de8b821
FormatterKit: 12dea999a2df19e389f7b821962fc4088de8b821 JSONKit: a01a22c75f27eae76b4badd55a91c20fe6e86477
DEPENDENCIES: COCOAPODS: 0.16.0.rc2
- AFNetworking (~> 0.7.0)
- FormatterKit
SPEC CHECKSUMS:
FormatterKit/UnitOfInformationFormatter: 12dea999a2df19e389f7b821962fc4088de8b821
AFNetworking: 7bf22b0ed1d9068909cd67206db78204eb63dd2c
JSONKit: a01a22c75f27eae76b4badd55a91c20fe6e86477
FormatterKit/URLRequestFormatter: 12dea999a2df19e389f7b821962fc4088de8b821
FormatterKit: 12dea999a2df19e389f7b821962fc4088de8b821
FormatterKit/OrdinalNumberFormatter: 12dea999a2df19e389f7b821962fc4088de8b821
FormatterKit/TimeIntervalFormatter: 12dea999a2df19e389f7b821962fc4088de8b821
FormatterKit/ArrayFormatter: 12dea999a2df19e389f7b821962fc4088de8b821
FormatterKit/LocationFormatter: 12dea999a2df19e389f7b821962fc4088de8b821
PODS: PODS:
- AFNetworking (0.7.0): - AFNetworking (0.7.0):
- JSONKit - JSONKit
...@@ -28,8 +17,19 @@ PODS: ...@@ -28,8 +17,19 @@ PODS:
- FormatterKit/UnitOfInformationFormatter (1.0.0) - FormatterKit/UnitOfInformationFormatter (1.0.0)
- JSONKit (1.5pre) - JSONKit (1.5pre)
COCOAPODS: 0.15.1
DEPENDENCIES: DEPENDENCIES:
- AFNetworking (~> 0.7.0) - AFNetworking (~> 0.7.0)
- FormatterKit - FormatterKit
SPEC CHECKSUMS:
AFNetworking: 7bf22b0ed1d9068909cd67206db78204eb63dd2c
FormatterKit: 12dea999a2df19e389f7b821962fc4088de8b821
FormatterKit/ArrayFormatter: 12dea999a2df19e389f7b821962fc4088de8b821
FormatterKit/LocationFormatter: 12dea999a2df19e389f7b821962fc4088de8b821
FormatterKit/OrdinalNumberFormatter: 12dea999a2df19e389f7b821962fc4088de8b821
FormatterKit/TimeIntervalFormatter: 12dea999a2df19e389f7b821962fc4088de8b821
FormatterKit/URLRequestFormatter: 12dea999a2df19e389f7b821962fc4088de8b821
FormatterKit/UnitOfInformationFormatter: 12dea999a2df19e389f7b821962fc4088de8b821
JSONKit: a01a22c75f27eae76b4badd55a91c20fe6e86477
COCOAPODS: 0.16.0.rc2
PODS:
- MGSplitViewController (1.0.0)
DEPENDENCIES: DEPENDENCIES:
- MGSplitViewController (= 1.0.0) - MGSplitViewController (= 1.0.0)
SPEC CHECKSUMS: SPEC CHECKSUMS:
MGSplitViewController: e0b0bc01aa81e1559765c39e7a764c890dac373a MGSplitViewController: e0b0bc01aa81e1559765c39e7a764c890dac373a
PODS: COCOAPODS: 0.16.0.rc2
- MGSplitViewController (1.0.0)
COCOAPODS: 0.15.1
...@@ -37,10 +37,10 @@ DEPENDENCIES: ...@@ -37,10 +37,10 @@ DEPENDENCIES:
SPEC CHECKSUMS: SPEC CHECKSUMS:
FileMD5Hash: c3b015e6fb293eea0a0c276747f61f20408c2644 FileMD5Hash: c3b015e6fb293eea0a0c276747f61f20408c2644
ISO8601DateFormatter: dc05a2481edf49668d85d3ff8c466c32eb544780 ISO8601DateFormatter: dc05a2481edf49668d85d3ff8c466c32eb544780
JSONKit: 3d4708953ea7ae399a49777372d8b060a43ddd27 JSONKit: a01a22c75f27eae76b4badd55a91c20fe6e86477
LibComponentLogging-Core: c80e88f2b7fb204554de7bec13374daf394097e8 LibComponentLogging-Core: 9c2914bc501a0656450860a136b0e8e52f3e16d4
LibComponentLogging-NSLog: d8f54e7eb65bb893f91cab5864ecf8e85ebd9359 LibComponentLogging-NSLog: a4bb0f6de612eef7b5fcdbd9cc96dc868ba1f2df
NSData+Base64: be7e201540fa7805ecedc1f38d456e008be259b2 NSData+Base64: 8b910cb8a64f45daec6fb15936c36a9a911c57ca
RestKit: a9f24f857c792183bcc656f891abe93d38e342ee RestKit: a9f24f857c792183bcc656f891abe93d38e342ee
RestKit/JSON: a9f24f857c792183bcc656f891abe93d38e342ee RestKit/JSON: a9f24f857c792183bcc656f891abe93d38e342ee
RestKit/Network: a9f24f857c792183bcc656f891abe93d38e342ee RestKit/Network: a9f24f857c792183bcc656f891abe93d38e342ee
...@@ -50,4 +50,4 @@ SPEC CHECKSUMS: ...@@ -50,4 +50,4 @@ SPEC CHECKSUMS:
SOCKit: 9d71b00c699cf5aa2989d6aa12f3392b048123db SOCKit: 9d71b00c699cf5aa2989d6aa12f3392b048123db
cocoa-oauth: 8f4c8b77c77ac660de37f8125557c4ec09b0118a cocoa-oauth: 8f4c8b77c77ac660de37f8125557c4ec09b0118a
COCOAPODS: 0.13.0 COCOAPODS: 0.16.0.rc2
COCOAPODS: 0.15.1 PODS:
- AFNetworking (1.0RC1)
DEPENDENCIES: DEPENDENCIES:
- AFNetworking - AFNetworking
...@@ -7,5 +8,4 @@ DEPENDENCIES: ...@@ -7,5 +8,4 @@ DEPENDENCIES:
SPEC CHECKSUMS: SPEC CHECKSUMS:
AFNetworking: b21c1252d437fd322e7db1caa93b163d76a362cb AFNetworking: b21c1252d437fd322e7db1caa93b163d76a362cb
PODS: COCOAPODS: 0.16.0.rc2
- AFNetworking (1.0RC1)
...@@ -11,4 +11,4 @@ SPEC CHECKSUMS: ...@@ -11,4 +11,4 @@ SPEC CHECKSUMS:
AFNetworking: b21c1252d437fd322e7db1caa93b163d76a362cb AFNetworking: b21c1252d437fd322e7db1caa93b163d76a362cb
SSToolkit: 852044205c6a15586431e90f46b2ef01f693285a SSToolkit: 852044205c6a15586431e90f46b2ef01f693285a
COCOAPODS: 0.13.0 COCOAPODS: 0.16.0.rc2
...@@ -6,6 +6,6 @@ DEPENDENCIES: ...@@ -6,6 +6,6 @@ DEPENDENCIES:
- JSONKit - JSONKit
SPEC CHECKSUMS: SPEC CHECKSUMS:
JSONKit: 3d4708953ea7ae399a49777372d8b060a43ddd27 JSONKit: a01a22c75f27eae76b4badd55a91c20fe6e86477
COCOAPODS: 0.13.0 COCOAPODS: 0.16.0.rc2
...@@ -11,16 +11,16 @@ unless Gem::Version::Requirement.new('>= 1.4.0').satisfied_by?(Gem::Version.new( ...@@ -11,16 +11,16 @@ unless Gem::Version::Requirement.new('>= 1.4.0').satisfied_by?(Gem::Version.new(
exit 1 exit 1
end end
module Pod require 'cocoapods/version'
VERSION = '0.16.0.rc2'
module Pod
class PlainInformative < StandardError class PlainInformative < StandardError
end end
class Informative < PlainInformative class Informative < PlainInformative
def message def message
# TODO: remove formatting from raise calls and remove conditional # TODO: remove formatting from raise calls and remove conditional
super !~ /\[!\]/ ? "[!] #{super}\n".red : super super !~ /\[!\]/ ? "[!] #{super}".red : super
end end
end end
...@@ -41,7 +41,7 @@ module Pod ...@@ -41,7 +41,7 @@ module Pod
autoload :Spec, 'cocoapods/specification' autoload :Spec, 'cocoapods/specification'
autoload :Specification, 'cocoapods/specification' autoload :Specification, 'cocoapods/specification'
autoload :UI, 'cocoapods/user_interface' autoload :UI, 'cocoapods/user_interface'
autoload :Version, 'cocoapods/version' autoload :Version, 'cocoapods/version_class'
autoload :Pathname, 'pathname' autoload :Pathname, 'pathname'
autoload :FileList, 'cocoapods/file_list' autoload :FileList, 'cocoapods/file_list'
......
require 'colored' require 'colored'
require 'claide'
module Pod module Pod
class Command class PlainInformative
autoload :ErrorReport, 'cocoapods/command/error_report' include CLAide::InformativeError
autoload :Install, 'cocoapods/command/install'
autoload :List, 'cocoapods/command/list'
autoload :Linter, 'cocoapods/command/linter'
autoload :Outdated, 'cocoapods/command/outdated'
autoload :Push, 'cocoapods/command/push'
autoload :Repo, 'cocoapods/command/repo'
autoload :Search, 'cocoapods/command/search'
autoload :Setup, 'cocoapods/command/setup'
autoload :Spec, 'cocoapods/command/spec'
autoload :Update, 'cocoapods/command/update'
class Help < Informative
def initialize(command_class, argv, unrecognized_command = nil)
@command_class, @argv, @unrecognized_command = command_class, argv, unrecognized_command
end
def message
message = [
'',
@command_class.banner.gsub(/\$ pod (.*)/, '$ pod \1'.green),
'',
'Options:',
'',
options,
"\n",
].join("\n")
message << "[!] Unrecognized command: `#{@unrecognized_command}'\n".red if @unrecognized_command
message << "[!] Unrecognized argument#{@argv.count > 1 ? 's' : ''}: `#{@argv.join(' - ')}'\n".red unless @argv.empty?
message
end
private
def options
options = @command_class.options
keys = options.map(&:first)
key_size = keys.inject(0) { |size, key| key.size > size ? key.size : size }
options.map { |key, desc| " #{key.ljust(key_size)} #{desc}" }.join("\n")
end
end end
class ARGV < Array class Command < CLAide::Command
def options; select { |x| x.to_s[0,1] == '-' }; end autoload :ErrorReport, 'cocoapods/command/error_report'
def arguments; self - options; end autoload :Linter, 'cocoapods/command/linter'
def option(name); !!delete(name); end
def shift_argument; (arg = arguments[0]) && delete(arg); end
end
def self.banner self.abstract_command = true
commands = ['install', 'update', 'outdated', 'list', 'push', 'repo', 'search', 'setup', 'spec'].sort self.command = 'pod'
banner = "To see help for the available commands run:\n\n" self.description = 'CocoaPods, the Objective-C library package manager.'
banner + commands.map { |cmd| " * $ pod #{cmd.green} --help" }.join("\n")
end
def self.options def self.options
[ [
['--help', 'Show help information'], ['--silent', 'Show nothing'],
['--silent', 'Print nothing'], ['--version', 'Show the version of CocoaPods'],
['--no-color', 'Print output without color'], ].concat(super)
['--verbose', 'Print more information while working'],
['--version', 'Prints the version of CocoaPods'],
]
end end
def self.run(*argv) def self.parse(argv)
sub_command = parse(*argv) command = super
unless sub_command.is_a?(Setup) || ENV['SKIP_SETUP'] unless command.is_a?(Setup) || ENV['SKIP_SETUP']
Setup.new(ARGV.new).run_if_needed Setup.new(CLAide::ARGV.new([])).run_if_needed
end end
sub_command.run command
UI.puts
rescue Interrupt
puts "[!] Cancelled".red
Config.instance.verbose? ? raise : exit(1)
rescue Exception => e
if e.is_a?(PlainInformative) || ENV['COCOA_PODS_ENV'] == 'development' # also catches Informative
puts e.message
puts *e.backtrace if Config.instance.verbose? || ENV['COCOA_PODS_ENV'] == 'development'
else
puts ErrorReport.report(e)
end
exit 1
end end
def self.parse(*argv) def self.run(argv)
argv = ARGV.new(argv) argv = CLAide::ARGV.new(argv)
if argv.option('--version') if argv.flag?('version')
puts VERSION puts VERSION
exit!(0) exit!(0)
end end
super(argv)
show_help = argv.option('--help')
Config.instance.silent = argv.option('--silent')
Config.instance.verbose = argv.option('--verbose')
String.send(:define_method, :colorize) { |string , _| string } if argv.option( '--no-color' )
command_class = case command_argument = argv.shift_argument
when 'install' then Install
when 'list' then List
when 'outdated' then Outdated
when 'push' then Push
when 'repo' then Repo
when 'search' then Search
when 'setup' then Setup
when 'spec' then Spec
when 'update' then Update
end end
if command_class.nil? def self.report_error(error)
raise Help.new(self, argv, command_argument) if error.is_a?(Interrupt)
elsif show_help puts "[!] Cancelled".red
raise Help.new(command_class, argv) Config.instance.verbose? ? raise : exit(1)
else else
command_class.new(argv) puts ErrorReport.report(error)
exit 1
end end
end end
include Config::Mixin
def initialize(argv) def initialize(argv)
raise Help.new(self.class, argv) config.silent = argv.flag?('silent')
super
config.verbose = self.verbose?
# TODO we should probably not even load colored unless needed
String.send(:define_method, :colorize) { |string , _| string } unless self.colorize_output?
end end
include Config::Mixin
private private
def verify_podfile_exists! def verify_podfile_exists!
...@@ -145,3 +74,11 @@ module Pod ...@@ -145,3 +74,11 @@ module Pod
end end
end end
require 'cocoapods/command/list'
require 'cocoapods/command/outdated'
require 'cocoapods/command/project'
require 'cocoapods/command/push'
require 'cocoapods/command/repo'
require 'cocoapods/command/search'
require 'cocoapods/command/setup'
require 'cocoapods/command/spec'
module Pod module Pod
class Command class Command
class List < Command class List < Command
def self.banner self.summary = 'List pods'
%{List all pods: self.description = 'Lists all available pods.'
$ pod list
Lists all available pods.
$ pod list new
Lists the pods introduced in the master repository since the last check.}
end
def self.options def self.options
[[ [[
...@@ -24,19 +15,33 @@ module Pod ...@@ -24,19 +15,33 @@ module Pod
executable :git executable :git
def initialize(argv) def initialize(argv)
@update = argv.option('--update') @update = argv.flag?('update')
@stats = argv.option('--stats') @stats = argv.flag?('stats')
@new = argv.option('new') super
super unless argv.empty?
end end
def list_all def run
update_if_necessary!
sets = Source.all_sets sets = Source.all_sets
sets.each { |set| UI.pod(set, :name) } sets.each { |set| UI.pod(set, :name) }
UI.puts "\n#{sets.count} pods were found" UI.puts "\n#{sets.count} pods were found"
end end
def list_new def update_if_necessary!
if @update && config.verbose?
UI.section("\nUpdating Spec Repositories\n".yellow) do
Repo.new(ARGV.new(["update"])).run
end
end
end
class New < List
self.summary = 'Lists pods introduced in the master spec-repo since the last check'
def run
update_if_necessary!
days = [1,2,3,5,8] days = [1,2,3,5,8]
dates, groups = {}, {} dates, groups = {}, {}
days.each {|d| dates[d] = Time.now - 60 * 60 * 24 * d} days.each {|d| dates[d] = Time.now - 60 * 60 * 24 * d}
...@@ -62,12 +67,6 @@ module Pod ...@@ -62,12 +67,6 @@ module Pod
end end
end end
end end
def run
UI.section("\nUpdating Spec Repositories\n".yellow) do
Repo.new(ARGV.new(["update"])).run
end if @update && config.verbose?
@new ? list_new : list_all
end end
end end
end end
......
module Pod module Pod
class Command class Command
class Outdated < Command class Outdated < Command
def self.banner self.summary = 'Show outdated project dependencies'
%{Show outdated pods:
$ pod outdated
self.description = <<-DESC
Shows the outdated pods in the current Podfile.lock, but only those from Shows the outdated pods in the current Podfile.lock, but only those from
spec repos, not those from local/external sources or `:head' versions.} spec repos, not those from local/external sources or `:head' versions.
end DESC
def self.options def self.options
[["--no-update", "Skip running `pod repo update` before install"]].concat(super) [["--no-update", "Skip running `pod repo update` before install"]].concat(super)
end end
def initialize(argv) def initialize(argv)
config.skip_repo_update = argv.option('--no-update') config.skip_repo_update = argv.flag?('update', true)
super unless argv.empty? super
end end
def run def run
......
module Pod module Pod
class Command class Command
module Project
def self.options
[
["--no-clean", "Leave SCM dirs like `.git' and `.svn' intact after downloading"],
["--no-doc", "Skip documentation generation with appledoc"],
["--no-integrate", "Skip integration of the Pods libraries in the Xcode project(s)"],
["--no-update", "Skip running `pod repo update` before install"],
].concat(super)
end
def initialize(argv)
config.clean = argv.flag?('clean', true)
config.generate_docs = argv.flag?('doc', true)
config.integrate_targets = argv.flag?('integrate', true)
config.skip_repo_update = !argv.flag?('update', true)
super
end
def run_install_with_update(update)
sandbox = Sandbox.new(config.project_pods_root)
resolver = Resolver.new(config.podfile, config.lockfile, sandbox)
resolver.update_mode = update
Installer.new(resolver).install!
end
end
class Install < Command class Install < Command
def self.banner include Project
%{Installing dependencies of a project:
$ pod install self.summary = 'Install project dependencies'
self.description = <<-DESC
Downloads all dependencies defined in `Podfile' and creates an Xcode Downloads all dependencies defined in `Podfile' and creates an Xcode
Pods library project in `./Pods'. Pods library project in `./Pods'.
...@@ -19,37 +45,27 @@ module Pod ...@@ -19,37 +45,27 @@ module Pod
This will configure the project to reference the Pods static library, This will configure the project to reference the Pods static library,
add a build configuration file, and add a post build script to copy add a build configuration file, and add a post build script to copy
Pod resources.} Pod resources.
end DESC
def self.options def run
[ verify_podfile_exists!
["--no-clean", "Leave SCM dirs like `.git' and `.svn' intact after downloading"], run_install_with_update(false)
["--no-doc", "Skip documentation generation with appledoc"],
["--no-integrate", "Skip integration of the Pods libraries in the Xcode project(s)"],
["--no-update", "Skip running `pod repo update` before install"],
].concat(super)
end end
def initialize(argv)
config.clean = !argv.option('--no-clean')
config.generate_docs = !argv.option('--no-doc')
config.integrate_targets = !argv.option('--no-integrate')
config.skip_repo_update = argv.option('--no-update')
super unless argv.empty?
end end
def run_install_with_update(update) class Update < Command
sandbox = Sandbox.new(config.project_pods_root) include Project
resolver = Resolver.new(config.podfile, config.lockfile, sandbox)
resolver.update_mode = update self.summary = 'Update outdated project dependencies'
Installer.new(resolver).install!
end
def run def run
verify_podfile_exists! verify_podfile_exists!
run_install_with_update(false) verify_lockfile_exists!
run_install_with_update(true)
end end
end end
end end
end end
...@@ -4,16 +4,16 @@ require 'active_support/core_ext/string/inflections' ...@@ -4,16 +4,16 @@ require 'active_support/core_ext/string/inflections'
module Pod module Pod
class Command class Command
class Push < Command class Push < Command
def self.banner self.summary = 'Push new specifications to a spec-repo'
%{Pushing new specifications to a spec-repo:
$ pod push REPO [NAME.podspec]
self.description = <<-DESC
Validates NAME.podspec or `*.podspec' in the current working dir, creates Validates NAME.podspec or `*.podspec' in the current working dir, creates
a directory and version folder for the pod in the local copy of a directory and version folder for the pod in the local copy of
REPO (~/.cocoapods/[REPO]), copies the podspec file into the version directory, REPO (~/.cocoapods/[REPO]), copies the podspec file into the version directory,
and finally it pushes REPO to its remote.} and finally it pushes REPO to its remote.
end DESC
self.arguments = 'REPO [NAME.podspec]'
def self.options def self.options
[ ["--allow-warnings", "Allows to push if warnings are not evitable"], [ ["--allow-warnings", "Allows to push if warnings are not evitable"],
...@@ -24,11 +24,16 @@ module Pod ...@@ -24,11 +24,16 @@ module Pod
executable :git executable :git
def initialize(argv) def initialize(argv)
@allow_warnings = argv.option('--allow-warnings') @allow_warnings = argv.flag?('allow-warnings')
@local_only = argv.option('--local-only') @local_only = argv.flag?('local-only')
@repo = argv.shift_argument @repo = argv.shift_argument
@podspec = argv.shift_argument @podspec = argv.shift_argument
super unless argv.empty? && @repo super
end
def validate!
super
help! "A spec-repo name is required." unless @repo
end end
def run def run
...@@ -84,7 +89,7 @@ module Pod ...@@ -84,7 +89,7 @@ module Pod
lint_argv << "--silent" if config.silent lint_argv << "--silent" if config.silent
all_valid = true all_valid = true
podspec_files.each do |podspec| podspec_files.each do |podspec|
Spec.new(ARGV.new(lint_argv + [podspec.to_s])).run Spec.parse(lint_argv + [podspec.to_s]).run
end end
end end
......
...@@ -3,59 +3,34 @@ require 'fileutils' ...@@ -3,59 +3,34 @@ require 'fileutils'
module Pod module Pod
class Command class Command
class Repo < Command class Repo < Command
def self.banner self.abstract_command = true
%{Managing spec-repos:
$ pod repo add NAME URL [BRANCH] # TODO should not show a usage banner!
self.summary = 'Manage spec-repositories'
class Add < Repo
self.summary = 'Add a spec repo.'
self.description = <<-DESC
Clones `URL' in the local spec-repos directory at `~/.cocoapods'. The Clones `URL' in the local spec-repos directory at `~/.cocoapods'. The
remote can later be referred to by `NAME'. remote can later be referred to by `NAME'.
DESC
$ pod repo update [NAME] self.arguments = 'NAME URL [BRANCH]'
Updates the local clone of the spec-repo `NAME'. If `NAME' is omitted
this will update all spec-repos in `~/.cocoapods'.
$ pod repo lint [NAME | DIRECTORY]
Lints the spec-repo `NAME'. If a directory is provided it is assumed
to be the root of a repo. Finally, if NAME is not provided this will
lint all the spec-repos known to CocoaPods.}
end
def self.options
[["--only-errors", "Lint presents only the errors"]].concat(super)
end
extend Executable
executable :git
def initialize(argv) def initialize(argv)
case @action = argv.arguments[0] @name, @url, @branch = argv.shift_argument, argv.shift_argument, argv.shift_argument
when 'add'
unless (@name = argv.arguments[1]) && (@url = argv.arguments[2])
raise Informative, "#{@action == 'add' ? 'Adding' : 'Updating the remote of'} a repo needs a `name' and a `url'."
end
@branch = argv.arguments[3]
when 'update'
@name = argv.arguments[1]
when 'lint'
@name = argv.arguments[1]
@only_errors = argv.option('--only-errors')
else
super super
end end
end
def dir def validate!
config.repos_dir + @name super
unless @name && @url
help! "Adding a repo needs a `NAME' and a `URL."
end end
def run
send @action.gsub('-', '_')
end end
def add def run
UI.section("Cloning spec repo `#{@name}' from `#{@url}'#{" (branch `#{@branch}')" if @branch}") do UI.section("Cloning spec repo `#{@name}' from `#{@url}'#{" (branch `#{@branch}')" if @branch}") do
config.repos_dir.mkpath config.repos_dir.mkpath
Dir.chdir(config.repos_dir) { git!("clone '#{@url}' #{@name}") } Dir.chdir(config.repos_dir) { git!("clone '#{@url}' #{@name}") }
...@@ -63,8 +38,24 @@ module Pod ...@@ -63,8 +38,24 @@ module Pod
check_versions(dir) check_versions(dir)
end end
end end
end
class Update < Repo
self.summary = 'Update a spec repo.'
self.description = <<-DESC
Updates the local clone of the spec-repo `NAME'. If `NAME' is omitted
this will update all spec-repos in `~/.cocoapods'.
DESC
self.arguments = '[NAME]'
def initialize(argv)
@name = argv.shift_argument
super
end
def update def run
dirs = @name ? [dir] : config.repos_dir.children.select {|c| c.directory?} dirs = @name ? [dir] : config.repos_dir.children.select {|c| c.directory?}
dirs.each do |dir| dirs.each do |dir|
UI.section "Updating spec repo `#{dir.basename}'" do UI.section "Updating spec repo `#{dir.basename}'" do
...@@ -80,8 +71,30 @@ module Pod ...@@ -80,8 +71,30 @@ module Pod
check_versions(dir) check_versions(dir)
end end
end end
end
class Lint < Repo
self.summary = 'Validates all specs in a repo.'
self.description = <<-DESC
Lints the spec-repo `NAME'. If a directory is provided it is assumed
to be the root of a repo. Finally, if `NAME' is not provided this
will lint all the spec-repos known to CocoaPods.
DESC
self.arguments = '[ NAME | DIRECTORY ]'
def self.options
[["--only-errors", "Lint presents only the errors"]].concat(super)
end
def initialize(argv)
@name = argv.shift_argument
@only_errors = argv.flag?('only-errors')
super
end
def lint def run
if @name if @name
dirs = File.exists?(@name) ? [ Pathname.new(@name) ] : [ dir ] dirs = File.exists?(@name) ? [ Pathname.new(@name) ] : [ dir ]
else else
...@@ -129,10 +142,15 @@ module Pod ...@@ -129,10 +142,15 @@ module Pod
end end
end end
end end
end
def print_messages(type, messages) extend Executable
return if config.silent? executable :git
messages.each {|msg| UI.puts " - #{type.ljust(5)} | #{msg}"}
# TODO some of the following methods can probably move to one of the subclasses.
def dir
config.repos_dir + @name
end end
def check_versions(dir) def check_versions(dir)
...@@ -147,6 +165,13 @@ module Pod ...@@ -147,6 +165,13 @@ module Pod
UI.puts "\nCocoapods #{versions['last']} is available.\n".green if has_update(versions) && config.new_version_message? UI.puts "\nCocoapods #{versions['last']} is available.\n".green if has_update(versions) && config.new_version_message?
end end
protected
def print_messages(type, messages)
return if config.silent?
messages.each {|msg| UI.puts " - #{type.ljust(5)} | #{msg}"}
end
def self.compatible?(name) def self.compatible?(name)
dir = Config.instance.repos_dir + name dir = Config.instance.repos_dir + name
versions = versions(dir) versions = versions(dir)
......
module Pod module Pod
class Command class Command
class Search < Command class Search < Command
def self.banner self.summary = 'Search pods'
%{Search pods:
$ pod search [QUERY]
self.description = <<-DESC
Searches for pods, ignoring case, whose name matches `QUERY'. If the Searches for pods, ignoring case, whose name matches `QUERY'. If the
`--full' option is specified, this will also search in the summary and `--full' option is specified, this will also search in the summary and
description of the pods.} description of the pods.
end DESC
self.arguments = '[QUERY]'
def self.options def self.options
[[ [[
...@@ -19,10 +19,15 @@ module Pod ...@@ -19,10 +19,15 @@ module Pod
end end
def initialize(argv) def initialize(argv)
@full_text_search = argv.option('--full') @full_text_search = argv.flag?('full')
@stats = argv.option('--stats') @stats = argv.flag?('stats')
@query = argv.shift_argument @query = argv.shift_argument
super unless argv.empty? && @query super
end
def validate!
super
help! "A search query is required." unless @query
end end
def run def run
......
module Pod module Pod
class Command class Command
class Setup < Command class Setup < Command
def self.banner self.summary = 'Setup the CocoaPods environment'
%{Setup CocoaPods environment:
$ pod setup
self.description = <<-DESC
Creates a directory at `~/.cocoapods' which will hold your spec-repos. Creates a directory at `~/.cocoapods' which will hold your spec-repos.
This is where it will create a clone of the public `master' spec-repo from: This is where it will create a clone of the public `master' spec-repo from:
https://github.com/CocoaPods/Specs https://github.com/CocoaPods/Specs
If the clone already exists, it will ensure that it is up-to-date.} If the clone already exists, it will ensure that it is up-to-date.
end DESC
def self.options def self.options
[["--push", "Use this option to enable push access once granted"]].concat(super) [["--push", "Use this option to enable push access once granted"]].concat(super)
...@@ -22,8 +20,8 @@ module Pod ...@@ -22,8 +20,8 @@ module Pod
executable :git executable :git
def initialize(argv) def initialize(argv)
@push_option = argv.option('--push') @push_option = argv.flag?('push')
super unless argv.empty? super
end end
def dir def dir
...@@ -71,11 +69,11 @@ module Pod ...@@ -71,11 +69,11 @@ module Pod
end end
def add_master_repo def add_master_repo
@command ||= Repo.new(ARGV.new(['add', 'master', url, 'master'])).run @command ||= Repo::Add.parse(['master', url, 'master']).run
end end
def update_master_repo def update_master_repo
Repo.new(ARGV.new(['update', 'master'])).run Repo::Update.run(['master'])
end end
def set_master_repo_branch def set_master_repo_branch
......
...@@ -5,51 +5,31 @@ require 'active_support/core_ext/string/inflections' ...@@ -5,51 +5,31 @@ require 'active_support/core_ext/string/inflections'
module Pod module Pod
class Command class Command
class Spec < Command class Spec < Command
def self.banner self.abstract_command = true
%{Managing PodSpec files:
$ pod spec create [ NAME | https://github.com/USER/REPO ] self.summary = 'Manage pod specs'
class Create < Spec
self.summary = 'Create spec file stub.'
self.description = <<-DESC
Creates a PodSpec, in the current working dir, called `NAME.podspec'. Creates a PodSpec, in the current working dir, called `NAME.podspec'.
If a GitHub url is passed the spec is prepopulated. If a GitHub url is passed the spec is prepopulated.
DESC
$ pod spec lint [ NAME.podspec | DIRECTORY | http://PATH/NAME.podspec, ... ] self.arguments = '[ NAME | https://github.com/USER/REPO ]'
Validates `NAME.podspec'. If a directory is provided it validates
the podspec files found, including subfolders. In case
the argument is omitted, it defaults to the current working dir.}
end
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) def initialize(argv)
@action = argv.shift_argument @name_or_url, @url = argv.shift_argument, argv.shift_argument
if @action == 'create'
@name_or_url = argv.shift_argument
@url = argv.shift_argument
super if @name_or_url.nil?
super unless argv.empty?
elsif @action == 'lint'
@quick = argv.option('--quick')
@local = argv.option('--local')
@only_errors = argv.option('--only-errors')
@no_clean = argv.option('--no-clean')
@podspecs_paths = argv
else
super super
end end
end
def run def validate!
send @action super
help! "A pod name or repo URL is required." unless @name_or_url
end end
def create def run
if repo_id_match = (@url || @name_or_url).match(/github.com\/([^\/\.]*\/[^\/\.]*)\.*/) if repo_id_match = (@url || @name_or_url).match(/github.com\/([^\/\.]*\/[^\/\.]*)\.*/)
# This is to make sure Faraday doesn't warn the user about the `system_timer` gem missing. # This is to make sure Faraday doesn't warn the user about the `system_timer` gem missing.
old_warn, $-w = $-w, nil old_warn, $-w = $-w, nil
...@@ -71,8 +51,36 @@ module Pod ...@@ -71,8 +51,36 @@ module Pod
(Pathname.pwd + "#{data[:name]}.podspec").open('w') { |f| f << spec } (Pathname.pwd + "#{data[:name]}.podspec").open('w') { |f| f << spec }
UI.puts "\nSpecification created at #{data[:name]}.podspec".green UI.puts "\nSpecification created at #{data[:name]}.podspec".green
end end
end
def lint class Lint < Spec
self.summary = 'Validates a spec file.'
self.description = <<-DESC
Validates `NAME.podspec'. If a directory is provided it validates
the podspec files found, including subfolders. In case
the argument is omitted, it defaults to the current working dir.
DESC
self.arguments = '[ NAME.podspec | DIRECTORY | http://PATH/NAME.podspec, ... ]'
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')
@no_clean = argv.flag?('clean', false)
@podspecs_paths = argv.arguments!
super
end
def run
UI.puts UI.puts
invalid_count = 0 invalid_count = 0
podspecs_to_lint.each do |podspec| podspecs_to_lint.each do |podspec|
...@@ -116,7 +124,9 @@ module Pod ...@@ -116,7 +124,9 @@ module Pod
end end
podspecs_tmp_dir.rmtree if podspecs_tmp_dir.exist? podspecs_tmp_dir.rmtree if podspecs_tmp_dir.exist?
end end
end
# TODO some of the following methods can probably move to one of the subclasses.
private private
def print_messages(type, messages) def print_messages(type, messages)
......
module Pod
class Command
class Update < Install
def self.banner
%{Updating dependencies of a project:
$ pod update
Updates all dependencies.}
end
def self.options
[["--no-update", "Skip running `pod repo update` before install"]].concat(super)
end
def initialize(argv)
config.skip_repo_update = argv.option('--no-update')
super unless argv.empty?
end
def run
verify_podfile_exists!
verify_lockfile_exists!
run_install_with_update(true)
end
end
end
end
...@@ -82,7 +82,7 @@ module Pod ...@@ -82,7 +82,7 @@ module Pod
unless config.skip_repo_update? unless config.skip_repo_update?
UI.section 'Updating spec repositories' do UI.section 'Updating spec repositories' do
Command::Repo.new(Command::ARGV.new(["update"])).run Command::Repo::Update.parse([]).run
end if !@lockfile || !(@pods_by_state[:added] + @pods_by_state[:changed]).empty? || update_mode end if !@lockfile || !(@pods_by_state[:added] + @pods_by_state[:changed]).empty? || update_mode
end end
......
module Pod module Pod
class Version < Gem::Version VERSION = '0.16.0.rc2'
# @returns A Version described by its #to_s method.
#
# @TODO The `from' part of the regexp should be remove before 1.0.0.
#
def self.from_string(string)
if string =~ /HEAD (based on|from) (.*)/
v = Version.new($2)
v.head = true
v
else
Version.new(string)
end
end
attr_accessor :head
alias_method :head?, :head
def to_s
head? ? "HEAD based on #{super}" : super
end
end
end end
module Pod
class Version < Gem::Version
# @returns A Version described by its #to_s method.
#
# @TODO The `from' part of the regexp should be remove before 1.0.0.
#
def self.from_string(string)
if string =~ /HEAD (based on|from) (.*)/
v = Version.new($2)
v.head = true
v
else
Version.new(string)
end
end
attr_accessor :head
alias_method :head?, :head
def to_s
head? ? "HEAD based on #{super}" : super
end
end
end
require File.expand_path('../../../spec_helper', __FILE__) require File.expand_path('../../../spec_helper', __FILE__)
describe "Pod::Command::Install" do module Pod
extend SpecHelper::Command describe Command::Install do
extend SpecHelper::TemporaryDirectory extend SpecHelper::TemporaryDirectory
extend SpecHelper::TemporaryRepos
it "should include instructions on how to reference the xcode project" do
Pod::Command::Install.banner.should.match %r{xcodeproj 'path/to/XcodeProject'}
end
it "tells the user that no Podfile or podspec was found in the current working dir" do it "tells the user that no Podfile or podspec was found in the current working dir" do
exception = lambda { run_command('install','--no-update') }.should.raise Pod::Informative exception = lambda { run_command('install', '--no-update') }.should.raise Informative
exception.message.should.include "No `Podfile' found in the current working directory." exception.message.should.include "No `Podfile' found in the current working directory."
end end
end
end end
require File.expand_path('../../../spec_helper', __FILE__) require File.expand_path('../../../spec_helper', __FILE__)
describe "Pod::Command::List" do module Pod
describe Command::List do
extend SpecHelper::TemporaryRepos extend SpecHelper::TemporaryRepos
def command(arguments = argv) it "lists the known pods" do
command = Pod::Command::List.new(arguments) out = run_command('list')
end
it "complains for wrong parameters" do
lambda { command(argv('wrong')).run }.should.raise Pod::Command::Help
lambda { command(argv('--wrong')).run }.should.raise Pod::Command::Help
end
it "presents the known pods" do
list = command()
list.run
[ /ZBarSDK/, [ /ZBarSDK/,
/TouchJSON/, /TouchJSON/,
/SDURLCache/, /SDURLCache/,
/MagicalRecord/, /MagicalRecord/,
/A2DynamicDelegate/, /A2DynamicDelegate/,
/\d+ pods were found/ /\d+ pods were found/
].each { |regex| Pod::UI.output.should =~ regex } ].each { |regex| out.should =~ regex }
end end
it "returns the new pods" do it "lists the new pods" do
Time.stubs(:now).returns(Time.mktime(2012,2,3)) Time.stubs(:now).returns(Time.mktime(2012,2,3))
list = command(argv('new')) out = run_command('list', 'new')
list.run
[ 'iCarousel', [ 'iCarousel',
'libPusher', 'libPusher',
'SSCheckBoxView', 'SSCheckBoxView',
...@@ -36,8 +26,8 @@ describe "Pod::Command::List" do ...@@ -36,8 +26,8 @@ describe "Pod::Command::List" do
'FileMD5Hash', 'FileMD5Hash',
'cocoa-oauth', 'cocoa-oauth',
'iRate' 'iRate'
].each {|s| Pod::UI.output.should.include s } ].each {|s| out.should.include s }
end
end end
end end
require File.expand_path('../../../spec_helper', __FILE__) require File.expand_path('../../../spec_helper', __FILE__)
describe Pod::Command::Outdated do module Pod
extend SpecHelper::Command describe Command::Outdated do
extend SpecHelper::TemporaryDirectory extend SpecHelper::TemporaryDirectory
extend SpecHelper::TemporaryRepos extend SpecHelper::TemporaryRepos
it "tells the user that no Podfile was found in the current working dir" do it "tells the user that no Podfile was found in the current working dir" do
exception = lambda { run_command('outdated','--no-update') }.should.raise Pod::Informative exception = lambda { run_command('outdated', '--no-update') }.should.raise Informative
exception.message.should.include "No `Podfile' found in the current working directory." exception.message.should.include "No `Podfile' found in the current working directory."
end end
...@@ -14,9 +14,10 @@ describe Pod::Command::Outdated do ...@@ -14,9 +14,10 @@ describe Pod::Command::Outdated do
file = temporary_directory + 'Podfile' file = temporary_directory + 'Podfile'
File.open(file, 'w') {|f| f.write('platform :ios') } File.open(file, 'w') {|f| f.write('platform :ios') }
Dir.chdir(temporary_directory) do Dir.chdir(temporary_directory) do
exception = lambda { run_command('outdated','--no-update') }.should.raise Pod::Informative exception = lambda { run_command('outdated', '--no-update') }.should.raise Informative
exception.message.should.include "No `Podfile.lock' found in the current working directory" exception.message.should.include "No `Podfile.lock' found in the current working directory"
end end
end end
end
end end
This diff is collapsed.
...@@ -7,20 +7,9 @@ describe "Pod::Command::Repo" do ...@@ -7,20 +7,9 @@ describe "Pod::Command::Repo" do
end end
describe "In general" do describe "In general" do
extend SpecHelper::Command
extend SpecHelper::TemporaryDirectory extend SpecHelper::TemporaryDirectory
extend SpecHelper::TemporaryRepos extend SpecHelper::TemporaryRepos
it "runs with correct parameters" do
lambda { run_command('repo', 'update') }.should.not.raise
lambda { run_command('repo', 'lint', temporary_directory.to_s) }.should.not.raise
end
it "complains for wrong parameters" do
lambda { run_command('repo', 'add') }.should.raise Pod::Informative
lambda { run_command('repo', 'add', 'NAME') }.should.raise Pod::Informative
end
it "adds a spec-repo" do it "adds a spec-repo" do
run_command('repo', 'add', 'private', fixture('spec-repos/master')) run_command('repo', 'add', 'private', fixture('spec-repos/master'))
git_config('private', 'remote.origin.url').should == fixture('spec-repos/master').to_s git_config('private', 'remote.origin.url').should == fixture('spec-repos/master').to_s
...@@ -67,7 +56,6 @@ describe "Pod::Command::Repo" do ...@@ -67,7 +56,6 @@ describe "Pod::Command::Repo" do
end end
describe "Concerning a repo support" do describe "Concerning a repo support" do
extend SpecHelper::Command
extend SpecHelper::TemporaryDirectory extend SpecHelper::TemporaryDirectory
extend SpecHelper::TemporaryRepos extend SpecHelper::TemporaryRepos
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
require File.expand_path('../../spec_helper', __FILE__)
# describe "Pod::Command" do
# extend SpecHelper::Command
# extend SpecHelper::TemporaryDirectory
# extend SpecHelper::TemporaryRepos
#
# TODO:
# it "raises help informative if an unknown parameter is passed"
# it "performs setup if needed"
# end
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -28,7 +28,7 @@ module SpecHelper ...@@ -28,7 +28,7 @@ module SpecHelper
end end
def add_repo(name, from) def add_repo(name, from)
command = command('repo', 'add', name, from) command = Pod::Command.parse(['repo', 'add', name, from])
command.run command.run
# The test branch is used by the push specs # The test branch is used by the push specs
Dir.chdir(command.dir) do Dir.chdir(command.dir) do
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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