ps 0.0.4 → 0.0.5

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.
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.select {|proc| proc.command =~ args[0]}
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
@@ -1,5 +1,29 @@
1
1
  module PS
2
- class ProcessList < Array
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
@@ -1,3 +1,3 @@
1
1
  module PS
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ps
3
3
  version: !ruby/object:Gem::Version
4
- hash: 23
4
+ hash: 21
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 4
10
- version: 0.0.4
9
+ - 5
10
+ version: 0.0.5
11
11
  platform: ruby
12
12
  authors:
13
13
  - Tal Atlas