X11Dependency: use Version objects
This commit is contained in:
parent
3f6827374f
commit
fc2d403a82
@ -11,12 +11,16 @@ class X11Dependency < Requirement
|
|||||||
|
|
||||||
def initialize(name="x11", tags=[])
|
def initialize(name="x11", tags=[])
|
||||||
@name = name
|
@name = name
|
||||||
@min_version = tags.shift if /(\d\.)+\d/ === tags.first
|
if /(\d\.)+\d/ === tags.first
|
||||||
|
@min_version = Version.new(tags.shift)
|
||||||
|
else
|
||||||
|
@min_version = Version.new("0.0.0")
|
||||||
|
end
|
||||||
super(tags)
|
super(tags)
|
||||||
end
|
end
|
||||||
|
|
||||||
satisfy :build_env => false do
|
satisfy :build_env => false do
|
||||||
MacOS::XQuartz.installed? && (@min_version.nil? || @min_version <= MacOS::XQuartz.version)
|
MacOS::XQuartz.installed? && min_version <= Version.new(MacOS::Quartz.version)
|
||||||
end
|
end
|
||||||
|
|
||||||
def message; <<-EOS.undent
|
def message; <<-EOS.undent
|
||||||
@ -27,16 +31,7 @@ class X11Dependency < Requirement
|
|||||||
end
|
end
|
||||||
|
|
||||||
def <=> other
|
def <=> other
|
||||||
return nil unless X11Dependency === other
|
return unless X11Dependency === other
|
||||||
|
min_version <=> other.min_version
|
||||||
if min_version.nil? && other.min_version.nil?
|
|
||||||
0
|
|
||||||
elsif other.min_version.nil?
|
|
||||||
1
|
|
||||||
elsif min_version.nil?
|
|
||||||
-1
|
|
||||||
else
|
|
||||||
min_version <=> other.min_version
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -69,7 +69,7 @@ class DependencyCollectorTests < Homebrew::TestCase
|
|||||||
|
|
||||||
def test_x11_min_version
|
def test_x11_min_version
|
||||||
@d.add :x11 => '2.5.1'
|
@d.add :x11 => '2.5.1'
|
||||||
assert_equal "2.5.1", find_requirement(X11Dependency).min_version
|
assert_equal "2.5.1", find_requirement(X11Dependency).min_version.to_s
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_x11_tag
|
def test_x11_tag
|
||||||
@ -80,7 +80,7 @@ class DependencyCollectorTests < Homebrew::TestCase
|
|||||||
def test_x11_min_version_and_tag
|
def test_x11_min_version_and_tag
|
||||||
@d.add :x11 => ['2.5.1', :optional]
|
@d.add :x11 => ['2.5.1', :optional]
|
||||||
dep = find_requirement(X11Dependency)
|
dep = find_requirement(X11Dependency)
|
||||||
assert_equal '2.5.1', dep.min_version
|
assert_equal '2.5.1', dep.min_version.to_s
|
||||||
assert_predicate dep, :optional?
|
assert_predicate dep, :optional?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user