tddium-sys-proctable 0.9.2-x86-linux

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGES ADDED
@@ -0,0 +1,294 @@
1
+ == 0.9.1 - ???
2
+ * Added the pctcpu and pctmem members for Linux.
3
+ * Fixed a build warning for Darwin.
4
+ * Updates to the test suite for both Darwin and Linux.
5
+
6
+ == 0.9.0 - 14-Oct-2009
7
+ * Changed the license to Artistic 2.0.
8
+ * Fixed a bug in the OS X code where a segfault would occur when an attempt
9
+ was made to gather resource usage information on zombie processes. From
10
+ now on that information is always set to nil for zombie processes. Thanks
11
+ go to Tom Lianza for the spot and Philip Kromer for investigating the
12
+ root cause of the failure.
13
+ * Removed the FreeBSD code that read out of /proc. It was a pain from a
14
+ maintenance point of view, and most FreeBSD installs do not mount /proc
15
+ by default. The FreeBSD platform now uses the same code that the other
16
+ BSD platforms use.
17
+ * Fixed a bug in the BSD code where the ProcTable::Error class had the
18
+ wrong parent class.
19
+ * Some major gemspec updates, including an updated license. The platform
20
+ handling logic is now in the Rakefile in the 'gem' task.
21
+ * Updated the README file to include an additional acknowledgement, a
22
+ license change and some minor formatting changes.
23
+ * The test-unit library was changed from a runtime to a development dependency.
24
+
25
+ == 0.8.1 - 6-Apr-2009
26
+ * The Linux and Solaris libraries now handle the possibility of a process
27
+ terminating in the middle of a read more gracefully. If that happens, they
28
+ merely skip to the next record, i.e. it's all or nothing. Thanks go to
29
+ Heejong Lee for the spot and patch.
30
+ * Fixed a bug in the Linux version where embedded nulls were not being
31
+ stripped out of the cmdline data.
32
+ * Added the comm alias back to the Solaris version. Thanks go to Jun Young Kim
33
+ for the spot.
34
+
35
+ == 0.8.0 - 26-Jan-2009
36
+ * The Linux and Solaris versions of this library are now pure Ruby. Be warned,
37
+ however, that only Solaris 8 and later are now supported. This may change
38
+ in a future release if there's demand to support 2.6 and 2.7.
39
+ * Some Struct::ProcTableStruct members have changed. As a general rule they
40
+ now more closely match the C struct member name. See individual platforms
41
+ for more details.
42
+ * Bug fix for the cmd_args struct member on Solaris.
43
+ * Bug fixes for OS X. Added a VERSION constant, fixed struct name, and changed
44
+ pct_cpu to pctcpu.
45
+ * The .new method is now explicitly illegal.
46
+ * The Struct::ProcTableStruct instances are now frozen. This is read-only data.
47
+ * Added the peak_page_file_usage and status members on MS Windows. The status
48
+ member is always nil, but was added for completeness.
49
+ * Fixed the quota_peak_paged_pool_usage member on MS Windows.
50
+ * ProcTableError is now ProcTable::Error.
51
+ * Minor test case fix for kvm/bsd based versions.
52
+ * Added the 'time' library as a require for Windows (to parse MS date/time
53
+ format strings).
54
+ * The kvm (bsd.c) implementation now works for FreeBSD 7.
55
+ * Added many more tests.
56
+ * Added some benchmarking code in the 'benchmarks' directory.
57
+ * Added a 'bench' Rake task.
58
+ * Renamed the test_ps.rb file to example_ps.rb in order to avoid any possible
59
+ confusion with actual test files.
60
+ * Added an 'example' rake task to run the example file.
61
+
62
+ == 0.7.6 - 11-Jul-2007
63
+ * Fixed the starttime for Linux. Thanks go to Yaroslav Dmitriev for the spot.
64
+ * Fixed a bug in the MS Windows version within a private method that parsed
65
+ an MS specific date format. This was caused by a backwards incompatible
66
+ change in the Time.parse method in Ruby 1.8.6. See ruby-core: 11245 ff.
67
+ * Fixed the gemspec (I hope). Please let me know if you have problems.
68
+ * Added a Rakefile. Building, testing and installing should now be handled via
69
+ Rake tasks. The install.rb file has been removed - that code is now
70
+ integrated in the Rakefile.
71
+ * Minor directory layout changes and cleanup (mostly for the extconf.rb file).
72
+ * Side note - it seems that the code for OS X *does* work, at least on 10.4.10.
73
+ I can only conclude that previous reports about it failing were related to
74
+ bugs in OS X or were really just build issues. Apologies (and thanks, again)
75
+ to David Felstead for the code. However, see the README for more information
76
+ specific to OS X, as there are shortcomings.
77
+
78
+ == 0.7.5 - 23-Nov-2006
79
+ * Fixed int/long issues for Linux. Thanks go to Matt Lightner for the spot.
80
+ * Minor documentation fixes and changes to the extconf.rb file.
81
+
82
+ == 0.7.4 - 20-Nov-2006
83
+ * Added a patch that deals with the large file compilation issue on Solaris.
84
+ You no longer need to build Ruby with --disable-largefile, or build a
85
+ 64 bit Ruby, in order for this package to work. Thanks go to Steven Jenkins
86
+ for the information that led to the patch.
87
+ * Added inline rdoc to the source code.
88
+ * Added a gemspec.
89
+ * Fixed some potential 64 bit issues (struct declarations).
90
+ * Added preliminary support for Darwin (OS X). The code was provided by
91
+ David Felstead, but does not appear to compile successfully. Help wanted.
92
+
93
+ == 0.7.3 - 27-Oct-2005
94
+ * Fix for 1.8.3 and later (rb_pid_t). This should have only affected
95
+ Solaris.
96
+
97
+ == 0.7.2 - 15-May-2005
98
+ * Bug fix for the FreeBSD version that reads from /proc.
99
+ * Eliminated the test bug on Linux (inexplicably caused by File.copy). The
100
+ test suite should now run without segfaulting.
101
+ * Include bsd.c in tarball (oops).
102
+ * Minor test updates for FreeBSD.
103
+ * The 'pct_cpu' member for the BSD/kvm version has been changed to 'pctcpu'
104
+ for consistency with other platforms.
105
+
106
+ == 0.7.1 - 8-May-2005
107
+ * Bug fixed for the cmdline info on Linux. Thanks go to Arash Abedinzadeh
108
+ for the spot.
109
+ * Added an example program.
110
+ * Minor setup fix for Win32 in tc_all.rb.
111
+
112
+ == 0.7.0 - 25-Apr-2005
113
+ * Scrapped the C implementation for Windows in favor of an OLE + WMI pure Ruby
114
+ approach. See documentation for details.
115
+ * Added an optional lkvm implementation for BSD users. This is automatically
116
+ used if the /proc filesystem isn't found.
117
+ * Added prusage info for the Solaris version.
118
+ * Added name, eid, euid, gid and guid information for Linux. Thanks go to
119
+ James Hranicky for the patch.
120
+ * Fixed some potential bugs in the Linux version. Thanks go to James
121
+ Hranicky for the spot.
122
+ * Added the 'sys/top' package.
123
+ * ProcTable.fields no longer supports a block form.
124
+ * The BTIME (boot time) information has been removed from the Linux version.
125
+ If you want that information, use sys-uptime instead.
126
+ * The .html and .rd files have been removed. You can generate html on your
127
+ own with rdoc if you like.
128
+ * Some code cleanup on the C side of the house.
129
+ * Most documents made rdoc friendly.
130
+ * Renamed 'install_pure_ruby.rb' to just 'install.rb'.
131
+ * Removed the 'INSTALL' file. Installation instructions are in the README.
132
+ * Some test suite cleanup and reorganization.
133
+ * Moved project to RubyForge.
134
+
135
+ == 0.6.4 - 31-Mar-2004
136
+ * Fixed a bug in the pure Ruby version for Win32. Thanks go to Mark Hudson
137
+ for the spot.
138
+ * Fixed a bug in the C implementation for Win32 where the cmdline and path
139
+ values were sometimes wrong for running processes. Thanks go to Park Heesob
140
+ for the fix.
141
+ * Updated the VERSION constant and removed the VERSION class method in the
142
+ pure Ruby version for Win32.
143
+ * Updated install_pure_ruby.rb and test.rb scripts.
144
+ * Updated warranty information.
145
+ * The extconf.rb script has been revamped. See the INSTALL and README files
146
+ for important changes since the last release.
147
+ * The start ProcInfo struct member on Solaris, HP-UX and FreeBSD is now a
148
+ Time object, not a Fixnum/Bignum.
149
+ * Modified linux.c yet again to make gcc happy when it comes to multi-line
150
+ string literals.
151
+ * Minor change to way process state is handled on HP-UX.
152
+ * Documentation additions and updates, including warranty information.
153
+
154
+ == 0.6.3 - 24-Feb-2004
155
+ * Fixed a bug in the Solaris version where the cmd_args array did not
156
+ necessarily contain data on 2.7 and later. The current patch still
157
+ does not quite fix the problem for 2.6 and earlier but can be easily
158
+ derived manually by parsing the cmdline string.
159
+
160
+ == 0.6.2 - 20-Jan-2004
161
+ * Fixed a small memory leak in the solaris version.
162
+
163
+ == 0.6.1 - 31-Dec-2003
164
+ * Fixed a minor bug in the cmdline field on Linux where a blank character
165
+ was being appended to the end of the field.
166
+ * Fixed a minor annoyance where the windows.rb file was being copied into
167
+ the Ruby lib directory on install.
168
+ * Added a test_memleak.rb file. Currently only supported on Linux and
169
+ only does a file descriptor count check. I plan to expand this to
170
+ other platforms in the future.
171
+ * Minor test suite changes
172
+ * MANIFEST correction and update.
173
+
174
+ == 0.6.0 - 22-Oct-2003
175
+ * Significant API change (and thus, a version jump) - only a
176
+ single argument is now accepted to the ps() method, and only a PID
177
+ (Fixnum) is regarded as a valid argument.
178
+ * Calling ps() with a pid returns a single ProcTable struct (or nil
179
+ if the pid is not found), instead of a one element array.
180
+ * Argument to ps() now works properly on HP-UX and Win32.
181
+ * Removed the '#include <sys/types32.h>' in sunos.h. It wasn't needed
182
+ and you're not supposed to include it directly.
183
+ * Fixed 2.6 compatibility issue with regards to cmdline on Solaris.
184
+ * Removed the ProcStatException completely on Linux. There was no reason
185
+ to fail on a directory read for /proc/xxx/stat. If the read fails
186
+ (meaning the process died in the middle of collecting info for it), it
187
+ is simply ignored.
188
+ * The ttynum bug on HPUX has been fixed. In addition, the return value for
189
+ this field is now a string rather than an int and the field name has
190
+ been changed to "ttydev".
191
+ * The ttynum field has been changed to ttydev on Solaris and HPUX. On
192
+ Solaris, the ttydev is now reported as -1 if there is no associated tty.
193
+ In a future release, Solaris and the other *nix platforms will be changed
194
+ so that ttydev is always a device name (i.e String).
195
+ * Added plain text documentation for all platforms.
196
+ * Some test suite cleanup.
197
+ * Changed .rd2 extension to just '.rd'.
198
+
199
+ == 0.5.2 - 18-Jul-2003
200
+ * Modified cmdline to extend past the traditional 80 character limit on
201
+ Solaris, where possible (Solaris 2.6+ only).
202
+ * Added the cmdline_args and num_args fields on Solaris, which returns
203
+ an array of cmdline arguments and the number of cmdline arguments,
204
+ respectively.
205
+ * Minor modification to fields() method, in addition to warning cleanup
206
+ for Solaris.
207
+ * Changed "defunct" state string to "zombie" for Solaris.
208
+ * Should cleanly compile with -Wall -W now (gcc) on Solaris.
209
+ * Added solaris.txt to doc directory.
210
+ * MANIFEST corrections.
211
+
212
+ == 0.5.1 - 16-Jul-2003
213
+ * Fixed a nasty file descriptor bug in the Linux code, where file descriptors
214
+ were continuously being used up.
215
+ * Added the BTIME (boot time) constant for Linux.
216
+ * Fixed up the test/test.rb file a bit.
217
+ * Added BTIME tests to tc_linux.rb.
218
+
219
+ == 0.5.0 - 11-Jul-200
220
+ * Added HP-UX support!
221
+ * Note that passing PID's or strings as arguments to ps() is not supported
222
+ in the HP-UX version. This functionality will be stripped out of the
223
+ other versions in a future release. See the README file for more details.
224
+ * Removed the VERSION() class method. Use the constant instead.
225
+ * Separated the rd docs from their respective source files. Now in the doc
226
+ directory.
227
+ * Got rid of the interactive html generation in extconf.rb.
228
+ * Changed License to Artistic.
229
+
230
+ == 0.4.3 - 30-May-2003
231
+ * Added a version.h file to store the version number. Modified all of the
232
+ C source files to use that instead of hard coding the version everywhere.
233
+ * Added a generic test.rb script for those without TestUnit installed, or
234
+ just futzing in general. Modified the extconf.rb script to copy this
235
+ instead of writing an inline HERE document.
236
+ * Modified extconf.rb so that it builds with mingw or cygwin. Thanks go to
237
+ Peter Fischer for the spot and patch.
238
+ * Modified test suite to work with TestUnit 0.1.6 or 0.1.8.
239
+
240
+ == 0.4.2 - 14-Apr-2003
241
+ * Added pure Ruby version for Win32 - thanks Park Heesob.
242
+ * Modified extconf.rb file to handle pure Ruby versions.
243
+ * Added install_pure_ruby.rb file, an alternate installation
244
+ script for pure Ruby versions.
245
+
246
+ == 0.4.1 - 31-Mar-2003
247
+ * Added support for Solaris 2.5.x.
248
+ * All exceptions are now a direct subclass of StandardError.
249
+ * Value returned for wchan now more meaningful (2.5.x only for now).
250
+ * Fixed the start, utime and ctime for FreeBSD.
251
+ * Minor fix to FreeBSD test suite.
252
+ * Some changes to extconf.rb.
253
+ * Minor doc changes.
254
+ * Added License and Copyright info.
255
+
256
+ == 0.4.0 - 10-Mar-2003
257
+ * Added MS Windows support (non-cygwin).
258
+ * Added environment information for Linux version.
259
+ * Added real exceptions (type depends on platform).
260
+ * Added a test suite (for those with testunit installed).
261
+ * Removed the sys-uname requirement.
262
+ * Heavily modified the extconf.rb script.
263
+ * Changed "Changelog" to "CHANGES" and "Manifest" to "MANIFEST".
264
+ * Added a VERSION constant and class method.
265
+ * Minor internal directory layout change (put 'os' under 'lib').
266
+ * Changed package name to lower case.
267
+ * Doc changes, including license information.
268
+
269
+ == 0.3.1 - 16-Aug-2002
270
+ * Added a "comm" field to the sunos version. I am going to try to make this a
271
+ common field for all platforms to help reduce RUBY_PLATFORM checking.
272
+ * Fixed the release date for 0.3.0 (was accidentally marked *July*).
273
+ * Added an INSTALL file.
274
+ * Minor documentation change to the sunos.c source file.
275
+
276
+ == 0.3.0 - 11-Aug-2002
277
+ * Added FreeBSD support!
278
+ * Struct name changed to just "ProcTableStruct" to be compliant with future
279
+ versions of Ruby.
280
+ * The ps() function now returns an array of ProcTableStruct's in lvalue context.
281
+ * Fixed the ability to search by process name in Linux.
282
+ * Modified Linux "comm" field to strip parenthesis.
283
+ * Some doc changes/additions.
284
+ * Added Sean Chittenden to the "Acknowledgements" section. Sean provided me
285
+ with access to a FreeBSD box, which is how I was able to provide FreeBSD
286
+ support. Thanks Sean!
287
+
288
+ == 0.2.0 - 19-Jul-2002
289
+ * Added the ability to search by process name.
290
+ * test.rb modified to be cross-platform.
291
+ * Solaris - fixed bug with fname (was accidentally called "name").
292
+
293
+ == 0.1.0 - 2-Jul-2002
294
+ - Initial release.
data/MANIFEST ADDED
@@ -0,0 +1,30 @@
1
+ * CHANGES
2
+ * MANIFEST
3
+ * Rakefile
4
+ * README
5
+ * sys-proctable.gemspec
6
+ * doc/bsd.txt
7
+ * doc/hpux.txt
8
+ * doc/linux.txt
9
+ * doc/solaris.txt
10
+ * doc/top.txt
11
+ * doc/windows.txt
12
+ * example/example_ps.rb
13
+ * ext/bsd/extconf.rb
14
+ * ext/bsd/sys/proctable.c
15
+ * ext/darwin/extconf.rb
16
+ * ext/darwin/sys/proctable.c
17
+ * ext/hpux/extconf.rb
18
+ * ext/hpux/sys/proctable.c
19
+ * lib/sys/top.rb
20
+ * lib/linux/sys/proctable.rb
21
+ * lib/sunos/sys/proctable.rb
22
+ * lib/windows/sys/proctable.rb
23
+ * test/test_sys_proctable_all.rb
24
+ * test/test_sys_proctable_darwin.rb
25
+ * test/test_sys_proctable_hpux.rb
26
+ * test/test_sys_proctable_bsd.rb
27
+ * test/test_sys_proctable_linux.rb
28
+ * test/test_sys_proctable_sunos.rb
29
+ * test/test_sys_proctable_windows.rb
30
+ * test/test_sys_top.rb
data/README ADDED
@@ -0,0 +1,119 @@
1
+ == Description
2
+ A Ruby interface for gathering process information.
3
+
4
+ == Prerequisites
5
+ * Test::Unit 2.x (development only)
6
+
7
+ == Supported Platforms
8
+ * Windows 2000 or later
9
+ * Linux 2.6+
10
+ * BSD (various flavors)
11
+ * Solaris 8+
12
+ * HP-UX 10+
13
+ * OS X 10.4+
14
+
15
+ == Installation
16
+ gem install sys-proctable
17
+
18
+ You may need to specify a platform in some cases. For example:
19
+
20
+ gem install sys-proctable --platform mswin32 # Windows
21
+ gem install sys-proctable --platform sunos # Solaris
22
+ gem install sys-proctable --platform linux # Linux
23
+
24
+ == Synopsis
25
+ require 'sys/proctable'
26
+ include Sys
27
+
28
+ # Everything
29
+ ProcTable.ps{ |p|
30
+ puts p.pid.to_s
31
+ puts p.comm
32
+ # ...
33
+ }
34
+
35
+ # Just one process
36
+ s = ProcTable.ps(2123)
37
+ puts s.pid.to_s
38
+ puts s.comm
39
+ # ...
40
+
41
+ # Return the results as an array of ProcTableStructs
42
+ a = ProcTable.ps
43
+ a.each do |p|
44
+ puts a.pid
45
+ # ...
46
+ end
47
+
48
+ == Notes
49
+ Windows users may pass a host name as a second argument to get process
50
+ information from a different host. This relies on the WMI service running.
51
+
52
+ == Known Issues
53
+ === BSD
54
+ A kvm interface is used. That means the owner of the process using the
55
+ sys-proctable library needs to be a member of the kvm group (or root).
56
+
57
+ === Solaris
58
+ The cmdline member on Solaris is limited to 80 characters unless you (or
59
+ your program) own the process. This is a Solaris design flaw/feature.
60
+
61
+ === OS X
62
+ At the moment you do not get the full command line string. The code required
63
+ to get this information is obnoxious and I don't have any compelling desire
64
+ to add it. However, if you're willing to submit a patch I'll accept it.
65
+
66
+ You can find a good starting point with the OS X code found in Dan Urist's
67
+ Proc::ProcessTable module. You can find that module on CPAN. Point your
68
+ browser at http://search.cpan.org.
69
+
70
+ === Thread Safety
71
+ I am not currently using a thread-safe version of readdir() for versions
72
+ of this library that use C. I am not especially concerned about it either.
73
+ If you are trying to read information out of /proc from different threads
74
+ at the same time there is something seriously wrong with your code logic.
75
+ Using readdir_r() still won't solve all potential thread safety issues anyway.
76
+
77
+ == Future Plans
78
+ Research has indicated that the kvm approach is less favored than a sysctl
79
+ approach on BSD variants. I will try to add this interface in a future
80
+ release.
81
+
82
+ == Acknowledgements
83
+ This library is largely based on the Perl module Proc::ProcessTable by
84
+ Dan Urist. Many ideas, as well as large chunks of code, were taken
85
+ from his work. So, a big THANK YOU goes out to Dan Urist.
86
+
87
+ A big thanks also goes out to Mike Hall who was very helpful with ideas,
88
+ logic and testing.
89
+
90
+ Thanks also go to Sean Chittenden for providing an account on one of his
91
+ FreeBSD machines. This is how the FreeBSD support was (initially) added.
92
+
93
+ Thanks go to James Hranicky for providing a patch that grabs name, eid,
94
+ euid, gid and guid info in the Linux version, along with some general
95
+ debugging help.
96
+
97
+ Thanks go to David Felstead for the original OS X code.
98
+
99
+ Finally I'd like to thank all the folks who have submitted bug reports
100
+ and/or patches.
101
+
102
+ == Help Wanted
103
+ I do not have access to all platforms. If your platform is not supported
104
+ then you will need to either submit a patch or give me a remote account
105
+ on a box with a compiler so that I can write the code.
106
+
107
+ == More documentation
108
+ See the documentation under the 'doc' directory for more information,
109
+ including platform specific notes and issues.
110
+
111
+ == License
112
+ Artistic 2.0
113
+
114
+ == Copyright
115
+ (C) 2003-2010 Daniel J. Berger
116
+ All Rights Reserved.
117
+
118
+ == Author
119
+ Daniel J. Berger
data/Rakefile ADDED
@@ -0,0 +1,158 @@
1
+ require 'rake'
2
+ require 'rake/clean'
3
+ require 'rake/testtask'
4
+ require 'rbconfig'
5
+ include Config
6
+
7
+ CLEAN.include(
8
+ '**/*.gem', # Gem files
9
+ '**/*.rbc', # Rubinius
10
+ '**/*.o', # C object file
11
+ '**/*.log', # Ruby extension build log
12
+ '**/Makefile', # C Makefile
13
+ '**/conftest.dSYM', # OS X build directory
14
+ "**/*.#{CONFIG['DLEXT']}" # C shared object
15
+ )
16
+
17
+ desc 'Build the sys-proctable library for C versions of sys-proctable'
18
+ task :build => [:clean] do
19
+ case Config::CONFIG['host_os']
20
+ when /bsd/i
21
+ dir = 'ext/bsd'
22
+ when /darwin/i
23
+ dir = 'ext/darwin'
24
+ when /hpux/i
25
+ dir = 'ext/hpux'
26
+ end
27
+
28
+ unless Config::CONFIG['host_os'] =~ /win32|mswin|dos|cygwin|mingw|windows|linux|sunos|solaris/i
29
+ Dir.chdir(dir) do
30
+ ruby 'extconf.rb'
31
+ sh 'make'
32
+ cp 'proctable.' + Config::CONFIG['DLEXT'], 'sys'
33
+ end
34
+ end
35
+ end
36
+
37
+ desc 'Install the sys-proctable library'
38
+ task :install => [:build] do
39
+ file = nil
40
+ dir = File.join(Config::CONFIG['sitelibdir'], 'sys')
41
+
42
+ Dir.mkdir(dir) unless File.exists?(dir)
43
+
44
+ case Config::CONFIG['host_os']
45
+ when /mswin|win32|msdos|cygwin|mingw|windows/i
46
+ file = 'lib/windows/sys/proctable.rb'
47
+ when /linux/i
48
+ file = 'lib/linux/sys/proctable.rb'
49
+ when /sunos|solaris/i
50
+ file = 'lib/sunos/sys/proctable.rb'
51
+ when /bsd/i
52
+ Dir.chdir('ext/bsd'){ sh 'make install' }
53
+ when /darwin/i
54
+ Dir.chdir('ext/darwin'){ sh 'make install' }
55
+ when /hpux/i
56
+ Dir.chdir('ext/hpux'){ sh 'make install' }
57
+ end
58
+
59
+ cp(file, dir, :verbose => true) if file
60
+ end
61
+
62
+ desc 'Uninstall the sys-proctable library'
63
+ task :uninstall do
64
+ case Config::CONFIG['host_os']
65
+ when /win32|mswin|dos|cygwin|mingw|windows|linux|sunos|solaris/i
66
+ dir = File.join(Config::CONFIG['sitelibdir'], 'sys')
67
+ file = File.join(dir, 'proctable.rb')
68
+ else
69
+ dir = File.join(Config::CONFIG['sitearchdir'], 'sys')
70
+ file = File.join(dir, 'proctable.' + Config::CONFIG['DLEXT'])
71
+ end
72
+
73
+ rm(file)
74
+ end
75
+
76
+ desc 'Run the benchmark suite'
77
+ task :bench => [:build] do
78
+ sh "ruby -Ilib benchmarks/bench_ps.rb"
79
+ end
80
+
81
+ desc 'Run the example program'
82
+ task :example => [:build] do
83
+ sh 'ruby -Ilib -Iext examples/example_ps.rb'
84
+ end
85
+
86
+ desc 'Run the test suite'
87
+ Rake::TestTask.new do |t|
88
+ task :test => :build
89
+ t.libs << 'test' << '.'
90
+
91
+ case Config::CONFIG['host_os']
92
+ when /mswin|msdos|cygwin|mingw|windows/i
93
+ t.test_files = FileList['test/test_sys_proctable_windows.rb']
94
+ t.libs << 'lib/windows'
95
+ when /linux/i
96
+ t.test_files = FileList['test/test_sys_proctable_linux.rb']
97
+ t.libs << 'lib/linux'
98
+ when /sunos|solaris/i
99
+ t.test_files = FileList['test/test_sys_proctable_sunos.rb']
100
+ t.libs << 'lib/sunos'
101
+ when /darwin/i
102
+ t.libs << 'ext/darwin'
103
+ t.test_files = FileList['test/test_sys_proctable_darwin.rb']
104
+ when /bsd/i
105
+ t.libs << 'ext/bsd'
106
+ t.test_files = FileList['test/test_sys_proctable_bsd.rb']
107
+ when /hpux/i
108
+ t.libs << 'ext/hpux'
109
+ t.test_files = FileList['test/test_sys_proctable_hpux.rb']
110
+ end
111
+ end
112
+
113
+ namespace :gem do
114
+ desc 'Create a gem'
115
+ task :create => [:clean] do
116
+ spec = eval(IO.read('sys-proctable.gemspec'))
117
+
118
+ case Config::CONFIG['host_os']
119
+ when /bsd/i
120
+ spec.files << 'ext/bsd/sys/proctable.c'
121
+ spec.extra_rdoc_files << 'ext/bsd/sys/proctable.c'
122
+ spec.test_files << 'test/test_sys_proctable_bsd.rb'
123
+ spec.extensions = ['ext/bsd/extconf.rb']
124
+ when /darwin/i
125
+ spec.files << 'ext/darwin/sys/proctable.c'
126
+ spec.extra_rdoc_files << 'ext/darwin/sys/proctable.c'
127
+ spec.test_files << 'test/test_sys_proctable_darwin.rb'
128
+ spec.extensions = ['ext/darwin/extconf.rb']
129
+ when /hpux/i
130
+ spec.files << 'ext/hpux/sys/proctable.c'
131
+ spec.extra_rdoc_files << 'ext/hpux/sys/proctable.c'
132
+ spec.test_files << 'test/test_sys_proctable_hpux.rb'
133
+ spec.extensions = ['ext/hpux/extconf.rb']
134
+ when /linux/i
135
+ spec.require_paths = ['lib', 'lib/linux']
136
+ spec.files += ['lib/linux/sys/proctable.rb']
137
+ spec.test_files << 'test/test_sys_proctable_linux.rb'
138
+ when /sunos|solaris/i
139
+ spec.require_paths = ['lib', 'lib/sunos']
140
+ spec.files += ['lib/sunos/sys/proctable.rb']
141
+ spec.test_files << 'test/test_sys_proctable_sunos.rb'
142
+ when /mswin|win32|dos|cygwin|mingw|windows/i
143
+ spec.require_paths = ['lib', 'lib/windows']
144
+ spec.files += ['lib/windows/sys/proctable.rb']
145
+ spec.test_files << 'test/test_sys_proctable_windows.rb'
146
+ end
147
+
148
+ Gem::Builder.new(spec).build
149
+ end
150
+
151
+ desc 'Install the sys-proctable library as a gem'
152
+ task :install => [:create] do
153
+ gem_name = Dir['*.gem'].first
154
+ sh "gem install #{gem_name}"
155
+ end
156
+ end
157
+
158
+ task :default => :test