2014-10-27 00:52:55 +00:00
|
|
|
module Tests
|
|
|
|
class Version
|
|
|
|
def initialize(version)
|
2020-11-03 05:56:49 +00:00
|
|
|
@version = Gem::Version.new(version.to_s)
|
2014-10-27 00:52:55 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def <(other_version)
|
|
|
|
compare?(:<, other_version)
|
|
|
|
end
|
|
|
|
|
|
|
|
def <=(other_version)
|
|
|
|
compare?(:<=, other_version)
|
|
|
|
end
|
|
|
|
|
|
|
|
def ==(other_version)
|
|
|
|
compare?(:==, other_version)
|
|
|
|
end
|
|
|
|
|
|
|
|
def >=(other_version)
|
|
|
|
compare?(:>=, other_version)
|
|
|
|
end
|
|
|
|
|
|
|
|
def >(other_version)
|
|
|
|
compare?(:>, other_version)
|
|
|
|
end
|
|
|
|
|
|
|
|
def =~(other_version)
|
|
|
|
Gem::Requirement.new(other_version).satisfied_by?(version)
|
|
|
|
end
|
|
|
|
|
|
|
|
def to_s
|
|
|
|
version.to_s
|
|
|
|
end
|
|
|
|
|
|
|
|
protected
|
|
|
|
|
|
|
|
attr_reader :version
|
|
|
|
|
|
|
|
private
|
|
|
|
|
2020-09-06 13:09:31 +00:00
|
|
|
def compare?(operator, other_version)
|
|
|
|
Gem::Requirement.new("#{operator} #{other_version}").satisfied_by?(version)
|
2014-10-27 00:52:55 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|