Class: Dependabot::Pub::UpdateChecker::LatestVersionFinder

Inherits:
Object
  • Object
show all
Extended by:
T::Sig
Includes:
Package
Defined in:
lib/dependabot/pub/update_checker/latest_version_finder.rb

Constant Summary collapse

DAY_IN_SECONDS =
T.let(24 * 60 * 60, Integer)

Instance Method Summary collapse

Constructor Details

#initialize(dependency:, dependency_files:, credentials:, ignored_versions: [], security_advisories: [], options: {}, cooldown_options: nil) ⇒ LatestVersionFinder

Returns a new instance of LatestVersionFinder.



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/dependabot/pub/update_checker/latest_version_finder.rb', line 33

def initialize(
  dependency:,
  dependency_files:,
  credentials:,
  ignored_versions: [],
  security_advisories: [],
  options: {},
  cooldown_options: nil
)
  @dependency = dependency
  @dependency_files = dependency_files
  @credentials = credentials
  @ignored_versions = ignored_versions
  @security_advisories = security_advisories
  @options = options
  @cooldown_options = cooldown_options
end

Instance Method Details

#current_reportObject



52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/dependabot/pub/update_checker/latest_version_finder.rb', line 52

def current_report
  @current_report ||= T.let(
    T.must(
      PackageDetailsFetcher.new(
        dependency: dependency,
        dependency_files: dependency_files,
        credentials: credentials,
        ignored_versions: ignored_versions,
        security_advisories: security_advisories,
        options: options
      ).report.find { |d| d["name"] == dependency.name }
    ),
    T.nilable(T::Hash[String, T.untyped])
  )
end

#latest_resolvable_versionObject



77
78
79
80
81
82
# File 'lib/dependabot/pub/update_checker/latest_version_finder.rb', line 77

def latest_resolvable_version
  latest_resolvable_version = current_report["singleBreaking"]&.find { |d| d["name"] == dependency.name }
  return nil unless latest_resolvable_version

  filter_cooldown_versions(latest_resolvable_version["version"])
end

#latest_resolvable_version_hashObject



106
107
108
# File 'lib/dependabot/pub/update_checker/latest_version_finder.rb', line 106

def latest_resolvable_version_hash
  current_report["singleBreaking"].find { |d| d["name"] == dependency.name }
end

#latest_resolvable_version_with_no_unlockObject



85
86
87
88
89
90
# File 'lib/dependabot/pub/update_checker/latest_version_finder.rb', line 85

def latest_resolvable_version_with_no_unlock
  version_with_no_unlock = current_report["compatible"]&.find { |d| d["name"] == dependency.name }
  return nil unless version_with_no_unlock

  filter_cooldown_versions(version_with_no_unlock["version"])
end

#latest_versionObject



69
70
71
72
73
74
# File 'lib/dependabot/pub/update_checker/latest_version_finder.rb', line 69

def latest_version
  latest_version = current_report["latest"]
  return nil unless latest_version

  filter_cooldown_versions(latest_version)
end

#latest_version_resolvable_with_full_unlockObject



93
94
95
96
97
98
# File 'lib/dependabot/pub/update_checker/latest_version_finder.rb', line 93

def latest_version_resolvable_with_full_unlock
  version_with_full_unlock = current_report["multiBreaking"]&.find { |d| d["name"] == dependency.name }
  return nil unless version_with_full_unlock

  filter_cooldown_versions(version_with_full_unlock["version"])
end

#latest_version_resolvable_with_full_unlock_hashObject



101
102
103
# File 'lib/dependabot/pub/update_checker/latest_version_finder.rb', line 101

def latest_version_resolvable_with_full_unlock_hash
  current_report["multiBreaking"]
end