Class: Dependabot::Nuget::NativeUpdateChecker::NativeRequirementsUpdater
- Inherits:
-
Object
- Object
- Dependabot::Nuget::NativeUpdateChecker::NativeRequirementsUpdater
- Extended by:
- T::Sig
- Defined in:
- lib/dependabot/nuget/native_update_checker/native_requirements_updater.rb
Instance Method Summary collapse
-
#initialize(requirements:, dependency_details:) ⇒ NativeRequirementsUpdater
constructor
A new instance of NativeRequirementsUpdater.
- #updated_requirements ⇒ Object
Constructor Details
#initialize(requirements:, dependency_details:) ⇒ NativeRequirementsUpdater
Returns a new instance of NativeRequirementsUpdater.
28 29 30 31 |
# File 'lib/dependabot/nuget/native_update_checker/native_requirements_updater.rb', line 28 def initialize(requirements:, dependency_details:) @requirements = requirements @dependency_details = dependency_details end |
Instance Method Details
#updated_requirements ⇒ Object
34 35 36 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 65 66 67 68 69 |
# File 'lib/dependabot/nuget/native_update_checker/native_requirements_updater.rb', line 34 def updated_requirements return requirements unless clean_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, clean_version.to_s ) end next req if new_req == req.fetch(:requirement) new_source = req[:source]&.dup unless @dependency_details.nil? new_source = { type: "nuget_repo", source_url: @dependency_details.info_url } end req.merge({ requirement: new_req, source: new_source }) end end |