Improves the version comparison

This commit is contained in:
erwanlr
2014-07-30 12:11:04 +01:00
parent 12d275c26b
commit 1e6b5a1e4d
2 changed files with 14 additions and 0 deletions

View File

@@ -10,6 +10,10 @@ class VersionCompare
#
# @return [ Boolean ]
def self.lesser_or_equal?(version1, version2)
# Prepend a '0' if the version starts with a '.'
version1 = "0#{version1}" if version1 && version1[0,1] == '.'
version2 = "0#{version2}" if version2 && version2[0,1] == '.'
return true if (version1 == version2)
# Both versions must be set
return false unless (version1 and version2)