ps 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/ps.rb +1 -1
- data/lib/ps/process_list.rb +26 -2
- data/lib/ps/version.rb +1 -1
- metadata +3 -3
data/lib/ps.rb
CHANGED
@@ -70,7 +70,7 @@ def PS *args
|
|
70
70
|
when Regexp
|
71
71
|
opts = args[1] || {}
|
72
72
|
procs = PS.all(opts)
|
73
|
-
procs = procs.
|
73
|
+
procs = procs.command(args[0])
|
74
74
|
procs = procs.select {|proc| proc.pid != Process.pid} unless opts[:include_self]
|
75
75
|
procs
|
76
76
|
when Integer
|
data/lib/ps/process_list.rb
CHANGED
@@ -1,5 +1,29 @@
|
|
1
1
|
module PS
|
2
|
-
class ProcessList
|
3
|
-
|
2
|
+
class ProcessList
|
3
|
+
def initialize(target=nil)
|
4
|
+
@target = target || []
|
5
|
+
end
|
6
|
+
|
7
|
+
def command regex
|
8
|
+
grep(regex) {|proc| proc.command||proc.cmd}
|
9
|
+
end
|
10
|
+
|
11
|
+
def pids
|
12
|
+
@target.collect {|proc| proc.pid}.compact
|
13
|
+
end
|
14
|
+
|
15
|
+
def over val, amnt
|
16
|
+
select do |proc|
|
17
|
+
proc.__send__(val) >= amnt
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
# Ugh shoot me for using method missing, couldn't get
|
22
|
+
# it to work any other way.
|
23
|
+
def method_missing(name, *args, &blk)
|
24
|
+
new_target = @target.send(name, *args, &blk)
|
25
|
+
|
26
|
+
new_target.class == @target.class ? self.class.new(new_target) : new_target
|
27
|
+
end
|
4
28
|
end
|
5
29
|
end
|
data/lib/ps/version.rb
CHANGED
metadata
CHANGED