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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f8f76d6f0836c26f999f5354fb66878964f731c0
4
- data.tar.gz: f4e5cd23c6bfcf19621e66beb391b873dd37fc3f
3
+ metadata.gz: 610bb9f91e8d2677de1ee78a3b8a7ad8f5c57fc2
4
+ data.tar.gz: 54d7e91c4aa7edb55c54de232b70a9b41d7d5a5f
5
5
  SHA512:
6
- metadata.gz: ef4bcde07bca8d30a069bb6ec57d0f8cda82572ff5b4d61f11568ce2681faa03ab5c95d950a2f33bc18d34ec725ddc508c163bdde1759cf13f6179379b9b42ca
7
- data.tar.gz: 6270daf98b3bf80d76a1a8078e70e2fb5bbd96c08049b55d596bc51d8343e3cfaf621376d23c109d40156c025d2dcaa2baec983e1210215f9747a9bdb5daebd1
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 (File.read("/proc/meminfo").lines.grep(/MemAvailable/).first.split[1].to_i / 1024)
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.0"
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.0
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 00:00:00.000000000 Z
11
+ date: 2017-05-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport