Commit 5b562bb3 authored by Eloy Durán's avatar Eloy Durán

Refactor and cleanup command source files.

parent bff1e393
......@@ -54,9 +54,8 @@ module Pod
def self.banner
commands = ['install', 'update', 'outdated', 'list', 'push', 'repo', 'search', 'setup', 'spec'].sort
banner = "\nTo see help for the available commands run:\n\n"
commands.each {|cmd| banner << " * $ pod #{cmd.green} --help\n"}
banner
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
......@@ -132,6 +131,25 @@ module Pod
private
def verify_podfile_exists!
unless config.podfile
raise Informative, "No `Podfile' found in the current working directory."
end
end
def verify_lockfile_exists!
unless config.lockfile
raise Informative, "No `Podfile.lock' found in the current working directory, run `pod install'."
end
end
def update_spec_repos_if_necessary!
if @update_repo
print_title 'Updating Spec Repositories', true
Repo.new(ARGV.new(["update"])).run
end
end
def print_title(title, only_verbose = true)
if config.verbose?
puts "\n" + title.yellow
......
......@@ -19,8 +19,7 @@ module Pod
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.
}
Pod resources.}
end
def self.options
......@@ -40,20 +39,18 @@ module Pod
super unless argv.empty?
end
def run
unless podfile = config.podfile
raise Informative, "No `Podfile' found in the current working directory."
end
if @update_repo
print_title 'Updating Spec Repositories', true
Repo.new(ARGV.new(["update"])).run
end
def run_install_with_update(update)
sandbox = Sandbox.new(config.project_pods_root)
resolver = Resolver.new(podfile, config.lockfile, sandbox)
resolver = Resolver.new(config.podfile, config.lockfile, sandbox)
resolver.update_mode = update
Installer.new(resolver).install!
end
def run
verify_podfile_exists!
update_spec_repos_if_necessary!
run_install_with_update(false)
end
end
end
end
......@@ -6,7 +6,7 @@ module Pod
$ pod outdated
Shows the outdated pods in the current Podfile.lock. }
Shows the outdated pods in the current Podfile.lock.}
end
def self.options
......@@ -21,17 +21,9 @@ module Pod
end
def run
unless podfile = config.podfile
raise Informative, "No `Podfile' found in the current working directory."
end
unless lockfile = config.lockfile
raise Informative, "No `Podfile.lock' found in the current working directory, run `pod install'."
end
if @update_repo
print_title 'Updating Spec Repositories', true
Repo.new(ARGV.new(["update"])).run
end
verify_podfile_exists!
verify_lockfile_exists!
update_spec_repos_if_necessary!
sandbox = Sandbox.new(config.project_pods_root)
resolver = Resolver.new(podfile, lockfile, sandbox)
......
......@@ -4,7 +4,7 @@ module Pod
class Command
class Push < Command
def self.banner
%{Pushing new specifications to a spec-repo:
%{Pushing new specifications to a spec-repo:
$ pod push REPO [NAME.podspec]
......
......@@ -2,7 +2,7 @@ module Pod
class Command
class Setup < Command
def self.banner
%{Setup CocoaPods environment:
%{Setup CocoaPods environment:
$ pod setup
......
......@@ -4,7 +4,7 @@ module Pod
class Command
class Spec < Command
def self.banner
%{Managing PodSpec files:
%{Managing PodSpec files:
$ pod spec create [ NAME | https://github.com/USER/REPO ]
......
module Pod
class Command
class Update < Command
class Update < Install
def self.banner
%{Updating dependencies of a project:
......@@ -9,40 +9,11 @@ module Pod
Updates all dependencies.}
end
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.option('--no-clean')
config.generate_docs = !argv.option('--no-doc')
config.integrate_targets = !argv.option('--no-integrate')
@update_repo = !argv.option('--no-update')
super unless argv.empty?
end
def run
unless podfile = config.podfile
raise Informative, "No `Podfile' found in the current working directory."
end
unless lockfile = config.lockfile
raise Informative, "No `Podfile.lock' found in the current working directory, run `pod install'."
end
if @update_repo
print_title 'Updating Spec Repositories', true
Repo.new(ARGV.new(["update"])).run
end
sandbox = Sandbox.new(config.project_pods_root)
resolver = Resolver.new(podfile, lockfile, sandbox)
resolver.update_mode = true
Installer.new(resolver).install!
verify_podfile_exists!
verify_lockfile_exists!
update_spec_repos_if_necessary!
run_install_with_update(true)
end
end
end
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment