Class: Dependabot::Nuget::UpdateChecker::RequirementsUpdater
- Inherits:
-
Object
- Object
- Dependabot::Nuget::UpdateChecker::RequirementsUpdater
- Extended by:
- T::Sig
- Defined in:
- lib/dependabot/nuget/update_checker/requirements_updater.rb
Instance Method Summary collapse
-
#initialize(requirements:, latest_version:, source_details:) ⇒ RequirementsUpdater
constructor
A new instance of RequirementsUpdater.
- #updated_requirements ⇒ Object
Constructor Details
#initialize(requirements:, latest_version:, source_details:) ⇒ RequirementsUpdater
Returns a new instance of RequirementsUpdater.
28 29 30 31 32 33 34 |
# File 'lib/dependabot/nuget/update_checker/requirements_updater.rb', line 28 def initialize(requirements:, latest_version:, source_details:) @requirements = requirements @source_details = source_details return unless latest_version @latest_version = T.let(version_class.new(latest_version), Dependabot::Nuget::Version) end |
Instance Method Details
#updated_requirements ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/dependabot/nuget/update_checker/requirements_updater.rb', line 37 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?(",") new_req = if req.fetch(:requirement).include?("*") update_wildcard_requirement(req.fetch(:requirement)) else # Since range requirements are excluded by the line above we can # replace anything that looks like a version with the new # version req[:requirement].sub( /#{Nuget::Version::VERSION_PATTERN}/o, latest_version.to_s ) end next req if new_req == req.fetch(:requirement) req.merge(requirement: new_req, source: updated_source) end end |