sys-uptime 0.7.6 → 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: '09aa4c4ea6a68982ee2b7574e18041b0a476f06f3531e71736d83d54b3322b49'
4
- data.tar.gz: 4aab0dd2a800aa78d4597876c1e7889e8970037e9493d1a0faf7780c81133b9b
3
+ metadata.gz: 2957cde7da0c9e0e2acb79ab96d53b03f3b0171fd54d394ac1502e6a145ffe88
4
+ data.tar.gz: ef6b4b6604056498d634208a2abe7e9375cf612b44f3215157e44e5b7cf97387
5
5
  SHA512:
6
- metadata.gz: 222cc669eccbd1d04ea4d5410be8193b265dac268c4bb1e652d9e560a8d4c119225626abf103112988402d215d78ebab1ce317350e87cdd95af5c561ddd9b7c1
7
- data.tar.gz: 599316932c555fb289ff1f9aa277e397f33764e474ce16d9e8244e0e3373d9a60fc355f688afe7f963f42c033c6c0df927d0295b8df42796023a813aa780b77f
6
+ metadata.gz: 2a00c7b0333a433ea9546454fd8a80ae2c158e9e37aa66cbb6888728ea5d89ac3c277bc33841e905fa358a6470f40f82d3d63cf26f7fcd3604e403cfb57283db
7
+ data.tar.gz: 83ff78420f11ed0f98f1861c68dfe687029fc18057386f708fc91d1752cae54dbdfebbe0c9d310163b1ece605ab9f2c0e2983f5ed96c26154e80cd3ffa9a16f8
checksums.yaml.gz.sig CHANGED
Binary file
data/CHANGES.md CHANGED
@@ -1,3 +1,7 @@
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
+
1
5
  ## 0.7.6 - 9-Apr-2023
2
6
  * Constructor is now officially private, as are several constants that were
3
7
  never meant to be public.
data/README.md CHANGED
@@ -10,6 +10,9 @@ ffi 0.1.0 or later on Unixy platforms.
10
10
 
11
11
  `gem install sys-uptime`
12
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
+
13
16
  ## Synopsis
14
17
  ```ruby
15
18
  require 'sys-uptime'
@@ -30,12 +33,12 @@ p Uptime.boot_time
30
33
  ```
31
34
 
32
35
  ## Notes
33
- On MS Windows the +Uptime.uptime+ and +Uptime.boot_time+ methods optionally
36
+ On MS Windows the `Uptime.uptime` and `Uptime.boot_time` methods optionally
34
37
  takes a host name as a single argument. The default is localhost.
35
38
 
36
39
  The current time, users and load average are not included in this library
37
40
  module, even though you may be used to seeing them with the command
38
- line version of +uptime+.
41
+ line version of `uptime`.
39
42
 
40
43
  ## Known Bugs
41
44
  None that I am aware of. Please log any bugs you find on the project
@@ -48,7 +51,7 @@ website at https://github.com/djberg96/sys-uptime.
48
51
  Apache-2.0
49
52
 
50
53
  ## Copyright
51
- Copyright 2002-2023, Daniel J. Berger
54
+ Copyright 2002-2025, Daniel J. Berger
52
55
 
53
56
  All Rights Reserved. This module is free software. It may be used,
54
57
  redistributed and/or modified under the same terms as Ruby itself.
@@ -39,14 +39,15 @@ module Sys
39
39
 
40
40
  CTL_KERN = 1 # Kernel
41
41
  KERN_BOOTTIME = 21 # Time kernel was booted
42
- TICKS = 100 # Ticks per second (TODO: use sysconf)
43
42
  BOOT_TIME = 2 # Boot time
43
+ SC_CLK_TCK = 2 # Sysconf parameter for clock ticks per second
44
44
 
45
45
  private_constant :CTL_KERN
46
46
  private_constant :KERN_BOOTTIME
47
- private_constant :TICKS
48
47
  private_constant :BOOT_TIME
48
+ private_constant :SC_CLK_TCK
49
49
 
50
+ # Private wrapper class for struct tms
50
51
  class Tms < FFI::Struct
51
52
  layout(
52
53
  :tms_utime, :clock_t,
@@ -58,6 +59,7 @@ module Sys
58
59
 
59
60
  private_constant :Tms
60
61
 
62
+ # Private wrapper class for struct timeval
61
63
  class Timeval < FFI::Struct
62
64
  layout(
63
65
  :tv_sec, :long,
@@ -67,6 +69,7 @@ module Sys
67
69
 
68
70
  private_constant :Timeval
69
71
 
72
+ # Private wrapper class for struct exit_status
70
73
  class ExitStatus < FFI::Struct
71
74
  layout(
72
75
  :e_termination, :short,
@@ -76,6 +79,7 @@ module Sys
76
79
 
77
80
  private_constant :ExitStatus
78
81
 
82
+ # Private wrapper class for struct utmpx
79
83
  class Utmpx < FFI::Struct
80
84
  layout(
81
85
  :ut_user, [:char, 32],
@@ -93,6 +97,17 @@ module Sys
93
97
 
94
98
  private_constant :Utmpx
95
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
110
+
96
111
  # Returns a Time object indicating the time the system was last booted.
97
112
  #
98
113
  # Example:
@@ -155,7 +170,7 @@ module Sys
155
170
  time(nil) - tv[:tv_sec]
156
171
  else
157
172
  tms = Tms.new
158
- times(tms) / TICKS
173
+ times(tms) / ticks_per_second
159
174
  end
160
175
  end
161
176
 
data/lib/sys/uptime.rb CHANGED
@@ -11,7 +11,7 @@ module Sys
11
11
  # The Uptime class serves as a base singleton class to hang uptime related methods on.
12
12
  class Uptime
13
13
  # The version of the sys-uptime library
14
- VERSION = '0.7.6'
14
+ VERSION = '0.8.0'
15
15
 
16
16
  private_class_method :new
17
17
  end
@@ -14,7 +14,7 @@ RSpec.describe Sys::Uptime do
14
14
  let(:plausible_seconds) { ENV['CI'] ? 30 : 120 }
15
15
 
16
16
  example 'version is set to expected value' do
17
- expect(Sys::Uptime::VERSION).to eql('0.7.6')
17
+ expect(Sys::Uptime::VERSION).to eql('0.8.0')
18
18
  expect(Sys::Uptime::VERSION.frozen?).to be(true)
19
19
  end
20
20
 
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.7.6'
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'
@@ -31,7 +31,8 @@ Gem::Specification.new do |spec|
31
31
  'source_code_uri' => 'https://github.com/djberg96/sys-uptime',
32
32
  'wiki_uri' => 'https://github.com/djberg96/sys-uptime/wiki',
33
33
  'rubygems_mfa_required' => 'true',
34
- 'github_repo' => 'https://github.com/djberg96/sys-uptime'
34
+ 'github_repo' => 'https://github.com/djberg96/sys-uptime',
35
+ 'funding_uri' => 'https://github.com/sponsors/djberg96'
35
36
  }
36
37
 
37
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.7.6
4
+ version: 0.8.0
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: 2023-04-10 00:00:00.000000000 Z
38
+ date: 2025-07-08 00:00:00.000000000 Z
39
39
  dependencies:
40
40
  - !ruby/object:Gem::Dependency
41
41
  name: ffi
@@ -142,6 +142,7 @@ metadata:
142
142
  wiki_uri: https://github.com/djberg96/sys-uptime/wiki
143
143
  rubygems_mfa_required: 'true'
144
144
  github_repo: https://github.com/djberg96/sys-uptime
145
+ funding_uri: https://github.com/sponsors/djberg96
145
146
  post_install_message:
146
147
  rdoc_options: []
147
148
  require_paths:
@@ -157,7 +158,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
157
158
  - !ruby/object:Gem::Version
158
159
  version: '0'
159
160
  requirements: []
160
- rubygems_version: 3.3.26
161
+ rubygems_version: 3.5.22
161
162
  signing_key:
162
163
  specification_version: 4
163
164
  summary: A Ruby interface for getting system uptime information.
metadata.gz.sig CHANGED
Binary file