ps-ruby 0.0.3 → 0.0.4
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/example/example.rb +4 -4
- data/lib/ps-ruby/ps-ruby.rb +4 -2
- data/lib/ps-ruby/version.rb +1 -1
- data/ps-ruby-0.0.3.gem +0 -0
- data/readme.md +1 -1
- 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: 2aeab74853811588e65ce33b20351cd946bf6cb0
|
4
|
+
data.tar.gz: dfa27d8bd46824de4084541547b04d238e16ec04
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: eb30a4daf207b107c11c9b493709e17c9e3e1cc433bd9e95dd22e514422cd7892df3995dae0ffc9f90f25ffb95bdca10fe60d43b3e0618b9143843af5ebf4ceb
|
7
|
+
data.tar.gz: a3c4a07949071e2bbafeebb4f512c264a329025ab6a707da46d2b8a0e127a1b12407c05e04e0d8af5609182987ff3adc8bc2244873e0d63b854b461c86c1ca00
|
data/example/example.rb
CHANGED
@@ -7,9 +7,6 @@ puts PS.attrs.to_s
|
|
7
7
|
# display a simple table
|
8
8
|
PS.find_processes("zsh").simple_display
|
9
9
|
|
10
|
-
# find by special attrs
|
11
|
-
put PS.find_processes("PID", PROCESS_ID)
|
12
|
-
|
13
10
|
# Kill all process named 'irb'
|
14
11
|
# PS.find_processes("irb").kill!
|
15
12
|
|
@@ -19,4 +16,7 @@ PS.find_processes("chrome").first.alive?
|
|
19
16
|
# chaining select
|
20
17
|
ms = PS.find_processes("Microsoft")
|
21
18
|
word = ms.find_processes("Word")
|
22
|
-
ppt = ms.find_processes("PowerPoint")
|
19
|
+
ppt = ms.find_processes("PowerPoint")
|
20
|
+
|
21
|
+
# find by special attrs
|
22
|
+
put PS.find_processes("PID", PROCESS_ID)
|
data/lib/ps-ruby/ps-ruby.rb
CHANGED
@@ -6,7 +6,7 @@ class PsProcess < Hash
|
|
6
6
|
end
|
7
7
|
|
8
8
|
def alive?
|
9
|
-
PS.get_all_processes.
|
9
|
+
PS.get_all_processes.pick_attr("PID").include?(self["PID"])
|
10
10
|
end
|
11
11
|
end
|
12
12
|
|
@@ -43,7 +43,7 @@ class PsProcessList < Array
|
|
43
43
|
PsProcessList.new(self.select{|x| x[attr_name] =~ regex })
|
44
44
|
end
|
45
45
|
|
46
|
-
def
|
46
|
+
def pick_attr(attr_name)
|
47
47
|
self.map{|x| x[attr_name] } if PS.attrs.include?(attr_name)
|
48
48
|
end
|
49
49
|
|
@@ -76,10 +76,12 @@ module PS
|
|
76
76
|
def get_all_processes
|
77
77
|
table = raw_aux.split("\n").map{|x| x.split(/\s+/) }
|
78
78
|
attrs = table.shift
|
79
|
+
is_percent = ["%CPU", "%MEM"].map{|x| attrs.index(x) }
|
79
80
|
table = table.reduce(PsProcessList.new) {|s, x|
|
80
81
|
if x.size > attrs.size
|
81
82
|
x = x[0..(attrs.size-2)] + [x[(attrs.size-1)..-1].join(" ")]
|
82
83
|
end
|
84
|
+
is_percent.each{|k| x[k] = x[k].to_f }
|
83
85
|
s << PsProcess[attrs.zip(x)]
|
84
86
|
}
|
85
87
|
table
|
data/lib/ps-ruby/version.rb
CHANGED
data/ps-ruby-0.0.3.gem
ADDED
Binary file
|
data/readme.md
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ps-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- HondaDai
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-04-
|
11
|
+
date: 2015-04-29 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description:
|
14
14
|
email:
|
@@ -28,6 +28,7 @@ files:
|
|
28
28
|
- lib/ps-ruby.rb
|
29
29
|
- lib/ps-ruby/ps-ruby.rb
|
30
30
|
- lib/ps-ruby/version.rb
|
31
|
+
- ps-ruby-0.0.3.gem
|
31
32
|
- ps-ruby.gemspec
|
32
33
|
- readme.md
|
33
34
|
homepage: https://github.com/HondaDai/ps-ruby
|