Class: BoxGrinder::RPMVersion
- Inherits:
-
Object
- Object
- BoxGrinder::RPMVersion
- Defined in:
- lib/boxgrinder-build/helpers/linux-helper.rb
Overview
A class tha helps dealing with RPM version numbers
Instance Method Summary collapse
- #compare(v1, v2) ⇒ Object
-
#newest(versions) ⇒ Object
Returns newest version from the array.
- #split(version) ⇒ Object
Instance Method Details
#compare(v1, v2) ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/boxgrinder-build/helpers/linux-helper.rb', line 36 def compare(v1, v2) s1 = split(v1) s2 = split(v2) for i in (0..s1.size-1) cmp = (s1[i].to_i <=> s2[i].to_i) return cmp unless cmp == 0 end 0 end |
#newest(versions) ⇒ Object
Returns newest version from the array
50 51 52 |
# File 'lib/boxgrinder-build/helpers/linux-helper.rb', line 50 def newest(versions) versions.sort { |x,y| compare(x,y) }.last end |
#split(version) ⇒ Object
26 27 28 29 30 31 32 33 34 |
# File 'lib/boxgrinder-build/helpers/linux-helper.rb', line 26 def split(version) version_array = [] version.split('-').each do |v| v.split('.').each { |nb| version_array << nb } end version_array end |