Class: Dependabot::Python::UpdateChecker::PipCompileVersionResolver

Inherits:
Object
  • Object
show all
Defined in:
lib/dependabot/python/update_checker/pip_compile_version_resolver.rb

Overview

This class does version resolution for pip-compile. Its approach is:

  • Unlock the dependency we’re checking in the requirements.in file

  • Run ‘pip-compile` and see what the result is

rubocop:disable Metrics/ClassLength

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(dependency:, dependency_files:, credentials:) ⇒ PipCompileVersionResolver

Returns a new instance of PipCompileVersionResolver.



25
26
27
28
29
# File 'lib/dependabot/python/update_checker/pip_compile_version_resolver.rb', line 25

def initialize(dependency:, dependency_files:, credentials:)
  @dependency               = dependency
  @dependency_files         = dependency_files
  @credentials              = credentials
end

Instance Attribute Details

#credentialsObject (readonly)

Returns the value of attribute credentials.



23
24
25
# File 'lib/dependabot/python/update_checker/pip_compile_version_resolver.rb', line 23

def credentials
  @credentials
end

#dependencyObject (readonly)

Returns the value of attribute dependency.



23
24
25
# File 'lib/dependabot/python/update_checker/pip_compile_version_resolver.rb', line 23

def dependency
  @dependency
end

#dependency_filesObject (readonly)

Returns the value of attribute dependency_files.



23
24
25
# File 'lib/dependabot/python/update_checker/pip_compile_version_resolver.rb', line 23

def dependency_files
  @dependency_files
end

Instance Method Details

#latest_resolvable_version(requirement: nil) ⇒ Object



31
32
33
34
35
36
# File 'lib/dependabot/python/update_checker/pip_compile_version_resolver.rb', line 31

def latest_resolvable_version(requirement: nil)
  version_string =
    fetch_latest_resolvable_version_string(requirement: requirement)

  version_string.nil? ? nil : Python::Version.new(version_string)
end

#resolvable?(version:) ⇒ Boolean

Returns:

  • (Boolean)


38
39
40
41
42
43
44
45
46
47
# File 'lib/dependabot/python/update_checker/pip_compile_version_resolver.rb', line 38

def resolvable?(version:)
  @resolvable ||= {}
  return @resolvable[version] if @resolvable.key?(version)

  if fetch_latest_resolvable_version_string(requirement: "==#{version}")
    @resolvable[version] = true
  else
    @resolvable[version] = false
  end
end