sys-uptime 0.7.2-universal-mingw32 → 0.7.3-universal-mingw32
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +4 -2
- data.tar.gz.sig +0 -0
- data/{CHANGES → CHANGES.rdoc} +9 -0
- data/{MANIFEST → MANIFEST.rdoc} +4 -4
- data/README.rdoc +67 -0
- data/Rakefile +3 -11
- data/lib/sys/unix/sys/uptime.rb +1 -1
- data/lib/sys/uptime.rb +1 -1
- data/lib/sys/windows/sys/uptime.rb +3 -0
- data/spec/sys_uptime_spec.rb +103 -0
- data/sys-uptime.gemspec +5 -4
- metadata +28 -15
- metadata.gz.sig +0 -0
- data/README +0 -66
- data/test/test_sys_uptime.rb +0 -107
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d7827091dd7125a7ad60624559b9b7f54e71b8cc6618f05a9cc170dbe537e2ec
|
4
|
+
data.tar.gz: 62e980ba422eb79f8b460cb9608b5b3debab1fb2a086ee58cf230f11cd249eb8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4304da8a34289d133c89a77ba5dc7c9ac3731380f1061a5b3fd5070b04768cd6119976b4abd70acb9d95d567a9403fb5b702473d4f9f2074a3e0f57bc972595f
|
7
|
+
data.tar.gz: 8f6de7fa09186f89b73e1340ef7867310bbecf4bb60628c06ef94fc31a9b3fe78b34dc46025abd76a1421b0bf5453fbf3bfa9481e72cbc644bbac9b6fff35e5f
|
checksums.yaml.gz.sig
CHANGED
@@ -1,2 +1,4 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
r���1iQ�{C�0o X����eh
|
2
|
+
OM2�%��CzMP���"M���Iqt����a�]��LO��� o|'�?1�A��8���$�#(�㶈�Y(�;�F�Ƽ���Z�w7�
|
3
|
+
S���j;�[!��oY��z,}r`m���.�v�+"��8������w�� ^��?̷��J3v�4tߐm2�/�ٌ��V�Z!�g�Y�ɺ�:�[����7�`)����#�_q��)F�g&P`��n
|
4
|
+
� G"��%#�"��s2A�>1�i�9-h|;�D�Ǔ��m
|
data.tar.gz.sig
CHANGED
Binary file
|
data/{CHANGES → CHANGES.rdoc}
RENAMED
@@ -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.
|
data/{MANIFEST → MANIFEST.rdoc}
RENAMED
@@ -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
|
-
*
|
11
|
+
* spec/sys_uptime_spec.rb
|
data/README.rdoc
ADDED
@@ -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
|
-
|
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 => :
|
34
|
+
task :default => :spec
|
data/lib/sys/unix/sys/uptime.rb
CHANGED
@@ -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
|
data/lib/sys/uptime.rb
CHANGED
@@ -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
|
data/sys-uptime.gemspec
CHANGED
@@ -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.
|
5
|
+
spec.version = '0.7.3'
|
6
6
|
spec.author = 'Daniel J. Berger'
|
7
|
-
spec.license = 'Apache
|
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 = '
|
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
|
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.
|
4
|
+
version: 0.7.3
|
5
5
|
platform: universal-mingw32
|
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:
|
39
|
-
dependencies:
|
38
|
+
date:
|
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
|
description: |2
|
41
55
|
The sys-uptime library is a simple interface for gathering uptime
|
42
56
|
information. You can retrieve data in seconds, minutes, days, hours,
|
@@ -45,13 +59,13 @@ email: djberg96@gmail.com
|
|
45
59
|
executables: []
|
46
60
|
extensions: []
|
47
61
|
extra_rdoc_files:
|
48
|
-
- CHANGES
|
49
|
-
-
|
50
|
-
-
|
62
|
+
- CHANGES.rdoc
|
63
|
+
- MANIFEST.rdoc
|
64
|
+
- README.rdoc
|
51
65
|
files:
|
52
66
|
- certs
|
53
67
|
- certs/djberg96_pub.pem
|
54
|
-
- CHANGES
|
68
|
+
- CHANGES.rdoc
|
55
69
|
- examples
|
56
70
|
- examples/uptime_test.rb
|
57
71
|
- lib
|
@@ -64,15 +78,15 @@ files:
|
|
64
78
|
- lib/sys/windows/sys
|
65
79
|
- lib/sys/windows/sys/uptime.rb
|
66
80
|
- lib/sys-uptime.rb
|
67
|
-
- MANIFEST
|
81
|
+
- MANIFEST.rdoc
|
68
82
|
- Rakefile
|
69
|
-
- README
|
83
|
+
- README.rdoc
|
84
|
+
- spec
|
85
|
+
- spec/sys_uptime_spec.rb
|
70
86
|
- sys-uptime.gemspec
|
71
|
-
- test
|
72
|
-
- test/test_sys_uptime.rb
|
73
87
|
homepage: https://github.com/djberg96/sys-uptime
|
74
88
|
licenses:
|
75
|
-
- Apache
|
89
|
+
- Apache-2.0
|
76
90
|
metadata:
|
77
91
|
homepage_uri: https://github.com/djberg96/sys-uptime
|
78
92
|
bug_tracker_uri: https://github.com/djberg96/sys-uptime/issues
|
@@ -95,10 +109,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
95
109
|
- !ruby/object:Gem::Version
|
96
110
|
version: '0'
|
97
111
|
requirements: []
|
98
|
-
|
99
|
-
rubygems_version: 2.7.6
|
112
|
+
rubygems_version: 3.0.3
|
100
113
|
signing_key:
|
101
114
|
specification_version: 4
|
102
115
|
summary: A Ruby interface for getting system uptime information.
|
103
116
|
test_files:
|
104
|
-
-
|
117
|
+
- 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
|
data/test/test_sys_uptime.rb
DELETED
@@ -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
|