sys-uptime 0.7.2 → 0.7.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 72e69131ad6cd87126c07f6ee1b86f96bcb94fad06481b31e0af63b9e2e3d1f2
4
- data.tar.gz: 04d76a92b4c30697055281729d04123e3c90bf382f3a75a6b1490f297593c026
3
+ metadata.gz: b60e5a8e0c80b7bc4596d476f5a65f14012eae7727e157871c67c20db8b9e7e5
4
+ data.tar.gz: 8f47059f06522c513b7ae2c139c1f536dc7d0e836531e51b6e19494cee4171af
5
5
  SHA512:
6
- metadata.gz: d68dc7da76c7e4c9968175b3ac7cb5355004345c087483d914096fa4e06232397adca500c2512c7136cc497cff944ffa0704a3737b080d53a1ec8528f97e3173
7
- data.tar.gz: 86eb66468d20d99647a647e856e3a29364e08fcdd41ac8425bc9ec3f61f4525fde6054cbb83f96fbed99280a184da58b8f644caf1bf3bc15b91cad4baabc16c7
6
+ metadata.gz: 1821026a7dd878dad5b3d6bfd4c9be6cc8eec3535e527dbda2a7f5539a5d5c8b8e1bbac7a17c2289c8598835062e8b250f2b660037cc85e7f715724656ec70ef
7
+ data.tar.gz: 2b05cc363f44cbb5ffd4cd8172073981484f72d1c0b11cad3f28a78fb935499b99f8568a939e51adb1aa6da768829ad2ab8cd6a28e8fc5719d12f7b4adeed21c
Binary file
data.tar.gz.sig CHANGED
Binary file
@@ -1,3 +1,12 @@
1
+ == 0.7.3 - 31-Dec-2019
2
+ * Attempting to call Sys::Uptime.new will now raise an error. I thought
3
+ this was already the case, but apparently one of the tests was bad.
4
+ * Added explicit .rdoc extensions to various text files so that github
5
+ will display them nicely.
6
+ * Switched from test-unit to rspec as the testing framework of choice.
7
+ * Updated the gemspec to reflect the filename updates, as well as the
8
+ added development dependency.
9
+
1
10
  == 0.7.2 - 4-Nov-2018
2
11
  * Added metadata to the gemspec.
3
12
  * The VERSION constant is now frozen.
@@ -1,11 +1,11 @@
1
- * CHANGES
2
- * MANIFEST
1
+ * CHANGES.rdoc
2
+ * MANIFEST.rdoc
3
3
  * Rakefile
4
- * README
4
+ * README.rdoc
5
5
  * sys-uptime.gemspec
6
6
  * certs/djberg96_pub.pem
7
7
  * examples/test.rb
8
8
  * lib/sys-uptime.rb
9
9
  * lib/unix/sys/uptime.rb
10
10
  * lib/windows/sys/uptime.rb
11
- * test/test_sys_uptime.rb
11
+ * spec/sys_uptime_spec.rb
@@ -0,0 +1,67 @@
1
+ == Description
2
+ A Ruby interface for getting system uptime information.
3
+
4
+ == Prerequisites
5
+ ffi 0.1.0 or later on Unixy platforms.
6
+
7
+ == Installation
8
+
9
+ gem install sys-uptime
10
+
11
+ == Synopsis
12
+ require 'sys-uptime'
13
+ include Sys
14
+
15
+ # Get everything
16
+ p Uptime.uptime
17
+ p Uptime.dhms.join(', ')
18
+
19
+ # Get individual units
20
+ p Uptime.days
21
+ p Uptime.hours
22
+ p Uptime.minutes
23
+ p Uptime.seconds
24
+
25
+ # Get the boot time
26
+ p Uptime.boot_time
27
+
28
+ == Notes
29
+ On MS Windows the +Uptime.uptime+ and +Uptime.boot_time+ methods optionally
30
+ takes a host name as a single argument. The default is localhost.
31
+
32
+ The current time, users and load average are not included in this library
33
+ module, even though you may be used to seeing them with the command
34
+ line version of +uptime+.
35
+
36
+ == Known Bugs
37
+ None that I am aware of. Please log any bugs you find on the project
38
+ website at https://github.com/djberg96/sys-uptime.
39
+
40
+ == Questions
41
+ "Doesn't Struct::Tms do this?" - No.
42
+
43
+ == License
44
+ Apache-2.0
45
+
46
+ == Copyright
47
+ Copyright 2002-2019, Daniel J. Berger
48
+
49
+ All Rights Reserved. This module is free software. It may be used,
50
+ redistributed and/or modified under the same terms as Ruby itself.
51
+
52
+ == Warranty
53
+ This library is provided "as is" and without any express or
54
+ implied warranties, including, without limitation, the implied
55
+ warranties of merchantability and fitness for a particular purpose.
56
+
57
+ == Acknowledgements
58
+ Andrea Fazzi for help with the FFI version.
59
+
60
+ Mike Hall for help with the BSD side of things for the original C code.
61
+
62
+ Ola Eriksson, whose source code I shamelessly plagiarized to get a better
63
+ implementation for systems that have the utmpx.h header file for the
64
+ original C code.
65
+
66
+ == Author
67
+ Daniel J. Berger
data/Rakefile CHANGED
@@ -1,6 +1,7 @@
1
1
  require 'rake'
2
2
  require 'rake/clean'
3
3
  require 'rake/testtask'
4
+ require 'rspec/core/rake_task'
4
5
 
5
6
  CLEAN.include("**/*.gem", "**/*.rbx", "**/*.rbc")
6
7
 
@@ -28,15 +29,6 @@ namespace 'gem' do
28
29
  end
29
30
 
30
31
  desc "Run the test suite"
31
- Rake::TestTask.new do |t|
32
- if File::ALT_SEPARATOR
33
- t.libs << 'lib/windows'
34
- else
35
- t.libs << 'lib/unix'
36
- end
37
-
38
- t.warning = true
39
- t.verbose = true
40
- end
32
+ RSpec::Core::RakeTask.new(:spec)
41
33
 
42
- task :default => :test
34
+ task :default => :spec
@@ -26,7 +26,7 @@ module Sys
26
26
  attach_function :time, [:pointer], :time_t
27
27
  attach_function :times, [:pointer], :clock_t
28
28
 
29
- private_class_method :strerror, :sysconf, :time, :times
29
+ private_class_method :strerror, :sysconf, :time, :times, :new
30
30
 
31
31
  begin
32
32
  attach_function :sysctl, [:pointer, :uint, :pointer, :pointer, :pointer, :size_t], :int
@@ -7,6 +7,6 @@ end
7
7
  module Sys
8
8
  class Uptime
9
9
  # The version of the sys-uptime library
10
- VERSION = '0.7.2'.freeze
10
+ VERSION = '0.7.3'.freeze
11
11
  end
12
12
  end
@@ -13,6 +13,9 @@ module Sys
13
13
  # Error typically raised in one of the Uptime methods should fail.
14
14
  class Error < StandardError; end
15
15
 
16
+ # You cannot instantiate an instance of Sys::Uptime.
17
+ private_class_method :new
18
+
16
19
  # Returns the boot time as a Time object.
17
20
  #
18
21
  # Example:
@@ -0,0 +1,103 @@
1
+ #####################################################################
2
+ # sys_uptime_spec.rb
3
+ #
4
+ # Test suite for sys-uptime. This should generally be run via the
5
+ # 'rake test' task, since it handles the pre-setup code for you.
6
+ #####################################################################
7
+ require 'sys/uptime'
8
+ require 'test-unit'
9
+ require 'socket'
10
+
11
+ describe Sys::Uptime do
12
+ example "version is set to expected value" do
13
+ expect(Sys::Uptime::VERSION).to eql('0.7.3')
14
+ expect(Sys::Uptime::VERSION.frozen?).to be(true)
15
+ end
16
+
17
+ example "seconds method basic functionality" do
18
+ expect(Sys::Uptime).to respond_to(:seconds)
19
+ expect{ Sys::Uptime.seconds }.not_to raise_error
20
+ end
21
+
22
+ example "seconds method returns a plausible value" do
23
+ expect(Sys::Uptime.seconds).to be_kind_of(Integer)
24
+ expect(Sys::Uptime.seconds).to be > 300
25
+ end
26
+
27
+ example "minutes method basic functionality" do
28
+ expect(Sys::Uptime).to respond_to(:minutes)
29
+ expect{ Sys::Uptime.minutes }.not_to raise_error
30
+ end
31
+
32
+ example "minutes method returns a plausible value" do
33
+ expect(Sys::Uptime.minutes).to be_kind_of(Integer)
34
+ expect(Sys::Uptime.minutes).to be > 5
35
+ end
36
+
37
+ example "hours method basic functionality" do
38
+ expect(Sys::Uptime).to respond_to(:hours)
39
+ expect{ Sys::Uptime.hours }.not_to raise_error
40
+ end
41
+
42
+ example "hours method returns a plausible value" do
43
+ expect(Sys::Uptime.hours).to be_kind_of(Integer)
44
+ expect(Sys::Uptime.hours).to be > 0
45
+ end
46
+
47
+ example "days method basic functionality" do
48
+ expect(Sys::Uptime).to respond_to(:days)
49
+ expect{ Sys::Uptime.days }.not_to raise_error
50
+ end
51
+
52
+ example "days method returns a plausible value" do
53
+ expect(Sys::Uptime.days).to be_kind_of(Integer)
54
+ expect(Sys::Uptime.days).to be >= 0
55
+ end
56
+
57
+ example "uptime method basic functionality" do
58
+ expect(Sys::Uptime).to respond_to(:uptime)
59
+ expect{ Sys::Uptime.uptime }.not_to raise_error
60
+ end
61
+
62
+ example "uptime method returns a non-empty string" do
63
+ expect(Sys::Uptime.uptime).to be_kind_of(String)
64
+ expect(Sys::Uptime.uptime.empty?).to be(false)
65
+ end
66
+
67
+ example "uptime method does not accept any arguments", :unless => File::ALT_SEPARATOR do
68
+ expect{ Sys::Uptime.uptime(1) }.to raise_error(ArgumentError)
69
+ end
70
+
71
+ example "uptime accepts a host name on Windows", :if => File::ALT_SEPARATOR do
72
+ expect{ Sys::Uptime.uptime(Socket.gethostname) }.not_to raise_error
73
+ end
74
+
75
+ example "dhms method basic functionality" do
76
+ expect(Sys::Uptime).to respond_to(:dhms)
77
+ expect{ Sys::Uptime.dhms }.not_to raise_error
78
+ expect(Sys::Uptime.dhms).to be_kind_of(Array)
79
+ end
80
+
81
+ example "dhms method returns an array of four elements" do
82
+ expect(Sys::Uptime.dhms).not_to be_empty
83
+ expect(Sys::Uptime.dhms.length).to eql(4)
84
+ end
85
+
86
+ example "boot_time method basic functionality" do
87
+ expect(Sys::Uptime).to respond_to(:boot_time)
88
+ expect{ Sys::Uptime.boot_time }.not_to raise_error
89
+ end
90
+
91
+ example "boot_time method returns a Time object" do
92
+ expect(Sys::Uptime.boot_time).to be_kind_of(Time)
93
+ end
94
+
95
+ example "Uptime class cannot be instantiated" do
96
+ expect{ Sys::Uptime.new }.to raise_error(StandardError)
97
+ end
98
+
99
+ example "Ensure that ffi functions are private" do
100
+ methods = Sys::Uptime.methods(false).map{ |e| e.to_s }
101
+ expect(methods).not_to include('time', 'times')
102
+ end
103
+ end
@@ -2,17 +2,18 @@ require 'rubygems'
2
2
 
3
3
  Gem::Specification.new do |spec|
4
4
  spec.name = 'sys-uptime'
5
- spec.version = '0.7.2'
5
+ spec.version = '0.7.3'
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 = 'https://github.com/djberg96/sys-uptime'
10
10
  spec.summary = 'A Ruby interface for getting system uptime information.'
11
- spec.test_file = 'test/test_sys_uptime.rb'
11
+ spec.test_file = 'spec/sys_uptime_spec.rb'
12
12
  spec.files = Dir["**/*"].reject{ |f| f.include?('git') }
13
13
  spec.cert_chain = ['certs/djberg96_pub.pem']
14
14
 
15
- spec.extra_rdoc_files = ['CHANGES', 'README', 'MANIFEST']
15
+ spec.extra_rdoc_files = Dir["*.rdoc"]
16
+ spec.add_development_dependency 'rspec', '~> 3'
16
17
 
17
18
  spec.metadata = {
18
19
  'homepage_uri' => 'https://github.com/djberg96/sys-uptime',
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sys-uptime
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.2
4
+ version: 0.7.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel J. Berger
@@ -35,8 +35,22 @@ cert_chain:
35
35
  ORVCZpRuCPpmC8qmqxUnARDArzucjaclkxjLWvCVHeFa9UP7K3Nl9oTjJNv+7/jM
36
36
  WZs4eecIcUc4tKdHxcAJ0MO/Dkqq7hGaiHpwKY76wQ1+8xAh
37
37
  -----END CERTIFICATE-----
38
- date: 2018-11-04 00:00:00.000000000 Z
38
+ date:
39
39
  dependencies:
40
+ - !ruby/object:Gem::Dependency
41
+ name: rspec
42
+ requirement: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - "~>"
45
+ - !ruby/object:Gem::Version
46
+ version: '3'
47
+ type: :development
48
+ prerelease: false
49
+ version_requirements: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - "~>"
52
+ - !ruby/object:Gem::Version
53
+ version: '3'
40
54
  - !ruby/object:Gem::Dependency
41
55
  name: ffi
42
56
  requirement: !ruby/object:Gem::Requirement
@@ -59,16 +73,13 @@ email: djberg96@gmail.com
59
73
  executables: []
60
74
  extensions: []
61
75
  extra_rdoc_files:
62
- - CHANGES
63
- - README
64
- - MANIFEST
76
+ - CHANGES.rdoc
77
+ - MANIFEST.rdoc
78
+ - README.rdoc
65
79
  files:
66
- - test
67
- - test/test_sys_uptime.rb
68
80
  - sys-uptime.gemspec
69
- - CHANGES
70
- - MANIFEST
71
- - README
81
+ - spec
82
+ - spec/sys_uptime_spec.rb
72
83
  - Rakefile
73
84
  - certs
74
85
  - certs/djberg96_pub.pem
@@ -84,9 +95,12 @@ files:
84
95
  - lib/sys/windows
85
96
  - lib/sys/windows/sys
86
97
  - lib/sys/windows/sys/uptime.rb
98
+ - CHANGES.rdoc
99
+ - MANIFEST.rdoc
100
+ - README.rdoc
87
101
  homepage: https://github.com/djberg96/sys-uptime
88
102
  licenses:
89
- - Apache 2.0
103
+ - Apache-2.0
90
104
  metadata:
91
105
  homepage_uri: https://github.com/djberg96/sys-uptime
92
106
  bug_tracker_uri: https://github.com/djberg96/sys-uptime/issues
@@ -109,10 +123,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
109
123
  - !ruby/object:Gem::Version
110
124
  version: '0'
111
125
  requirements: []
112
- rubyforge_project:
113
- rubygems_version: 2.7.6
126
+ rubygems_version: 3.0.6
114
127
  signing_key:
115
128
  specification_version: 4
116
129
  summary: A Ruby interface for getting system uptime information.
117
130
  test_files:
118
- - test/test_sys_uptime.rb
131
+ - spec/sys_uptime_spec.rb
metadata.gz.sig CHANGED
Binary file
data/README DELETED
@@ -1,66 +0,0 @@
1
- = Description
2
- A Ruby interface for getting system uptime information.
3
-
4
- = Prerequisites
5
- ffi 0.1.0 or later on Unixy platforms.
6
-
7
- = Installation
8
- gem install sys-uptime
9
-
10
- = Synopsis
11
- require 'sys-uptime'
12
- include Sys
13
-
14
- # Get everything
15
- p Uptime.uptime
16
- p Uptime.dhms.join(', ')
17
-
18
- # Get individual units
19
- p Uptime.days
20
- p Uptime.hours
21
- p Uptime.minutes
22
- p Uptime.seconds
23
-
24
- # Get the boot time
25
- p Uptime.boot_time
26
-
27
- = Notes
28
- On MS Windows the Uptime.uptime and Uptime_boot_time methods optionally
29
- takes a host name as a single argument. The default is localhost.
30
-
31
- The current time, users and load average are not included in this library
32
- module, even though you may be used to seeing them with the command
33
- line version of 'uptime'.
34
-
35
- == Known Bugs
36
- None that I am aware of. Please log any bugs you find on the project
37
- website at https://github.com/djberg96/sys-uptime.
38
-
39
- == Questions
40
- "Doesn't Struct::Tms do this?" - No.
41
-
42
- == License
43
- Apache 2.0
44
-
45
- == Copyright
46
- Copyright 2002-2018, Daniel J. Berger
47
-
48
- All Rights Reserved. This module is free software. It may be used,
49
- redistributed and/or modified under the same terms as Ruby itself.
50
-
51
- == Warranty
52
- This library is provided "as is" and without any express or
53
- implied warranties, including, without limitation, the implied
54
- warranties of merchantability and fitness for a particular purpose.
55
-
56
- == Acknowledgements
57
- Andrea Fazzi for help with the FFI version.
58
-
59
- Mike Hall for help with the BSD side of things for the original C code.
60
-
61
- Ola Eriksson, whose source code I shamelessly plagiarized to get a better
62
- implementation for systems that have the utmpx.h header file for the
63
- original C code.
64
-
65
- == Author
66
- Daniel J. Berger
@@ -1,107 +0,0 @@
1
- #####################################################################
2
- # test_sys_uptime.rb
3
- #
4
- # Test suite for sys-uptime. This should generally be run via the
5
- # 'rake test' task, since it handles the pre-setup code for you.
6
- #####################################################################
7
- require 'sys/uptime'
8
- require 'test-unit'
9
- require 'socket'
10
- include Sys
11
-
12
- class TC_Sys_Uptime < Test::Unit::TestCase
13
- test "version is set to expected value" do
14
- assert_equal('0.7.2', Uptime::VERSION)
15
- assert_true(Uptime::VERSION.frozen?)
16
- end
17
-
18
- test "seconds method basic functionality" do
19
- assert_respond_to(Uptime, :seconds)
20
- assert_nothing_raised{ Uptime.seconds }
21
- end
22
-
23
- test "seconds method returns a plausible value" do
24
- assert_kind_of(Integer, Uptime.seconds)
25
- assert_true(Uptime.seconds > 300)
26
- end
27
-
28
- test "minutes method basic functionality" do
29
- assert_respond_to(Uptime, :minutes)
30
- assert_nothing_raised{ Uptime.minutes }
31
- end
32
-
33
- test "minutes method returns a plausible value" do
34
- assert_kind_of(Integer, Uptime.minutes)
35
- assert_true(Uptime.minutes > 5)
36
- end
37
-
38
- test "hours method basic functionality" do
39
- assert_respond_to(Uptime, :hours)
40
- assert_nothing_raised{ Uptime.hours }
41
- end
42
-
43
- test "hours method returns a plausible value" do
44
- assert_kind_of(Integer, Uptime.hours)
45
- assert_true(Uptime.hours > 0)
46
- end
47
-
48
- test "days method basic functionality" do
49
- assert_respond_to(Uptime, :days)
50
- assert_nothing_raised{ Uptime.days }
51
- end
52
-
53
- test "days method returns a plausible value" do
54
- assert_kind_of(Integer, Uptime.days)
55
- assert_true(Uptime.days >= 0)
56
- end
57
-
58
- test "uptime method basic functionality" do
59
- assert_respond_to(Uptime, :uptime)
60
- assert_nothing_raised{ Uptime.uptime }
61
- end
62
-
63
- test "uptime method returns a non-empty string" do
64
- assert_kind_of(String, Uptime.uptime)
65
- assert_false(Uptime.uptime.empty?)
66
- end
67
-
68
- test "uptime method does not accept any arguments" do
69
- omit_if(File::ALT_SEPARATOR)
70
- assert_raise(ArgumentError){ Uptime.uptime(1) }
71
- end
72
-
73
- test "uptime accepts a host name on Windows" do
74
- omit_unless(File::ALT_SEPARATOR, "MS Windows only")
75
- assert_nothing_raised{ Uptime.uptime(Socket.gethostname) }
76
- end
77
-
78
- test "dhms method basic functionality" do
79
- assert_respond_to(Uptime, :dhms)
80
- assert_nothing_raised{ Uptime.dhms }
81
- assert_kind_of(Array, Uptime.dhms)
82
- end
83
-
84
- test "dhms method returns an array of four elements" do
85
- assert_false(Uptime.dhms.empty?)
86
- assert_equal(4, Uptime.dhms.length)
87
- end
88
-
89
- test "boot_time method basic functionality" do
90
- assert_respond_to(Uptime, :boot_time)
91
- assert_nothing_raised{ Uptime.boot_time }
92
- end
93
-
94
- test "boot_time method returns a Time object" do
95
- assert_kind_of(Time, Uptime.boot_time)
96
- end
97
-
98
- test "Uptime class cannot be instantiated" do
99
- assert_kind_of(StandardError, Uptime::Error.new)
100
- end
101
-
102
- test "Ensure that ffi functions are private" do
103
- methods = Uptime.methods(false).map{ |e| e.to_s }
104
- assert_false(methods.include?('time'))
105
- assert_false(methods.include?('times'))
106
- end
107
- end