duffy 0.1.2 → 0.1.3
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 +4 -4
- data/lib/duffy/system.rb +30 -0
- data/lib/duffy/version.rb +1 -1
- data/lib/duffy.rb +3 -2
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 433f82e6504765b1f181ff285d0fff14af108a9f
|
4
|
+
data.tar.gz: 53bf173530d996ada6f88a700c5c13b3b9a083f4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7f447f4885d3a1d8d9089a7498a35126eccc88b2c0a9139c350ac667fff42e4ebaa57138c5eae150936ea2dbc472a7ffaf52de9bb1aa1275cefa7ee3efc731fc
|
7
|
+
data.tar.gz: b41ad2fb968c7346aee161125588ecfe6465e6874458f00302ef0e9d657070ed719ee8593d2061105a28d0def5c13666412c91dd13a9f80f8b91019cc9ebe4c6
|
data/lib/duffy/system.rb
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
module Duffy
|
2
|
+
|
3
|
+
# Depending on your hardware, you may want to make decisions in your code.
|
4
|
+
# I use this to figure out how many processes I can launch in parallel.
|
5
|
+
|
6
|
+
# This is linux specific (for now) and will return 1 for everything on other systems.
|
7
|
+
|
8
|
+
class System
|
9
|
+
class << self
|
10
|
+
|
11
|
+
# How many Physical CPUs do you have.
|
12
|
+
# Detected by counting unique physical IDs
|
13
|
+
def cpus
|
14
|
+
File.read('/proc/cpuinfo').scan(/^physical id.*/).uniq.count rescue 1
|
15
|
+
end
|
16
|
+
|
17
|
+
# How many actual CPU cores do we have not including Hyperthreading
|
18
|
+
# "cpu cores" in cpuinfo is on a per physical processor basis, so we multiply by the number of CPUs
|
19
|
+
def cores
|
20
|
+
(File.read('/proc/cpuinfo').scan(/^cpu cores.*/).first.scan(/\d+$/).first.to_i rescue 1) * cpus
|
21
|
+
end
|
22
|
+
|
23
|
+
# How many threads does the system have.
|
24
|
+
def threads
|
25
|
+
File.read('/proc/cpuinfo').scan(/^processor\s*:/).size rescue 1
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
data/lib/duffy/version.rb
CHANGED
data/lib/duffy.rb
CHANGED
@@ -7,10 +7,11 @@ require File.dirname(__FILE__) + "/duffy/engine" if defined?(Rails)
|
|
7
7
|
require File.dirname(__FILE__) + "/duffy/railtie" if defined?(Rails)
|
8
8
|
|
9
9
|
# Normal Requirements
|
10
|
-
require File.dirname(__FILE__) + "/duffy/
|
10
|
+
require File.dirname(__FILE__) + "/duffy/date"
|
11
11
|
require File.dirname(__FILE__) + "/duffy/git"
|
12
12
|
require File.dirname(__FILE__) + "/duffy/string"
|
13
|
-
require File.dirname(__FILE__) + "/duffy/
|
13
|
+
require File.dirname(__FILE__) + "/duffy/system"
|
14
|
+
require File.dirname(__FILE__) + "/duffy/version"
|
14
15
|
|
15
16
|
|
16
17
|
# Required to add assets to pipeline
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: duffy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jacob Duffy
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-03-
|
11
|
+
date: 2015-03-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -101,6 +101,7 @@ files:
|
|
101
101
|
- lib/duffy/git.rb
|
102
102
|
- lib/duffy/railtie.rb
|
103
103
|
- lib/duffy/string.rb
|
104
|
+
- lib/duffy/system.rb
|
104
105
|
- lib/duffy/version.rb
|
105
106
|
- spec/date_spec.rb
|
106
107
|
- spec/spec_helper.rb
|