sys-uptime 0.7.5 → 0.8.0
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 +4 -4
- checksums.yaml.gz.sig +0 -0
- data/CHANGES.md +11 -0
- data/Gemfile +2 -11
- data/README.md +9 -4
- data/Rakefile +4 -8
- data/lib/sys/unix/sys/uptime.rb +42 -15
- data/lib/sys/uptime.rb +7 -1
- data/lib/sys/windows/sys/uptime.rb +12 -15
- data/lib/sys-uptime.rb +2 -0
- data/spec/sys_uptime_spec.rb +61 -53
- data/sys-uptime.gemspec +20 -8
- data.tar.gz.sig +0 -0
- metadata +55 -10
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2957cde7da0c9e0e2acb79ab96d53b03f3b0171fd54d394ac1502e6a145ffe88
|
4
|
+
data.tar.gz: ef6b4b6604056498d634208a2abe7e9375cf612b44f3215157e44e5b7cf97387
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2a00c7b0333a433ea9546454fd8a80ae2c158e9e37aa66cbb6888728ea5d89ac3c277bc33841e905fa358a6470f40f82d3d63cf26f7fcd3604e403cfb57283db
|
7
|
+
data.tar.gz: 83ff78420f11ed0f98f1861c68dfe687029fc18057386f708fc91d1752cae54dbdfebbe0c9d310163b1ece605ab9f2c0e2983f5ed96c26154e80cd3ffa9a16f8
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/CHANGES.md
CHANGED
@@ -1,3 +1,14 @@
|
|
1
|
+
## 0.8.0 - 7-Jul-2025
|
2
|
+
* Use sysconf instead of hard coded value for ticks on Unixy platforms that
|
3
|
+
aren't Linux and don't define sysctl.
|
4
|
+
|
5
|
+
## 0.7.6 - 9-Apr-2023
|
6
|
+
* Constructor is now officially private, as are several constants that were
|
7
|
+
never meant to be public.
|
8
|
+
* Lots of rubocop suggested updates.
|
9
|
+
* Minor refactoring for Windows.
|
10
|
+
* Minor updates, including Rakefile and gemspec metadata.
|
11
|
+
|
1
12
|
## 0.7.5 - 29-Oct-2020
|
2
13
|
* Switched docs to markdown format.
|
3
14
|
* Added a Gemfile.
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
[](https://github.com/djberg96/sys-uptime/actions/workflows/ruby.yml)
|
2
|
+
|
1
3
|
## Description
|
2
4
|
A Ruby interface for getting system uptime information.
|
3
5
|
|
@@ -8,8 +10,11 @@ ffi 0.1.0 or later on Unixy platforms.
|
|
8
10
|
|
9
11
|
`gem install sys-uptime`
|
10
12
|
|
13
|
+
## Adding the trusted cert
|
14
|
+
`gem cert --add <(curl -Ls https://raw.githubusercontent.com/djberg96/sys-uptime/main/certs/djberg96_pub.pem)`
|
15
|
+
|
11
16
|
## Synopsis
|
12
|
-
```
|
17
|
+
```ruby
|
13
18
|
require 'sys-uptime'
|
14
19
|
include Sys
|
15
20
|
|
@@ -28,12 +33,12 @@ p Uptime.boot_time
|
|
28
33
|
```
|
29
34
|
|
30
35
|
## Notes
|
31
|
-
On MS Windows the
|
36
|
+
On MS Windows the `Uptime.uptime` and `Uptime.boot_time` methods optionally
|
32
37
|
takes a host name as a single argument. The default is localhost.
|
33
38
|
|
34
39
|
The current time, users and load average are not included in this library
|
35
40
|
module, even though you may be used to seeing them with the command
|
36
|
-
line version of
|
41
|
+
line version of `uptime`.
|
37
42
|
|
38
43
|
## Known Bugs
|
39
44
|
None that I am aware of. Please log any bugs you find on the project
|
@@ -46,7 +51,7 @@ website at https://github.com/djberg96/sys-uptime.
|
|
46
51
|
Apache-2.0
|
47
52
|
|
48
53
|
## Copyright
|
49
|
-
Copyright 2002-
|
54
|
+
Copyright 2002-2025, Daniel J. Berger
|
50
55
|
|
51
56
|
All Rights Reserved. This module is free software. It may be used,
|
52
57
|
redistributed and/or modified under the same terms as Ruby itself.
|
data/Rakefile
CHANGED
@@ -2,6 +2,7 @@ require 'rake'
|
|
2
2
|
require 'rake/clean'
|
3
3
|
require 'rake/testtask'
|
4
4
|
require 'rspec/core/rake_task'
|
5
|
+
require 'rubocop/rake_task'
|
5
6
|
|
6
7
|
CLEAN.include("**/*.gem", "**/*.rbx", "**/*.rbc", "**/*.lock")
|
7
8
|
|
@@ -9,15 +10,8 @@ namespace 'gem' do
|
|
9
10
|
desc 'Build the sys-uptime gem'
|
10
11
|
task :create => [:clean] do
|
11
12
|
require 'rubygems/package'
|
12
|
-
spec =
|
13
|
+
spec = Gem::Specification.load('sys-uptime.gemspec')
|
13
14
|
spec.signing_key = File.join(Dir.home, '.ssh', 'gem-private_key.pem')
|
14
|
-
|
15
|
-
if File::ALT_SEPARATOR
|
16
|
-
spec.platform = Gem::Platform.new(['universal', 'mingw32'])
|
17
|
-
else
|
18
|
-
spec.add_dependency('ffi', '~> 1.1')
|
19
|
-
end
|
20
|
-
|
21
15
|
Gem::Package.build(spec)
|
22
16
|
end
|
23
17
|
|
@@ -28,6 +22,8 @@ namespace 'gem' do
|
|
28
22
|
end
|
29
23
|
end
|
30
24
|
|
25
|
+
RuboCop::RakeTask.new
|
26
|
+
|
31
27
|
desc "Run the test suite"
|
32
28
|
RSpec::Core::RakeTask.new(:spec)
|
33
29
|
|
data/lib/sys/unix/sys/uptime.rb
CHANGED
@@ -1,8 +1,9 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'ffi'
|
2
4
|
|
3
5
|
# The Sys module serves as a namespace only.
|
4
6
|
module Sys
|
5
|
-
|
6
7
|
# The Uptime class encapsulates various bits of information regarding your
|
7
8
|
# system's uptime, including boot time.
|
8
9
|
class Uptime
|
@@ -12,8 +13,6 @@ module Sys
|
|
12
13
|
# Error typically raised in one of the Uptime methods should fail.
|
13
14
|
class Error < StandardError; end
|
14
15
|
|
15
|
-
private
|
16
|
-
|
17
16
|
# Hit this issue on Linux, not sure why
|
18
17
|
begin
|
19
18
|
find_type(:clock_t)
|
@@ -29,7 +28,7 @@ module Sys
|
|
29
28
|
private_class_method :strerror, :sysconf, :time, :times, :new
|
30
29
|
|
31
30
|
begin
|
32
|
-
attach_function :sysctl, [
|
31
|
+
attach_function :sysctl, %i[pointer uint pointer pointer pointer size_t], :int
|
33
32
|
private_class_method :sysctl
|
34
33
|
rescue FFI::NotFoundError
|
35
34
|
attach_function :setutxent, [], :void
|
@@ -40,9 +39,15 @@ module Sys
|
|
40
39
|
|
41
40
|
CTL_KERN = 1 # Kernel
|
42
41
|
KERN_BOOTTIME = 21 # Time kernel was booted
|
43
|
-
TICKS = 100 # Ticks per second (TODO: use sysconf)
|
44
42
|
BOOT_TIME = 2 # Boot time
|
43
|
+
SC_CLK_TCK = 2 # Sysconf parameter for clock ticks per second
|
45
44
|
|
45
|
+
private_constant :CTL_KERN
|
46
|
+
private_constant :KERN_BOOTTIME
|
47
|
+
private_constant :BOOT_TIME
|
48
|
+
private_constant :SC_CLK_TCK
|
49
|
+
|
50
|
+
# Private wrapper class for struct tms
|
46
51
|
class Tms < FFI::Struct
|
47
52
|
layout(
|
48
53
|
:tms_utime, :clock_t,
|
@@ -52,6 +57,9 @@ module Sys
|
|
52
57
|
)
|
53
58
|
end
|
54
59
|
|
60
|
+
private_constant :Tms
|
61
|
+
|
62
|
+
# Private wrapper class for struct timeval
|
55
63
|
class Timeval < FFI::Struct
|
56
64
|
layout(
|
57
65
|
:tv_sec, :long,
|
@@ -59,6 +67,9 @@ module Sys
|
|
59
67
|
)
|
60
68
|
end
|
61
69
|
|
70
|
+
private_constant :Timeval
|
71
|
+
|
72
|
+
# Private wrapper class for struct exit_status
|
62
73
|
class ExitStatus < FFI::Struct
|
63
74
|
layout(
|
64
75
|
:e_termination, :short,
|
@@ -66,6 +77,9 @@ module Sys
|
|
66
77
|
)
|
67
78
|
end
|
68
79
|
|
80
|
+
private_constant :ExitStatus
|
81
|
+
|
82
|
+
# Private wrapper class for struct utmpx
|
69
83
|
class Utmpx < FFI::Struct
|
70
84
|
layout(
|
71
85
|
:ut_user, [:char, 32],
|
@@ -81,7 +95,18 @@ module Sys
|
|
81
95
|
)
|
82
96
|
end
|
83
97
|
|
84
|
-
|
98
|
+
private_constant :Utmpx
|
99
|
+
|
100
|
+
# Get ticks per second using sysconf, fallback to 100 if not available
|
101
|
+
def self.ticks_per_second
|
102
|
+
@ticks_per_second ||= begin
|
103
|
+
sysconf(SC_CLK_TCK)
|
104
|
+
rescue
|
105
|
+
100
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
private_class_method :ticks_per_second
|
85
110
|
|
86
111
|
# Returns a Time object indicating the time the system was last booted.
|
87
112
|
#
|
@@ -91,14 +116,14 @@ module Sys
|
|
91
116
|
#
|
92
117
|
def self.boot_time
|
93
118
|
if RbConfig::CONFIG['host_os'] =~ /linux/i
|
94
|
-
Time.now -
|
119
|
+
Time.now - seconds
|
95
120
|
elsif respond_to?(:sysctl, true)
|
96
121
|
tv = Timeval.new
|
97
122
|
mib = FFI::MemoryPointer.new(:int, 2).write_array_of_int([CTL_KERN, KERN_BOOTTIME])
|
98
123
|
size = FFI::MemoryPointer.new(:long, 1).write_int(tv.size)
|
99
124
|
|
100
125
|
if sysctl(mib, 2, tv, size, nil, 0) != 0
|
101
|
-
raise SystemCallError,
|
126
|
+
raise SystemCallError, "sysctl function failed: #{strerror(FFI.errno)}"
|
102
127
|
end
|
103
128
|
|
104
129
|
Time.at(tv[:tv_sec], tv[:tv_usec])
|
@@ -126,24 +151,26 @@ module Sys
|
|
126
151
|
#
|
127
152
|
def self.seconds
|
128
153
|
if RbConfig::CONFIG['host_os'] =~ /linux/i
|
154
|
+
# rubocop:disable Lint/RescueException
|
129
155
|
begin
|
130
|
-
|
156
|
+
File.read('/proc/uptime').split.first.to_i
|
131
157
|
rescue Exception => err
|
132
158
|
raise Error, err
|
133
159
|
end
|
160
|
+
# rubocop:enable Lint/RescueException
|
134
161
|
elsif respond_to?(:sysctl, true)
|
135
162
|
tv = Timeval.new
|
136
163
|
mib = FFI::MemoryPointer.new(:int, 2).write_array_of_int([CTL_KERN, KERN_BOOTTIME])
|
137
164
|
size = FFI::MemoryPointer.new(:long, 1).write_int(tv.size)
|
138
165
|
|
139
166
|
if sysctl(mib, 2, tv, size, nil, 0) != 0
|
140
|
-
raise SystemCallError,
|
167
|
+
raise SystemCallError, "sysctl function failed: #{strerror(FFI.errno)}"
|
141
168
|
end
|
142
169
|
|
143
170
|
time(nil) - tv[:tv_sec]
|
144
171
|
else
|
145
172
|
tms = Tms.new
|
146
|
-
times(tms) /
|
173
|
+
times(tms) / ticks_per_second
|
147
174
|
end
|
148
175
|
end
|
149
176
|
|
@@ -187,11 +214,11 @@ module Sys
|
|
187
214
|
def self.uptime
|
188
215
|
secs = seconds
|
189
216
|
days = secs / 86400
|
190
|
-
secs
|
217
|
+
secs -= days * 86400
|
191
218
|
hours = secs / 3600
|
192
|
-
secs
|
193
|
-
mins
|
194
|
-
secs
|
219
|
+
secs -= hours * 3600
|
220
|
+
mins = secs / 60
|
221
|
+
secs -= mins * 60
|
195
222
|
|
196
223
|
"#{days}:#{hours}:#{mins}:#{secs}"
|
197
224
|
end
|
data/lib/sys/uptime.rb
CHANGED
@@ -1,12 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
if File::ALT_SEPARATOR
|
2
4
|
require_relative 'windows/sys/uptime'
|
3
5
|
else
|
4
6
|
require_relative 'unix/sys/uptime'
|
5
7
|
end
|
6
8
|
|
9
|
+
# The Sys module serves as a namespace only.
|
7
10
|
module Sys
|
11
|
+
# The Uptime class serves as a base singleton class to hang uptime related methods on.
|
8
12
|
class Uptime
|
9
13
|
# The version of the sys-uptime library
|
10
|
-
VERSION = '0.
|
14
|
+
VERSION = '0.8.0'
|
15
|
+
|
16
|
+
private_class_method :new
|
11
17
|
end
|
12
18
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'win32ole'
|
2
4
|
require 'socket'
|
3
5
|
require 'date'
|
@@ -5,11 +7,9 @@ require 'time'
|
|
5
7
|
|
6
8
|
# The Sys module serves as a namespace only.
|
7
9
|
module Sys
|
8
|
-
|
9
10
|
# The Uptime class encapsulates various bits of information regarding your
|
10
11
|
# system's uptime, including boot time.
|
11
12
|
class Uptime
|
12
|
-
|
13
13
|
# Error typically raised in one of the Uptime methods should fail.
|
14
14
|
class Error < StandardError; end
|
15
15
|
|
@@ -26,15 +26,12 @@ module Sys
|
|
26
26
|
cs = "winmgmts://#{host}/root/cimv2"
|
27
27
|
begin
|
28
28
|
wmi = WIN32OLE.connect(cs)
|
29
|
-
rescue WIN32OLERuntimeError =>
|
30
|
-
raise Error,
|
29
|
+
rescue WIN32OLERuntimeError => err
|
30
|
+
raise Error, err
|
31
31
|
else
|
32
|
-
query =
|
33
|
-
|
34
|
-
|
35
|
-
time_array = parse_ms_date(ole.LastBootupTime)
|
36
|
-
return Time.mktime(*time_array)
|
37
|
-
}
|
32
|
+
query = 'select LastBootupTime from Win32_OperatingSystem'
|
33
|
+
result = wmi.ExecQuery(query).itemIndex(0).LastBootupTime
|
34
|
+
Time.parse(result.split('.').first)
|
38
35
|
end
|
39
36
|
end
|
40
37
|
|
@@ -81,7 +78,7 @@ module Sys
|
|
81
78
|
#
|
82
79
|
# Sys::Uptime.hours # => 33
|
83
80
|
#
|
84
|
-
def self.hours(host=Socket.gethostname)
|
81
|
+
def self.hours(host = Socket.gethostname)
|
85
82
|
minutes(host) / 60
|
86
83
|
end
|
87
84
|
|
@@ -92,7 +89,7 @@ module Sys
|
|
92
89
|
#
|
93
90
|
# Sys::Uptime.minutes # => 1980
|
94
91
|
#
|
95
|
-
def self.minutes(host=Socket.gethostname)
|
92
|
+
def self.minutes(host = Socket.gethostname)
|
96
93
|
seconds(host) / 60
|
97
94
|
end
|
98
95
|
|
@@ -103,7 +100,7 @@ module Sys
|
|
103
100
|
#
|
104
101
|
# Sys::Uptime.seconds # => 118800
|
105
102
|
#
|
106
|
-
def self.seconds(host=Socket.gethostname)
|
103
|
+
def self.seconds(host = Socket.gethostname)
|
107
104
|
get_seconds(host)
|
108
105
|
end
|
109
106
|
|
@@ -114,7 +111,7 @@ module Sys
|
|
114
111
|
#
|
115
112
|
def self.parse_ms_date(str)
|
116
113
|
return if str.nil?
|
117
|
-
|
114
|
+
Time.parse(str.split('.').first)
|
118
115
|
end
|
119
116
|
|
120
117
|
private_class_method :parse_ms_date
|
@@ -139,7 +136,7 @@ module Sys
|
|
139
136
|
# Returns the number of seconds since boot.
|
140
137
|
#
|
141
138
|
def self.get_seconds(host)
|
142
|
-
(Time.now - boot_time).to_i
|
139
|
+
(Time.now - boot_time(host)).to_i
|
143
140
|
end
|
144
141
|
|
145
142
|
private_class_method :get_seconds
|
data/lib/sys-uptime.rb
CHANGED
data/spec/sys_uptime_spec.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
#####################################################################
|
2
4
|
# sys_uptime_spec.rb
|
3
5
|
#
|
@@ -8,96 +10,102 @@ require 'sys/uptime'
|
|
8
10
|
require 'rspec'
|
9
11
|
require 'socket'
|
10
12
|
|
11
|
-
describe Sys::Uptime do
|
12
|
-
|
13
|
-
|
13
|
+
RSpec.describe Sys::Uptime do
|
14
|
+
let(:plausible_seconds) { ENV['CI'] ? 30 : 120 }
|
15
|
+
|
16
|
+
example 'version is set to expected value' do
|
17
|
+
expect(Sys::Uptime::VERSION).to eql('0.8.0')
|
14
18
|
expect(Sys::Uptime::VERSION.frozen?).to be(true)
|
15
19
|
end
|
16
20
|
|
17
|
-
example
|
18
|
-
expect
|
19
|
-
|
21
|
+
example 'constructor is private' do
|
22
|
+
expect{ described_class.new }.to raise_error(NoMethodError)
|
23
|
+
end
|
24
|
+
|
25
|
+
example 'seconds method basic functionality' do
|
26
|
+
expect(described_class).to respond_to(:seconds)
|
27
|
+
expect{ described_class.seconds }.not_to raise_error
|
20
28
|
end
|
21
29
|
|
22
|
-
example
|
23
|
-
expect(
|
24
|
-
expect(
|
30
|
+
example 'seconds method returns a plausible value' do
|
31
|
+
expect(described_class.seconds).to be_a(Integer)
|
32
|
+
expect(described_class.seconds).to be > plausible_seconds
|
25
33
|
end
|
26
34
|
|
27
|
-
example
|
28
|
-
expect(
|
29
|
-
expect{
|
35
|
+
example 'minutes method basic functionality' do
|
36
|
+
expect(described_class).to respond_to(:minutes)
|
37
|
+
expect{ described_class.minutes }.not_to raise_error
|
30
38
|
end
|
31
39
|
|
32
|
-
example
|
33
|
-
expect(
|
34
|
-
expect(
|
40
|
+
example 'minutes method returns a plausible value', :unless => ENV.fetch('CI', nil) do
|
41
|
+
expect(described_class.minutes).to be_a(Integer)
|
42
|
+
expect(described_class.minutes).to be > 3
|
35
43
|
end
|
36
44
|
|
37
|
-
example
|
38
|
-
expect(
|
39
|
-
expect{
|
45
|
+
example 'hours method basic functionality' do
|
46
|
+
expect(described_class).to respond_to(:hours)
|
47
|
+
expect{ described_class.hours }.not_to raise_error
|
40
48
|
end
|
41
49
|
|
42
|
-
example
|
43
|
-
expect(
|
44
|
-
expect(
|
50
|
+
example 'hours method returns a plausible value' do
|
51
|
+
expect(described_class.hours).to be_a(Integer)
|
52
|
+
expect(described_class.hours).to be >= 0
|
45
53
|
end
|
46
54
|
|
47
|
-
example
|
48
|
-
expect(
|
49
|
-
expect{
|
55
|
+
example 'days method basic functionality' do
|
56
|
+
expect(described_class).to respond_to(:days)
|
57
|
+
expect{ described_class.days }.not_to raise_error
|
50
58
|
end
|
51
59
|
|
52
|
-
example
|
53
|
-
expect(
|
54
|
-
expect(
|
60
|
+
example 'days method returns a plausible value' do
|
61
|
+
expect(described_class.days).to be_a(Integer)
|
62
|
+
expect(described_class.days).to be >= 0
|
55
63
|
end
|
56
64
|
|
57
|
-
example
|
58
|
-
expect(
|
59
|
-
expect{
|
65
|
+
example 'uptime method basic functionality' do
|
66
|
+
expect(described_class).to respond_to(:uptime)
|
67
|
+
expect{ described_class.uptime }.not_to raise_error
|
60
68
|
end
|
61
69
|
|
62
|
-
example
|
63
|
-
expect(
|
64
|
-
expect(
|
70
|
+
example 'uptime method returns a non-empty string' do
|
71
|
+
expect(described_class.uptime).to be_a(String)
|
72
|
+
expect(described_class.uptime.empty?).to be(false)
|
65
73
|
end
|
66
74
|
|
67
|
-
example
|
68
|
-
expect{
|
75
|
+
example 'uptime method does not accept any arguments', :unless => File::ALT_SEPARATOR do
|
76
|
+
expect{ described_class.uptime(1) }.to raise_error(ArgumentError)
|
69
77
|
end
|
70
78
|
|
71
|
-
example
|
72
|
-
expect{
|
79
|
+
example 'uptime accepts a host name on Windows', :if => File::ALT_SEPARATOR do
|
80
|
+
expect{ described_class.uptime(Socket.gethostname) }.not_to raise_error
|
73
81
|
end
|
74
82
|
|
75
|
-
example
|
76
|
-
expect(
|
77
|
-
expect{
|
78
|
-
expect(
|
83
|
+
example 'dhms method basic functionality' do
|
84
|
+
expect(described_class).to respond_to(:dhms)
|
85
|
+
expect{ described_class.dhms }.not_to raise_error
|
86
|
+
expect(described_class.dhms).to be_a(Array)
|
79
87
|
end
|
80
88
|
|
81
|
-
example
|
82
|
-
expect(
|
83
|
-
expect(
|
89
|
+
example 'dhms method returns an array of four elements' do
|
90
|
+
expect(described_class.dhms).not_to be_empty
|
91
|
+
expect(described_class.dhms.length).to eq(4)
|
84
92
|
end
|
85
93
|
|
86
|
-
example
|
87
|
-
expect(
|
88
|
-
expect{
|
94
|
+
example 'boot_time method basic functionality' do
|
95
|
+
expect(described_class).to respond_to(:boot_time)
|
96
|
+
expect{ described_class.boot_time }.not_to raise_error
|
89
97
|
end
|
90
98
|
|
91
|
-
example
|
92
|
-
expect(
|
99
|
+
example 'boot_time method returns a Time object' do
|
100
|
+
expect(described_class.boot_time).to be_a(Time)
|
93
101
|
end
|
94
102
|
|
95
|
-
example
|
96
|
-
expect{
|
103
|
+
example 'Uptime class cannot be instantiated' do
|
104
|
+
expect{ described_class.new }.to raise_error(StandardError)
|
97
105
|
end
|
98
106
|
|
99
|
-
example
|
100
|
-
methods =
|
107
|
+
example 'Ensure that ffi functions are private' do
|
108
|
+
methods = described_class.methods(false).map(&:to_s)
|
101
109
|
expect(methods).not_to include('time', 'times')
|
102
110
|
end
|
103
111
|
end
|
data/sys-uptime.gemspec
CHANGED
@@ -2,7 +2,7 @@ require 'rubygems'
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |spec|
|
4
4
|
spec.name = 'sys-uptime'
|
5
|
-
spec.version = '0.
|
5
|
+
spec.version = '0.8.0'
|
6
6
|
spec.author = 'Daniel J. Berger'
|
7
7
|
spec.license = 'Apache-2.0'
|
8
8
|
spec.email = 'djberg96@gmail.com'
|
@@ -12,15 +12,27 @@ Gem::Specification.new do |spec|
|
|
12
12
|
spec.files = Dir["**/*"].reject{ |f| f.include?('git') }
|
13
13
|
spec.cert_chain = ['certs/djberg96_pub.pem']
|
14
14
|
|
15
|
-
|
15
|
+
if File::ALT_SEPARATOR
|
16
|
+
spec.platform = Gem::Platform.new(['universal', 'mingw32'])
|
17
|
+
else
|
18
|
+
spec.add_dependency('ffi', '~> 1.1')
|
19
|
+
end
|
20
|
+
|
21
|
+
spec.add_development_dependency('rake')
|
22
|
+
spec.add_development_dependency('rspec', '~> 3.9')
|
23
|
+
spec.add_development_dependency('rubocop')
|
24
|
+
spec.add_development_dependency('rubocop-rspec')
|
16
25
|
|
17
26
|
spec.metadata = {
|
18
|
-
'homepage_uri'
|
19
|
-
'bug_tracker_uri'
|
20
|
-
'changelog_uri'
|
21
|
-
'documentation_uri'
|
22
|
-
'source_code_uri'
|
23
|
-
'wiki_uri'
|
27
|
+
'homepage_uri' => 'https://github.com/djberg96/sys-uptime',
|
28
|
+
'bug_tracker_uri' => 'https://github.com/djberg96/sys-uptime/issues',
|
29
|
+
'changelog_uri' => 'https://github.com/djberg96/sys-uptime/blob/main/CHANGES.md',
|
30
|
+
'documentation_uri' => 'https://github.com/djberg96/sys-uptime/wiki',
|
31
|
+
'source_code_uri' => 'https://github.com/djberg96/sys-uptime',
|
32
|
+
'wiki_uri' => 'https://github.com/djberg96/sys-uptime/wiki',
|
33
|
+
'rubygems_mfa_required' => 'true',
|
34
|
+
'github_repo' => 'https://github.com/djberg96/sys-uptime',
|
35
|
+
'funding_uri' => 'https://github.com/sponsors/djberg96'
|
24
36
|
}
|
25
37
|
|
26
38
|
spec.description = <<-EOF
|
data.tar.gz.sig
CHANGED
Binary file
|
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.
|
4
|
+
version: 0.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel J. Berger
|
@@ -35,8 +35,36 @@ cert_chain:
|
|
35
35
|
ORVCZpRuCPpmC8qmqxUnARDArzucjaclkxjLWvCVHeFa9UP7K3Nl9oTjJNv+7/jM
|
36
36
|
WZs4eecIcUc4tKdHxcAJ0MO/Dkqq7hGaiHpwKY76wQ1+8xAh
|
37
37
|
-----END CERTIFICATE-----
|
38
|
-
date:
|
38
|
+
date: 2025-07-08 00:00:00.000000000 Z
|
39
39
|
dependencies:
|
40
|
+
- !ruby/object:Gem::Dependency
|
41
|
+
name: ffi
|
42
|
+
requirement: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - "~>"
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '1.1'
|
47
|
+
type: :runtime
|
48
|
+
prerelease: false
|
49
|
+
version_requirements: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - "~>"
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '1.1'
|
54
|
+
- !ruby/object:Gem::Dependency
|
55
|
+
name: rake
|
56
|
+
requirement: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - ">="
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '0'
|
61
|
+
type: :development
|
62
|
+
prerelease: false
|
63
|
+
version_requirements: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - ">="
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: '0'
|
40
68
|
- !ruby/object:Gem::Dependency
|
41
69
|
name: rspec
|
42
70
|
requirement: !ruby/object:Gem::Requirement
|
@@ -52,19 +80,33 @@ dependencies:
|
|
52
80
|
- !ruby/object:Gem::Version
|
53
81
|
version: '3.9'
|
54
82
|
- !ruby/object:Gem::Dependency
|
55
|
-
name:
|
83
|
+
name: rubocop
|
56
84
|
requirement: !ruby/object:Gem::Requirement
|
57
85
|
requirements:
|
58
|
-
- - "
|
86
|
+
- - ">="
|
59
87
|
- !ruby/object:Gem::Version
|
60
|
-
version: '
|
61
|
-
type: :
|
88
|
+
version: '0'
|
89
|
+
type: :development
|
62
90
|
prerelease: false
|
63
91
|
version_requirements: !ruby/object:Gem::Requirement
|
64
92
|
requirements:
|
65
|
-
- - "
|
93
|
+
- - ">="
|
66
94
|
- !ruby/object:Gem::Version
|
67
|
-
version: '
|
95
|
+
version: '0'
|
96
|
+
- !ruby/object:Gem::Dependency
|
97
|
+
name: rubocop-rspec
|
98
|
+
requirement: !ruby/object:Gem::Requirement
|
99
|
+
requirements:
|
100
|
+
- - ">="
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: '0'
|
103
|
+
type: :development
|
104
|
+
prerelease: false
|
105
|
+
version_requirements: !ruby/object:Gem::Requirement
|
106
|
+
requirements:
|
107
|
+
- - ">="
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
68
110
|
description: |2
|
69
111
|
The sys-uptime library is a simple interface for gathering uptime
|
70
112
|
information. You can retrieve data in seconds, minutes, days, hours,
|
@@ -94,10 +136,13 @@ licenses:
|
|
94
136
|
metadata:
|
95
137
|
homepage_uri: https://github.com/djberg96/sys-uptime
|
96
138
|
bug_tracker_uri: https://github.com/djberg96/sys-uptime/issues
|
97
|
-
changelog_uri: https://github.com/djberg96/sys-uptime/blob/
|
139
|
+
changelog_uri: https://github.com/djberg96/sys-uptime/blob/main/CHANGES.md
|
98
140
|
documentation_uri: https://github.com/djberg96/sys-uptime/wiki
|
99
141
|
source_code_uri: https://github.com/djberg96/sys-uptime
|
100
142
|
wiki_uri: https://github.com/djberg96/sys-uptime/wiki
|
143
|
+
rubygems_mfa_required: 'true'
|
144
|
+
github_repo: https://github.com/djberg96/sys-uptime
|
145
|
+
funding_uri: https://github.com/sponsors/djberg96
|
101
146
|
post_install_message:
|
102
147
|
rdoc_options: []
|
103
148
|
require_paths:
|
@@ -113,7 +158,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
113
158
|
- !ruby/object:Gem::Version
|
114
159
|
version: '0'
|
115
160
|
requirements: []
|
116
|
-
rubygems_version: 3.
|
161
|
+
rubygems_version: 3.5.22
|
117
162
|
signing_key:
|
118
163
|
specification_version: 4
|
119
164
|
summary: A Ruby interface for getting system uptime information.
|
metadata.gz.sig
CHANGED
Binary file
|