Class: Anticuado::IOS::Carthage

Inherits:
Base
  • Object
show all
Defined in:
lib/anticuado/ios/carthage.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 ‘carthage 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
# File 'lib/anticuado/ios/carthage.rb', line 19

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

  return [] if index.nil?

  array[index + 1..array.size].map do |library|
    versions = library.split(/[\s|"]/) # e.g. ["Result", "", "2.0.0", "", "->", "", "2.1.3"]
    {
        library_name: versions[0],
        current_version: versions[2],
        available_version: versions[6],
        latest_version: versions[6]
    }
  end
end

.outdated(project = nil) ⇒ String

Returns The result of command ‘carthage outdated`.

Parameters:

  • project (String) (defaults to: nil)

    Path to project directory.

Returns:

  • (String)

    The result of command ‘carthage outdated`.



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

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

  if project
    `carthage outdated --project-directory #{project}`
  else
    `carthage outdated`
  end
end