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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 74bb820f689a9409f74d6048f4d5492d0a9e711d
4
- data.tar.gz: 9dac2fcc3a9763d9091f3fcf42b17e80d40b26c9
3
+ metadata.gz: ab9c878066ae8497d5bf7e5a50a5761b97e2ec66
4
+ data.tar.gz: 0f38a8fd0a248e80da06cf901f937b94b0be664d
5
5
  SHA512:
6
- metadata.gz: f492e22a68a869c3e080888c1976cd72cdbd1a0f0c6a260c3f2a22749af12ee29ff56b82c56efa1b499917f8620f959314a76d2edbbf20e67ccf93d9537ff03a
7
- data.tar.gz: 605b6e4020dbb0fdff63c40dd78f52caab1d727880fdc38becfd9731190bdc5d5270e1f24757d6a49ec9b1cdc2d5285b13342acabce6f4b32df135dc8d69fa41
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 ps
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
- DELIMITER = "!"
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
- module UnixPs
7
- def self.processes
8
- ps_output = `ps aux | awk '{print $1 "#{DELIMITER}" $2 "#{DELIMITER}" $3 "#{DELIMITER}" $4 "#{DELIMITER}" $5 "#{DELIMITER}" $6 "#{DELIMITER}" $7 "#{DELIMITER}" $8 "#{DELIMITER}" $9 "#{DELIMITER}" $10 "#{DELIMITER}" $11}'`.lines
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
@@ -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(DELIMITER)
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]
@@ -1,3 +1,3 @@
1
1
  module UnixPs
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
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.1
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-04 00:00:00.000000000 Z
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: