unix-ps 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 74bb820f689a9409f74d6048f4d5492d0a9e711d
4
+ data.tar.gz: 9dac2fcc3a9763d9091f3fcf42b17e80d40b26c9
5
+ SHA512:
6
+ metadata.gz: f492e22a68a869c3e080888c1976cd72cdbd1a0f0c6a260c3f2a22749af12ee29ff56b82c56efa1b499917f8620f959314a76d2edbbf20e67ccf93d9537ff03a
7
+ data.tar.gz: 605b6e4020dbb0fdff63c40dd78f52caab1d727880fdc38becfd9731190bdc5d5270e1f24757d6a49ec9b1cdc2d5285b13342acabce6f4b32df135dc8d69fa41
data/.gitignore ADDED
@@ -0,0 +1,34 @@
1
+ *.gem
2
+ *.rbc
3
+ /.config
4
+ /coverage/
5
+ /InstalledFiles
6
+ /pkg/
7
+ /spec/reports/
8
+ /test/tmp/
9
+ /test/version_tmp/
10
+ /tmp/
11
+
12
+ ## Specific to RubyMotion:
13
+ .dat*
14
+ .repl_history
15
+ build/
16
+
17
+ ## Documentation cache and generated files:
18
+ /.yardoc/
19
+ /_yardoc/
20
+ /doc/
21
+ /rdoc/
22
+
23
+ ## Environment normalisation:
24
+ /.bundle/
25
+ /lib/bundler/man/
26
+
27
+ # for a library or gem, you might want to ignore these files since the code is
28
+ # intended to run in multiple environments; otherwise, check them in:
29
+ # Gemfile.lock
30
+ # .ruby-version
31
+ # .ruby-gemset
32
+
33
+ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
34
+ .rvmrc
data/README.md ADDED
@@ -0,0 +1,4 @@
1
+ unix-ps
2
+ =======
3
+
4
+ A Ruby wrapper around the unix tool ps
data/lib/unix_ps.rb ADDED
@@ -0,0 +1,16 @@
1
+ require './unix_ps/unix_process'
2
+
3
+ # Subject to change, hopefully this does not cause issues
4
+ DELIMITER = "!"
5
+
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
+
10
+ # Pop off header columns
11
+ ps_output.shift
12
+
13
+ # Generate objects
14
+ ps_output.collect { |line| UnixProcess.new(line) }
15
+ end
16
+ end
@@ -0,0 +1,33 @@
1
+ require 'time'
2
+
3
+ module UnixPs
4
+ # Class that represents a unix process' basic information
5
+ class UnixProcess
6
+
7
+ attr_accessor :user, :pid, :cpu, :mem, :vsz, :rss, :tty, :stat, :start, :time, :command
8
+
9
+ def initialize(line)
10
+ # Split each line into fields by the delimiter
11
+ fields = line.split(DELIMITER)
12
+
13
+ # Assign the fields
14
+ @user = fields[0]
15
+ @pid = fields[1].to_i
16
+ @cpu = fields[2]
17
+ @mem = fields[3]
18
+ @vsz = fields[4]
19
+ @rss = fields[5]
20
+ @tty = fields[6]
21
+ @stat = fields[7]
22
+ @start = Time.parse(fields[8])
23
+ @time = fields[9]
24
+ @command = fields[10]
25
+ end
26
+
27
+ def kill!(sig=nil)
28
+ sig ||= 'INT'
29
+ Process.kill(sig, self.pid)
30
+ end
31
+
32
+ end
33
+ end
@@ -0,0 +1,3 @@
1
+ module UnixPs
2
+ VERSION = "0.0.1"
3
+ end
data/unix_ps.gemspec ADDED
@@ -0,0 +1,17 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "unix_ps/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "unix-ps"
7
+ s.version = UnixPs::VERSION
8
+ s.platform = Gem::Platform::RUBY
9
+ s.authors = ["Jason Parraga"]
10
+ s.email = ["Sovietaced@gmail.com"]
11
+ s.homepage = "https://github.com/Sovietaced/unix-ps"
12
+ s.summary = %q{A Ruby wrapper around the unix tool ps.}
13
+ s.description = %q{A Ruby wrapper around the unix tool ps.}
14
+
15
+ s.files = `git ls-files`.split("\n")
16
+ s.require_paths = ["lib"]
17
+ end
metadata ADDED
@@ -0,0 +1,49 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: unix-ps
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Jason Parraga
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-06-04 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: A Ruby wrapper around the unix tool ps.
14
+ email:
15
+ - Sovietaced@gmail.com
16
+ executables: []
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - ".gitignore"
21
+ - README.md
22
+ - lib/unix_ps.rb
23
+ - lib/unix_ps/unix_process.rb
24
+ - lib/unix_ps/version.rb
25
+ - unix_ps.gemspec
26
+ homepage: https://github.com/Sovietaced/unix-ps
27
+ licenses: []
28
+ metadata: {}
29
+ post_install_message:
30
+ rdoc_options: []
31
+ require_paths:
32
+ - lib
33
+ required_ruby_version: !ruby/object:Gem::Requirement
34
+ requirements:
35
+ - - ">="
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ required_rubygems_version: !ruby/object:Gem::Requirement
39
+ requirements:
40
+ - - ">="
41
+ - !ruby/object:Gem::Version
42
+ version: '0'
43
+ requirements: []
44
+ rubyforge_project:
45
+ rubygems_version: 2.2.2
46
+ signing_key:
47
+ specification_version: 4
48
+ summary: A Ruby wrapper around the unix tool ps.
49
+ test_files: []