lib/ps.rb in ps-0.0.7 vs lib/ps.rb in ps-0.0.8

- old
+ new

@@ -47,11 +47,11 @@ end def from_lsof match, args={} lines = `lsof -i #{match} -sTCP:LISTEN`.chomp.split("\n") lines.shift # remove header - + pids = lines.collect do |line| if m = line.match(/\s*\w+\s+(\d+)/) m[1].to_i end end.compact @@ -66,19 +66,27 @@ require 'ps/process_list' require 'ps/process_list_printer' def PS *args case args[0] + when /\:\d+$/ + PS.from_lsof(*args) when Regexp opts = args[1] || {} procs = PS.all(opts) procs = procs.select {|proc| proc.command =~ args[0]} procs = procs.select {|proc| proc.pid != Process.pid} unless opts[:include_self] procs when Integer - PS.pid(*args).first + if args[1].is_a?(Integer) + PS.pid(*args) + else + PS.pid(*args).first + end + when Array + pids = args[0] + pids << args[1] || {} + PS.pid(*pids) when Hash PS.all(*args) - when /\:\d+$/ - PS.from_lsof(*args) end end