Class: Dependabot::Dep::UpdateChecker::RequirementsUpdater
- Inherits:
-
Object
- Object
- Dependabot::Dep::UpdateChecker::RequirementsUpdater
- Defined in:
- lib/dependabot/dep/update_checker/requirements_updater.rb
Defined Under Namespace
Classes: UnfixableRequirement
Constant Summary collapse
- VERSION_REGEX =
/[0-9]+(?:\.[A-Za-z0-9\-*]+)*/.freeze
- ALLOWED_UPDATE_STRATEGIES =
%i(widen_ranges bump_versions).freeze
Instance Method Summary collapse
-
#initialize(requirements:, updated_source:, update_strategy:, latest_version:, latest_resolvable_version:) ⇒ RequirementsUpdater
constructor
A new instance of RequirementsUpdater.
- #updated_requirements ⇒ Object
Constructor Details
#initialize(requirements:, updated_source:, update_strategy:, latest_version:, latest_resolvable_version:) ⇒ RequirementsUpdater
Returns a new instance of RequirementsUpdater.
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/dependabot/dep/update_checker/requirements_updater.rb', line 16 def initialize(requirements:, updated_source:, update_strategy:, latest_version:, latest_resolvable_version:) @requirements = requirements @updated_source = updated_source @update_strategy = update_strategy check_update_strategy if latest_version && version_class.correct?(latest_version) @latest_version = version_class.new(latest_version) end return unless latest_resolvable_version return unless version_class.correct?(latest_resolvable_version) @latest_resolvable_version = version_class.new(latest_resolvable_version) end |
Instance Method Details
#updated_requirements ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/dependabot/dep/update_checker/requirements_updater.rb', line 35 def updated_requirements requirements.map do |req| req = req.merge(source: updated_source) next req unless latest_resolvable_version next initial_req_after_source_change(req) unless req[:requirement] case update_strategy when :widen_ranges then widen_requirement(req) when :bump_versions then update_version(req) else raise "Unexpected update strategy: #{update_strategy}" end end end |