sys-proctable 1.0.0-universal-solaris → 1.1.0-universal-solaris

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
  SHA1:
3
- metadata.gz: 59966a3c688b6d7fb98bba6482632f5f01147ffe
4
- data.tar.gz: 1055dcd5f57820caf8158a96c2eac5c966304c8a
3
+ metadata.gz: f31175f32c7c13591b147331489965df9c6f76f7
4
+ data.tar.gz: e1051e2f7e1341735c9c07edf1364d2381ebbac2
5
5
  SHA512:
6
- metadata.gz: b99bb67d3da0f1b540e420be7f766ce87b46c1290724ed5b432c9f479927d6b005f168af2895e2f0a6238a27890a9def8f5b67d7b1480269745efc7bc221271d
7
- data.tar.gz: 85a09a320df439ed6d1ca14d7b21b122899576a6ba9bfb7a9cca8d714e3bde89054e069424bdda177e9ec1b3c32ac806cb5b7f71a816bb51f5e92c0702db2f80
6
+ metadata.gz: b569e7498fd55177a735fac875e2ead59cd207e7071a6888a88f4677fde0ec1b836f5af485d2ec82d133fc61b76c29fa9faa72346591abf8d85c7d2e31343f1e
7
+ data.tar.gz: 192871cd2d2776e9292cdd2b936330e9525096a29357cf5d5bd24e1b338dd23e130d02ca8e81224f34b0ad4547d39c3ad1e6c0bf4384f6f8d06d72e2c561d6c2
Binary file
data.tar.gz.sig CHANGED
Binary file
data/CHANGES CHANGED
@@ -1,6 +1,16 @@
1
+ == 1.1.0 - ???
2
+ * License was changed to Apache 2.0.
3
+ * The OS X version now requires OS X 10.7 or later.
4
+ * Scrapped the C implementation for OS X, and replaced it with a libproc wrapper
5
+ using FFI, so it is now pure Ruby. Note that some new struct members have been
6
+ added, while others have been dropped. This includes pctcpu, so Sys::Top does
7
+ not work at the moment.
8
+ * Rakefile updates to accomodate the changes for OS X.
9
+ * Some test suite updates and refactoring.
10
+
1
11
  == 1.0.0 - 11-Jan-2016
2
12
  * Added smaps information for Linux. Thanks go to Joe Rafaniello for the patch.
3
- * This is not really a major release. I just ran out of version numbers.
13
+ * This really should not have been a major release, sorry.
4
14
 
5
15
  == 0.9.9 - 8-Nov-2015
6
16
  * Added support for cgroups on Linux. Thanks go to Dennis Günnewig for the patch.
data/MANIFEST CHANGED
@@ -11,14 +11,13 @@
11
11
  * doc/top.txt
12
12
  * doc/windows.txt
13
13
  * example/example_ps.rb
14
- * ext/darwin/extconf.rb
15
- * ext/darwin/sys/proctable.c
16
14
  * ext/hpux/extconf.rb
17
15
  * ext/hpux/sys/proctable.c
18
16
  * lib/sys-proctable.rb
19
17
  * lib/sys/top.rb
20
18
  * lib/sys/proctable/version.rb
21
19
  * lib/aix/sys/proctable.rb
20
+ * lib/darwin/sys/proctable.rb
22
21
  * lib/freebsd/sys/proctable.rb
23
22
  * lib/linux/sys/proctable.rb
24
23
  * lib/sunos/sys/proctable.rb
data/README CHANGED
@@ -10,7 +10,7 @@
10
10
  * FreeBSD
11
11
  * Solaris 8+
12
12
  * HP-UX 10+
13
- * OS X 10.4+
13
+ * OS X 10.7+
14
14
  * AIX 5.3+
15
15
 
16
16
  == Installation
@@ -22,6 +22,7 @@
22
22
  gem install sys-proctable --platform sunos # Solaris
23
23
  gem install sys-proctable --platform linux # Linux
24
24
  gem install sys-proctable --platform freebsd # FreeBSD
25
+ gem install sys-proctable --platform darwin # OS X
25
26
 
26
27
  == Synopsis
27
28
  require 'sys/proctable'
@@ -60,16 +61,13 @@
60
61
  The cmdline member on Solaris is limited to 80 characters unless you (or
61
62
  your program) own the process. This is a Solaris design flaw/feature.
62
63
 
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.
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.
69
67
 
70
68
  == Future Plans
71
69
  Add support for NetBSD and OpenBSD.
72
- Convert existing C code to FFI.
70
+ Convert remaining C code (just HP-UX at this point) to FFI.
73
71
 
74
72
  == Acknowledgements
75
73
  This library was originally based on the Perl module Proc::ProcessTable
@@ -87,7 +85,7 @@
87
85
  debugging help.
88
86
 
89
87
  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.
88
+ to Matthias Zirnstein for adding the original cmdline support for OS X.
91
89
 
92
90
  Finally I'd like to thank all the folks who have submitted bug reports
93
91
  and/or patches.
@@ -102,17 +100,11 @@
102
100
  including platform specific notes and issues.
103
101
 
104
102
  == License
105
- Artistic 2.0
103
+ Apache 2.0
106
104
 
107
105
  == Copyright
108
106
  (C) 2003-2016 Daniel J. Berger
109
107
  All Rights Reserved.
110
108
 
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
109
  == Author
118
110
  Daniel J. Berger
data/Rakefile CHANGED
@@ -27,15 +27,12 @@ task :build => [:clean] do
27
27
  end
28
28
 
29
29
  case CONFIG['host_os']
30
- when /darwin/i
31
- dir = 'ext/darwin'
32
- ext = '.bundle'
33
30
  when /hpux/i
34
31
  dir = 'ext/hpux'
35
32
  ext = '.sl'
36
33
  end
37
34
 
38
- if CONFIG['host_os'] =~ /darwin|hpux/i
35
+ if CONFIG['host_os'] =~ /hpux/i
39
36
  Dir.chdir(dir) do
40
37
  ruby 'extconf.rb'
41
38
  sh 'make'
@@ -63,7 +60,7 @@ task :install => [:build] do
63
60
  when /freebsd/i
64
61
  file = 'lib/freebsd/sys/proctable.rb'
65
62
  when /darwin/i
66
- Dir.chdir('ext/darwin'){ sh 'make install' }
63
+ file = 'lib/darwin/sys/proctable.rb'
67
64
  when /hpux/i
68
65
  Dir.chdir('ext/hpux'){ sh 'make install' }
69
66
  end
@@ -74,7 +71,7 @@ end
74
71
  desc 'Uninstall the sys-proctable library'
75
72
  task :uninstall do
76
73
  case CONFIG['host_os']
77
- when /darwin|hpux/i
74
+ when /hpux/i
78
75
  dir = File.join(CONFIG['sitearchdir'], 'sys')
79
76
  file = File.join(dir, 'proctable.' + CONFIG['DLEXT'])
80
77
  else
@@ -117,7 +114,7 @@ Rake::TestTask.new do |t|
117
114
  t.test_files = FileList['test/test_sys_proctable_freebsd.rb']
118
115
  t.libs << 'lib/freebsd'
119
116
  when /darwin/i
120
- t.libs << 'ext/darwin'
117
+ t.libs << 'lib/darwin'
121
118
  t.test_files = FileList['test/test_sys_proctable_darwin.rb']
122
119
  when /hpux/i
123
120
  t.libs << 'ext/hpux'
@@ -153,10 +150,10 @@ namespace :gem do
153
150
  spec.add_dependency('ffi')
154
151
  when /darwin/i
155
152
  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'
153
+ spec.require_paths = ['lib', 'lib/darwin']
154
+ spec.files += ['lib/darwin/sys/proctable.rb']
158
155
  spec.test_files << 'test/test_sys_proctable_darwin.rb'
159
- spec.extensions = ['ext/darwin/extconf.rb']
156
+ spec.add_dependency('ffi')
160
157
  when /hpux/i
161
158
  spec.platform = Gem::Platform.new(['universal', 'hpux'])
162
159
  spec.files << 'ext/hpux/sys/proctable.c'
@@ -1,6 +1,6 @@
1
1
  module Sys
2
2
  class ProcTable
3
3
  # The version of the sys-proctable library
4
- VERSION = '1.0.0'
4
+ VERSION = '1.1.0'.freeze
5
5
  end
6
6
  end
@@ -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.0.0'
5
+ spec.version = '1.1.0'
6
6
  spec.author = 'Daniel J. Berger'
7
- spec.license = 'Artistic 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.platform = Gem::Platform::CURRENT # Probably altered by Rake task
@@ -15,66 +15,77 @@ class TC_ProcTable_All < Test::Unit::TestCase
15
15
  end
16
16
 
17
17
  def setup
18
- @pid = @@windows ? 0 : 1
18
+ @pid = Process.pid
19
19
  end
20
20
 
21
- def test_version
22
- assert_equal('1.0.0', ProcTable::VERSION)
21
+ test "version is set to expected value" do
22
+ assert_equal('1.1.0', ProcTable::VERSION)
23
23
  end
24
24
 
25
- def test_fields
25
+ test "fields basic functionality" do
26
26
  assert_respond_to(ProcTable, :fields)
27
27
  assert_nothing_raised{ ProcTable.fields }
28
+ end
29
+
30
+ test "fields returns expected type" do
28
31
  assert_kind_of(Array, ProcTable.fields)
29
32
  assert_kind_of(String, ProcTable.fields.first)
30
33
  end
31
34
 
32
- def test_ps
35
+ test "ps basic functionality" do
33
36
  assert_respond_to(ProcTable, :ps)
34
37
  assert_nothing_raised{ ProcTable.ps }
35
38
  assert_nothing_raised{ ProcTable.ps{} }
36
39
  end
37
40
 
38
- def test_ps_with_pid
41
+ test "ps accepts an optional pid" do
39
42
  assert_nothing_raised{ ProcTable.ps(0) }
40
43
  end
41
44
 
42
- def test_ps_with_explicit_nil
45
+ test "ps with explicit nil works as expected" do
43
46
  assert_nothing_raised{ ProcTable.ps(nil) }
44
47
  assert_kind_of(Array, ProcTable.ps(nil))
45
48
  end
46
49
 
47
- def test_ps_return_value
50
+ test "ps returns expected results" do
48
51
  assert_kind_of(Array, ProcTable.ps)
49
52
  assert_kind_of(Struct::ProcTableStruct, ProcTable.ps(@pid))
50
- assert_equal(nil, ProcTable.ps(999999999))
51
- assert_equal(nil, ProcTable.ps(999999999){})
52
- assert_equal(nil, ProcTable.ps{})
53
53
  end
54
54
 
55
- def test_ps_returned_struct_is_frozen
55
+ test "ps returns nil if process does not exist" do
56
+ assert_nil(ProcTable.ps(999999999))
57
+ assert_nil(ProcTable.ps(999999999){})
58
+ assert_nil(ProcTable.ps{})
59
+ end
60
+
61
+ test "structs returned by ps are frozen" do
56
62
  assert_true(ProcTable.ps.first.frozen?)
57
63
  end
58
64
 
59
- def test_ps_expected_errors
65
+ test "ps accepts numeric arguments only" do
60
66
  assert_raises(TypeError){ ProcTable.ps('vim') }
67
+ end
68
+
69
+ test "ps accepts a maximum of one argument on Unix platforms" do
61
70
  omit_if(@@windows, 'ArgumentError check skipped on MS Windows')
62
71
  assert_raises(ArgumentError){ ProcTable.ps(0, 'localhost') }
63
72
  end
64
73
 
65
- def test_new_not_allowed
74
+ test "traditional constructor is disabled" do
66
75
  assert_raise(NoMethodError){ Sys::ProcTable.new }
67
76
  end
68
77
 
69
- def test_error_class_defined
78
+ test "custom error class is defined" do
70
79
  assert_not_nil(Sys::ProcTable::Error)
71
80
  assert_kind_of(StandardError, Sys::ProcTable::Error.new)
72
81
  end
73
82
 
74
- def test_from_thread
75
- Thread.new do
76
- Sys::ProcTable.ps
77
- end.value
83
+ test "ps works within a thread" do
84
+ assert_nothing_raised{
85
+ Thread.new do
86
+ Sys::ProcTable.ps
87
+ end.value
88
+ }
78
89
  end
79
90
 
80
91
  def teardown
@@ -2,45 +2,64 @@
2
2
  # test_sys_top.rb
3
3
  #
4
4
  # Test suite for the sys-top library that is included with this distribution.
5
+ #
6
+ # Tests omitted on OSX until I figure out how to get pctcpu information.
5
7
  ##############################################################################
6
- require 'rubygems'
7
- gem 'test-unit'
8
-
9
- require 'test/unit'
8
+ require 'test-unit'
10
9
  require 'sys/top'
11
10
 
12
11
  class TC_Top < Test::Unit::TestCase
13
12
  include Sys
14
13
 
15
- def test_version
14
+ def setup
15
+ @osx = RbConfig::CONFIG['host_os'] =~ /darwin/i
16
+ end
17
+
18
+ test "top version" do
16
19
  assert_equal('1.0.4', Top::VERSION)
17
20
  end
18
21
 
19
- def test_top_basic
22
+ test "top basic functionality" do
20
23
  assert_respond_to(Top, :top)
24
+ end
25
+
26
+ test "top works with no arguments" do
27
+ omit_if(@osx)
21
28
  assert_nothing_raised{ Top.top }
29
+ end
30
+
31
+ test "top accepts optional arguments" do
32
+ omit_if(@osx)
22
33
  assert_nothing_raised{ Top.top(5) }
23
34
  assert_nothing_raised{ Top.top(5, 'cmdline') }
24
35
  end
25
36
 
26
- def test_top
37
+ test "top with no arguments returns expected results" do
38
+ omit_if(@osx)
27
39
  assert_equal(10, Top.top.length)
28
40
  assert_kind_of(Struct::ProcTableStruct, Top.top.first)
29
41
  end
30
42
 
31
- def test_top_with_size
43
+ test "top with size argument returns expected result" do
44
+ omit_if(@osx)
32
45
  assert_equal(5, Top.top(5).length)
33
46
  end
34
47
 
35
- def test_top_with_size_and_sort_by_field
48
+ test "top with size and sort_by argument returns expected result" do
49
+ omit_if(@osx)
36
50
  assert_equal(5, Top.top(5, :cmdline).length)
37
51
  end
38
52
 
39
- def test_top_return_type
53
+ test "top returns an array" do
54
+ omit_if(@osx)
40
55
  assert_kind_of(Array, Top.top)
41
56
  end
42
57
 
43
- def test_top_expected_errors
58
+ test "top accepts a maximum of two arguments" do
44
59
  assert_raises(ArgumentError){ Top.top(1, 'foo', 2) }
45
60
  end
61
+
62
+ def teardown
63
+ @osx = nil
64
+ end
46
65
  end
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.0.0
4
+ version: 1.1.0
5
5
  platform: universal-solaris
6
6
  authors:
7
7
  - Daniel J. Berger
@@ -30,7 +30,7 @@ cert_chain:
30
30
  EJYzxdPOrx2n6NYR3Hk+vHP0U7UBSveI6+qx+ndQYaeyCn+GRX2PKS9h66YF/Q1V
31
31
  tGSHgAmcLlkdGgan182qsE/4kKM=
32
32
  -----END CERTIFICATE-----
33
- date: 2016-01-11 00:00:00.000000000 Z
33
+ date: 2016-06-19 00:00:00.000000000 Z
34
34
  dependencies:
35
35
  - !ruby/object:Gem::Dependency
36
36
  name: test-unit
@@ -90,7 +90,7 @@ files:
90
90
  - lib/sunos/sys/proctable.rb
91
91
  homepage: http://github.com/djberg96/sys-proctable
92
92
  licenses:
93
- - Artistic 2.0
93
+ - Apache 2.0
94
94
  metadata: {}
95
95
  post_install_message:
96
96
  rdoc_options: []
metadata.gz.sig CHANGED
Binary file