Class: Dependabot::Python::PipenvRunner

Inherits:
Object
  • Object
show all
Extended by:
T::Sig
Defined in:
lib/dependabot/python/pipenv_runner.rb

Instance Method Summary collapse

Constructor Details

#initialize(dependency:, lockfile:, language_version_manager:) ⇒ PipenvRunner

Returns a new instance of PipenvRunner.



22
23
24
25
26
# File 'lib/dependabot/python/pipenv_runner.rb', line 22

def initialize(dependency:, lockfile:, language_version_manager:)
  @dependency = dependency
  @lockfile = lockfile
  @language_version_manager = language_version_manager
end

Instance Method Details

#run(command, fingerprint: nil) ⇒ Object



47
48
49
50
51
52
53
54
# File 'lib/dependabot/python/pipenv_runner.rb', line 47

def run(command, fingerprint: nil)
  run_command(
    "pyenv local #{language_version_manager.python_major_minor}",
    fingerprint: "pyenv local <python_major_minor>"
  )

  run_command(command, fingerprint: fingerprint)
end

#run_upgrade(constraint) ⇒ Object



29
30
31
32
33
34
35
# File 'lib/dependabot/python/pipenv_runner.rb', line 29

def run_upgrade(constraint)
  constraint = "" if constraint == "*"
  command = "pyenv exec pipenv upgrade --verbose #{dependency_name}#{constraint}"
  command << " --dev" if lockfile_section == "develop"

  run(command, fingerprint: "pyenv exec pipenv upgrade --verbose <dependency_name><constraint>")
end

#run_upgrade_and_fetch_version(constraint) ⇒ Object



38
39
40
41
42
43
44
# File 'lib/dependabot/python/pipenv_runner.rb', line 38

def run_upgrade_and_fetch_version(constraint)
  run_upgrade(constraint)

  updated_lockfile = JSON.parse(File.read("Pipfile.lock"))

  fetch_version_from_parsed_lockfile(updated_lockfile)
end