Sha256: 0052dace052341a146576ca9d42d676aac3de45095d5c2f2e2d17a5745407c6e

Contents?: true

Size: 773 Bytes

Versions: 66

Compression:

Stored size: 773 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

66 entries across 66 versions & 1 rubygems

Version Path
albacore-3.0.1 ./lib/albacore/facts.rb
albacore-3.0.0.pre.alpha.6 ./lib/albacore/facts.rb
albacore-3.0.0.pre.alpha.5 ./lib/albacore/facts.rb
albacore-3.0.0.pre.alpha.4 ./lib/albacore/facts.rb
albacore-3.0.0.pre.alpha.3 ./lib/albacore/facts.rb
albacore-3.0.0.pre.alpha.2 ./lib/albacore/facts.rb
albacore-3.0.0.pre.alpha ./lib/albacore/facts.rb
albacore-2.8.0 ./lib/albacore/facts.rb
albacore-2.7.0 ./lib/albacore/facts.rb
albacore-2.6.8 ./lib/albacore/facts.rb
albacore-2.6.7 ./lib/albacore/facts.rb
albacore-2.6.6 ./lib/albacore/facts.rb
albacore-2.6.4 ./lib/albacore/facts.rb
albacore-2.6.3 ./lib/albacore/facts.rb
albacore-2.6.2 ./lib/albacore/facts.rb
albacore-2.6.1 ./lib/albacore/facts.rb
albacore-2.6.0 ./lib/albacore/facts.rb
albacore-2.5.14 ./lib/albacore/facts.rb
albacore-2.5.13 ./lib/albacore/facts.rb
albacore-2.5.11 ./lib/albacore/facts.rb