Class: Dependabot::Python::UpdateChecker::RequirementsUpdater
- Inherits:
-
Object
- Object
- Dependabot::Python::UpdateChecker::RequirementsUpdater
- Extended by:
- T::Sig
- Defined in:
- lib/dependabot/python/update_checker/requirements_updater.rb
Overview
rubocop:disable Metrics/ClassLength
Defined Under Namespace
Classes: UnfixableRequirement
Constant Summary collapse
- PYPROJECT_OR_SEPARATOR =
T.let(/(?<=[a-zA-Z0-9*])\s*\|+/, Regexp)
- PYPROJECT_SEPARATOR =
T.let(/#{PYPROJECT_OR_SEPARATOR}|,/, Regexp)
- LOWER_BOUND_OPS =
T.let(%w(> >=).freeze, T::Array[String])
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.
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/dependabot/python/update_checker/requirements_updater.rb', line 44 def initialize( requirements:, update_strategy:, has_lockfile:, latest_resolvable_version: ) @requirements = T.let(requirements, T::Array[T::Hash[Symbol, T.untyped]]) @update_strategy = T.let(update_strategy, Dependabot::RequirementsUpdateStrategy) @has_lockfile = T.let(has_lockfile, T::Boolean) @latest_resolvable_version = T.let(nil, T.nilable(Dependabot::Python::Version)) 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.
31 32 33 |
# File 'lib/dependabot/python/update_checker/requirements_updater.rb', line 31 def has_lockfile @has_lockfile end |
#latest_resolvable_version ⇒ Object (readonly)
Returns the value of attribute latest_resolvable_version.
34 35 36 |
# File 'lib/dependabot/python/update_checker/requirements_updater.rb', line 34 def latest_resolvable_version @latest_resolvable_version end |
#requirements ⇒ Object (readonly)
Returns the value of attribute requirements.
25 26 27 |
# File 'lib/dependabot/python/update_checker/requirements_updater.rb', line 25 def requirements @requirements end |
#update_strategy ⇒ Object (readonly)
Returns the value of attribute update_strategy.
28 29 30 |
# File 'lib/dependabot/python/update_checker/requirements_updater.rb', line 28 def update_strategy @update_strategy end |
Instance Method Details
#updated_requirements ⇒ Object
61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/dependabot/python/update_checker/requirements_updater.rb', line 61 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 |