Sha256: 6abcf86caab19bd61868065dd9adf5415ec934fd6d84b658b2ac77985612aa82

Contents?: true

Size: 803 Bytes

Versions: 40

Compression:

Stored size: 803 Bytes

Contents

# -*- encoding: utf-8 -*-

module Albacore
  module Facts
    
    def self.processor_count
      case RbConfig::CONFIG['host_os']
      when /darwin9/
        `hwprefs cpu_count`.to_i
      when /darwin/
        ((`which hwprefs` != '') ? `hwprefs thread_count` : `sysctl -n hw.ncpu`).to_i
      when /linux/
        `cat /proc/cpuinfo | grep processor | wc -l`.to_i
      when /freebsd/
        `sysctl -n hw.ncpu`.to_i
      when /mswin|mingw/
        require 'win32ole'
        # http://msdn.microsoft.com/en-us/library/windows/desktop/aa394373%28v=vs.85%29.aspx
        wmi = WIN32OLE.connect("winmgmts://")
        cpu = wmi.ExecQuery("select NumberOfLogicalProcessors from Win32_Processor")
        cpu.to_enum.first.NumberOfLogicalProcessors
      end
    end
  end
end

Version data entries

40 entries across 40 versions & 1 rubygems

Version Path
albacore-2.0.0.rc.20 lib/albacore/facts.rb
albacore-2.0.0.rc.19 lib/albacore/facts.rb
albacore-2.0.0.rc.18 lib/albacore/facts.rb
albacore-2.0.0.rc.17 lib/albacore/facts.rb
albacore-2.0.0.rc.15 lib/albacore/facts.rb
albacore-2.0.0.rc.14 lib/albacore/facts.rb
albacore-2.0.0.rc.13 lib/albacore/facts.rb
albacore-2.0.0.rc.12 lib/albacore/facts.rb
albacore-2.0.0.rc.11 lib/albacore/facts.rb
albacore-2.0.0.rc.10 lib/albacore/facts.rb
albacore-2.0.0.rc.9 lib/albacore/facts.rb
albacore-2.0.0.rc.8 lib/albacore/facts.rb
albacore-2.0.0.rc.7 lib/albacore/facts.rb
albacore-2.0.0.rc.6 lib/albacore/facts.rb
albacore-2.0.0.rc.5 lib/albacore/facts.rb
albacore-2.0.0.rc.4 lib/albacore/facts.rb
albacore-2.0.0.rc.3 lib/albacore/facts.rb
albacore-2.0.0.rc.2 lib/albacore/facts.rb
albacore-2.0.0.rc.1 lib/albacore/facts.rb
albacore-0.6.2.rc1 lib/albacore/facts.rb