Class: Pod::Command::Update

Inherits:
Pod::Command show all
Includes:
ProjectDirectory, RepoUpdate
Defined in:
lib/cocoapods/command/update.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Pod::Command

#ensure_master_spec_repo_exists!, report_error, run

Methods included from Pod::Config::Mixin

#config

Constructor Details

#initialize(argv) ⇒ Update

Returns a new instance of Update


32
33
34
35
36
37
38
39
40
41
# File 'lib/cocoapods/command/update.rb', line 32

def initialize(argv)
  @pods = argv.arguments!

  @source_urls = argv.option('sources', '').split(',')
  @excluded_pods = argv.option('exclude-pods', '').split(',')
  @clean_install = argv.flag?('clean-install', false)
  @source_pods = @source_urls.flat_map { |url| config.sources_manager.source_with_name_or_url(url).pods }

  super
end

Class Method Details

.optionsObject


22
23
24
25
26
27
28
29
30
# File 'lib/cocoapods/command/update.rb', line 22

def self.options
  [
    ["--sources=#{Pod::TrunkSource::TRUNK_REPO_URL}", 'The sources from which to update dependent pods. ' \
     'Multiple sources must be comma-delimited'],
    ['--exclude-pods=podName', 'Pods to exclude during update. Multiple pods must be comma-delimited'],
    ['--clean-install', 'Ignore the contents of the project cache and force a full pod installation. This only ' \
     'applies to projects that have enabled incremental installation'],
  ].concat(super)
end

Instance Method Details

#runObject


43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/cocoapods/command/update.rb', line 43

def run
  verify_podfile_exists!

  installer = installer_for_config
  installer.repo_update = repo_update?(:default => true)
  installer.clean_install = @clean_install
  if @pods.any? || @excluded_pods.any? || @source_pods.any?
    verify_lockfile_exists!
    verify_pods_are_installed!
    verify_excluded_pods_are_installed!

    @pods += @source_pods.select { |pod| config.lockfile.pod_names.include?(pod) }
    @pods = config.lockfile.pod_names.dup if @pods.empty?
    @pods -= @excluded_pods

    installer.update = { :pods => @pods }
  else
    UI.puts 'Update all pods'.yellow
    installer.update = true
  end
  installer.install!
end