MacOSVersion -> MacOS::Version
This commit is contained in:
parent
b41bb64c7a
commit
7fbeb0df3d
@ -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
|
||||
|
||||
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 '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
|
||||
|
||||
@ -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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user