Class: Pod::Command::Update

Inherits:
Pod::Command show all
Includes:
Project
Defined in:
lib/cocoapods/command/project.rb

Overview

————————————————————————-#

Instance Method Summary collapse

Methods included from Project

included, #run_install_with_update

Methods inherited from Pod::Command

#ensure_master_spec_repo_exists!, options, report_error, run

Methods included from Pod::Config::Mixin

#config

Constructor Details

#initialize(argv) ⇒ Update

Returns a new instance of Update.



125
126
127
128
# File 'lib/cocoapods/command/project.rb', line 125

def initialize(argv)
  @pods = argv.arguments! unless argv.arguments.empty?
  super
end

Instance Method Details

#runObject



130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
# File 'lib/cocoapods/command/project.rb', line 130

def run
  verify_podfile_exists!

  if @pods
    verify_lockfile_exists!

    # 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

    if missing_pods.length > 0
      if missing_pods.length > 1
        message = "Pods `#{missing_pods.join('`, `')}` are not " \
          'installed and cannot be updated'
      else
        message = "The `#{missing_pods.first}` Pod is not installed " \
          'and cannot be updated'
      end
      raise Informative, message
    end

    run_install_with_update(:pods => @pods)
  else
    UI.puts 'Update all pods'.yellow unless @pods
    run_install_with_update(true)
  end
end