Class: Verquest::VersionResolver
- Inherits:
-
Object
- Object
- Verquest::VersionResolver
- Defined in:
- lib/verquest/version_resolver.rb
Overview
Resolves requested version identifiers to actual version objects
The VersionResolver handles version resolution logic, finding the appropriate version to use based on a requested version identifier. It implements a “downgrading” strategy - when an exact version match isn’t found, it returns the closest earlier version.
Class Method Summary collapse
-
.call(requested_version, versions) ⇒ String?
Resolves a requested version to the appropriate available version.
Class Method Details
.call(requested_version, versions) ⇒ String?
Resolves a requested version to the appropriate available version
This method implements the version resolution strategy:
-
If an exact match is found, that version is returned
-
If the requested version is between two available versions, the earlier one is returned
-
If the requested version is after all available versions, the latest version is returned
32 33 34 35 36 37 38 39 40 |
# File 'lib/verquest/version_resolver.rb', line 32 def self.call(requested_version, versions) versions.each_with_index do |version, index| return version if version == requested_version if requested_version > version && ((versions[index + 1] && requested_version < versions[index + 1]) || !versions[index + 1]) return version end end end |