Commit d8cb489a authored by Marius Rackwitz's avatar Marius Rackwitz

[Command::Update] Extract #verify_pods_are_installed!

Increases code readability.
parent 368f89ea
...@@ -73,30 +73,33 @@ module Pod ...@@ -73,30 +73,33 @@ module Pod
super super
end end
# Check if all given pods are installed
#
def verify_pods_are_installed!
lockfile_roots = config.lockfile.pod_names.map { |p| Specification.root_name(p) }
missing_pods = @pods.map { |p| Specification.root_name(p) }.select do |pod|
!lockfile_roots.include?(pod)
end
unless missing_pods.empty?
message = if missing_pods.length > 1
"Pods `#{missing_pods.join('`, `')}` are not " \
'installed and cannot be updated'
else
"The `#{missing_pods.first}` Pod is not installed " \
'and cannot be updated'
end
raise Informative, message
end
end
def run def run
verify_podfile_exists! verify_podfile_exists!
installer = installer_for_config installer = installer_for_config
if @pods if @pods
verify_lockfile_exists! verify_lockfile_exists!
verify_pods_are_installed!
# Check if all given pods are installed
lockfile_roots = config.lockfile.pod_names.map { |p| Specification.root_name(p) }
missing_pods = @pods.map { |p| Specification.root_name(p) }.select do |pod|
!lockfile_roots.include?(pod)
end
unless missing_pods.empty?
message = if missing_pods.length > 1
"Pods `#{missing_pods.join('`, `')}` are not " \
'installed and cannot be updated'
else
"The `#{missing_pods.first}` Pod is not installed " \
'and cannot be updated'
end
raise Informative, message
end
installer.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
......
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