Class: Dependabot::Nuget::UpdateChecker::VersionFinder

Inherits:
Object
  • Object
show all
Defined in:
lib/dependabot/nuget/update_checker/version_finder.rb

Constant Summary collapse

NUGET_RANGE_REGEX =
/[\(\[].*,.*[\)\]]/.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(dependency:, dependency_files:, credentials:, ignored_versions:, raise_on_ignored: false, security_advisories:) ⇒ VersionFinder

Returns a new instance of VersionFinder.


19
20
21
22
23
24
25
26
27
28
# File 'lib/dependabot/nuget/update_checker/version_finder.rb', line 19

def initialize(dependency:, dependency_files:, credentials:,
               ignored_versions:, raise_on_ignored: false,
               security_advisories:)
  @dependency          = dependency
  @dependency_files    = dependency_files
  @credentials         = credentials
  @ignored_versions    = ignored_versions
  @raise_on_ignored    = raise_on_ignored
  @security_advisories = security_advisories
end

Instance Attribute Details

#credentialsObject (readonly)

Returns the value of attribute credentials


56
57
58
# File 'lib/dependabot/nuget/update_checker/version_finder.rb', line 56

def credentials
  @credentials
end

#dependencyObject (readonly)

Returns the value of attribute dependency


56
57
58
# File 'lib/dependabot/nuget/update_checker/version_finder.rb', line 56

def dependency
  @dependency
end

#dependency_filesObject (readonly)

Returns the value of attribute dependency_files


56
57
58
# File 'lib/dependabot/nuget/update_checker/version_finder.rb', line 56

def dependency_files
  @dependency_files
end

#ignored_versionsObject (readonly)

Returns the value of attribute ignored_versions


56
57
58
# File 'lib/dependabot/nuget/update_checker/version_finder.rb', line 56

def ignored_versions
  @ignored_versions
end

#security_advisoriesObject (readonly)

Returns the value of attribute security_advisories


56
57
58
# File 'lib/dependabot/nuget/update_checker/version_finder.rb', line 56

def security_advisories
  @security_advisories
end

Instance Method Details

#latest_version_detailsObject


30
31
32
33
34
35
36
37
38
# File 'lib/dependabot/nuget/update_checker/version_finder.rb', line 30

def latest_version_details
  @latest_version_details ||=
    begin
      possible_versions = versions
      possible_versions = filter_prereleases(possible_versions)
      possible_versions = filter_ignored_versions(possible_versions)
      possible_versions.max_by { |hash| hash.fetch(:version) }
    end
end

#lowest_security_fix_version_detailsObject


40
41
42
43
44
45
46
47
48
49
50
# File 'lib/dependabot/nuget/update_checker/version_finder.rb', line 40

def lowest_security_fix_version_details
  @lowest_security_fix_version_details ||=
    begin
      possible_versions = versions
      possible_versions = filter_prereleases(possible_versions)
      possible_versions = filter_vulnerable_versions(possible_versions)
      possible_versions = filter_ignored_versions(possible_versions)
      possible_versions = filter_lower_versions(possible_versions)
      possible_versions.min_by { |hash| hash.fetch(:version) }
    end
end

#versionsObject


52
53
54
# File 'lib/dependabot/nuget/update_checker/version_finder.rb', line 52

def versions
  available_v3_versions + available_v2_versions
end