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:
- AFNetworking (0.7.0):
PODS:
- AFNetworking (0.7.0):
- JSONKit - JSONKit
- FormatterKit (1.0.0): - FormatterKit (1.0.0):
- FormatterKit/ArrayFormatter (= 1.0.0) - FormatterKit/ArrayFormatter (= 1.0.0)
- FormatterKit/LocationFormatter (= 1.0.0) - FormatterKit/LocationFormatter (= 1.0.0)
- FormatterKit/OrdinalNumberFormatter (= 1.0.0) - FormatterKit/OrdinalNumberFormatter (= 1.0.0)
...@@ -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)
SPEC CHECKSUMS: DEPENDENCIES:
FormatterKit/UnitOfInformationFormatter: 12dea999a2df19e389f7b821962fc4088de8b821 - AFNetworking (~> 0.7.0)
FormatterKit/TimeIntervalFormatter: 12dea999a2df19e389f7b821962fc4088de8b821 - FormatterKit
SPEC CHECKSUMS:
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: PODS:
FormatterKit/UnitOfInformationFormatter: 12dea999a2df19e389f7b821962fc4088de8b821 - AFNetworking (0.7.0):
AFNetworking: 7bf22b0ed1d9068909cd67206db78204eb63dd2c
JSONKit: a01a22c75f27eae76b4badd55a91c20fe6e86477
FormatterKit/URLRequestFormatter: 12dea999a2df19e389f7b821962fc4088de8b821
FormatterKit: 12dea999a2df19e389f7b821962fc4088de8b821
FormatterKit/OrdinalNumberFormatter: 12dea999a2df19e389f7b821962fc4088de8b821
FormatterKit/TimeIntervalFormatter: 12dea999a2df19e389f7b821962fc4088de8b821
FormatterKit/ArrayFormatter: 12dea999a2df19e389f7b821962fc4088de8b821
FormatterKit/LocationFormatter: 12dea999a2df19e389f7b821962fc4088de8b821
PODS:
- AFNetworking (0.7.0):
- JSONKit - JSONKit
- FormatterKit (1.0.0): - FormatterKit (1.0.0):
- FormatterKit/ArrayFormatter (= 1.0.0) - FormatterKit/ArrayFormatter (= 1.0.0)
- FormatterKit/LocationFormatter (= 1.0.0) - FormatterKit/LocationFormatter (= 1.0.0)
- FormatterKit/OrdinalNumberFormatter (= 1.0.0) - FormatterKit/OrdinalNumberFormatter (= 1.0.0)
...@@ -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
DEPENDENCIES: PODS:
- MGSplitViewController (1.0.0)
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
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
include CLAide::InformativeError
end
class Command < CLAide::Command
autoload :ErrorReport, 'cocoapods/command/error_report' autoload :ErrorReport, 'cocoapods/command/error_report'
autoload :Install, 'cocoapods/command/install'
autoload :List, 'cocoapods/command/list'
autoload :Linter, 'cocoapods/command/linter' 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 self.abstract_command = true
options = @command_class.options self.command = 'pod'
keys = options.map(&:first) self.description = 'CocoaPods, the Objective-C library package manager.'
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
class ARGV < Array
def options; select { |x| x.to_s[0,1] == '-' }; end
def arguments; self - options; end
def option(name); !!delete(name); end
def shift_argument; (arg = arguments[0]) && delete(arg); end
end
def self.banner
commands = ['install', 'update', 'outdated', 'list', 'push', 'repo', 'search', 'setup', 'spec'].sort
banner = "To see help for the available commands run:\n\n"
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)
end
show_help = argv.option('--help') def self.report_error(error)
Config.instance.silent = argv.option('--silent') if error.is_a?(Interrupt)
Config.instance.verbose = argv.option('--verbose') puts "[!] Cancelled".red
Config.instance.verbose? ? raise : exit(1)
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
if command_class.nil?
raise Help.new(self, argv, command_argument)
elsif show_help
raise Help.new(command_class, argv)
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,51 +15,59 @@ module Pod ...@@ -24,51 +15,59 @@ 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!
days = [1,2,3,5,8] if @update && config.verbose?
dates, groups = {}, {} UI.section("\nUpdating Spec Repositories\n".yellow) do
days.each {|d| dates[d] = Time.now - 60 * 60 * 24 * d} Repo.new(ARGV.new(["update"])).run
sets = Source.all_sets end
creation_dates = Pod::Specification::Statistics.instance.creation_dates(sets) end
end
class New < List
self.summary = 'Lists pods introduced in the master spec-repo since the last check'
def run
update_if_necessary!
sets.each do |set| days = [1,2,3,5,8]
set_date = creation_dates[set.name] dates, groups = {}, {}
days.each do |d| days.each {|d| dates[d] = Time.now - 60 * 60 * 24 * d}
if set_date >= dates[d] sets = Source.all_sets
groups[d] = [] unless groups[d] creation_dates = Pod::Specification::Statistics.instance.creation_dates(sets)
groups[d] << set
break sets.each do |set|
set_date = creation_dates[set.name]
days.each do |d|
if set_date >= dates[d]
groups[d] = [] unless groups[d]
groups[d] << set
break
end
end end
end end
end days.reverse.each do |d|
days.reverse.each do |d| sets = groups[d]
sets = groups[d] next unless sets
next unless sets UI.section("\nPods added in the last #{"day".pluralize(d)}".yellow) do
UI.section("\nPods added in the last #{"day".pluralize(d)}".yellow) do sorted = sets.sort_by {|s| creation_dates[s.name]}
sorted = sets.sort_by {|s| creation_dates[s.name]} sorted.each { |set| UI.pod(set, (@stats ? :stats : :name)) }
sorted.each { |set| UI.pod(set, (@stats ? :stats : :name)) } end
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 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.} DESC
end
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
class Install < Command module Project
def self.banner
%{Installing dependencies of a project:
$ pod install
Downloads all dependencies defined in `Podfile' and creates an Xcode
Pods library project in `./Pods'.
The Xcode project file should be specified in your `Podfile` like this:
xcodeproj 'path/to/XcodeProject'
If no xcodeproj is specified, then a search for an Xcode project will
be made. If more than one Xcode project is found, the command will
raise an error.
This will configure the project to reference the Pods static library,
add a build configuration file, and add a post build script to copy
Pod resources.}
end
def self.options def self.options
[ [
["--no-clean", "Leave SCM dirs like `.git' and `.svn' intact after downloading"], ["--no-clean", "Leave SCM dirs like `.git' and `.svn' intact after downloading"],
...@@ -32,11 +11,11 @@ module Pod ...@@ -32,11 +11,11 @@ module Pod
end end
def initialize(argv) def initialize(argv)
config.clean = !argv.option('--no-clean') config.clean = argv.flag?('clean', true)
config.generate_docs = !argv.option('--no-doc') config.generate_docs = argv.flag?('doc', true)
config.integrate_targets = !argv.option('--no-integrate') config.integrate_targets = argv.flag?('integrate', true)
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_install_with_update(update) def run_install_with_update(update)
...@@ -45,11 +24,48 @@ module Pod ...@@ -45,11 +24,48 @@ module Pod
resolver.update_mode = update resolver.update_mode = update
Installer.new(resolver).install! Installer.new(resolver).install!
end end
end
class Install < Command
include Project
self.summary = 'Install project dependencies'
self.description = <<-DESC
Downloads all dependencies defined in `Podfile' and creates an Xcode
Pods library project in `./Pods'.
The Xcode project file should be specified in your `Podfile` like this:
xcodeproj 'path/to/XcodeProject'
If no xcodeproj is specified, then a search for an Xcode project will
be made. If more than one Xcode project is found, the command will
raise an error.
This will configure the project to reference the Pods static library,
add a build configuration file, and add a post build script to copy
Pod resources.
DESC
def run def run
verify_podfile_exists! verify_podfile_exists!
run_install_with_update(false) run_install_with_update(false)
end end
end end
class Update < Command
include Project
self.summary = 'Update outdated project dependencies'
def run
verify_podfile_exists!
verify_lockfile_exists!
run_install_with_update(true)
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
a directory and version folder for the pod in the local copy of
REPO (~/.cocoapods/[REPO]), copies the podspec file into the version directory,
and finally it pushes REPO to its remote.
DESC
Validates NAME.podspec or `*.podspec' in the current working dir, creates self.arguments = 'REPO [NAME.podspec]'
a directory and version folder for the pod in the local copy of
REPO (~/.cocoapods/[REPO]), copies the podspec file into the version directory,
and finally it pushes REPO to its remote.}
end
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,136 +3,154 @@ require 'fileutils' ...@@ -3,136 +3,154 @@ 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'
Clones `URL' in the local spec-repos directory at `~/.cocoapods'. The class Add < Repo
remote can later be referred to by `NAME'. self.summary = 'Add a spec repo.'
$ pod repo update [NAME] self.description = <<-DESC
Clones `URL' in the local spec-repos directory at `~/.cocoapods'. The
remote can later be referred to by `NAME'.
DESC
Updates the local clone of the spec-repo `NAME'. If `NAME' is omitted self.arguments = 'NAME URL [BRANCH]'
this will update all spec-repos in `~/.cocoapods'.
$ pod repo lint [NAME | DIRECTORY] def initialize(argv)
@name, @url, @branch = argv.shift_argument, argv.shift_argument, argv.shift_argument
Lints the spec-repo `NAME'. If a directory is provided it is assumed super
to be the root of a repo. Finally, if NAME is not provided this will end
lint all the spec-repos known to CocoaPods.}
end
def self.options
[["--only-errors", "Lint presents only the errors"]].concat(super)
end
extend Executable def validate!
executable :git super
unless @name && @url
help! "Adding a repo needs a `NAME' and a `URL."
end
end
def initialize(argv) def run
case @action = argv.arguments[0] UI.section("Cloning spec repo `#{@name}' from `#{@url}'#{" (branch `#{@branch}')" if @branch}") do
when 'add' config.repos_dir.mkpath
unless (@name = argv.arguments[1]) && (@url = argv.arguments[2]) Dir.chdir(config.repos_dir) { git!("clone '#{@url}' #{@name}") }
raise Informative, "#{@action == 'add' ? 'Adding' : 'Updating the remote of'} a repo needs a `name' and a `url'." Dir.chdir(dir) { git!("checkout #{@branch}") } if @branch
check_versions(dir)
end 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
end end
end end
def dir class Update < Repo
config.repos_dir + @name self.summary = 'Update a spec repo.'
end
def run self.description = <<-DESC
send @action.gsub('-', '_') Updates the local clone of the spec-repo `NAME'. If `NAME' is omitted
end this will update all spec-repos in `~/.cocoapods'.
DESC
self.arguments = '[NAME]'
def add def initialize(argv)
UI.section("Cloning spec repo `#{@name}' from `#{@url}'#{" (branch `#{@branch}')" if @branch}") do @name = argv.shift_argument
config.repos_dir.mkpath super
Dir.chdir(config.repos_dir) { git!("clone '#{@url}' #{@name}") }
Dir.chdir(dir) { git!("checkout #{@branch}") } if @branch
check_versions(dir)
end end
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
Dir.chdir(dir) do Dir.chdir(dir) do
`git rev-parse >/dev/null 2>&1` `git rev-parse >/dev/null 2>&1`
if $?.exitstatus.zero? if $?.exitstatus.zero?
git!("pull") git!("pull")
else else
UI.message "Not a git repository" UI.message "Not a git repository"
end
end end
end end
check_versions(dir)
end end
check_versions(dir)
end end
end end
def lint class Lint < Repo
if @name self.summary = 'Validates all specs in a repo.'
dirs = File.exists?(@name) ? [ Pathname.new(@name) ] : [ dir ]
else self.description = <<-DESC
dirs = config.repos_dir.children.select {|c| c.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.
DESC
self.arguments = '[ NAME | DIRECTORY ]'
def self.options
[["--only-errors", "Lint presents only the errors"]].concat(super)
end end
dirs.each do |dir|
check_versions(dir)
UI.puts "\nLinting spec repo `#{dir.realpath.basename}'\n".yellow
podspecs = Pathname.glob( dir + '**/*.podspec')
invalid_count = 0
podspecs.each do |podspec|
linter = Linter.new(podspec)
linter.quick = true
linter.repo_path = dir
linter.lint
case linter.result_type
when :error
invalid_count += 1
color = :red
should_display = true
when :warning
color = :yellow
should_display = !@only_errors
end
if should_display def initialize(argv)
UI.puts " -> ".send(color) << linter.spec_name @name = argv.shift_argument
print_messages('ERROR', linter.errors) @only_errors = argv.flag?('only-errors')
unless @only_errors super
print_messages('WARN', linter.warnings) end
print_messages('NOTE', linter.notes)
def run
if @name
dirs = File.exists?(@name) ? [ Pathname.new(@name) ] : [ dir ]
else
dirs = config.repos_dir.children.select {|c| c.directory?}
end
dirs.each do |dir|
check_versions(dir)
UI.puts "\nLinting spec repo `#{dir.realpath.basename}'\n".yellow
podspecs = Pathname.glob( dir + '**/*.podspec')
invalid_count = 0
podspecs.each do |podspec|
linter = Linter.new(podspec)
linter.quick = true
linter.repo_path = dir
linter.lint
case linter.result_type
when :error
invalid_count += 1
color = :red
should_display = true
when :warning
color = :yellow
should_display = !@only_errors
end
if should_display
UI.puts " -> ".send(color) << linter.spec_name
print_messages('ERROR', linter.errors)
unless @only_errors
print_messages('WARN', linter.warnings)
print_messages('NOTE', linter.notes)
end
UI.puts unless config.silent?
end end
UI.puts unless config.silent?
end end
end UI.puts "Analyzed #{podspecs.count} podspecs files.\n\n" unless config.silent?
UI.puts "Analyzed #{podspecs.count} podspecs files.\n\n" unless config.silent?
if invalid_count == 0 if invalid_count == 0
UI.puts "All the specs passed validation.".green << "\n\n" unless config.silent? UI.puts "All the specs passed validation.".green << "\n\n" unless config.silent?
else else
raise Informative, "#{invalid_count} podspecs failed validation." raise Informative, "#{invalid_count} podspecs failed validation."
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
`--full' option is specified, this will also search in the summary and
description of the pods.
DESC
Searches for pods, ignoring case, whose name matches `QUERY'. If the self.arguments = '[QUERY]'
`--full' option is specified, this will also search in the summary and
description of the pods.}
end
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.
This is where it will create a clone of the public `master' spec-repo from:
Creates a directory at `~/.cocoapods' which will hold your spec-repos. https://github.com/CocoaPods/Specs
This is where it will create a clone of the public `master' spec-repo from:
https://github.com/CocoaPods/Specs If the clone already exists, it will ensure that it is up-to-date.
DESC
If the clone already exists, it will ensure that it is up-to-date.}
end
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
......
This diff is collapsed.
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 it "tells the user that no Podfile or podspec was found in the current working dir" do
Pod::Command::Install.banner.should.match %r{xcodeproj 'path/to/XcodeProject'} exception = lambda { run_command('install', '--no-update') }.should.raise Informative
end exception.message.should.include "No `Podfile' found in the current working directory."
end
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.message.should.include "No `Podfile' found in the current working directory."
end end
end end
This diff is collapsed.
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
it "tells the user that no Lockfile was found in the current working dir" do it "tells the user that no Lockfile was found in the current working dir" 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.
This diff is collapsed.
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.
This diff is collapsed.
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