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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 27b9a5bf4d430558299ac0752859081b77266e2c
4
- data.tar.gz: 3df3f6e3f78f55f272a3034f78b818451e959236
3
+ metadata.gz: 433f82e6504765b1f181ff285d0fff14af108a9f
4
+ data.tar.gz: 53bf173530d996ada6f88a700c5c13b3b9a083f4
5
5
  SHA512:
6
- metadata.gz: d34d78f2e9564458c0c6e6af9972205170cb847b075a783535b809d34ff53abf8db2e3d6978c03a323c5d32122598024f9caf387893c13c9caf585cbe0f52040
7
- data.tar.gz: fc4c763e052d4880f821793d6d21172d2d4547bb038e69cd1baec94e8c762c909dec617ae7b5b3019016ceb9625315ffb3ec60acc1fcc80cb5e24f6560a5543f
6
+ metadata.gz: 7f447f4885d3a1d8d9089a7498a35126eccc88b2c0a9139c350ac667fff42e4ebaa57138c5eae150936ea2dbc472a7ffaf52de9bb1aa1275cefa7ee3efc731fc
7
+ data.tar.gz: b41ad2fb968c7346aee161125588ecfe6465e6874458f00302ef0e9d657070ed719ee8593d2061105a28d0def5c13666412c91dd13a9f80f8b91019cc9ebe4c6
@@ -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
@@ -1,3 +1,3 @@
1
1
  module Duffy
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
3
3
  end
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/version"
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/date"
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.2
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 00:00:00.000000000 Z
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