aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/hardware.rb
diff options
context:
space:
mode:
authorMisty De Meo2013-03-17 13:30:12 -0500
committerMisty De Meo2013-03-23 13:40:18 -0500
commite7f66519dc6881f49e594ddb2fae857580c2c033 (patch)
tree5746795ec7dfd4478f85858bbdbb516290caded1 /Library/Homebrew/hardware.rb
parent17a92eab118763bdabe23bb0319e6ab5b18f8488 (diff)
downloadhomebrew-e7f66519dc6881f49e594ddb2fae857580c2c033.tar.bz2
Hardware: separate out CPU values into CPU module
* CPU functions now exist in Hardware::CPU * Added compatibility functions in compat/hardware_compat.rb * Names are less specific to Mac hardware, e.g. CPU.family instead of Hardware.intel_family * Hardware::CPU.family works for both Intel and PowerPC * New helper methods on CPU, like .sse4? and .altivec? Signed-off-by: Misty De Meo <mistydemeo@gmail.com>
Diffstat (limited to 'Library/Homebrew/hardware.rb')
-rw-r--r--Library/Homebrew/hardware.rb40
1 files changed, 30 insertions, 10 deletions
diff --git a/Library/Homebrew/hardware.rb b/Library/Homebrew/hardware.rb
index ded0c9ccb..b139215ae 100644
--- a/Library/Homebrew/hardware.rb
+++ b/Library/Homebrew/hardware.rb
@@ -1,11 +1,39 @@
+require 'hardware_compat'
+
class Hardware
+ module CPU extend self
+ def type
+ @type || :dunno
+ end
+
+ def family
+ @family || :dunno
+ end
+
+ def cores
+ @cores || 1
+ end
+
+ def bits
+ @bits || 64
+ end
+
+ def is_32_bit?
+ bits == 32
+ end
+
+ def is_64_bit?
+ bits == 64
+ end
+ end
+
case RUBY_PLATFORM.downcase
when /darwin/
require 'os/mac/hardware'
- extend MacOSHardware
+ CPU.extend MacCPUs
when /linux/
require 'os/linux/hardware'
- extend LinuxHardware
+ CPU.extend LinuxCPUs
else
raise "The system `#{`uname`.chomp}' is not supported."
end
@@ -19,12 +47,4 @@ class Hardware
Hardware.processor_count
end
end
-
- def self.is_32_bit?
- not self.is_64_bit?
- end
-
- def self.bits
- Hardware.is_64_bit? ? 64 : 32
- end
end