unix-ps 0.0.1 → 0.0.2
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/README.md +19 -1
- data/lib/unix_ps.rb +14 -5
- data/lib/unix_ps/unix_process.rb +2 -1
- data/lib/unix_ps/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ab9c878066ae8497d5bf7e5a50a5761b97e2ec66
|
4
|
+
data.tar.gz: 0f38a8fd0a248e80da06cf901f937b94b0be664d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3469a6d60ef28d04629690a4517393454da098324150b8094064d963e05d11273850629a436bc34795bf38059336d203723f29ac265dcb5843107940ce014f18
|
7
|
+
data.tar.gz: ae76bef0a80c82d28365f3c2073f7674584e6e837d38a1a3aad9d100dd983115a9978e4636e4f5be5046df1e473ca03d4692c5ce6a8077b67c4bdb6817bd6c5c
|
data/README.md
CHANGED
@@ -1,4 +1,22 @@
|
|
1
1
|
unix-ps
|
2
2
|
=======
|
3
3
|
|
4
|
-
A Ruby wrapper around the unix tool
|
4
|
+
A Ruby wrapper around the unix tool __ps__
|
5
|
+
|
6
|
+
Getting started
|
7
|
+
=======
|
8
|
+
Add unix-ps to your Gemfile with:
|
9
|
+
|
10
|
+
```ruby
|
11
|
+
gem 'unix-ps'
|
12
|
+
```
|
13
|
+
|
14
|
+
Usage
|
15
|
+
=======
|
16
|
+
Get a list of running processes
|
17
|
+
```ruby
|
18
|
+
UnixPs.processes.first
|
19
|
+
=> #<UnixPs::UnixProcess:0x007fa553834758 @user="jason", @pid=54672, @cpu="100.5", @mem="0.6", @vsz="1115436", @rss="93692", @tty="??", @stat="R", @start=2014-06-04 00:00:00 -0700, @time="3162:49.67", @command="/Applications/Dropbox.app/Contents/MacOS/Dropbox\n">
|
20
|
+
```
|
21
|
+
|
22
|
+
|
data/lib/unix_ps.rb
CHANGED
@@ -1,11 +1,20 @@
|
|
1
1
|
require './unix_ps/unix_process'
|
2
|
+
module UnixPs
|
2
3
|
|
3
|
-
# Subject to change, hopefully this does not cause issues
|
4
|
-
|
4
|
+
# Subject to change, hopefully this does not cause issues
|
5
|
+
DELIM = "!"
|
6
|
+
COLUMNS = (1..11).collect{|i| "$#{i}"}
|
7
|
+
COLUMNS = COLUMNS.join(" \"#{DELIM}\" ")
|
5
8
|
|
6
|
-
|
7
|
-
|
8
|
-
ps_output =
|
9
|
+
def self.processes(search=nil)
|
10
|
+
|
11
|
+
ps_output = nil
|
12
|
+
|
13
|
+
if search.is_a? String
|
14
|
+
ps_output = `ps aux | grep #{search} | awk '{print #{COLUMNS}}'`.lines
|
15
|
+
else
|
16
|
+
ps_output = `ps aux | awk '{print #{COLUMNS}}'`.lines
|
17
|
+
end
|
9
18
|
|
10
19
|
# Pop off header columns
|
11
20
|
ps_output.shift
|
data/lib/unix_ps/unix_process.rb
CHANGED
@@ -8,7 +8,7 @@ module UnixPs
|
|
8
8
|
|
9
9
|
def initialize(line)
|
10
10
|
# Split each line into fields by the delimiter
|
11
|
-
fields = line.split(
|
11
|
+
fields = line.split(UnixPs::DELIM)
|
12
12
|
|
13
13
|
# Assign the fields
|
14
14
|
@user = fields[0]
|
@@ -19,6 +19,7 @@ module UnixPs
|
|
19
19
|
@rss = fields[5]
|
20
20
|
@tty = fields[6]
|
21
21
|
@stat = fields[7]
|
22
|
+
puts fields[8]
|
22
23
|
@start = Time.parse(fields[8])
|
23
24
|
@time = fields[9]
|
24
25
|
@command = fields[10]
|
data/lib/unix_ps/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: unix-ps
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jason Parraga
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-06-
|
11
|
+
date: 2014-06-05 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: A Ruby wrapper around the unix tool ps.
|
14
14
|
email:
|