celluloid-essentials 0.20.0 → 0.20.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d06b378549089c71c661eb25c11fe031ab71f33c
4
- data.tar.gz: aa4e43ec6fa721d6712b52f7cacab131c3ae382c
3
+ metadata.gz: 298af10b2efa750acf7ed68d7fe8d1380d02aa7d
4
+ data.tar.gz: fb8f2c3b686218ac91f6c4de93b1f6edc66f0022
5
5
  SHA512:
6
- metadata.gz: 3380fe0205bdaac19d6a438f88c7febb581382dc85569232296f302554d84e3522633868a1f1e07080cc5c6fec2ead6926e59449106bf08c54666589469abfe1
7
- data.tar.gz: 4a1f722532d49b4642f8a27b69f9a994e223d6741b2e7c43a32322770764db83ab90f5ab6d58102580e44aff0639f874a0ba4a6977a1d33b495aa57817bde23c
6
+ metadata.gz: f0beda51987351c6f0111d7d1c753058fdcb1e6390e58ff56515cf0743c58a1c4ef43629a7aab30de11cc4eff4ae1a03686b6d38dd9db3879e995837e31aa482
7
+ data.tar.gz: 2b9064f0c050853e00400fa225bcf14d78b0db1fc928c7ea37af52baa86a57089fdc09fc1f8eed2b71a1e2237e20430e5a0e16f57d5b7c88cc491b8ab6f68c13
@@ -4,7 +4,7 @@ require File.expand_path("../culture/sync", __FILE__)
4
4
 
5
5
  Gem::Specification.new do |gem|
6
6
  gem.name = "celluloid-essentials"
7
- gem.version = "0.20.0"
7
+ gem.version = "0.20.1"
8
8
  gem.platform = Gem::Platform::RUBY
9
9
  gem.summary = "Internally used tools, and superstructural dependencies of Celluloid"
10
10
  gem.description = "Notifications, Internals, Logging, Probe, and essential Celluloid pieces demanding Supervision"
@@ -6,29 +6,56 @@ module Celluloid
6
6
  @cores ||= count_cores
7
7
  end
8
8
 
9
- private
9
+ private unless $CELLULOID_TEST
10
10
 
11
11
  def count_cores
12
- result = from_env || from_sysdev || from_sysctl
13
- Integer(result.to_s[/\d+/], 10) if result
12
+ from_result(from_env || from_sysdev || from_java || from_proc || from_win32ole || from_sysctl) || 1
14
13
  end
15
14
 
16
15
  def from_env
17
16
  result = ENV["NUMBER_OF_PROCESSORS"]
18
- result if result
17
+ result if result && !result.empty?
18
+ rescue
19
19
  end
20
20
 
21
21
  def from_sysdev
22
22
  ::IO.read("/sys/devices/system/cpu/present").split("-").last.to_i + 1
23
23
  rescue Errno::ENOENT
24
- result = Dir["/sys/devices/system/cpu/cpu*"].count { |n| n =~ /cpu\d+/ }
25
- result unless result.zero?
24
+ begin
25
+ result = Dir["/sys/devices/system/cpu/cpu*"].count { |n| n =~ /cpu\d+/ }
26
+ result unless result.zero?
27
+ rescue
28
+ end
29
+ rescue
30
+ end
31
+
32
+ def from_java
33
+ Java::Java.lang.Runtime.getRuntime.availableProcessors if defined? Java::Java
34
+ rescue
35
+ end
36
+
37
+ def from_proc
38
+ File.read('/proc/cpuinfo').scan(/^processor\s*:/).size if File.exist?('/proc/cpuinfo')
39
+ rescue
40
+ end
41
+
42
+ def from_win32ole
43
+ require 'win32ole'
44
+ WIN32OLE.connect("winmgmts://").ExecQuery("select * from Win32_ComputerSystem").NumberOfProcessors
45
+ rescue
26
46
  end
27
47
 
28
48
  def from_sysctl
29
- result = `sysctl -n hw.ncpu`
30
- result if $CHILD_STATUS.success?
31
- rescue Errno::ENOENT
49
+ Integer `sysctl -n hw.ncpu 2>/dev/null`
50
+ rescue
51
+ end
52
+
53
+ def from_result(result)
54
+ if result
55
+ i = Integer(result.to_s[/\d+/], 10)
56
+ return i if i > 0
57
+ end
58
+ rescue
32
59
  end
33
60
  end
34
61
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: celluloid-essentials
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.20.0
4
+ version: 0.20.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tony Arcieri
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-07-04 00:00:00.000000000 Z
12
+ date: 2015-07-15 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  requirement: !ruby/object:Gem::Requirement
@@ -320,7 +320,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
320
320
  version: 1.3.6
321
321
  requirements: []
322
322
  rubyforge_project:
323
- rubygems_version: 2.4.6
323
+ rubygems_version: 2.4.8
324
324
  signing_key:
325
325
  specification_version: 4
326
326
  summary: Internally used tools, and superstructural dependencies of Celluloid