Method: Autobuild::Git.compare_versions

Defined in:
lib/autobuild/import/git.rb

.compare_versions(actual, required) ⇒ Integer

Helper method to compare two (partial) versions represented as array of integers

Returns:

  • (Integer)

    -1 if actual is greater than required, 0 if equal, and 1 if actual is smaller than required



98
99
100
101
102
103
104
105
106
107
108
# File 'lib/autobuild/import/git.rb', line 98

def self.compare_versions(actual, required)
    return -compare_versions(required, actual) if actual.size > required.size

    actual += [0] * (required.size - actual.size)
    actual.zip(required).each do |v_act, v_req|
        if v_act > v_req then return -1
        elsif v_act < v_req then return 1
        end
    end
    0
end