The heuristic used by the default version comparison is simple. A
version string is scanned for strings of digits, split into an array of
these strings, and then an element-wise comparison is done.
This fails when presented with something like
Version.new("1.0.0beta7") <=> Version.new("1.0.0")
because the first three digits match, and the fourth digit of the
receiver (7) is greater than the assumed fourth digit of the parameter
(0).
Fix this by defining an element-wise comparator on a new VersionElement
class. This allows us to correctly compare "alpha", "beta", and "rc"
style version strings, and keeps the logic out of the main version
comparison.
Signed-off-by: Jack Nagel <jacknagel@gmail.com>
This will allow us to do comparisons like
if MacOS.version >= :lion
and hopefully deprecate the MacOS.<name>? family of methods, which are
counterinitutive.
A version scheme is a class that inherits from Version and reimplements
Version#<=>. This will allow formulae to specify a custom comparison
method that will be used instead of the default, for cases where the
default is insufficient.