dependencies - Greatest compatibility rule in ruby -


using gem::dependency.new(nil, rule).match?(nil, version), can check if version match compatibility rule.

with %w<0.1 0.2.1 0.44>.map {|v| gem::version.new v}.max.to_s can find last version.

i have array of dependencies , need find greatest, there simple way it?

['~1.5', '~1.6'] -> '~1.6' example

just array of version strings?

['~1.5', '~1.6'].map { |d| d.sub "~", "" }.map(&:to_f).max 

Comments