aboutsummaryrefslogtreecommitdiffstats
path: root/Library
diff options
context:
space:
mode:
authorJack Nagel2013-06-06 16:02:27 -0500
committerJack Nagel2013-06-06 16:02:27 -0500
commit79a769215fc75fecea9fe0ddbebdc4bae166086a (patch)
tree9351e04285ca37e6a8f7727348864fd65241940e /Library
parent159b9d8e2dd08ab4ad913e56669e961a7767b3d9 (diff)
downloadbrew-79a769215fc75fecea9fe0ddbebdc4bae166086a.tar.bz2
Decouple bottle tags from MacOS.cat
Diffstat (limited to 'Library')
-rw-r--r--Library/Homebrew/bottles.rb15
-rw-r--r--Library/Homebrew/cmd/bottle.rb2
-rw-r--r--Library/Homebrew/formula_support.rb4
-rw-r--r--Library/Homebrew/macos.rb19
-rw-r--r--Library/Homebrew/test/test_bottle_tag.rb44
-rw-r--r--Library/Homebrew/test/test_version_subclasses.rb34
6 files changed, 65 insertions, 53 deletions
diff --git a/Library/Homebrew/bottles.rb b/Library/Homebrew/bottles.rb
index 96562f6c3..4932a191b 100644
--- a/Library/Homebrew/bottles.rb
+++ b/Library/Homebrew/bottles.rb
@@ -54,7 +54,7 @@ def bottle_new_revision f
end
def bottle_native_suffix revision=nil
- ".#{MacOS.cat}#{bottle_suffix(revision)}"
+ ".#{bottle_tag}#{bottle_suffix(revision)}"
end
def bottle_suffix revision=nil
@@ -63,7 +63,7 @@ def bottle_suffix revision=nil
end
def bottle_native_regex
- /(\.#{MacOS.cat}\.bottle\.(\d+\.)?tar\.gz)$/o
+ /(\.#{bottle_tag}\.bottle\.(\d+\.)?tar\.gz)$/o
end
def bottle_regex
@@ -78,3 +78,14 @@ end
def bottle_url f
"#{bottle_root_url(f)}/#{bottle_filename(f)}"
end
+
+def bottle_tag
+ case MacOS.version
+ when 10.8, 10.7, 10.5
+ MacOS.cat
+ when 10.6
+ Hardware.is_64_bit? ? :snow_leopard : :snow_leopard_32
+ else
+ Hardware::CPU.type == :ppc ? Hardware::CPU.family : MacOS.cat
+ end
+end
diff --git a/Library/Homebrew/cmd/bottle.rb b/Library/Homebrew/cmd/bottle.rb
index 5f4501392..8019f6c0e 100644
--- a/Library/Homebrew/cmd/bottle.rb
+++ b/Library/Homebrew/cmd/bottle.rb
@@ -66,7 +66,7 @@ module Homebrew extend self
puts " prefix #{prefix}" if prefix
puts " cellar #{cellar}" if cellar
puts " revision #{bottle_revision}" if bottle_revision > 0
- puts " sha1 '#{sha1}' => :#{MacOS.cat}"
+ puts " sha1 '#{sha1}' => :#{bottle_tag}"
puts "end"
end
end
diff --git a/Library/Homebrew/formula_support.rb b/Library/Homebrew/formula_support.rb
index f1eebd1d7..54f00f262 100644
--- a/Library/Homebrew/formula_support.rb
+++ b/Library/Homebrew/formula_support.rb
@@ -98,8 +98,8 @@ class Bottle < SoftwareSpec
@#{cksum}[value] = Checksum.new(:#{cksum}, key)
end
- if @#{cksum}.has_key? MacOS.cat
- @checksum = @#{cksum}[MacOS.cat]
+ if @#{cksum}.has_key? bottle_tag
+ @checksum = @#{cksum}[bottle_tag]
end
end
EOS
diff --git a/Library/Homebrew/macos.rb b/Library/Homebrew/macos.rb
index bd44ef7ab..b0320c9f4 100644
--- a/Library/Homebrew/macos.rb
+++ b/Library/Homebrew/macos.rb
@@ -10,21 +10,12 @@ module MacOS extend self
end
def cat
- @cat ||= uncached_cat
- end
-
- def uncached_cat
case MacOS.version
- when 10.8
- :mountain_lion
- when 10.7
- :lion
- when 10.6
- Hardware.is_64_bit? ? :snow_leopard : :snow_leopard_32
- when 10.5
- :leopard
- else
- Hardware::CPU.family if Hardware::CPU.type == :ppc
+ when 10.8 then :mountain_lion
+ when 10.7 then :lion
+ when 10.6 then :snow_leopard
+ when 10.5 then :leopard
+ when 10.4 then :tiger
end
end
diff --git a/Library/Homebrew/test/test_bottle_tag.rb b/Library/Homebrew/test/test_bottle_tag.rb
new file mode 100644
index 000000000..50028c164
--- /dev/null
+++ b/Library/Homebrew/test/test_bottle_tag.rb
@@ -0,0 +1,44 @@
+require 'testing_env'
+require 'bottles'
+
+class BottleTagTests < Test::Unit::TestCase
+ def test_cat_tiger_ppc
+ MacOS.stubs(:version).returns(MacOS::Version.new(10.4))
+ Hardware::CPU.stubs(:type).returns(:ppc)
+ Hardware::CPU.stubs(:family).returns(:foo)
+ assert_equal :foo, bottle_tag
+ end
+
+ def test_cat_tiger_intel
+ MacOS.stubs(:version).returns(MacOS::Version.new(10.4))
+ Hardware::CPU.stubs(:type).returns(:intel)
+ assert_equal :tiger, bottle_tag
+ end
+
+ def test_cat_leopard
+ MacOS.stubs(:version).returns(MacOS::Version.new(10.5))
+ assert_equal :leopard, bottle_tag
+ end
+
+ def test_cat_snow_leopard_32
+ MacOS.stubs(:version).returns(MacOS::Version.new(10.6))
+ Hardware.stubs(:is_64_bit?).returns(false)
+ assert_equal :snow_leopard_32, bottle_tag
+ end
+
+ def test_cat_snow_leopard_64
+ MacOS.stubs(:version).returns(MacOS::Version.new(10.6))
+ Hardware.stubs(:is_64_bit?).returns(true)
+ assert_equal :snow_leopard, bottle_tag
+ end
+
+ def test_cat_lion
+ MacOS.stubs(:version).returns(MacOS::Version.new(10.7))
+ assert_equal :lion, bottle_tag
+ end
+
+ def test_cat_mountain_lion
+ MacOS.stubs(:version).returns(MacOS::Version.new(10.8))
+ assert_equal :mountain_lion, bottle_tag
+ end
+end
diff --git a/Library/Homebrew/test/test_version_subclasses.rb b/Library/Homebrew/test/test_version_subclasses.rb
index a855f9df5..6b18246ba 100644
--- a/Library/Homebrew/test/test_version_subclasses.rb
+++ b/Library/Homebrew/test/test_version_subclasses.rb
@@ -39,38 +39,4 @@ class MacOSVersionTests < Test::Unit::TestCase
assert_operator @v, :===, Version.new(10.7)
assert_operator @v, :<, Version.new(10.8)
end
-
- def test_cat_tiger
- MacOS.stubs(:version).returns(MacOS::Version.new(10.4))
- Hardware::CPU.stubs(:type).returns(:ppc)
- Hardware::CPU.stubs(:family).returns(:foo)
- assert_equal :foo, MacOS.uncached_cat
- end
-
- def test_cat_leopard
- MacOS.stubs(:version).returns(MacOS::Version.new(10.5))
- assert_equal :leopard, MacOS.uncached_cat
- end
-
- def test_cat_snow_leopard_32
- MacOS.stubs(:version).returns(MacOS::Version.new(10.6))
- Hardware.stubs(:is_64_bit?).returns(false)
- assert_equal :snow_leopard_32, MacOS.uncached_cat
- end
-
- def test_cat_snow_leopard_64
- MacOS.stubs(:version).returns(MacOS::Version.new(10.6))
- Hardware.stubs(:is_64_bit?).returns(true)
- assert_equal :snow_leopard, MacOS.uncached_cat
- end
-
- def test_cat_lion
- MacOS.stubs(:version).returns(MacOS::Version.new(10.7))
- assert_equal :lion, MacOS.uncached_cat
- end
-
- def test_cat_mountain_lion
- MacOS.stubs(:version).returns(MacOS::Version.new(10.8))
- assert_equal :mountain_lion, MacOS.uncached_cat
- end
end