sys-proctable 1.0.0-universal-mingw32 → 1.1.0-universal-mingw32

Sign up to get free protection for your applications and to get access to all the features.
data/MANIFEST CHANGED
@@ -1,34 +1,33 @@
1
- * CHANGES
2
- * MANIFEST
3
- * Rakefile
4
- * README
5
- * sys-proctable.gemspec
6
- * doc/aix.txt
7
- * doc/bsd.txt
8
- * doc/hpux.txt
9
- * doc/linux.txt
10
- * doc/solaris.txt
11
- * doc/top.txt
12
- * doc/windows.txt
13
- * example/example_ps.rb
14
- * ext/darwin/extconf.rb
15
- * ext/darwin/sys/proctable.c
16
- * ext/hpux/extconf.rb
17
- * ext/hpux/sys/proctable.c
18
- * lib/sys-proctable.rb
19
- * lib/sys/top.rb
20
- * lib/sys/proctable/version.rb
21
- * lib/aix/sys/proctable.rb
22
- * lib/freebsd/sys/proctable.rb
23
- * lib/linux/sys/proctable.rb
24
- * lib/sunos/sys/proctable.rb
25
- * lib/windows/sys/proctable.rb
26
- * test/test_sys_proctable_aix.rb
27
- * test/test_sys_proctable_all.rb
28
- * test/test_sys_proctable_darwin.rb
29
- * test/test_sys_proctable_freebsd.rb
30
- * test/test_sys_proctable_hpux.rb
31
- * test/test_sys_proctable_linux.rb
32
- * test/test_sys_proctable_sunos.rb
33
- * test/test_sys_proctable_windows.rb
34
- * test/test_sys_top.rb
1
+ * CHANGES
2
+ * MANIFEST
3
+ * Rakefile
4
+ * README
5
+ * sys-proctable.gemspec
6
+ * doc/aix.txt
7
+ * doc/bsd.txt
8
+ * doc/hpux.txt
9
+ * doc/linux.txt
10
+ * doc/solaris.txt
11
+ * doc/top.txt
12
+ * doc/windows.txt
13
+ * example/example_ps.rb
14
+ * ext/hpux/extconf.rb
15
+ * ext/hpux/sys/proctable.c
16
+ * lib/sys-proctable.rb
17
+ * lib/sys/top.rb
18
+ * lib/sys/proctable/version.rb
19
+ * lib/aix/sys/proctable.rb
20
+ * lib/darwin/sys/proctable.rb
21
+ * lib/freebsd/sys/proctable.rb
22
+ * lib/linux/sys/proctable.rb
23
+ * lib/sunos/sys/proctable.rb
24
+ * lib/windows/sys/proctable.rb
25
+ * test/test_sys_proctable_aix.rb
26
+ * test/test_sys_proctable_all.rb
27
+ * test/test_sys_proctable_darwin.rb
28
+ * test/test_sys_proctable_freebsd.rb
29
+ * test/test_sys_proctable_hpux.rb
30
+ * test/test_sys_proctable_linux.rb
31
+ * test/test_sys_proctable_sunos.rb
32
+ * test/test_sys_proctable_windows.rb
33
+ * test/test_sys_top.rb
data/README CHANGED
@@ -1,118 +1,110 @@
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
- * FreeBSD
11
- * Solaris 8+
12
- * HP-UX 10+
13
- * OS X 10.4+
14
- * AIX 5.3+
15
-
16
- == Installation
17
- gem install sys-proctable
18
-
19
- You may need to specify a platform in some cases. For example:
20
-
21
- gem install sys-proctable --platform mswin32 # Windows
22
- gem install sys-proctable --platform sunos # Solaris
23
- gem install sys-proctable --platform linux # Linux
24
- gem install sys-proctable --platform freebsd # FreeBSD
25
-
26
- == Synopsis
27
- require 'sys/proctable'
28
- include Sys
29
-
30
- # Everything
31
- ProcTable.ps{ |p|
32
- puts p.pid.to_s
33
- puts p.comm
34
- # ...
35
- }
36
-
37
- # Just one process
38
- s = ProcTable.ps(2123)
39
- puts s.pid.to_s
40
- puts s.comm
41
- # ...
42
-
43
- # Return the results as an array of ProcTableStructs
44
- a = ProcTable.ps
45
- a.each do |p|
46
- puts p.pid
47
- # ...
48
- end
49
-
50
- == Notes
51
- Windows users may pass a host name as a second argument to get process
52
- information from a different host. This relies on the WMI service running.
53
-
54
- == Known Issues
55
- === FreeBSD
56
- A kvm interface is used. That means the owner of the process using the
57
- sys-proctable library needs to be a member of the kvm group (or root).
58
-
59
- === Solaris
60
- The cmdline member on Solaris is limited to 80 characters unless you (or
61
- your program) own the process. This is a Solaris design flaw/feature.
62
-
63
- === Thread Safety
64
- I am not currently using a thread-safe version of readdir() for versions
65
- of this library that use C. I am not especially concerned about it either.
66
- If you are trying to read information out of /proc from different threads
67
- at the same time there is something seriously wrong with your code logic.
68
- Using readdir_r() still won't solve all potential thread safety issues anyway.
69
-
70
- == Future Plans
71
- Add support for NetBSD and OpenBSD.
72
- Convert existing C code to FFI.
73
-
74
- == Acknowledgements
75
- This library was originally based on the Perl module Proc::ProcessTable
76
- by Dan Urist. Many ideas, as well as large chunks of code, were taken
77
- from his work. So, a big THANK YOU goes out to Dan Urist.
78
-
79
- A big thanks also goes out to Mike Hall who was very helpful with ideas,
80
- logic and testing.
81
-
82
- Thanks also go to Sean Chittenden for providing an account on one of his
83
- FreeBSD machines. This is how the FreeBSD support was (initially) added.
84
-
85
- Thanks go to James Hranicky for providing a patch that grabs name, eid,
86
- euid, gid and guid info in the Linux version, along with some general
87
- debugging help.
88
-
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.
91
-
92
- Finally I'd like to thank all the folks who have submitted bug reports
93
- and/or patches.
94
-
95
- == Help Wanted
96
- I do not have access to all platforms. If your platform is not supported
97
- then you will need to either submit a patch or give me a remote account
98
- on a box with a compiler so that I can write the code.
99
-
100
- == More documentation
101
- See the documentation under the 'doc' directory for more information,
102
- including platform specific notes and issues.
103
-
104
- == License
105
- Artistic 2.0
106
-
107
- == Copyright
108
- (C) 2003-2016 Daniel J. Berger
109
- All Rights Reserved.
110
-
111
- == Contributions
112
- Although this library is free, please consider having your company
113
- setup a gittip if used by your company professionally.
114
-
115
- http://www.gittip.com/djberg96/
116
-
117
- == Author
118
- Daniel J. Berger
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
+ * FreeBSD
11
+ * Solaris 8+
12
+ * HP-UX 10+
13
+ * OS X 10.7+
14
+ * AIX 5.3+
15
+
16
+ == Installation
17
+ gem install sys-proctable
18
+
19
+ You may need to specify a platform in some cases. For example:
20
+
21
+ gem install sys-proctable --platform mswin32 # Windows
22
+ gem install sys-proctable --platform sunos # Solaris
23
+ gem install sys-proctable --platform linux # Linux
24
+ gem install sys-proctable --platform freebsd # FreeBSD
25
+ gem install sys-proctable --platform darwin # OS X
26
+
27
+ == Synopsis
28
+ require 'sys/proctable'
29
+ include Sys
30
+
31
+ # Everything
32
+ ProcTable.ps{ |p|
33
+ puts p.pid.to_s
34
+ puts p.comm
35
+ # ...
36
+ }
37
+
38
+ # Just one process
39
+ s = ProcTable.ps(2123)
40
+ puts s.pid.to_s
41
+ puts s.comm
42
+ # ...
43
+
44
+ # Return the results as an array of ProcTableStructs
45
+ a = ProcTable.ps
46
+ a.each do |p|
47
+ puts p.pid
48
+ # ...
49
+ end
50
+
51
+ == Notes
52
+ Windows users may pass a host name as a second argument to get process
53
+ information from a different host. This relies on the WMI service running.
54
+
55
+ == Known Issues
56
+ === FreeBSD
57
+ A kvm interface is used. That means the owner of the process using the
58
+ sys-proctable library needs to be a member of the kvm group (or root).
59
+
60
+ === Solaris
61
+ The cmdline member on Solaris is limited to 80 characters unless you (or
62
+ your program) own the process. This is a Solaris design flaw/feature.
63
+
64
+ === OS X
65
+ The libproc interface is used. That means you will only get list of
66
+ processes that you have access to. To get a full listing, run as root.
67
+
68
+ == Future Plans
69
+ Add support for NetBSD and OpenBSD.
70
+ Convert remaining C code (just HP-UX at this point) to FFI.
71
+
72
+ == Acknowledgements
73
+ This library was originally based on the Perl module Proc::ProcessTable
74
+ by Dan Urist. Many ideas, as well as large chunks of code, were taken
75
+ from his work. So, a big THANK YOU goes out to Dan Urist.
76
+
77
+ A big thanks also goes out to Mike Hall who was very helpful with ideas,
78
+ logic and testing.
79
+
80
+ Thanks also go to Sean Chittenden for providing an account on one of his
81
+ FreeBSD machines. This is how the FreeBSD support was (initially) added.
82
+
83
+ Thanks go to James Hranicky for providing a patch that grabs name, eid,
84
+ euid, gid and guid info in the Linux version, along with some general
85
+ debugging help.
86
+
87
+ Thanks go to David Felstead for the original OS X code. Thanks also go
88
+ to Matthias Zirnstein for adding the original cmdline support for OS X.
89
+
90
+ Finally I'd like to thank all the folks who have submitted bug reports
91
+ and/or patches.
92
+
93
+ == Help Wanted
94
+ I do not have access to all platforms. If your platform is not supported
95
+ then you will need to either submit a patch or give me a remote account
96
+ on a box with a compiler so that I can write the code.
97
+
98
+ == More documentation
99
+ See the documentation under the 'doc' directory for more information,
100
+ including platform specific notes and issues.
101
+
102
+ == License
103
+ Apache 2.0
104
+
105
+ == Copyright
106
+ (C) 2003-2016 Daniel J. Berger
107
+ All Rights Reserved.
108
+
109
+ == Author
110
+ Daniel J. Berger
data/Rakefile CHANGED
@@ -1,218 +1,215 @@
1
- require 'rake'
2
- require 'rake/clean'
3
- require 'rake/testtask'
4
- require 'rbconfig'
5
- include RbConfig
6
-
7
- CLEAN.include(
8
- '**/*.core', # Core dump files
9
- '**/*.gem', # Gem files
10
- '**/*.rbc', # Rubinius
11
- '**/*.rbx', # Rubinius
12
- '**/*.o', # C object file
13
- '**/*.log', # Ruby extension build log
14
- '**/Makefile', # C Makefile
15
- '**/conftest.dSYM', # OS X build directory
16
- "**/*.#{CONFIG['DLEXT']}" # C shared object
17
- )
18
-
19
- desc 'Build the sys-proctable library for C versions of sys-proctable'
20
- task :build => [:clean] do
21
- if RUBY_PLATFORM == 'java'
22
- if ENV['JRUBY_OPTS']
23
- ENV['JRUBY_OPTS'] += ' -Xcext.enabled=true'
24
- else
25
- ENV['JRUBY_OPTS'] = '-Xcext.enabled=true'
26
- end
27
- end
28
-
29
- case CONFIG['host_os']
30
- when /darwin/i
31
- dir = 'ext/darwin'
32
- ext = '.bundle'
33
- when /hpux/i
34
- dir = 'ext/hpux'
35
- ext = '.sl'
36
- end
37
-
38
- if CONFIG['host_os'] =~ /darwin|hpux/i
39
- Dir.chdir(dir) do
40
- ruby 'extconf.rb'
41
- sh 'make'
42
- cp 'proctable' + ext, 'sys'
43
- end
44
- end
45
- end
46
-
47
- desc 'Install the sys-proctable library'
48
- task :install => [:build] do
49
- file = nil
50
- dir = File.join(CONFIG['sitelibdir'], 'sys')
51
-
52
- Dir.mkdir(dir) unless File.exists?(dir)
53
-
54
- case CONFIG['host_os']
55
- when /mswin|win32|msdos|cygwin|mingw|windows/i
56
- file = 'lib/windows/sys/proctable.rb'
57
- when /linux/i
58
- file = 'lib/linux/sys/proctable.rb'
59
- when /sunos|solaris/i
60
- file = 'lib/sunos/sys/proctable.rb'
61
- when /aix/i
62
- file = 'lib/aix/sys/proctable.rb'
63
- when /freebsd/i
64
- file = 'lib/freebsd/sys/proctable.rb'
65
- when /darwin/i
66
- Dir.chdir('ext/darwin'){ sh 'make install' }
67
- when /hpux/i
68
- Dir.chdir('ext/hpux'){ sh 'make install' }
69
- end
70
-
71
- cp(file, dir, :verbose => true) if file
72
- end
73
-
74
- desc 'Uninstall the sys-proctable library'
75
- task :uninstall do
76
- case CONFIG['host_os']
77
- when /darwin|hpux/i
78
- dir = File.join(CONFIG['sitearchdir'], 'sys')
79
- file = File.join(dir, 'proctable.' + CONFIG['DLEXT'])
80
- else
81
- dir = File.join(CONFIG['sitelibdir'], 'sys')
82
- file = File.join(dir, 'proctable.rb')
83
- end
84
-
85
- rm(file)
86
- end
87
-
88
- desc 'Run the benchmark suite'
89
- task :bench => [:build] do
90
- sh "ruby -Ilib benchmarks/bench_ps.rb"
91
- end
92
-
93
- desc 'Run the example program'
94
- task :example => [:build] do
95
- sh 'ruby -Ilib -Iext examples/example_ps.rb'
96
- end
97
-
98
- desc 'Run the test suite'
99
- Rake::TestTask.new do |t|
100
- task :test => :build
101
- t.libs << 'test' << '.'
102
-
103
- case CONFIG['host_os']
104
- when /mswin|msdos|cygwin|mingw|windows/i
105
- t.test_files = FileList['test/test_sys_proctable_windows.rb']
106
- t.libs << 'lib/windows'
107
- when /linux/i
108
- t.test_files = FileList['test/test_sys_proctable_linux.rb']
109
- t.libs << 'lib/linux'
110
- when /sunos|solaris/i
111
- t.test_files = FileList['test/test_sys_proctable_sunos.rb']
112
- t.libs << 'lib/sunos'
113
- when /aix/i
114
- t.test_files = FileList['test/test_sys_proctable_aix.rb']
115
- t.libs << 'lib/aix'
116
- when /freebsd/i
117
- t.test_files = FileList['test/test_sys_proctable_freebsd.rb']
118
- t.libs << 'lib/freebsd'
119
- when /darwin/i
120
- t.libs << 'ext/darwin'
121
- t.test_files = FileList['test/test_sys_proctable_darwin.rb']
122
- when /hpux/i
123
- t.libs << 'ext/hpux'
124
- t.test_files = FileList['test/test_sys_proctable_hpux.rb']
125
- end
126
- end
127
-
128
- namespace :gem do
129
- desc 'Create a gem for the specified OS, or your current OS by default'
130
- task :create, [:os] => [:clean] do |_task, args|
131
- require 'rubygems/package'
132
-
133
- if args.is_a?(String)
134
- os = args
135
- else
136
- args.with_defaults(:os => CONFIG['host_os'])
137
- os = args[:os]
138
- end
139
-
140
- spec = eval(IO.read('sys-proctable.gemspec'))
141
- spec.files += ['lib/sys-proctable.rb']
142
-
143
- # I've had to manually futz with the spec here in some cases
144
- # in order to get the universal platform settings I want because
145
- # of some bugginess in Rubygems' platform.rb.
146
- #
147
- case os
148
- when /freebsd/i
149
- spec.platform = Gem::Platform.new(['universal', 'freebsd'])
150
- spec.require_paths = ['lib', 'lib/freebsd']
151
- spec.files += ['lib/freebsd/sys/proctable.rb']
152
- spec.test_files << 'test/test_sys_proctable_freebsd.rb'
153
- spec.add_dependency('ffi')
154
- when /darwin/i
155
- spec.platform = Gem::Platform.new(['universal', 'darwin'])
156
- spec.files << 'ext/darwin/sys/proctable.c'
157
- spec.extra_rdoc_files << 'ext/darwin/sys/proctable.c'
158
- spec.test_files << 'test/test_sys_proctable_darwin.rb'
159
- spec.extensions = ['ext/darwin/extconf.rb']
160
- when /hpux/i
161
- spec.platform = Gem::Platform.new(['universal', 'hpux'])
162
- spec.files << 'ext/hpux/sys/proctable.c'
163
- spec.extra_rdoc_files << 'ext/hpux/sys/proctable.c'
164
- spec.test_files << 'test/test_sys_proctable_hpux.rb'
165
- spec.extensions = ['ext/hpux/extconf.rb']
166
- when /linux/i
167
- spec.platform = Gem::Platform.new(['universal', 'linux'])
168
- spec.require_paths = ['lib', 'lib/linux']
169
- spec.files += ['lib/linux/sys/proctable.rb', 'lib/linux/sys/proctable/cgroup_entry.rb', 'lib/linux/sys/proctable/smaps.rb']
170
- spec.test_files << 'test/test_sys_proctable_linux.rb'
171
- when /sunos|solaris/i
172
- spec.platform = Gem::Platform.new(['universal', 'solaris'])
173
- spec.require_paths = ['lib', 'lib/sunos']
174
- spec.files += ['lib/sunos/sys/proctable.rb']
175
- spec.test_files << 'test/test_sys_proctable_sunos.rb'
176
- when /aix/i
177
- spec.platform = Gem::Platform.new(['universal', 'aix5'])
178
- spec.require_paths = ['lib', 'lib/aix']
179
- spec.files += ['lib/aix/sys/proctable.rb']
180
- spec.test_files << 'test/test_sys_proctable_aix.rb'
181
- when /mswin|win32|dos|cygwin|mingw|windows/i
182
- spec.platform = Gem::Platform.new(['universal', 'mingw32'])
183
- spec.require_paths = ['lib', 'lib/windows']
184
- spec.files += ['lib/windows/sys/proctable.rb']
185
- spec.test_files << 'test/test_sys_proctable_windows.rb'
186
- else
187
- raise "Unsupported platform: #{os}"
188
- end
189
-
190
- spec.test_files << 'test/test_sys_top.rb'
191
-
192
- # https://github.com/rubygems/rubygems/issues/147
193
- spec.original_platform = spec.platform
194
-
195
- spec.signing_key = File.join(Dir.home, '.ssh', 'gem-private_key.pem')
196
-
197
- Gem::Package.build(spec, true)
198
- end
199
-
200
- desc 'Create a gem for each supported OS'
201
- task :create_all => [:clean] do
202
- platforms = %w[aix darwin freebsd hpux linux solaris windows]
203
- Rake::Task["clean"].execute
204
- platforms.each{ |os|
205
- FileUtils.mkdir_p("pkg/#{os}")
206
- Rake::Task["gem:create"].execute(os)
207
- Dir.glob("*.gem").each{ |gem| FileUtils.mv(gem, "pkg/#{os}") }
208
- }
209
- end
210
-
211
- desc 'Install the sys-proctable library as a gem'
212
- task :install => [:create] do
213
- gem_name = Dir['*.gem'].first
214
- sh "gem install -l #{gem_name}"
215
- end
216
- end
217
-
218
- task :default => :test
1
+ require 'rake'
2
+ require 'rake/clean'
3
+ require 'rake/testtask'
4
+ require 'rbconfig'
5
+ include RbConfig
6
+
7
+ CLEAN.include(
8
+ '**/*.core', # Core dump files
9
+ '**/*.gem', # Gem files
10
+ '**/*.rbc', # Rubinius
11
+ '**/*.rbx', # Rubinius
12
+ '**/*.o', # C object file
13
+ '**/*.log', # Ruby extension build log
14
+ '**/Makefile', # C Makefile
15
+ '**/conftest.dSYM', # OS X build directory
16
+ "**/*.#{CONFIG['DLEXT']}" # C shared object
17
+ )
18
+
19
+ desc 'Build the sys-proctable library for C versions of sys-proctable'
20
+ task :build => [:clean] do
21
+ if RUBY_PLATFORM == 'java'
22
+ if ENV['JRUBY_OPTS']
23
+ ENV['JRUBY_OPTS'] += ' -Xcext.enabled=true'
24
+ else
25
+ ENV['JRUBY_OPTS'] = '-Xcext.enabled=true'
26
+ end
27
+ end
28
+
29
+ case CONFIG['host_os']
30
+ when /hpux/i
31
+ dir = 'ext/hpux'
32
+ ext = '.sl'
33
+ end
34
+
35
+ if CONFIG['host_os'] =~ /hpux/i
36
+ Dir.chdir(dir) do
37
+ ruby 'extconf.rb'
38
+ sh 'make'
39
+ cp 'proctable' + ext, 'sys'
40
+ end
41
+ end
42
+ end
43
+
44
+ desc 'Install the sys-proctable library'
45
+ task :install => [:build] do
46
+ file = nil
47
+ dir = File.join(CONFIG['sitelibdir'], 'sys')
48
+
49
+ Dir.mkdir(dir) unless File.exists?(dir)
50
+
51
+ case CONFIG['host_os']
52
+ when /mswin|win32|msdos|cygwin|mingw|windows/i
53
+ file = 'lib/windows/sys/proctable.rb'
54
+ when /linux/i
55
+ file = 'lib/linux/sys/proctable.rb'
56
+ when /sunos|solaris/i
57
+ file = 'lib/sunos/sys/proctable.rb'
58
+ when /aix/i
59
+ file = 'lib/aix/sys/proctable.rb'
60
+ when /freebsd/i
61
+ file = 'lib/freebsd/sys/proctable.rb'
62
+ when /darwin/i
63
+ file = 'lib/darwin/sys/proctable.rb'
64
+ when /hpux/i
65
+ Dir.chdir('ext/hpux'){ sh 'make install' }
66
+ end
67
+
68
+ cp(file, dir, :verbose => true) if file
69
+ end
70
+
71
+ desc 'Uninstall the sys-proctable library'
72
+ task :uninstall do
73
+ case CONFIG['host_os']
74
+ when /hpux/i
75
+ dir = File.join(CONFIG['sitearchdir'], 'sys')
76
+ file = File.join(dir, 'proctable.' + CONFIG['DLEXT'])
77
+ else
78
+ dir = File.join(CONFIG['sitelibdir'], 'sys')
79
+ file = File.join(dir, 'proctable.rb')
80
+ end
81
+
82
+ rm(file)
83
+ end
84
+
85
+ desc 'Run the benchmark suite'
86
+ task :bench => [:build] do
87
+ sh "ruby -Ilib benchmarks/bench_ps.rb"
88
+ end
89
+
90
+ desc 'Run the example program'
91
+ task :example => [:build] do
92
+ sh 'ruby -Ilib -Iext examples/example_ps.rb'
93
+ end
94
+
95
+ desc 'Run the test suite'
96
+ Rake::TestTask.new do |t|
97
+ task :test => :build
98
+ t.libs << 'test' << '.'
99
+
100
+ case CONFIG['host_os']
101
+ when /mswin|msdos|cygwin|mingw|windows/i
102
+ t.test_files = FileList['test/test_sys_proctable_windows.rb']
103
+ t.libs << 'lib/windows'
104
+ when /linux/i
105
+ t.test_files = FileList['test/test_sys_proctable_linux.rb']
106
+ t.libs << 'lib/linux'
107
+ when /sunos|solaris/i
108
+ t.test_files = FileList['test/test_sys_proctable_sunos.rb']
109
+ t.libs << 'lib/sunos'
110
+ when /aix/i
111
+ t.test_files = FileList['test/test_sys_proctable_aix.rb']
112
+ t.libs << 'lib/aix'
113
+ when /freebsd/i
114
+ t.test_files = FileList['test/test_sys_proctable_freebsd.rb']
115
+ t.libs << 'lib/freebsd'
116
+ when /darwin/i
117
+ t.libs << 'lib/darwin'
118
+ t.test_files = FileList['test/test_sys_proctable_darwin.rb']
119
+ when /hpux/i
120
+ t.libs << 'ext/hpux'
121
+ t.test_files = FileList['test/test_sys_proctable_hpux.rb']
122
+ end
123
+ end
124
+
125
+ namespace :gem do
126
+ desc 'Create a gem for the specified OS, or your current OS by default'
127
+ task :create, [:os] => [:clean] do |_task, args|
128
+ require 'rubygems/package'
129
+
130
+ if args.is_a?(String)
131
+ os = args
132
+ else
133
+ args.with_defaults(:os => CONFIG['host_os'])
134
+ os = args[:os]
135
+ end
136
+
137
+ spec = eval(IO.read('sys-proctable.gemspec'))
138
+ spec.files += ['lib/sys-proctable.rb']
139
+
140
+ # I've had to manually futz with the spec here in some cases
141
+ # in order to get the universal platform settings I want because
142
+ # of some bugginess in Rubygems' platform.rb.
143
+ #
144
+ case os
145
+ when /freebsd/i
146
+ spec.platform = Gem::Platform.new(['universal', 'freebsd'])
147
+ spec.require_paths = ['lib', 'lib/freebsd']
148
+ spec.files += ['lib/freebsd/sys/proctable.rb']
149
+ spec.test_files << 'test/test_sys_proctable_freebsd.rb'
150
+ spec.add_dependency('ffi')
151
+ when /darwin/i
152
+ spec.platform = Gem::Platform.new(['universal', 'darwin'])
153
+ spec.require_paths = ['lib', 'lib/darwin']
154
+ spec.files += ['lib/darwin/sys/proctable.rb']
155
+ spec.test_files << 'test/test_sys_proctable_darwin.rb'
156
+ spec.add_dependency('ffi')
157
+ when /hpux/i
158
+ spec.platform = Gem::Platform.new(['universal', 'hpux'])
159
+ spec.files << 'ext/hpux/sys/proctable.c'
160
+ spec.extra_rdoc_files << 'ext/hpux/sys/proctable.c'
161
+ spec.test_files << 'test/test_sys_proctable_hpux.rb'
162
+ spec.extensions = ['ext/hpux/extconf.rb']
163
+ when /linux/i
164
+ spec.platform = Gem::Platform.new(['universal', 'linux'])
165
+ spec.require_paths = ['lib', 'lib/linux']
166
+ spec.files += ['lib/linux/sys/proctable.rb', 'lib/linux/sys/proctable/cgroup_entry.rb', 'lib/linux/sys/proctable/smaps.rb']
167
+ spec.test_files << 'test/test_sys_proctable_linux.rb'
168
+ when /sunos|solaris/i
169
+ spec.platform = Gem::Platform.new(['universal', 'solaris'])
170
+ spec.require_paths = ['lib', 'lib/sunos']
171
+ spec.files += ['lib/sunos/sys/proctable.rb']
172
+ spec.test_files << 'test/test_sys_proctable_sunos.rb'
173
+ when /aix/i
174
+ spec.platform = Gem::Platform.new(['universal', 'aix5'])
175
+ spec.require_paths = ['lib', 'lib/aix']
176
+ spec.files += ['lib/aix/sys/proctable.rb']
177
+ spec.test_files << 'test/test_sys_proctable_aix.rb'
178
+ when /mswin|win32|dos|cygwin|mingw|windows/i
179
+ spec.platform = Gem::Platform.new(['universal', 'mingw32'])
180
+ spec.require_paths = ['lib', 'lib/windows']
181
+ spec.files += ['lib/windows/sys/proctable.rb']
182
+ spec.test_files << 'test/test_sys_proctable_windows.rb'
183
+ else
184
+ raise "Unsupported platform: #{os}"
185
+ end
186
+
187
+ spec.test_files << 'test/test_sys_top.rb'
188
+
189
+ # https://github.com/rubygems/rubygems/issues/147
190
+ spec.original_platform = spec.platform
191
+
192
+ spec.signing_key = File.join(Dir.home, '.ssh', 'gem-private_key.pem')
193
+
194
+ Gem::Package.build(spec, true)
195
+ end
196
+
197
+ desc 'Create a gem for each supported OS'
198
+ task :create_all => [:clean] do
199
+ platforms = %w[aix darwin freebsd hpux linux solaris windows]
200
+ Rake::Task["clean"].execute
201
+ platforms.each{ |os|
202
+ FileUtils.mkdir_p("pkg/#{os}")
203
+ Rake::Task["gem:create"].execute(os)
204
+ Dir.glob("*.gem").each{ |gem| FileUtils.mv(gem, "pkg/#{os}") }
205
+ }
206
+ end
207
+
208
+ desc 'Install the sys-proctable library as a gem'
209
+ task :install => [:create] do
210
+ gem_name = Dir['*.gem'].first
211
+ sh "gem install -l #{gem_name}"
212
+ end
213
+ end
214
+
215
+ task :default => :test