Class: Dependabot::Maven::UpdateChecker::RequirementsUpdater
- Inherits:
-
Object
- Object
- Dependabot::Maven::UpdateChecker::RequirementsUpdater
- Defined in:
- lib/dependabot/maven/update_checker/requirements_updater.rb
Instance Method Summary collapse
-
#initialize(requirements:, latest_version:, source_url:, properties_to_update:) ⇒ RequirementsUpdater
constructor
A new instance of RequirementsUpdater.
- #updated_requirements ⇒ Object
Constructor Details
#initialize(requirements:, latest_version:, source_url:, properties_to_update:) ⇒ RequirementsUpdater
Returns a new instance of RequirementsUpdater.
16 17 18 19 20 21 22 23 24 |
# File 'lib/dependabot/maven/update_checker/requirements_updater.rb', line 16 def initialize(requirements:, latest_version:, source_url:, properties_to_update:) @requirements = requirements @source_url = source_url @properties_to_update = properties_to_update return unless latest_version @latest_version = version_class.new(latest_version) end |
Instance Method Details
#updated_requirements ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/dependabot/maven/update_checker/requirements_updater.rb', line 26 def updated_requirements return requirements unless latest_version # Note: Order is important here. The FileUpdater needs the updated # requirement at index `i` to correspond to the previous requirement # at the same index. requirements.map do |req| next req if req.fetch(:requirement).nil? next req if req.fetch(:requirement).include?(",") property_name = req.dig(:metadata, :property_name) if property_name && !properties_to_update.include?(property_name) next req end new_req = update_requirement(req[:requirement]) req.merge(requirement: new_req, source: updated_source) end end |