Commit b31abc36 authored by Marius Rackwitz's avatar Marius Rackwitz

[Command] Add Command#installer_for_config

Use that instead of Project#run_install_with_update
parent 4345124a
...@@ -33,7 +33,6 @@ module Pod ...@@ -33,7 +33,6 @@ module Pod
self.plugin_prefixes = %w(claide cocoapods) self.plugin_prefixes = %w(claide cocoapods)
[Install, Update, Outdated, IPC::Podfile, IPC::Repl].each { |c| c.send(:include, ProjectDirectory) } [Install, Update, Outdated, IPC::Podfile, IPC::Repl].each { |c| c.send(:include, ProjectDirectory) }
[Outdated].each { |c| c.send(:include, Project) }
def self.options def self.options
[ [
...@@ -102,6 +101,14 @@ module Pod ...@@ -102,6 +101,14 @@ module Pod
private private
# Returns a new {Installer} parametrized from the {Config}.
#
# @return [Installer]
#
def installer_for_config
Installer.new(config.sandbox, config.podfile, config.lockfile)
end
# Checks that the podfile exists. # Checks that the podfile exists.
# #
# @raise If the podfile does not exists. # @raise If the podfile does not exists.
......
...@@ -32,30 +32,9 @@ module Pod ...@@ -32,30 +32,9 @@ module Pod
end end
end end
# Provides support for the common behaviour of the `install` and `update`
# commands.
#
module Project
# Runs the installer.
#
# @param [Hash, Boolean, nil] update
# Pods that have been requested to be updated or true if all Pods
# should be updated
#
# @return [void]
#
def run_install_with_update(update)
installer = Installer.new(config.sandbox, config.podfile, config.lockfile)
installer.update = update
installer.install!
end
end
#-------------------------------------------------------------------------# #-------------------------------------------------------------------------#
class Install < Command class Install < Command
include Project
self.summary = 'Install project dependencies to Podfile.lock versions' self.summary = 'Install project dependencies to Podfile.lock versions'
self.description = <<-DESC self.description = <<-DESC
...@@ -88,15 +67,15 @@ module Pod ...@@ -88,15 +67,15 @@ module Pod
def run def run
verify_podfile_exists! verify_podfile_exists!
run_install_with_update(false) installer = installer_for_config
installer.update = false
installer.install!
end end
end end
#-------------------------------------------------------------------------# #-------------------------------------------------------------------------#
class Update < Command class Update < Command
include Project
self.summary = 'Update outdated project dependencies and create new ' \ self.summary = 'Update outdated project dependencies and create new ' \
'Podfile.lock' 'Podfile.lock'
...@@ -127,6 +106,7 @@ module Pod ...@@ -127,6 +106,7 @@ module Pod
def run def run
verify_podfile_exists! verify_podfile_exists!
installer = installer_for_config
if @pods if @pods
verify_lockfile_exists! verify_lockfile_exists!
...@@ -147,11 +127,12 @@ module Pod ...@@ -147,11 +127,12 @@ module Pod
raise Informative, message raise Informative, message
end end
run_install_with_update(:pods => @pods) installer.update = { :pods => @pods }
else else
UI.puts 'Update all pods'.yellow unless @pods UI.puts 'Update all pods'.yellow unless @pods
run_install_with_update(true) installer.update = true
end end
installer.install!
end end
end 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