Class: Makit::Version

Inherits:
Object
  • Object
show all
Defined in:
lib/makit/version_util.rb

Overview

Version utility class for handling version comparisons

Class Method Summary collapse

Class Method Details

.get_highest_version(versions) ⇒ String?

Get the highest version from a list of version strings

Parameters:

  • versions (Array<String>)

    array of version strings

Returns:

  • (String, nil)

    highest version string or nil if empty



10
11
12
13
14
15
16
17
18
19
# File 'lib/makit/version_util.rb', line 10

def self.get_highest_version(versions)
  return nil if versions.nil? || versions.empty?

  # Sort versions using Gem::Version for proper semantic versioning

  sorted_versions = versions.sort_by { |v| Gem::Version.new(v) }
  sorted_versions.last
rescue ArgumentError
  # If any version is invalid, fall back to string sorting

  versions.max
end