Class: Pod::Command::Outdated

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

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Pod::Command

#ensure_master_spec_repo_exists!, ensure_not_root_or_allowed!, report_error, run

Methods included from Pod::Config::Mixin

#config

Constructor Details

#initialize(argv) ⇒ Outdated

Returns a new instance of Outdated.



20
21
22
23
# File 'lib/cocoapods/command/outdated.rb', line 20

def initialize(argv)
  @ignore_prerelease = argv.flag?('ignore-prerelease')
  super
end

Class Method Details

.optionsObject



14
15
16
17
18
# File 'lib/cocoapods/command/outdated.rb', line 14

def self.options
  [
    ['--ignore-prerelease', "Don't consider prerelease versions to be updates"],
  ].concat(super)
end

Instance Method Details

#runObject

Run the command



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/cocoapods/command/outdated.rb', line 27

def run
  if updates.empty?
    UI.puts 'No pod updates are available.'.yellow
  else
    UI.section 'The color indicates what happens when you run `pod update`' do
      UI.puts "#{'<green>'.green}\t - Will be updated to the newest version"
      UI.puts "#{'<blue>'.blue}\t - Will be updated, but not to the newest version because of specified version in Podfile"
      UI.puts "#{'<red>'.red}\t - Will not be updated because of specified version in Podfile"
      UI.puts ''
    end if ansi_output?
    UI.section 'The following pod updates are available:' do
      updates.each do |(name, from_version, matching_version, to_version)|
        color = :blue
        if matching_version == to_version
          color = :green
        elsif from_version == matching_version
          color = :red
        end
        # For the specs, its necessary that to_s is called here even though it is redundant
        # https://github.com/CocoaPods/CocoaPods/pull/7204#issuecomment-342512015
        UI.puts "- #{name} #{from_version.to_s.send(color)} -> #{matching_version.to_s.send(color)} " \
        "(latest version #{to_version.to_s})" # rubocop:disable Lint/StringConversionInInterpolation
      end
    end
  end

  if deprecated_pods.any?
    UI.section 'The following pods are deprecated:' do
      deprecated_pods.each do |spec|
        if spec.deprecated_in_favor_of
          UI.puts "- #{spec.name}" \
            " (in favor of #{spec.deprecated_in_favor_of})"
        else
          UI.puts "- #{spec.name}"
        end
      end
    end
  end
end