sys-uname 1.3.1 → 1.4.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 +5 -0
- data/README.md +8 -0
- data/Rakefile +4 -1
- data/doc/uname.rdoc +1 -1
- data/lib/sys/uname.rb +1 -1
- data/lib/sys/unix/uname.rb +10 -0
- data/lib/sys/windows/uname.rb +10 -0
- data/spec/sys_platform_spec.rb +1 -1
- data/spec/sys_uname_spec.rb +75 -3
- data/sys-uname.gemspec +5 -2
- data.tar.gz.sig +0 -0
- metadata +18 -3
- 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: ad4c473ea5c40f0b55c3b4532e95a8b0e2601fff9b5fa6c8d1fc356fc5441a50
|
4
|
+
data.tar.gz: 1ea8f7aa1063f6d678eeaff6913f476c11489da82d5f29b354060b462b2d2a43
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cc062981ca47f27820efe007e42ecc82889a8fce22843bac0b54b166cad6196e81db3e38ef360aa23955cf70308f6cf4c698ac8e95b4c2018969bc2710f218e4
|
7
|
+
data.tar.gz: 699d554f7c7e38e0d734445f304ecc9a2ea4c6e083da0c58fab0a07f2b7270e3dd396257b9aef952032b9ec0c95d59086fb7ab538d6256f30362af549e93acae
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/CHANGES.md
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
## 1.4.0 - 26-Aug-2025
|
2
|
+
* The sysname, nodename, release, version and machine methods are now memoized.
|
3
|
+
* The memoist gem has been added as a dependency.
|
4
|
+
* Specs added for memoization.
|
5
|
+
|
1
6
|
## 1.3.1 - 19-Nov-2024
|
2
7
|
* Remove a useless ostruct require. Thanks go to Koichi Ito for the spot and patch.
|
3
8
|
|
data/README.md
CHANGED
@@ -26,6 +26,14 @@ p Sys::Uname.uname
|
|
26
26
|
p Sys::Platform.linux? # => true
|
27
27
|
p Sys::Platform::ARCH # => :x86_64
|
28
28
|
```
|
29
|
+
|
30
|
+
## Memoist Notes
|
31
|
+
As of version 1.4.0 most methods are memoized via the memoist gem since
|
32
|
+
these values are unlikely to change during without a restart/reboot. As
|
33
|
+
per the memoist documentation, you can force a cache flush if desired to
|
34
|
+
refresh the values.
|
35
|
+
|
36
|
+
https://github.com/matthewrudy/memoist
|
29
37
|
|
30
38
|
## BSD flavors, including OS X
|
31
39
|
Users on BSD platforms get the extra `Uname.model` method.
|
data/Rakefile
CHANGED
data/doc/uname.rdoc
CHANGED
data/lib/sys/uname.rb
CHANGED
data/lib/sys/unix/uname.rb
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
require 'ffi'
|
4
4
|
require 'rbconfig'
|
5
|
+
require 'memoist'
|
5
6
|
|
6
7
|
# The Sys module serves as a namespace only.
|
7
8
|
module Sys
|
@@ -246,6 +247,15 @@ module Sys
|
|
246
247
|
end
|
247
248
|
end
|
248
249
|
|
250
|
+
class << self
|
251
|
+
extend Memoist
|
252
|
+
memoize :sysname
|
253
|
+
memoize :nodename
|
254
|
+
memoize :release
|
255
|
+
memoize :version
|
256
|
+
memoize :machine
|
257
|
+
end
|
258
|
+
|
249
259
|
private
|
250
260
|
|
251
261
|
# Returns the model for systems that define sysctl().
|
data/lib/sys/windows/uname.rb
CHANGED
@@ -3,6 +3,7 @@
|
|
3
3
|
require 'socket'
|
4
4
|
require 'time'
|
5
5
|
require 'win32ole'
|
6
|
+
require 'memoist'
|
6
7
|
|
7
8
|
# The Sys module provides a namespace only.
|
8
9
|
module Sys
|
@@ -476,6 +477,15 @@ module Sys
|
|
476
477
|
end
|
477
478
|
end
|
478
479
|
|
480
|
+
class << self
|
481
|
+
extend Memoist
|
482
|
+
memoize :sysname
|
483
|
+
memoize :nodename
|
484
|
+
memoize :release
|
485
|
+
memoize :version
|
486
|
+
memoize :machine
|
487
|
+
end
|
488
|
+
|
479
489
|
# Converts a string in the format '20040703074625.015625-360' into a
|
480
490
|
# Ruby Time object.
|
481
491
|
#
|
data/spec/sys_platform_spec.rb
CHANGED
@@ -9,7 +9,7 @@ require 'spec_helper'
|
|
9
9
|
|
10
10
|
RSpec.describe Sys::Platform do
|
11
11
|
example 'the VERSION constant is set to the expected value' do
|
12
|
-
expect(Sys::Platform::VERSION).to eql('1.
|
12
|
+
expect(Sys::Platform::VERSION).to eql('1.4.0')
|
13
13
|
expect(Sys::Platform::VERSION).to be_frozen
|
14
14
|
end
|
15
15
|
|
data/spec/sys_uname_spec.rb
CHANGED
@@ -26,7 +26,7 @@ RSpec.describe Sys::Uname do
|
|
26
26
|
|
27
27
|
context 'universal singleton methods' do
|
28
28
|
example 'version constant is set to expected value' do
|
29
|
-
expect(Sys::Uname::VERSION).to eql('1.
|
29
|
+
expect(Sys::Uname::VERSION).to eql('1.4.0')
|
30
30
|
expect(Sys::Uname::VERSION).to be_frozen
|
31
31
|
end
|
32
32
|
|
@@ -270,9 +270,9 @@ RSpec.describe Sys::Uname do
|
|
270
270
|
expect(described_class.uname.number_of_users).to be_a(Integer)
|
271
271
|
end
|
272
272
|
|
273
|
-
example 'organization'
|
273
|
+
example 'organization' do
|
274
274
|
expect{ described_class.uname.organization }.not_to raise_error
|
275
|
-
expect(described_class.uname.organization).to be_a(String)
|
275
|
+
expect(described_class.uname.organization).to be_a(String).or be_nil
|
276
276
|
end
|
277
277
|
|
278
278
|
example 'os_language' do
|
@@ -396,4 +396,76 @@ RSpec.describe Sys::Uname do
|
|
396
396
|
expect(described_class.uname.windows_directory).to be_a(String)
|
397
397
|
end
|
398
398
|
end
|
399
|
+
|
400
|
+
context 'memoization', :unix do
|
401
|
+
before(:each) do
|
402
|
+
# Clear any existing memoization cache before each test
|
403
|
+
described_class.flush_cache if described_class.respond_to?(:flush_cache)
|
404
|
+
end
|
405
|
+
|
406
|
+
example 'sysname method is memoized' do
|
407
|
+
first_call = described_class.sysname
|
408
|
+
second_call = described_class.sysname
|
409
|
+
|
410
|
+
expect(first_call).to equal(second_call)
|
411
|
+
expect(first_call.object_id).to eq(second_call.object_id)
|
412
|
+
end
|
413
|
+
|
414
|
+
example 'nodename method is memoized' do
|
415
|
+
first_call = described_class.nodename
|
416
|
+
second_call = described_class.nodename
|
417
|
+
|
418
|
+
expect(first_call).to equal(second_call)
|
419
|
+
expect(first_call.object_id).to eq(second_call.object_id)
|
420
|
+
end
|
421
|
+
|
422
|
+
example 'release method is memoized' do
|
423
|
+
first_call = described_class.release
|
424
|
+
second_call = described_class.release
|
425
|
+
|
426
|
+
expect(first_call).to equal(second_call)
|
427
|
+
expect(first_call.object_id).to eq(second_call.object_id)
|
428
|
+
end
|
429
|
+
|
430
|
+
example 'version method is memoized' do
|
431
|
+
first_call = described_class.version
|
432
|
+
second_call = described_class.version
|
433
|
+
|
434
|
+
expect(first_call).to equal(second_call)
|
435
|
+
expect(first_call.object_id).to eq(second_call.object_id)
|
436
|
+
end
|
437
|
+
|
438
|
+
example 'machine method is memoized' do
|
439
|
+
first_call = described_class.machine
|
440
|
+
second_call = described_class.machine
|
441
|
+
|
442
|
+
expect(first_call).to equal(second_call)
|
443
|
+
expect(first_call.object_id).to eq(second_call.object_id)
|
444
|
+
end
|
445
|
+
|
446
|
+
example 'memoized methods maintain independence' do
|
447
|
+
# Test that different methods return different values but each is consistently memoized
|
448
|
+
sysname1 = described_class.sysname
|
449
|
+
nodename1 = described_class.nodename
|
450
|
+
|
451
|
+
# Different methods should return different values
|
452
|
+
expect(sysname1).not_to eq(nodename1)
|
453
|
+
|
454
|
+
# But repeated calls should return the same object
|
455
|
+
sysname2 = described_class.sysname
|
456
|
+
nodename2 = described_class.nodename
|
457
|
+
|
458
|
+
expect(sysname1).to equal(sysname2)
|
459
|
+
expect(nodename1).to equal(nodename2)
|
460
|
+
end
|
461
|
+
|
462
|
+
example 'uname method is not memoized' do
|
463
|
+
# The main uname method should not be memoized, as it returns a new struct each time
|
464
|
+
first_call = described_class.uname
|
465
|
+
second_call = described_class.uname
|
466
|
+
|
467
|
+
# Should return equivalent structs but not the same object
|
468
|
+
expect(first_call.object_id).not_to eq(second_call.object_id)
|
469
|
+
end
|
470
|
+
end
|
399
471
|
end
|
data/sys-uname.gemspec
CHANGED
@@ -2,7 +2,7 @@ require 'rubygems'
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |spec|
|
4
4
|
spec.name = 'sys-uname'
|
5
|
-
spec.version = '1.
|
5
|
+
spec.version = '1.4.0'
|
6
6
|
spec.author = 'Daniel J. Berger'
|
7
7
|
spec.email = 'djberg96@gmail.com'
|
8
8
|
spec.homepage = 'http://github.com/djberg96/sys-uname'
|
@@ -15,6 +15,8 @@ Gem::Specification.new do |spec|
|
|
15
15
|
spec.extra_rdoc_files = Dir['doc/*.rdoc']
|
16
16
|
|
17
17
|
spec.add_dependency('ffi', '~> 1.1')
|
18
|
+
spec.add_dependency('memoist', '~> 0.16.2')
|
19
|
+
|
18
20
|
spec.add_development_dependency('rspec', '~> 3.9')
|
19
21
|
spec.add_development_dependency('rake')
|
20
22
|
spec.add_development_dependency('rubocop')
|
@@ -28,7 +30,8 @@ Gem::Specification.new do |spec|
|
|
28
30
|
'source_code_uri' => 'https://github.com/djberg96/sys-uname',
|
29
31
|
'wiki_uri' => 'https://github.com/djberg96/sys-uname/wiki',
|
30
32
|
'rubygems_mfa_required' => 'true',
|
31
|
-
'github_repo' => 'https://github.com/djberg96/sys-uname'
|
33
|
+
'github_repo' => 'https://github.com/djberg96/sys-uname',
|
34
|
+
'funding_uri' => 'https://github.com/sponsors/djberg96'
|
32
35
|
}
|
33
36
|
|
34
37
|
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-uname
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.4.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:
|
38
|
+
date: 2025-08-26 00:00:00.000000000 Z
|
39
39
|
dependencies:
|
40
40
|
- !ruby/object:Gem::Dependency
|
41
41
|
name: ffi
|
@@ -51,6 +51,20 @@ dependencies:
|
|
51
51
|
- - "~>"
|
52
52
|
- !ruby/object:Gem::Version
|
53
53
|
version: '1.1'
|
54
|
+
- !ruby/object:Gem::Dependency
|
55
|
+
name: memoist
|
56
|
+
requirement: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - "~>"
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: 0.16.2
|
61
|
+
type: :runtime
|
62
|
+
prerelease: false
|
63
|
+
version_requirements: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - "~>"
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: 0.16.2
|
54
68
|
- !ruby/object:Gem::Dependency
|
55
69
|
name: rspec
|
56
70
|
requirement: !ruby/object:Gem::Requirement
|
@@ -149,6 +163,7 @@ metadata:
|
|
149
163
|
wiki_uri: https://github.com/djberg96/sys-uname/wiki
|
150
164
|
rubygems_mfa_required: 'true'
|
151
165
|
github_repo: https://github.com/djberg96/sys-uname
|
166
|
+
funding_uri: https://github.com/sponsors/djberg96
|
152
167
|
post_install_message:
|
153
168
|
rdoc_options: []
|
154
169
|
require_paths:
|
@@ -164,7 +179,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
164
179
|
- !ruby/object:Gem::Version
|
165
180
|
version: '0'
|
166
181
|
requirements: []
|
167
|
-
rubygems_version: 3.5.
|
182
|
+
rubygems_version: 3.5.22
|
168
183
|
signing_key:
|
169
184
|
specification_version: 4
|
170
185
|
summary: An interface for returning uname (platform) information
|
metadata.gz.sig
CHANGED
Binary file
|