duffy 0.3.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/duffy/system.rb +3 -1
- data/lib/duffy/version.rb +2 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 610bb9f91e8d2677de1ee78a3b8a7ad8f5c57fc2
|
4
|
+
data.tar.gz: 54d7e91c4aa7edb55c54de232b70a9b41d7d5a5f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 111d5cd78c101bd1a81e3ec1a3ce578e4b59c0016753ccb645924059dc96c052f3516143447b2f6d5884599381e3542d7017e68f8f0add7bea496f47057e625a
|
7
|
+
data.tar.gz: e81c5e02cfd4dda855a18aabde30dae93048e41adfd3bbd483df7ee576c4502935e0cdcf38b916d2c70922e67bc7840a3eff1384a3f4d849a52d663ae697b380
|
data/lib/duffy/system.rb
CHANGED
@@ -78,7 +78,7 @@ module Duffy
|
|
78
78
|
def mem_available
|
79
79
|
case RUBY_PLATFORM
|
80
80
|
when /darwin/ then `vm_stat`.lines.grep(/(free:|inactive:)\s*(\d+)/){$2}.map(&:to_i).inject(:+) * 4 / 1024
|
81
|
-
when /linux/ then
|
81
|
+
when /linux/ then File.read("/proc/meminfo").lines.grep(/MemAvail|MemFree/).sort.first.split[1].to_i / 1024
|
82
82
|
else 0
|
83
83
|
end
|
84
84
|
rescue
|
@@ -95,6 +95,7 @@ module Duffy
|
|
95
95
|
private
|
96
96
|
|
97
97
|
# [CPU USE, CPU IDLE]
|
98
|
+
# LINUX
|
98
99
|
def proc_stat
|
99
100
|
cpu = File.open("/proc/stat", "r").read.lines.first
|
100
101
|
[cpu.split[1..3].map(&:to_i).inject(:+), cpu.split[1..4].map(&:to_i).inject(:+)]
|
@@ -102,6 +103,7 @@ module Duffy
|
|
102
103
|
|
103
104
|
# Poll proc_stat twice and find the usage in that time.
|
104
105
|
# Higher Sleep is more accurate, but obviously slower.
|
106
|
+
# LINUX
|
105
107
|
def proc_diff
|
106
108
|
s = proc_stat
|
107
109
|
sleep 0.2
|
data/lib/duffy/version.rb
CHANGED
@@ -1,8 +1,9 @@
|
|
1
1
|
module Duffy
|
2
|
-
VERSION = "0.3.
|
2
|
+
VERSION = "0.3.1"
|
3
3
|
end
|
4
4
|
|
5
5
|
# History
|
6
|
+
# 0.3.1 - Fixed mem_available for old linux distros.
|
6
7
|
# 0.3.0 - Added system memory methods. Removed deprecated icon methods.
|
7
8
|
# 0.2.7 - Deprecated "icon" and "excel_icon"
|
8
9
|
# 0.2.6 - Added cpu_percent to give the current total CPU usage percentage.
|
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.3.
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jacob Duffy
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-05-
|
11
|
+
date: 2017-05-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|