sys-proctable 0.9.1-universal-mingw32 → 0.9.2-universal-mingw32

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGES CHANGED
@@ -1,3 +1,11 @@
1
+ == 0.9.2 - 8-Oct-2012
2
+ * Added cmdline support for OS X. Thanks go to Matthias Zirnstein for
3
+ the patch.
4
+ * Warning cleanup for 1.9.
5
+ * Updated the gem platform handling. Replaced the borked string approach
6
+ with a two element array for Gem::Platform.new.
7
+ * MS date strings are now parse with DateTime instead of Date.
8
+
1
9
  == 0.9.1 - 3-Aug-2011
2
10
  * Added the pctcpu and pctmem members for Linux.
3
11
  * Added Errno::ESRCH to a rescue clause on Linux that fixed a bug
data/MANIFEST CHANGED
@@ -1,30 +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
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 CHANGED
@@ -20,6 +20,7 @@
20
20
  gem install sys-proctable --platform mswin32 # Windows
21
21
  gem install sys-proctable --platform sunos # Solaris
22
22
  gem install sys-proctable --platform linux # Linux
23
+ gem install sys-proctable --platform freebsd # BSD (any flavor)
23
24
 
24
25
  == Synopsis
25
26
  require 'sys/proctable'
@@ -58,15 +59,6 @@
58
59
  The cmdline member on Solaris is limited to 80 characters unless you (or
59
60
  your program) own the process. This is a Solaris design flaw/feature.
60
61
 
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
62
  === Thread Safety
71
63
  I am not currently using a thread-safe version of readdir() for versions
72
64
  of this library that use C. I am not especially concerned about it either.
@@ -94,7 +86,8 @@
94
86
  euid, gid and guid info in the Linux version, along with some general
95
87
  debugging help.
96
88
 
97
- Thanks go to David Felstead for the original OS X code.
89
+ Thanks go to David Felstead for the original OS X code. Thanks also go
90
+ to Matthias Zirnstein for adding cmdline support for OS X.
98
91
 
99
92
  Finally I'd like to thank all the folks who have submitted bug reports
100
93
  and/or patches.
@@ -112,7 +105,7 @@
112
105
  Artistic 2.0
113
106
 
114
107
  == Copyright
115
- (C) 2003-2010 Daniel J. Berger
108
+ (C) 2003-2012 Daniel J. Berger
116
109
  All Rights Reserved.
117
110
 
118
111
  == Author
data/Rakefile CHANGED
@@ -2,12 +2,13 @@ require 'rake'
2
2
  require 'rake/clean'
3
3
  require 'rake/testtask'
4
4
  require 'rbconfig'
5
- include Config
5
+ include RbConfig
6
6
 
7
7
  CLEAN.include(
8
8
  '**/*.core', # Core dump files
9
9
  '**/*.gem', # Gem files
10
10
  '**/*.rbc', # Rubinius
11
+ '.rbx', '**/*/.rbx', # Rubinius
11
12
  '**/*.o', # C object file
12
13
  '**/*.log', # Ruby extension build log
13
14
  '**/Makefile', # C Makefile
@@ -17,7 +18,7 @@ CLEAN.include(
17
18
 
18
19
  desc 'Build the sys-proctable library for C versions of sys-proctable'
19
20
  task :build => [:clean] do
20
- case Config::CONFIG['host_os']
21
+ case CONFIG['host_os']
21
22
  when /bsd/i
22
23
  dir = 'ext/bsd'
23
24
  when /darwin/i
@@ -26,11 +27,11 @@ task :build => [:clean] do
26
27
  dir = 'ext/hpux'
27
28
  end
28
29
 
29
- unless Config::CONFIG['host_os'] =~ /win32|mswin|dos|cygwin|mingw|windows|linux|sunos|solaris/i
30
+ unless CONFIG['host_os'] =~ /win32|mswin|dos|cygwin|mingw|windows|linux|sunos|solaris/i
30
31
  Dir.chdir(dir) do
31
32
  ruby 'extconf.rb'
32
33
  sh 'make'
33
- cp 'proctable.' + Config::CONFIG['DLEXT'], 'sys'
34
+ cp 'proctable.' + CONFIG['DLEXT'], 'sys'
34
35
  end
35
36
  end
36
37
  end
@@ -38,11 +39,11 @@ end
38
39
  desc 'Install the sys-proctable library'
39
40
  task :install => [:build] do
40
41
  file = nil
41
- dir = File.join(Config::CONFIG['sitelibdir'], 'sys')
42
+ dir = File.join(CONFIG['sitelibdir'], 'sys')
42
43
 
43
44
  Dir.mkdir(dir) unless File.exists?(dir)
44
45
 
45
- case Config::CONFIG['host_os']
46
+ case CONFIG['host_os']
46
47
  when /mswin|win32|msdos|cygwin|mingw|windows/i
47
48
  file = 'lib/windows/sys/proctable.rb'
48
49
  when /linux/i
@@ -62,13 +63,13 @@ end
62
63
 
63
64
  desc 'Uninstall the sys-proctable library'
64
65
  task :uninstall do
65
- case Config::CONFIG['host_os']
66
+ case CONFIG['host_os']
66
67
  when /win32|mswin|dos|cygwin|mingw|windows|linux|sunos|solaris/i
67
- dir = File.join(Config::CONFIG['sitelibdir'], 'sys')
68
+ dir = File.join(CONFIG['sitelibdir'], 'sys')
68
69
  file = File.join(dir, 'proctable.rb')
69
70
  else
70
- dir = File.join(Config::CONFIG['sitearchdir'], 'sys')
71
- file = File.join(dir, 'proctable.' + Config::CONFIG['DLEXT'])
71
+ dir = File.join(CONFIG['sitearchdir'], 'sys')
72
+ file = File.join(dir, 'proctable.' + CONFIG['DLEXT'])
72
73
  end
73
74
 
74
75
  rm(file)
@@ -89,7 +90,7 @@ Rake::TestTask.new do |t|
89
90
  task :test => :build
90
91
  t.libs << 'test' << '.'
91
92
 
92
- case Config::CONFIG['host_os']
93
+ case CONFIG['host_os']
93
94
  when /mswin|msdos|cygwin|mingw|windows/i
94
95
  t.test_files = FileList['test/test_sys_proctable_windows.rb']
95
96
  t.libs << 'lib/windows'
@@ -120,40 +121,38 @@ namespace :gem do
120
121
  # in order to get the universal platform settings I want because
121
122
  # of some bugginess in Rubygems' platform.rb.
122
123
  #
123
- case Config::CONFIG['host_os']
124
+ case CONFIG['host_os']
124
125
  when /bsd/i
125
- spec.platform = Gem::Platform.new('universal-bsd')
126
+ spec.platform = Gem::Platform.new(['universal', 'freebsd'])
127
+ spec.platform.version = nil
126
128
  spec.files << 'ext/bsd/sys/proctable.c'
127
129
  spec.extra_rdoc_files << 'ext/bsd/sys/proctable.c'
128
130
  spec.test_files << 'test/test_sys_proctable_bsd.rb'
129
131
  spec.extensions = ['ext/bsd/extconf.rb']
130
132
  when /darwin/i
131
- spec.platform = Gem::Platform.new('universal-darwin')
133
+ spec.platform = Gem::Platform.new(['universal', 'darwin'])
132
134
  spec.files << 'ext/darwin/sys/proctable.c'
133
135
  spec.extra_rdoc_files << 'ext/darwin/sys/proctable.c'
134
136
  spec.test_files << 'test/test_sys_proctable_darwin.rb'
135
137
  spec.extensions = ['ext/darwin/extconf.rb']
136
138
  when /hpux/i
137
- spec.platform = Gem::Platform.new('universal-hpux')
139
+ spec.platform = Gem::Platform.new(['universal', 'hpux'])
138
140
  spec.files << 'ext/hpux/sys/proctable.c'
139
141
  spec.extra_rdoc_files << 'ext/hpux/sys/proctable.c'
140
142
  spec.test_files << 'test/test_sys_proctable_hpux.rb'
141
143
  spec.extensions = ['ext/hpux/extconf.rb']
142
144
  when /linux/i
143
- spec.platform = Gem::Platform.new('universal-linux')
145
+ spec.platform = Gem::Platform.new(['universal', 'linux'])
144
146
  spec.require_paths = ['lib', 'lib/linux']
145
147
  spec.files += ['lib/linux/sys/proctable.rb']
146
148
  spec.test_files << 'test/test_sys_proctable_linux.rb'
147
149
  when /sunos|solaris/i
148
- spec.platform = Gem::Platform.new('universal-solaris10.0')
149
- spec.platform.version = nil
150
+ spec.platform = Gem::Platform.new(['universal', 'solaris'])
150
151
  spec.require_paths = ['lib', 'lib/sunos']
151
152
  spec.files += ['lib/sunos/sys/proctable.rb']
152
153
  spec.test_files << 'test/test_sys_proctable_sunos.rb'
153
154
  when /mswin|win32|dos|cygwin|mingw|windows/i
154
- spec.platform = Gem::Platform::CURRENT
155
- spec.platform.cpu = 'universal'
156
- spec.platform.version = nil
155
+ spec.platform = Gem::Platform.new(['universal', 'mingw32'])
157
156
  spec.require_paths = ['lib', 'lib/windows']
158
157
  spec.files += ['lib/windows/sys/proctable.rb']
159
158
  spec.test_files << 'test/test_sys_proctable_windows.rb'
@@ -1,21 +1,21 @@
1
- ########################################################################
2
- # bench_ps.rb
3
- #
4
- # Benchmark program to show overall speed and compare the block form
5
- # versus the non-block form. You should run this benchmark via the
6
- # 'rake bench' Rake task.
7
- ########################################################################
8
- require 'benchmark'
9
- require 'sys/proctable'
10
-
11
- MAX = 10
12
-
13
- Benchmark.bm do |bench|
14
- bench.report("Block form"){
15
- MAX.times{ Sys::ProcTable.ps{} }
16
- }
17
-
18
- bench.report("Non-block form"){
19
- MAX.times{ Sys::ProcTable.ps }
20
- }
21
- end
1
+ ########################################################################
2
+ # bench_ps.rb
3
+ #
4
+ # Benchmark program to show overall speed and compare the block form
5
+ # versus the non-block form. You should run this benchmark via the
6
+ # 'rake bench' Rake task.
7
+ ########################################################################
8
+ require 'benchmark'
9
+ require 'sys/proctable'
10
+
11
+ MAX = 10
12
+
13
+ Benchmark.bm do |bench|
14
+ bench.report("Block form"){
15
+ MAX.times{ Sys::ProcTable.ps{} }
16
+ }
17
+
18
+ bench.report("Non-block form"){
19
+ MAX.times{ Sys::ProcTable.ps }
20
+ }
21
+ end
data/doc/top.txt CHANGED
@@ -1,47 +1,47 @@
1
- = Description
2
- A simple 'top' interface for Ruby
3
-
4
- = Prerequisites
5
- Requires the "sys/proctable" package (which should be installed along
6
- with this package).
7
-
8
- = Synopsis
9
- require "sys/top"
10
-
11
- Sys::Top.top(5).each{ |ps|
12
- p ps
13
- }
14
-
15
- = Constants
16
- VERSION
17
- Returns the version number of this package as a String.
18
-
19
- = Class Methods
20
- Sys::Top.top(number=10, field="pctcpu")
21
- Returns an array of ProcTableStruct's. The size of the array (i.e. the
22
- number of processes) that it returns is based on +number+, and sorted by
23
- +pctcpu+. By default, the size and field values are 10 and "pctcpu",
24
- respectively.
25
-
26
- = Notes
27
- Not all fields are available on all platforms. Please check your
28
- platform specific documentation for which fields are available.
29
-
30
- = Bugs
31
- None that I'm aware of. Please log bug reports on the project page at
32
- http://www.rubyforge.org/projects/sysutils
33
-
34
- = License
35
- Artistic 2.0
36
-
37
- = Copyright
38
- (C) 2004-2009 Daniel J. Berger
39
- All Rights Reserved.
40
-
41
- = Warranty
42
- This package is provided "as is" and without any express or
43
- implied warranties, including, without limitation, the implied
44
- warranties of merchantability and fitness for a particular purpose.
45
-
46
- = Author
1
+ = Description
2
+ A simple 'top' interface for Ruby
3
+
4
+ = Prerequisites
5
+ Requires the "sys/proctable" package (which should be installed along
6
+ with this package).
7
+
8
+ = Synopsis
9
+ require "sys/top"
10
+
11
+ Sys::Top.top(5).each{ |ps|
12
+ p ps
13
+ }
14
+
15
+ = Constants
16
+ VERSION
17
+ Returns the version number of this package as a String.
18
+
19
+ = Class Methods
20
+ Sys::Top.top(number=10, field="pctcpu")
21
+ Returns an array of ProcTableStruct's. The size of the array (i.e. the
22
+ number of processes) that it returns is based on +number+, and sorted by
23
+ +pctcpu+. By default, the size and field values are 10 and "pctcpu",
24
+ respectively.
25
+
26
+ = Notes
27
+ Not all fields are available on all platforms. Please check your
28
+ platform specific documentation for which fields are available.
29
+
30
+ = Bugs
31
+ None that I'm aware of. Please log bug reports on the project page at
32
+ http://www.rubyforge.org/projects/sysutils
33
+
34
+ = License
35
+ Artistic 2.0
36
+
37
+ = Copyright
38
+ (C) 2004-2009 Daniel J. Berger
39
+ All Rights Reserved.
40
+
41
+ = Warranty
42
+ This package is provided "as is" and without any express or
43
+ implied warranties, including, without limitation, the implied
44
+ warranties of merchantability and fitness for a particular purpose.
45
+
46
+ = Author
47
47
  Daniel J. Berger
@@ -1,20 +1,20 @@
1
- #######################################################################
2
- # example_ps.rb
3
- #
4
- # Generic test program that demonstrates the use of ProcTable.ps. You
5
- # can run this via the 'rake example' task.
6
- #
7
- # Modify as you see fit
8
- #######################################################################
9
- require 'sys/proctable'
10
- include Sys
11
-
12
- puts "VERSION: " + ProcTable::VERSION
13
- sleep 2
14
-
15
- ProcTable.ps{ |s|
16
- ProcTable.fields.each{ |field|
17
- puts "#{field}: " + s.send(field).to_s
18
- }
19
- puts '=' * 30
20
- }
1
+ #######################################################################
2
+ # example_ps.rb
3
+ #
4
+ # Generic test program that demonstrates the use of ProcTable.ps. You
5
+ # can run this via the 'rake example' task.
6
+ #
7
+ # Modify as you see fit
8
+ #######################################################################
9
+ require 'sys/proctable'
10
+ include Sys
11
+
12
+ puts "VERSION: " + ProcTable::VERSION
13
+ sleep 2
14
+
15
+ ProcTable.ps{ |s|
16
+ ProcTable.fields.each{ |field|
17
+ puts "#{field}: " + s.send(field).to_s
18
+ }
19
+ puts '=' * 30
20
+ }
data/lib/sys/top.rb CHANGED
@@ -1,32 +1,29 @@
1
- require 'sys/proctable'
2
- require 'rbconfig'
3
-
4
- # The Sys module serves as a namespace only
5
- module Sys
6
-
7
- # The Top class serves as a toplevel name for the 'top' method.
8
- class Top
9
-
10
- # The version of the sys-top library
11
- VERSION = '1.0.3'
12
-
13
- # Returns an array of Struct::ProcTableStruct elements containing up
14
- # to +num+ elements, sorted by +field+. The default number of elements
15
- # is 10, while the default field is 'pctcpu'.
16
- #
17
- # Exception: the default sort field is 'pid' on Linux and Windows.
18
- #
19
- def self.top(num=10, field='pctcpu')
20
- field = field.to_s if field.is_a?(Symbol)
21
-
22
- windows = /mswin|win32|windows|dos|cygwin|mingw/i
23
-
24
- # Sort by pid on Windows by default
25
- if Config::CONFIG['host_os'].match(windows) && field == 'pctcpu'
26
- field = 'pid'
27
- end
28
-
29
- Sys::ProcTable.ps.sort_by{ |obj| obj.send(field) || '' }[0..num-1]
30
- end
31
- end
32
- end
1
+ require 'sys/proctable'
2
+
3
+ # The Sys module serves as a namespace only
4
+ module Sys
5
+
6
+ # The Top class serves as a toplevel name for the 'top' method.
7
+ class Top
8
+
9
+ # The version of the sys-top library
10
+ VERSION = '1.0.3'
11
+
12
+ # Returns an array of Struct::ProcTableStruct elements containing up
13
+ # to +num+ elements, sorted by +field+. The default number of elements
14
+ # is 10, while the default field is 'pctcpu'.
15
+ #
16
+ # Exception: the default sort field is 'pid' on Linux and Windows.
17
+ #
18
+ def self.top(num=10, field='pctcpu')
19
+ field = field.to_s if field.is_a?(Symbol)
20
+
21
+ # Sort by pid on Windows by default
22
+ if File::ALT_SEPARATOR && field == 'pctcpu'
23
+ field = 'pid'
24
+ end
25
+
26
+ Sys::ProcTable.ps.sort_by{ |obj| obj.send(field) || '' }[0..num-1]
27
+ end
28
+ end
29
+ end