sys-proctable 1.2.1 → 1.2.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cb96b1cfb746706244c26f2ce85f54740163cb9f9174237fd06767849ca62cb8
4
- data.tar.gz: f8b0b6d47efb86e64a630331a3408deb5baf2a6c8b1256bf55a0bad76f9c17c7
3
+ metadata.gz: 47da35e089de6a039ea5ae43c965d1ec207644aaf33dc4294f19a02927f42c0b
4
+ data.tar.gz: 68a6ba2f88db4b7e20f4762f3728e3841c30bf5ee857c2885fe698ea6a6c8d32
5
5
  SHA512:
6
- metadata.gz: 72bf0ffb98c4362deeb9506c6d2f50147c327fe0862575b06f5de1d342e6c9b3a7d5a0fd9a51d69e15cd2f1f68f8d8a9d67ceba12b8a8350f123498b759c4ac0
7
- data.tar.gz: 9acdc748cffeee40be36cff671b9f8057ec7fd9f416609f326882c28dfa5b9dd4fddba07a56ed9d64fe9d27b2743c242a3a9b04f902a2f9c3b442ab4ca38a2e1
6
+ metadata.gz: c5407d746f15c8eabb88c0b7dfea3a426aeb9f46b48af48b58718d955c692a0ef71324049e1e71ada918fe3eafa7955e20f912270e3b7478042d91d6e22a86e8
7
+ data.tar.gz: ddf616512c79a4a3980972f5bd661873ab97da2ee7d9be21f1193097f0dd0710d581bd2dfbb8c5c4ff6ff98a4fbfb5ad032aa4d1df92a17c6791de1de1fc7247
Binary file
data.tar.gz.sig CHANGED
Binary file
data/CHANGES CHANGED
@@ -1,3 +1,16 @@
1
+ == 1.2.2 - 12-Aug-2019
2
+ * Added compatibility for JRuby on Mac which apparently doesn't define a
3
+ read_uint64 method, nor a CharArray. Thanks go to Adithya Pentela for
4
+ the spot.
5
+ * Refactored the specs a bit, adding a spec_helper.rb. This was mainly
6
+ for JRuby compatibility.
7
+ * Updates to the travis.yml file for both Ruby and JRuby versions.
8
+ * Removed the doc directory and all the files it contained. It was
9
+ redundant, and some of the information was wrong. All of the
10
+ documentation you need is on the wiki.
11
+ * Cleaned up the MANIFEST file, updated the gemspec, and fixed the
12
+ license name, which was missing a hyphen.
13
+
1
14
  == 1.2.1 - 8-Jun-2018
2
15
  * The code for OSX is now more efficient when a pid argument is provided.
3
16
  Thanks go to Nick LaMuro for his efforts.
data/MANIFEST CHANGED
@@ -3,16 +3,9 @@
3
3
  * Rakefile
4
4
  * README
5
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
6
+ * benchmarks/bench_ps.rb
7
+ * benchmarks/bench_ips_ps.rb
13
8
  * example/example_ps.rb
14
- * ext/hpux/extconf.rb
15
- * ext/hpux/sys/proctable.c
16
9
  * lib/sys-proctable.rb
17
10
  * lib/sys/top.rb
18
11
  * lib/sys/proctable/version.rb
@@ -26,7 +19,6 @@
26
19
  * test/test_sys_proctable_all.rb
27
20
  * test/test_sys_proctable_darwin.rb
28
21
  * test/test_sys_proctable_freebsd.rb
29
- * test/test_sys_proctable_hpux.rb
30
22
  * test/test_sys_proctable_linux.rb
31
23
  * test/test_sys_proctable_sunos.rb
32
24
  * test/test_sys_proctable_windows.rb
data/README.md CHANGED
@@ -150,7 +150,7 @@ Apache 2.0
150
150
 
151
151
  ## Copyright
152
152
 
153
- (C) 2003-2018 Daniel J. Berger
153
+ (C) 2003-2019 Daniel J. Berger
154
154
  All Rights Reserved.
155
155
 
156
156
  ## Author
data/Rakefile CHANGED
@@ -51,7 +51,7 @@ end
51
51
 
52
52
  desc 'Run the test suite for the sys-proctable library'
53
53
  RSpec::Core::RakeTask.new(:spec) do |t|
54
- t.pattern = ['spec/sys_proctable_all_spec.rb']
54
+ t.pattern = ['spec/spec_helper.rb', 'spec/sys_proctable_all_spec.rb']
55
55
 
56
56
  case CONFIG['host_os']
57
57
  when /aix/i
@@ -0,0 +1,63 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'json'
4
+ require 'optparse'
5
+ require 'rbconfig'
6
+ require 'benchmark/ips'
7
+
8
+ @source, @gem = false
9
+
10
+ OptionParser.new do |opt|
11
+ opt.banner = "Usage: #{File.basename $0} [--gem|--source]"
12
+
13
+ opt.separator ""
14
+ opt.separator "Benchmark IPS (iterations per second) changes between"
15
+ opt.separator "source version of sys-proctable and previous gem"
16
+ opt.separator "version."
17
+ opt.separator ""
18
+ opt.separator "Requires that the both the source version of the gem"
19
+ opt.separator "be installed (run `rake install` to do this after"
20
+ opt.separator "each of your changes) and version installed via"
21
+ opt.separator "rubygems."
22
+ opt.separator ""
23
+ opt.separator "To run, call with `--gem` two times, and then with "
24
+ opt.separator "`--source` two times again."
25
+ opt.separator ""
26
+
27
+ opt.on("--source") { @source = true }
28
+ opt.on("--gem") { @gem = true }
29
+ end.parse!
30
+
31
+ if @source && !@gem
32
+ # Being paranoid here and making sure we get the version installed to
33
+ # sitelibdir
34
+ require File.join(RbConfig::CONFIG["sitelibdir"], "sys", "proctable")
35
+ else
36
+ @gem = true
37
+ require 'sys-proctable'
38
+ end
39
+
40
+ Benchmark.ips do |bench|
41
+ bench.report("Block form - pre patch") do
42
+ (puts "ERR: Please run with --gem"; exit 1) unless @gem
43
+ Sys::ProcTable.ps {}
44
+ end
45
+
46
+ bench.report("Non-block form - pre patch") do
47
+ (puts "ERR: Please run with --gem"; exit 1) unless @gem
48
+ Sys::ProcTable.ps
49
+ end
50
+
51
+ bench.report("Block form - post patch") do
52
+ (puts "ERR: Please run with --source"; exit 1) unless @source
53
+ Sys::ProcTable.ps {}
54
+ end
55
+
56
+ bench.report("Non-block form - post patch") do
57
+ (puts "ERR: Please run with --source"; exit 1) unless @source
58
+ Sys::ProcTable.ps
59
+ end
60
+
61
+ bench.hold! "bench_ips_ps.results"
62
+ bench.compare!
63
+ end
@@ -26,6 +26,11 @@ module Sys
26
26
  MAXTHREADNAMESIZE = 64
27
27
  PROC_PIDPATHINFO_MAXSIZE = MAXPATHLEN * 4
28
28
 
29
+ # JRuby on Mac
30
+ unless defined? FFI::StructLayout::CharArray
31
+ FFI::StructLayout::CharArray = FFI::StructLayout::CharArrayProxy
32
+ end
33
+
29
34
  class ProcBsdInfo < FFI::Struct
30
35
  layout(
31
36
  :pbi_flags, :uint32_t,
@@ -285,7 +290,13 @@ module Sys
285
290
 
286
291
  0.upto(max-1) do |index|
287
292
  tinfo = ProcThreadInfo.new
288
- nb = proc_pidinfo(pid, PROC_PIDTHREADINFO, buf[index].read_uint64, tinfo, tinfo.size)
293
+
294
+ # Use read_array_of_uint64 for compatibility with JRuby if necessary.
295
+ if buf[index].respond_to?(:read_uint64)
296
+ nb = proc_pidinfo(pid, PROC_PIDTHREADINFO, buf[index].read_uint64, tinfo, tinfo.size)
297
+ else
298
+ nb = proc_pidinfo(pid, PROC_PIDTHREADINFO, buf[index].read_array_of_uint64(1).first, tinfo, tinfo.size)
299
+ end
289
300
 
290
301
  if nb <= 0
291
302
  if [Errno::EPERM::Errno, Errno::ESRCH::Errno].include?(FFI.errno)
@@ -1,6 +1,6 @@
1
1
  module Sys
2
2
  class ProcTable
3
3
  # The version of the sys-proctable library
4
- VERSION = '1.2.1'.freeze
4
+ VERSION = '1.2.2'.freeze
5
5
  end
6
6
  end
@@ -0,0 +1,22 @@
1
+ RSpec.configure do |config|
2
+ config.filter_run_excluding :skip_jruby if RUBY_PLATFORM == 'java'
3
+ end
4
+
5
+ if RUBY_PLATFORM == 'java'
6
+ require 'ffi'
7
+ module Exec
8
+ extend FFI::Library
9
+ ffi_lib FFI::Library::LIBC
10
+ attach_function :fork, [], :int
11
+ end
12
+
13
+ def fork
14
+ pid = Exec.fork
15
+ if pid == 0
16
+ yield if block_given?
17
+ return nil
18
+ else
19
+ return pid
20
+ end
21
+ end
22
+ end
@@ -16,7 +16,7 @@ describe Sys::ProcTable do
16
16
  end
17
17
 
18
18
  it "has a VERSION constant set to the expected value" do
19
- expect(Sys::ProcTable::VERSION).to eql('1.2.1')
19
+ expect(Sys::ProcTable::VERSION).to eql('1.2.2')
20
20
  end
21
21
 
22
22
  it "defines a custom error class" do
@@ -87,30 +87,30 @@ describe Sys::ProcTable do
87
87
  expect(subject.svgid).to eql(Process.gid)
88
88
  end
89
89
 
90
- it "contains a comm member and returns the expected value" do
90
+ it "contains a comm member and returns the expected value", :skip_jruby do
91
91
  expect(subject).to respond_to(:comm)
92
92
  expect(subject.comm).to be_kind_of(String)
93
93
  expect(subject.comm).to eql('sleep')
94
94
  end
95
95
 
96
- it "contains a cmdline member and returns the expected value" do
96
+ it "contains a cmdline member and returns the expected value", :skip_jruby do
97
97
  expect(subject).to respond_to(:cmdline)
98
98
  expect(subject.cmdline).to be_kind_of(String)
99
99
  expect(subject.cmdline).to eql('sleep 60')
100
100
  end
101
101
 
102
- it "returns a string with the expected arguments for the cmdline member" do
102
+ it "returns a string with the expected arguments for the cmdline member", :skip_jruby do
103
103
  ptable = Sys::ProcTable.ps(pid: @pid2)
104
104
  expect(ptable.cmdline).to eql('ruby -Ilib -e sleep \'120\'.to_i -- foo bar')
105
105
  end
106
106
 
107
- it "contains an exe member and returns the expected value" do
107
+ it "contains an exe member and returns the expected value", :skip_jruby do
108
108
  expect(subject).to respond_to(:exe)
109
109
  expect(subject.exe).to be_kind_of(String)
110
110
  expect(subject.exe).to eql(`which sleep`.chomp)
111
111
  end
112
112
 
113
- it "contains an environ member and returns the expected value" do
113
+ it "contains an environ member and returns the expected value", :skip_jruby do
114
114
  expect(subject).to respond_to(:environ)
115
115
  expect(subject.environ).to be_kind_of(Hash)
116
116
  expect(subject.environ['A']).to eql('B')
@@ -2,9 +2,9 @@ require 'rubygems'
2
2
 
3
3
  Gem::Specification.new do |spec|
4
4
  spec.name = 'sys-proctable'
5
- spec.version = '1.2.1'
5
+ spec.version = '1.2.2'
6
6
  spec.author = 'Daniel J. Berger'
7
- spec.license = 'Apache 2.0'
7
+ spec.license = 'Apache-2.0'
8
8
  spec.email = 'djberg96@gmail.com'
9
9
  spec.homepage = 'http://github.com/djberg96/sys-proctable'
10
10
  spec.summary = 'An interface for providing process table information'
@@ -22,7 +22,7 @@ Gem::Specification.new do |spec|
22
22
  'sys-proctable.gemspec'
23
23
  ]
24
24
 
25
- spec.extra_rdoc_files = ['CHANGES', 'README.md', 'MANIFEST', 'doc/top.txt']
25
+ spec.extra_rdoc_files = ['CHANGES', 'README.md', 'MANIFEST']
26
26
 
27
27
  spec.add_dependency('ffi')
28
28
  spec.add_development_dependency('rspec')
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sys-proctable
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.1
4
+ version: 1.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel J. Berger
@@ -35,7 +35,7 @@ cert_chain:
35
35
  ORVCZpRuCPpmC8qmqxUnARDArzucjaclkxjLWvCVHeFa9UP7K3Nl9oTjJNv+7/jM
36
36
  WZs4eecIcUc4tKdHxcAJ0MO/Dkqq7hGaiHpwKY76wQ1+8xAh
37
37
  -----END CERTIFICATE-----
38
- date: 2018-06-08 00:00:00.000000000 Z
38
+ date: 2019-08-12 00:00:00.000000000 Z
39
39
  dependencies:
40
40
  - !ruby/object:Gem::Dependency
41
41
  name: ffi
@@ -92,8 +92,8 @@ extra_rdoc_files:
92
92
  - CHANGES
93
93
  - README.md
94
94
  - MANIFEST
95
- - doc/top.txt
96
95
  files:
96
+ - benchmarks/bench_ips_ps.rb
97
97
  - benchmarks/bench_ps.rb
98
98
  - examples/example_ps.rb
99
99
  - lib/aix/sys/proctable.rb
@@ -116,7 +116,7 @@ files:
116
116
  - sys-proctable.gemspec
117
117
  homepage: http://github.com/djberg96/sys-proctable
118
118
  licenses:
119
- - Apache 2.0
119
+ - Apache-2.0
120
120
  metadata:
121
121
  homepage_uri: https://github.com/djberg96/sys-proctable
122
122
  bug_tracker_uri: https://github.com/djberg96/sys-proctable/issues
@@ -140,11 +140,12 @@ required_rubygems_version: !ruby/object:Gem::Requirement
140
140
  version: '0'
141
141
  requirements: []
142
142
  rubyforge_project:
143
- rubygems_version: 2.7.6
143
+ rubygems_version: 2.7.6.2
144
144
  signing_key:
145
145
  specification_version: 4
146
146
  summary: An interface for providing process table information
147
147
  test_files:
148
+ - spec/spec_helper.rb
148
149
  - spec/sys_proctable_aix_spec.rb
149
150
  - spec/sys_proctable_all_spec.rb
150
151
  - spec/sys_proctable_darwin_spec.rb
metadata.gz.sig CHANGED
Binary file
@@ -1,47 +0,0 @@
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
- Daniel J. Berger