MacOSVersion -> MacOS::Version
This commit is contained in:
parent
b41bb64c7a
commit
7fbeb0df3d
@ -1,10 +1,11 @@
|
|||||||
|
require 'macos/version'
|
||||||
|
|
||||||
module MacOS extend self
|
module MacOS extend self
|
||||||
|
|
||||||
# This can be compared to numerics, strings, or symbols
|
# This can be compared to numerics, strings, or symbols
|
||||||
# using the standard Ruby Comparable methods.
|
# using the standard Ruby Comparable methods.
|
||||||
def version
|
def version
|
||||||
require 'version'
|
Version.new(MACOS_VERSION)
|
||||||
MacOSVersion.new(MACOS_VERSION.to_s)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def cat
|
def cat
|
||||||
|
|||||||
16
Library/Homebrew/macos/version.rb
Normal file
16
Library/Homebrew/macos/version.rb
Normal 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
|
||||||
@ -1,9 +1,10 @@
|
|||||||
require 'testing_env'
|
require 'testing_env'
|
||||||
require 'version'
|
require 'version'
|
||||||
|
require 'macos/version'
|
||||||
|
|
||||||
class MacOSVersionTests < Test::Unit::TestCase
|
class MacOSVersionTests < Test::Unit::TestCase
|
||||||
def setup
|
def setup
|
||||||
@v = MacOSVersion.new(10.7)
|
@v = MacOS::Version.new(10.7)
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_compare_with_symbol
|
def test_compare_with_symbol
|
||||||
|
|||||||
@ -208,17 +208,3 @@ class VersionSchemeDetector
|
|||||||
raise "Unknown version scheme #{@scheme} was requested."
|
raise "Unknown version scheme #{@scheme} was requested."
|
||||||
end
|
end
|
||||||
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
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user