Class: Anticuado::IOS::CocoaPods

Inherits:
Base
  • Object
show all
Defined in:
lib/anticuado/ios/cocoapods.rb

Class Method Summary collapse

Class Method Details

.format(outdated) ⇒ Array

Returns Array include outdated data. If target project have no outdated data, then return blank array such as ‘[]`.

Parameters:

  • outdated (String)

    The result of command ‘pod outdated`

Returns:

  • (Array)

    Array include outdated data. If target project have no outdated data, then return blank array such as ‘[]`



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/anticuado/ios/cocoapods.rb', line 19

def self.format(outdated)
  array = outdated.split(/\R/).map(&:strip)
  index = array.find_index("The following pod updates are available:")

  return [] if index.nil?

  array[index + 1..array.size].map { |library|
    versions = library.split(/\s/) # e.g. ["-", "AFNetworking", "2.5.4", "->", "3.1.0", "(latest", "version", "3.1.0)"]
    if versions[0] == "-"
      {
          library_name: versions[1],
          current_version: versions[2],
          available_version: versions[4],
          latest_version: versions[7].delete(")")
      }
    end
  }.compact
end

.outdated(project = nil) ⇒ String

Returns The result of command ‘pod outdated`.

Parameters:

  • project (String) (defaults to: nil)

    Path to project directory.

Returns:

  • (String)

    The result of command ‘pod outdated`.



6
7
8
9
10
11
12
13
14
# File 'lib/anticuado/ios/cocoapods.rb', line 6

def self.outdated(project = nil)
  return puts "have no pod command" if `which pod`.empty?

  if project
    `pod outdated --project-directory=#{project}`
  else
    `pod outdated`
  end
end