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

Merge branch 'claide' into 0.17

parents 750dfe2a 124df8a9
GIT
remote: git://github.com/CocoaPods/Xcodeproj.git
revision: cc71c669a05934886c56169bbe209014a7a1af8e
revision: eaab002f308e2641232630b1b5d4ab3c2f10a10a
specs:
xcodeproj (0.4.0.rc1)
xcodeproj (0.4.0.rc3)
activesupport (~> 3.2.6)
colored (~> 1.2)
......@@ -20,6 +20,7 @@ PATH
specs:
cocoapods (0.16.0.rc2)
activesupport (~> 3.2.6)
claide (~> 0.1)
colored (~> 1.2)
escape (~> 0.0.4)
faraday (~> 0.8.1)
......@@ -38,13 +39,14 @@ GEM
addressable (2.3.2)
awesome_print (1.1.0)
bacon (1.1.0)
claide (0.2.0)
coderay (1.0.8)
colored (1.2)
crack (0.3.1)
escape (0.0.4)
faraday (0.8.4)
multipart-post (~> 1.1)
faraday_middleware (0.8.8)
faraday_middleware (0.9.0)
faraday (>= 0.7.4, < 0.9)
github-markup (0.7.4)
hashie (1.2.0)
......
......@@ -13,4 +13,4 @@ end
require 'cocoapods'
Pod::Command.run(*ARGV)
Pod::Command.run(ARGV)
# -*- encoding: utf-8 -*-
$:.unshift File.expand_path('../lib', __FILE__)
require 'cocoapods'
require 'cocoapods/version'
Gem::Specification.new do |s|
s.name = "cocoapods"
......@@ -26,6 +26,7 @@ Gem::Specification.new do |s|
s.executables = %w{ pod }
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 'faraday', '~> 0.8.1'
......
COCOAPODS: 0.15.1
PODS:
- AFNetworking (0.7.0):
PODS:
- AFNetworking (0.7.0):
- JSONKit
- FormatterKit (1.0.0):
- FormatterKit (1.0.0):
- FormatterKit/ArrayFormatter (= 1.0.0)
- FormatterKit/LocationFormatter (= 1.0.0)
- FormatterKit/OrdinalNumberFormatter (= 1.0.0)
......@@ -19,17 +17,19 @@ PODS:
- FormatterKit/UnitOfInformationFormatter (1.0.0)
- JSONKit (1.5pre)
SPEC CHECKSUMS:
FormatterKit/UnitOfInformationFormatter: 12dea999a2df19e389f7b821962fc4088de8b821
FormatterKit/TimeIntervalFormatter: 12dea999a2df19e389f7b821962fc4088de8b821
DEPENDENCIES:
- AFNetworking (~> 0.7.0)
- FormatterKit
SPEC CHECKSUMS:
AFNetworking: 7bf22b0ed1d9068909cd67206db78204eb63dd2c
JSONKit: a01a22c75f27eae76b4badd55a91c20fe6e86477
FormatterKit/OrdinalNumberFormatter: 12dea999a2df19e389f7b821962fc4088de8b821
FormatterKit: 12dea999a2df19e389f7b821962fc4088de8b821
FormatterKit/ArrayFormatter: 12dea999a2df19e389f7b821962fc4088de8b821
FormatterKit/LocationFormatter: 12dea999a2df19e389f7b821962fc4088de8b821
FormatterKit/OrdinalNumberFormatter: 12dea999a2df19e389f7b821962fc4088de8b821
FormatterKit/TimeIntervalFormatter: 12dea999a2df19e389f7b821962fc4088de8b821
FormatterKit/URLRequestFormatter: 12dea999a2df19e389f7b821962fc4088de8b821
FormatterKit/ArrayFormatter: 12dea999a2df19e389f7b821962fc4088de8b821
FormatterKit: 12dea999a2df19e389f7b821962fc4088de8b821
FormatterKit/UnitOfInformationFormatter: 12dea999a2df19e389f7b821962fc4088de8b821
JSONKit: a01a22c75f27eae76b4badd55a91c20fe6e86477
DEPENDENCIES:
- AFNetworking (~> 0.7.0)
- FormatterKit
COCOAPODS: 0.16.0.rc2
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:
- AFNetworking (0.7.0):
PODS:
- AFNetworking (0.7.0):
- JSONKit
- FormatterKit (1.0.0):
- FormatterKit (1.0.0):
- FormatterKit/ArrayFormatter (= 1.0.0)
- FormatterKit/LocationFormatter (= 1.0.0)
- FormatterKit/OrdinalNumberFormatter (= 1.0.0)
......@@ -28,8 +17,19 @@ PODS:
- FormatterKit/UnitOfInformationFormatter (1.0.0)
- JSONKit (1.5pre)
COCOAPODS: 0.15.1
DEPENDENCIES:
DEPENDENCIES:
- AFNetworking (~> 0.7.0)
- 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)
SPEC CHECKSUMS:
SPEC CHECKSUMS:
MGSplitViewController: e0b0bc01aa81e1559765c39e7a764c890dac373a
PODS:
- MGSplitViewController (1.0.0)
COCOAPODS: 0.15.1
COCOAPODS: 0.16.0.rc2
......@@ -37,10 +37,10 @@ DEPENDENCIES:
SPEC CHECKSUMS:
FileMD5Hash: c3b015e6fb293eea0a0c276747f61f20408c2644
ISO8601DateFormatter: dc05a2481edf49668d85d3ff8c466c32eb544780
JSONKit: 3d4708953ea7ae399a49777372d8b060a43ddd27
LibComponentLogging-Core: c80e88f2b7fb204554de7bec13374daf394097e8
LibComponentLogging-NSLog: d8f54e7eb65bb893f91cab5864ecf8e85ebd9359
NSData+Base64: be7e201540fa7805ecedc1f38d456e008be259b2
JSONKit: a01a22c75f27eae76b4badd55a91c20fe6e86477
LibComponentLogging-Core: 9c2914bc501a0656450860a136b0e8e52f3e16d4
LibComponentLogging-NSLog: a4bb0f6de612eef7b5fcdbd9cc96dc868ba1f2df
NSData+Base64: 8b910cb8a64f45daec6fb15936c36a9a911c57ca
RestKit: a9f24f857c792183bcc656f891abe93d38e342ee
RestKit/JSON: a9f24f857c792183bcc656f891abe93d38e342ee
RestKit/Network: a9f24f857c792183bcc656f891abe93d38e342ee
......@@ -50,4 +50,4 @@ SPEC CHECKSUMS:
SOCKit: 9d71b00c699cf5aa2989d6aa12f3392b048123db
cocoa-oauth: 8f4c8b77c77ac660de37f8125557c4ec09b0118a
COCOAPODS: 0.13.0
COCOAPODS: 0.16.0.rc2
COCOAPODS: 0.15.1
PODS:
- AFNetworking (1.0RC1)
DEPENDENCIES:
DEPENDENCIES:
- AFNetworking
SPEC CHECKSUMS:
SPEC CHECKSUMS:
AFNetworking: b21c1252d437fd322e7db1caa93b163d76a362cb
PODS:
- AFNetworking (1.0RC1)
COCOAPODS: 0.16.0.rc2
......@@ -11,4 +11,4 @@ SPEC CHECKSUMS:
AFNetworking: b21c1252d437fd322e7db1caa93b163d76a362cb
SSToolkit: 852044205c6a15586431e90f46b2ef01f693285a
COCOAPODS: 0.13.0
COCOAPODS: 0.16.0.rc2
......@@ -6,6 +6,6 @@ DEPENDENCIES:
- JSONKit
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(
exit 1
end
module Pod
VERSION = '0.16.0.rc2'
require 'cocoapods/version'
module Pod
class PlainInformative < StandardError
end
class Informative < PlainInformative
def message
# TODO: remove formatting from raise calls and remove conditional
super !~ /\[!\]/ ? "[!] #{super}\n".red : super
super !~ /\[!\]/ ? "[!] #{super}".red : super
end
end
......@@ -41,7 +41,7 @@ module Pod
autoload :Spec, 'cocoapods/specification'
autoload :Specification, 'cocoapods/specification'
autoload :UI, 'cocoapods/user_interface'
autoload :Version, 'cocoapods/version'
autoload :Version, 'cocoapods/version_class'
autoload :Pathname, 'pathname'
autoload :FileList, 'cocoapods/file_list'
......
require 'colored'
require 'claide'
module Pod
class Command
class PlainInformative
include CLAide::InformativeError
end
class Command < CLAide::Command
autoload :ErrorReport, 'cocoapods/command/error_report'
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
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
self.abstract_command = true
self.command = 'pod'
self.description = 'CocoaPods, the Objective-C library package manager.'
def self.options
[
['--help', 'Show help information'],
['--silent', 'Print nothing'],
['--no-color', 'Print output without color'],
['--verbose', 'Print more information while working'],
['--version', 'Prints the version of CocoaPods'],
]
['--silent', 'Show nothing'],
['--version', 'Show the version of CocoaPods'],
].concat(super)
end
def self.run(*argv)
sub_command = parse(*argv)
unless sub_command.is_a?(Setup) || ENV['SKIP_SETUP']
Setup.new(ARGV.new).run_if_needed
def self.parse(argv)
command = super
unless command.is_a?(Setup) || ENV['SKIP_SETUP']
Setup.new(CLAide::ARGV.new([])).run_if_needed
end
sub_command.run
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
command
end
def self.parse(*argv)
argv = ARGV.new(argv)
if argv.option('--version')
def self.run(argv)
argv = CLAide::ARGV.new(argv)
if argv.flag?('version')
puts VERSION
exit!(0)
end
super(argv)
end
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
if command_class.nil?
raise Help.new(self, argv, command_argument)
elsif show_help
raise Help.new(command_class, argv)
def self.report_error(error)
if error.is_a?(Interrupt)
puts "[!] Cancelled".red
Config.instance.verbose? ? raise : exit(1)
else
command_class.new(argv)
puts ErrorReport.report(error)
exit 1
end
end
include Config::Mixin
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
include Config::Mixin
private
def verify_podfile_exists!
......@@ -145,3 +74,11 @@ module Pod
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
class Command
class List < Command
def self.banner
%{List all pods:
$ pod list
Lists all available pods.
$ pod list new
Lists the pods introduced in the master repository since the last check.}
end
self.summary = 'List pods'
self.description = 'Lists all available pods.'
def self.options
[[
......@@ -24,51 +15,59 @@ module Pod
executable :git
def initialize(argv)
@update = argv.option('--update')
@stats = argv.option('--stats')
@new = argv.option('new')
super unless argv.empty?
@update = argv.flag?('update')
@stats = argv.flag?('stats')
super
end
def list_all
def run
update_if_necessary!
sets = Source.all_sets
sets.each { |set| UI.pod(set, :name) }
UI.puts "\n#{sets.count} pods were found"
end
def list_new
days = [1,2,3,5,8]
dates, groups = {}, {}
days.each {|d| dates[d] = Time.now - 60 * 60 * 24 * d}
sets = Source.all_sets
creation_dates = Pod::Specification::Statistics.instance.creation_dates(sets)
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!
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
days = [1,2,3,5,8]
dates, groups = {}, {}
days.each {|d| dates[d] = Time.now - 60 * 60 * 24 * d}
sets = Source.all_sets
creation_dates = Pod::Specification::Statistics.instance.creation_dates(sets)
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
days.reverse.each do |d|
sets = groups[d]
next unless sets
UI.section("\nPods added in the last #{"day".pluralize(d)}".yellow) do
sorted = sets.sort_by {|s| creation_dates[s.name]}
sorted.each { |set| UI.pod(set, (@stats ? :stats : :name)) }
days.reverse.each do |d|
sets = groups[d]
next unless sets
UI.section("\nPods added in the last #{"day".pluralize(d)}".yellow) do
sorted = sets.sort_by {|s| creation_dates[s.name]}
sorted.each { |set| UI.pod(set, (@stats ? :stats : :name)) }
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
module Pod
class Command
class Outdated < Command
def self.banner
%{Show outdated pods:
self.summary = 'Show outdated project dependencies'
$ pod outdated
Shows the outdated pods in the current Podfile.lock, but only those from
spec repos, not those from local/external sources or `:head' versions.}
end
self.description = <<-DESC
Shows the outdated pods in the current Podfile.lock, but only those from
spec repos, not those from local/external sources or `:head' versions.
DESC
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?
config.skip_repo_update = argv.flag?('update', true)
super
end
def run
......
module Pod
class Command
class Install < Command
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
module Project
def self.options
[
["--no-clean", "Leave SCM dirs like `.git' and `.svn' intact after downloading"],
......@@ -32,11 +11,11 @@ module Pod
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?
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)
......@@ -45,11 +24,48 @@ module Pod
resolver.update_mode = update
Installer.new(resolver).install!
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
verify_podfile_exists!
run_install_with_update(false)
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
......@@ -4,16 +4,16 @@ require 'active_support/core_ext/string/inflections'
module Pod
class Command
class Push < Command
def self.banner
%{Pushing new specifications to a spec-repo:
self.summary = 'Push 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
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
self.arguments = 'REPO [NAME.podspec]'
def self.options
[ ["--allow-warnings", "Allows to push if warnings are not evitable"],
......@@ -24,11 +24,16 @@ module Pod
executable :git
def initialize(argv)
@allow_warnings = argv.option('--allow-warnings')
@local_only = argv.option('--local-only')
@allow_warnings = argv.flag?('allow-warnings')
@local_only = argv.flag?('local-only')
@repo = 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
def run
......@@ -84,7 +89,7 @@ module Pod
lint_argv << "--silent" if config.silent
all_valid = true
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
......
......@@ -3,136 +3,154 @@ require 'fileutils'
module Pod
class Command
class Repo < Command
def self.banner
%{Managing spec-repos:
self.abstract_command = true
$ 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
remote can later be referred to by `NAME'.
class Add < Repo
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
this will update all spec-repos in `~/.cocoapods'.
self.arguments = 'NAME URL [BRANCH]'
$ 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
def initialize(argv)
@name, @url, @branch = argv.shift_argument, argv.shift_argument, argv.shift_argument
super
end
extend Executable
executable :git
def validate!
super
unless @name && @url
help! "Adding a repo needs a `NAME' and a `URL."
end
end
def initialize(argv)
case @action = argv.arguments[0]
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'."
def run
UI.section("Cloning spec repo `#{@name}' from `#{@url}'#{" (branch `#{@branch}')" if @branch}") do
config.repos_dir.mkpath
Dir.chdir(config.repos_dir) { git!("clone '#{@url}' #{@name}") }
Dir.chdir(dir) { git!("checkout #{@branch}") } if @branch
check_versions(dir)
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
def dir
config.repos_dir + @name
end
class Update < Repo
self.summary = 'Update a spec repo.'
def run
send @action.gsub('-', '_')
end
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 add
UI.section("Cloning spec repo `#{@name}' from `#{@url}'#{" (branch `#{@branch}')" if @branch}") do
config.repos_dir.mkpath
Dir.chdir(config.repos_dir) { git!("clone '#{@url}' #{@name}") }
Dir.chdir(dir) { git!("checkout #{@branch}") } if @branch
check_versions(dir)
def initialize(argv)
@name = argv.shift_argument
super
end
end
def update
dirs = @name ? [dir] : config.repos_dir.children.select {|c| c.directory?}
dirs.each do |dir|
UI.section "Updating spec repo `#{dir.basename}'" do
Dir.chdir(dir) do
`git rev-parse >/dev/null 2>&1`
if $?.exitstatus.zero?
git!("pull")
else
UI.message "Not a git repository"
def run
dirs = @name ? [dir] : config.repos_dir.children.select {|c| c.directory?}
dirs.each do |dir|
UI.section "Updating spec repo `#{dir.basename}'" do
Dir.chdir(dir) do
`git rev-parse >/dev/null 2>&1`
if $?.exitstatus.zero?
git!("pull")
else
UI.message "Not a git repository"
end
end
end
check_versions(dir)
end
check_versions(dir)
end
end
def lint
if @name
dirs = File.exists?(@name) ? [ Pathname.new(@name) ] : [ dir ]
else
dirs = config.repos_dir.children.select {|c| c.directory?}
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
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)
def initialize(argv)
@name = argv.shift_argument
@only_errors = argv.flag?('only-errors')
super
end
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
UI.puts unless config.silent?
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
UI.puts "All the specs passed validation.".green << "\n\n" unless config.silent?
else
raise Informative, "#{invalid_count} podspecs failed validation."
if invalid_count == 0
UI.puts "All the specs passed validation.".green << "\n\n" unless config.silent?
else
raise Informative, "#{invalid_count} podspecs failed validation."
end
end
end
end
def print_messages(type, messages)
return if config.silent?
messages.each {|msg| UI.puts " - #{type.ljust(5)} | #{msg}"}
extend Executable
executable :git
# TODO some of the following methods can probably move to one of the subclasses.
def dir
config.repos_dir + @name
end
def check_versions(dir)
......@@ -147,6 +165,13 @@ module Pod
UI.puts "\nCocoapods #{versions['last']} is available.\n".green if has_update(versions) && config.new_version_message?
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)
dir = Config.instance.repos_dir + name
versions = versions(dir)
......
module Pod
class Command
class Search < Command
def self.banner
%{Search pods:
self.summary = '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
`--full' option is specified, this will also search in the summary and
description of the pods.}
end
self.arguments = '[QUERY]'
def self.options
[[
......@@ -19,10 +19,15 @@ module Pod
end
def initialize(argv)
@full_text_search = argv.option('--full')
@stats = argv.option('--stats')
@full_text_search = argv.flag?('full')
@stats = argv.flag?('stats')
@query = argv.shift_argument
super unless argv.empty? && @query
super
end
def validate!
super
help! "A search query is required." unless @query
end
def run
......
module Pod
class Command
class Setup < Command
def self.banner
%{Setup CocoaPods environment:
self.summary = 'Setup the 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.
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.}
end
If the clone already exists, it will ensure that it is up-to-date.
DESC
def self.options
[["--push", "Use this option to enable push access once granted"]].concat(super)
......@@ -22,8 +20,8 @@ module Pod
executable :git
def initialize(argv)
@push_option = argv.option('--push')
super unless argv.empty?
@push_option = argv.flag?('push')
super
end
def dir
......@@ -71,11 +69,11 @@ module Pod
end
def add_master_repo
@command ||= Repo.new(ARGV.new(['add', 'master', url, 'master'])).run
@command ||= Repo::Add.parse(['master', url, 'master']).run
end
def update_master_repo
Repo.new(ARGV.new(['update', 'master'])).run
Repo::Update.run(['master'])
end
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
unless config.skip_repo_update?
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
......
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
VERSION = '0.16.0.rc2'
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__)
describe "Pod::Command::Install" do
extend SpecHelper::Command
extend SpecHelper::TemporaryDirectory
extend SpecHelper::TemporaryRepos
module Pod
describe Command::Install do
extend SpecHelper::TemporaryDirectory
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
exception = lambda { run_command('install','--no-update') }.should.raise Pod::Informative
exception.message.should.include "No `Podfile' found in the current working directory."
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 Informative
exception.message.should.include "No `Podfile' found in the current working directory."
end
end
end
This diff is collapsed.
require File.expand_path('../../../spec_helper', __FILE__)
describe Pod::Command::Outdated do
extend SpecHelper::Command
extend SpecHelper::TemporaryDirectory
extend SpecHelper::TemporaryRepos
module Pod
describe Command::Outdated do
extend SpecHelper::TemporaryDirectory
extend SpecHelper::TemporaryRepos
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.message.should.include "No `Podfile' found in the current working directory."
end
it "tells the user that no Podfile was found in the current working dir" do
exception = lambda { run_command('outdated', '--no-update') }.should.raise Informative
exception.message.should.include "No `Podfile' found in the current working directory."
end
it "tells the user that no Lockfile was found in the current working dir" do
file = temporary_directory + 'Podfile'
File.open(file, 'w') {|f| f.write('platform :ios') }
Dir.chdir(temporary_directory) do
exception = lambda { run_command('outdated','--no-update') }.should.raise Pod::Informative
exception.message.should.include "No `Podfile.lock' found in the current working directory"
it "tells the user that no Lockfile was found in the current working dir" do
file = temporary_directory + 'Podfile'
File.open(file, 'w') {|f| f.write('platform :ios') }
Dir.chdir(temporary_directory) do
exception = lambda { run_command('outdated', '--no-update') }.should.raise Informative
exception.message.should.include "No `Podfile.lock' found in the current working directory"
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