Class: Fastlane::Helper::CarthageOutdatedHelper

Inherits:
DependencyManagerOutdatedHelper show all
Defined in:
lib/fastlane/plugin/dependency_manager_outdated/helper/carthage_outdated_helper.rb

Constant Summary collapse

MESSAGE =

class methods that you define here become available in your action as ‘Helper::CarthageOutdatedHelper.your_method`

"The following dependencies are outdated:"
PATTERN =

ex.) Alamofire “4.7.3” -> “4.7.3” (Latest: “4.8.2”)

/^(\S+) "(\S+)" -> "(\S+)" \(Latest: "(\S+)"\)$/
RESOLVED_PATTERN =

ex.) github “Alamofire/Alamofire” “4.7.3”

/^(\S+) "(\S+)" "(\S+)"$/

Class Method Summary collapse

Methods inherited from DependencyManagerOutdatedHelper

generate_slack_attachments, notify_slack

Class Method Details

.messageObject



25
26
27
# File 'lib/fastlane/plugin/dependency_manager_outdated/helper/carthage_outdated_helper.rb', line 25

def self.message
  MESSAGE
end

.nameObject



21
22
23
# File 'lib/fastlane/plugin/dependency_manager_outdated/helper/carthage_outdated_helper.rb', line 21

def self.name
  "Carthage"
end

.parse(str) ⇒ Object



29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/fastlane/plugin/dependency_manager_outdated/helper/carthage_outdated_helper.rb', line 29

def self.parse(str)
  results = []

  result = str.split(MESSAGE + "\n")[1]
  return results unless result

  libs = result.split("\n")

  libs.each do |lib|
    lib.match(PATTERN)
    results << Dependency.new($1, $2, $3, $4)
  end
  results.map { |r| r.to_hash }
end

.resolved(dir) ⇒ Object

href="https://github.com/Alamofire/Alamofire">github.com/Alamofire/Alamofire”, “RxSwift”=>“github.com/ReactiveX/RxSwift



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'lib/fastlane/plugin/dependency_manager_outdated/helper/carthage_outdated_helper.rb', line 45

def self.resolved(dir)
  lock_file = "Cartfile.resolved"
  dir ||= '.'
  # dir = File.dirname(File.expand_path(__FILE__))
  file = File.join(dir, lock_file)

  results = {}
  File.open(file) do |f|
    f.each_line do |lib|
      lib.match(RESOLVED_PATTERN)
      origin = $1
      repo = $2

      url = nil
      name = nil
      if origin == "github"
        url = "https://github.com/#{repo}"
        name = repo.split("/")[1]
      end
      if origin == "git"
        url = repo
        name = repo.split("/").last
      end
      if name && !name.empty?
        results[name] = url
      end
    end
  rescue => e
    UI.message e
  end
  results
end