rumblinthebronx-sys-proctable 0.9.6-universal-java → 0.9.7-universal-java
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/Rakefile +1 -0
- data/lib/linux/sys/proctable.rb +36 -2
- data/sys-proctable.gemspec +2 -2
- metadata +29 -25
data/Rakefile
CHANGED
@@ -143,6 +143,7 @@ namespace :gem do
|
|
143
143
|
spec.extensions = ['ext/hpux/extconf.rb']
|
144
144
|
when /linux/i
|
145
145
|
spec.platform = Gem::Platform.new(['universal', 'linux'])
|
146
|
+
spec.platform = Gem::Platform.new(['universal', 'java']) if RUBY_ENGINE == "jruby"
|
146
147
|
spec.require_paths = ['lib', 'lib/linux']
|
147
148
|
spec.files += ['lib/linux/sys/proctable.rb']
|
148
149
|
spec.test_files << 'test/test_sys_proctable_linux.rb'
|
data/lib/linux/sys/proctable.rb
CHANGED
@@ -81,7 +81,7 @@ module Sys
|
|
81
81
|
ProcTableStruct = Struct.new('ProcTableStruct', *@fields)
|
82
82
|
|
83
83
|
# Returns an Array of Proctable structs or just the matching one if +pid+ is given.
|
84
|
-
def self.ps_mac(process_id
|
84
|
+
def self.ps_mac(process_id=-100)
|
85
85
|
output = `ps aux`
|
86
86
|
output = output.split "\n"
|
87
87
|
output.delete output.first
|
@@ -104,6 +104,39 @@ module Sys
|
|
104
104
|
result << struct
|
105
105
|
end
|
106
106
|
|
107
|
+
raise "Process #{process_id} not found" if process_id.to_i > 0
|
108
|
+
result
|
109
|
+
end
|
110
|
+
|
111
|
+
# Returns an Array of Proctable structs or just the matching one if +pid+ is given.
|
112
|
+
def self.ps_windows(process_id=-100)
|
113
|
+
output = `tasklist`
|
114
|
+
output = output.split "\n"
|
115
|
+
output.delete output.first
|
116
|
+
output.delete output.first
|
117
|
+
output.delete output.first
|
118
|
+
result = []
|
119
|
+
|
120
|
+
output.each do |process_info|
|
121
|
+
struct = ProcTableStruct.new
|
122
|
+
struct.cmdline ||= ""
|
123
|
+
process_info = process_info.split
|
124
|
+
process_info.each do |field|
|
125
|
+
pid = Integer(field) rescue nil
|
126
|
+
|
127
|
+
if pid.nil?
|
128
|
+
struct.cmdline += field
|
129
|
+
else
|
130
|
+
struct.pid = pid
|
131
|
+
return struct if pid == process_id
|
132
|
+
break
|
133
|
+
end
|
134
|
+
end
|
135
|
+
|
136
|
+
result << struct
|
137
|
+
end
|
138
|
+
|
139
|
+
raise "Process #{process_id} not found" if process_id.to_i > 0
|
107
140
|
result
|
108
141
|
end
|
109
142
|
|
@@ -131,7 +164,8 @@ module Sys
|
|
131
164
|
# either return all information for a process, or none at all.
|
132
165
|
#
|
133
166
|
def self.ps(pid=nil)
|
134
|
-
return ps_mac(pid) if OS.mac?
|
167
|
+
return ps_mac(pid ||-100) if OS.mac?
|
168
|
+
return ps_windows(pid ||-100) if OS.windows?
|
135
169
|
raise NotImplementedError unless OS.linux?
|
136
170
|
array = block_given? ? nil : []
|
137
171
|
struct = nil
|
data/sys-proctable.gemspec
CHANGED
@@ -2,7 +2,7 @@ require 'rubygems'
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |spec|
|
4
4
|
spec.name = 'rumblinthebronx-sys-proctable'
|
5
|
-
spec.version = '0.9.
|
5
|
+
spec.version = '0.9.7'
|
6
6
|
spec.author = 'Daniel J. Berger'
|
7
7
|
spec.license = 'Artistic 2.0'
|
8
8
|
spec.email = 'djberg96@gmail.com'
|
@@ -30,7 +30,7 @@ Gem::Specification.new do |spec|
|
|
30
30
|
spec.extra_rdoc_files = ['CHANGES', 'README', 'MANIFEST', 'doc/top.txt']
|
31
31
|
|
32
32
|
spec.add_development_dependency('test-unit', '>= 2.4.0')
|
33
|
-
spec.
|
33
|
+
spec.add_runtime_dependency('os', '>= 0.9.6')
|
34
34
|
|
35
35
|
spec.description = <<-EOF
|
36
36
|
The sys-proctable library provides an interface for gathering information
|
metadata
CHANGED
@@ -1,52 +1,54 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rumblinthebronx-sys-proctable
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
5
|
-
prerelease:
|
4
|
+
version: 0.9.7
|
5
|
+
prerelease:
|
6
6
|
platform: universal-java
|
7
7
|
authors:
|
8
8
|
- Daniel J. Berger
|
9
|
-
autorequire:
|
9
|
+
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2013-01-04 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: test-unit
|
16
|
-
|
17
|
-
none: false
|
16
|
+
version_requirements: !ruby/object:Gem::Requirement
|
18
17
|
requirements:
|
19
18
|
- - ! '>='
|
20
19
|
- !ruby/object:Gem::Version
|
21
20
|
version: 2.4.0
|
22
|
-
type: :development
|
23
|
-
prerelease: false
|
24
|
-
version_requirements: !ruby/object:Gem::Requirement
|
25
21
|
none: false
|
22
|
+
requirement: !ruby/object:Gem::Requirement
|
26
23
|
requirements:
|
27
24
|
- - ! '>='
|
28
25
|
- !ruby/object:Gem::Version
|
29
26
|
version: 2.4.0
|
27
|
+
none: false
|
28
|
+
prerelease: false
|
29
|
+
type: :development
|
30
30
|
- !ruby/object:Gem::Dependency
|
31
31
|
name: os
|
32
|
-
|
33
|
-
none: false
|
32
|
+
version_requirements: !ruby/object:Gem::Requirement
|
34
33
|
requirements:
|
35
34
|
- - ! '>='
|
36
35
|
- !ruby/object:Gem::Version
|
37
36
|
version: 0.9.6
|
38
|
-
type: :development
|
39
|
-
prerelease: false
|
40
|
-
version_requirements: !ruby/object:Gem::Requirement
|
41
37
|
none: false
|
38
|
+
requirement: !ruby/object:Gem::Requirement
|
42
39
|
requirements:
|
43
40
|
- - ! '>='
|
44
41
|
- !ruby/object:Gem::Version
|
45
42
|
version: 0.9.6
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
43
|
+
none: false
|
44
|
+
prerelease: false
|
45
|
+
type: :runtime
|
46
|
+
description: |2
|
47
|
+
The sys-proctable library provides an interface for gathering information
|
48
|
+
about processes on your system, i.e. the process table. Most major
|
49
|
+
platforms are supported and, while different platforms may return
|
50
|
+
different information, the external interface is identical across
|
51
|
+
platforms.
|
50
52
|
email: djberg96@gmail.com
|
51
53
|
executables: []
|
52
54
|
extensions: []
|
@@ -70,29 +72,31 @@ files:
|
|
70
72
|
homepage: http://www.rubyforge.org/projects/sysutils
|
71
73
|
licenses:
|
72
74
|
- Artistic 2.0
|
73
|
-
post_install_message:
|
75
|
+
post_install_message:
|
74
76
|
rdoc_options: []
|
75
77
|
require_paths:
|
76
78
|
- lib
|
77
79
|
- lib/linux
|
78
80
|
required_ruby_version: !ruby/object:Gem::Requirement
|
79
|
-
none: false
|
80
81
|
requirements:
|
81
82
|
- - ! '>='
|
82
83
|
- !ruby/object:Gem::Version
|
83
|
-
version:
|
84
|
-
|
84
|
+
version: !binary |-
|
85
|
+
MA==
|
85
86
|
none: false
|
87
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
86
88
|
requirements:
|
87
89
|
- - ! '>='
|
88
90
|
- !ruby/object:Gem::Version
|
89
|
-
version:
|
91
|
+
version: !binary |-
|
92
|
+
MA==
|
93
|
+
none: false
|
90
94
|
requirements: []
|
91
95
|
rubyforge_project: sysutils
|
92
96
|
rubygems_version: 1.8.24
|
93
|
-
signing_key:
|
97
|
+
signing_key:
|
94
98
|
specification_version: 3
|
95
99
|
summary: An interface for providing process table information
|
96
100
|
test_files:
|
97
101
|
- test/test_sys_proctable_all.rb
|
98
|
-
has_rdoc:
|
102
|
+
has_rdoc:
|