MacOSVersion -> MacOS::Version

This commit is contained in:
Jack Nagel 2013-02-06 22:49:43 -06:00
parent b41bb64c7a
commit 7fbeb0df3d
4 changed files with 21 additions and 17 deletions

View File

@ -1,10 +1,11 @@
require 'macos/version'
module MacOS extend self
# This can be compared to numerics, strings, or symbols
# using the standard Ruby Comparable methods.
def version
require 'version'
MacOSVersion.new(MACOS_VERSION.to_s)
Version.new(MACOS_VERSION)
end
def cat

View File

@ -0,0 +1,16 @@
require 'version'
module MacOS
class Version < ::Version
def <=>(other)
v = case other
when :mountain_lion then 10.8
when :lion then 10.7
when :snow_leopard then 10.6
when :leopard then 10.5
else other.to_s
end
super(Version.new(v))
end
end
end

View File

@ -1,9 +1,10 @@
require 'testing_env'
require 'version'
require 'macos/version'
class MacOSVersionTests < Test::Unit::TestCase
def setup
@v = MacOSVersion.new(10.7)
@v = MacOS::Version.new(10.7)
end
def test_compare_with_symbol

View File

@ -208,17 +208,3 @@ class VersionSchemeDetector
raise "Unknown version scheme #{@scheme} was requested."
end
end
# Enable things like "MacOS.version >= :lion"
class MacOSVersion < Version
def <=>(other)
v = case other
when :mountain_lion then 10.8
when :lion then 10.7
when :snow_leopard then 10.6
when :leopard then 10.5
else other.to_s
end
super(Version.new(v))
end
end