Sha256: 3c7610d7ad502a0da471a3076dc8fd42b7c4df6d0ee181d86618e51a940b31f7
Contents?: true
Size: 1.13 KB
Versions: 2
Compression:
Stored size: 1.13 KB
Contents
class ImageOptim module Util # Run command redirecting both stdout and stderr to /dev/null, raising signal if command was signaled and return successfulness def self.run(*args) res = system "#{args.map(&:to_s).shelljoin} &> /dev/null" if $?.signaled? raise SignalException.new($?.termsig) end res end # http://stackoverflow.com/questions/891537/ruby-detect-number-of-cpus-installed def self.processor_count @processor_count ||= case host_os = RbConfig::CONFIG['host_os'] when /darwin9/ `hwprefs cpu_count` when /darwin/ (`which hwprefs` != '') ? `hwprefs thread_count` : `sysctl -n hw.ncpu` when /linux/ `grep -c processor /proc/cpuinfo` when /freebsd/ `sysctl -n hw.ncpu` when /mswin|mingw/ require 'win32ole' wmi = WIN32OLE.connect('winmgmts://') cpu = wmi.ExecQuery('select NumberOfLogicalProcessors from Win32_Processor') cpu.to_enum.first.NumberOfLogicalProcessors else warn "Unknown architecture (#{host_os}) assuming one processor." 1 end.to_i end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
image_optim-0.2.0 | lib/image_optim/util.rb |
image_optim-0.1.0 | lib/image_optim/util.rb |