Class: Dependabot::Python::UpdateChecker::RequirementsUpdater
- Inherits:
-
Object
- Object
- Dependabot::Python::UpdateChecker::RequirementsUpdater
- Defined in:
- lib/dependabot/python/update_checker/requirements_updater.rb
Defined Under Namespace
Classes: UnfixableRequirement
Constant Summary collapse
- PYPROJECT_OR_SEPARATOR =
/(?<=[a-zA-Z0-9*])\s*\|+/
- PYPROJECT_SEPARATOR =
/#{PYPROJECT_OR_SEPARATOR}|,/
Instance Attribute Summary collapse
-
#has_lockfile ⇒ Object
readonly
Returns the value of attribute has_lockfile.
-
#latest_resolvable_version ⇒ Object
readonly
Returns the value of attribute latest_resolvable_version.
-
#requirements ⇒ Object
readonly
Returns the value of attribute requirements.
-
#update_strategy ⇒ Object
readonly
Returns the value of attribute update_strategy.
Instance Method Summary collapse
-
#initialize(requirements:, update_strategy:, has_lockfile:, latest_resolvable_version:) ⇒ RequirementsUpdater
constructor
A new instance of RequirementsUpdater.
- #updated_requirements ⇒ Object
Constructor Details
#initialize(requirements:, update_strategy:, has_lockfile:, latest_resolvable_version:) ⇒ RequirementsUpdater
Returns a new instance of RequirementsUpdater.
24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/dependabot/python/update_checker/requirements_updater.rb', line 24 def initialize(requirements:, update_strategy:, has_lockfile:, latest_resolvable_version:) @requirements = requirements @update_strategy = update_strategy @has_lockfile = has_lockfile return unless latest_resolvable_version @latest_resolvable_version = Python::Version.new(latest_resolvable_version) end |
Instance Attribute Details
#has_lockfile ⇒ Object (readonly)
Returns the value of attribute has_lockfile.
21 22 23 |
# File 'lib/dependabot/python/update_checker/requirements_updater.rb', line 21 def has_lockfile @has_lockfile end |
#latest_resolvable_version ⇒ Object (readonly)
Returns the value of attribute latest_resolvable_version.
22 23 24 |
# File 'lib/dependabot/python/update_checker/requirements_updater.rb', line 22 def latest_resolvable_version @latest_resolvable_version end |
#requirements ⇒ Object (readonly)
Returns the value of attribute requirements.
19 20 21 |
# File 'lib/dependabot/python/update_checker/requirements_updater.rb', line 19 def requirements @requirements end |
#update_strategy ⇒ Object (readonly)
Returns the value of attribute update_strategy.
20 21 22 |
# File 'lib/dependabot/python/update_checker/requirements_updater.rb', line 20 def update_strategy @update_strategy end |
Instance Method Details
#updated_requirements ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/dependabot/python/update_checker/requirements_updater.rb', line 36 def updated_requirements return requirements if update_strategy.lockfile_only? requirements.map do |req| case req[:file] when /setup\.(?:py|cfg)$/ then updated_setup_requirement(req) when "pyproject.toml" then updated_pyproject_requirement(req) when "Pipfile" then updated_pipfile_requirement(req) when /\.txt$|\.in$/ then updated_requirement(req) else raise "Unexpected filename: #{req[:file]}" end end end |