sys-cpu 1.0.5 → 1.0.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7093a05a67945ccf9980c070421462c4a30a40d72ba9645230fad1d86381c0c1
4
- data.tar.gz: e411d1a7f0ce381fcd8660e9b7654d60c21c03459b25cb6cdd1b46c379196b10
3
+ metadata.gz: 240d4766057d3b5e6099092e037a858a527598955f303a6b1e958e78dd55f10e
4
+ data.tar.gz: 9a1041ac81a63a1205d28d94c59373a5868f17eb9e46b1cf4226f3488f7dafd9
5
5
  SHA512:
6
- metadata.gz: ff952395b1f70fedc9f01818efff2c4655ed19f2120351a84eec82690176a6de5664ca1b17648656b8eeaacaccc805c5077f4c50d79ad2983f1b3df92f14e6a8
7
- data.tar.gz: 07344e7816c0ccb3bc2217c4563d2c3c97875bd3e45cc8b463cd516b44f2cc38ba94df7798ae9e086886bd0bbcdae5da514244a19165f0d732c2ddb5179d85ca
6
+ metadata.gz: 9bb252c92d2460f38fdf65656c2d3875c55b6d3d2ec73863be3fcdd878d3d66a49a33f9a9d1d49ae65aa4c8d3d5a405bac2aa3bdaaa4edbc5d6854e12e6a29af
7
+ data.tar.gz: 993afd63ee978e9bd24682309221f9f4fbddb177f8ed748b9cf512317bf72ea5243b529d114e9407fbf198f00c685fc1a6a0afc4646e2230acce9a5dce8d0d08
checksums.yaml.gz.sig CHANGED
Binary file
data/CHANGES.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## 1.0.6 - 12-Aug-2022
2
+ * The Sys::CPU.model method will now return "ARM" for machines using an
3
+ ARM-based processor instead of "Uknown".
4
+
1
5
  ## 1.0.5 - 10-Aug-2022
2
6
  * Updated the cpu detection handling for Mac M1 systems. Thanks go to
3
7
  Julien W for the spot.
data/lib/sys/cpu.rb CHANGED
@@ -10,7 +10,7 @@ module Sys
10
10
  # This class is reopened for each of the supported platforms/operating systems.
11
11
  class CPU
12
12
  # The version of the sys-cpu gem.
13
- VERSION = '1.0.5'
13
+ VERSION = '1.0.6'
14
14
 
15
15
  private_class_method :new
16
16
  end
@@ -15,16 +15,22 @@ module Sys
15
15
 
16
16
  CTL_HW = 6 # Generic hardware/cpu
17
17
 
18
+ private_constant :CTL_HW
19
+
18
20
  HW_MACHINE = 1 # Machine class
19
21
  HW_MODEL = 2 # Specific machine model
20
22
  HW_NCPU = 3 # Number of CPU's
21
23
  HW_CPU_FREQ = 15 # CPU frequency
22
24
  HW_MACHINE_ARCH = 12 # Machine architecture
23
25
 
26
+ private_constant :HW_MACHINE, :HW_MODEL, :HW_NCPU, :HW_CPU_FREQ, :HW_MACHINE_ARCH
27
+
24
28
  SI_MACHINE = 5
25
29
  SI_ARCHITECTURE = 6
26
30
  SC_NPROCESSORS_ONLN = 15
27
31
 
32
+ private_constant :SI_MACHINE, :SI_ARCHITECTURE, :SC_NPROCESSORS_ONLN
33
+
28
34
  P_OFFLINE = 1
29
35
  P_ONLINE = 2
30
36
  P_FAULTED = 4
@@ -32,12 +38,19 @@ module Sys
32
38
  P_NOINTR = 6
33
39
  P_SPARE = 7
34
40
 
41
+ private_constant :P_OFFLINE, :P_ONLINE, :P_FAULTED, :P_POWEROFF, :P_NOINTR, :P_SPARE
42
+
35
43
  CPU_ARCH_ABI64 = 0x01000000
36
44
  CPU_TYPE_X86 = 7
37
45
  CPU_TYPE_X86_64 = (CPU_TYPE_X86 | CPU_ARCH_ABI64)
46
+ CPU_TYPE_ARM = 12
38
47
  CPU_TYPE_SPARC = 14
39
48
  CPU_TYPE_POWERPC = 18
40
49
  CPU_TYPE_POWERPC64 = CPU_TYPE_POWERPC | CPU_ARCH_ABI64
50
+ CPU_TYPE_ARM64 = CPU_TYPE_ARM | CPU_ARCH_ABI64
51
+
52
+ private_constant :CPU_ARCH_ABI64, :CPU_TYPE_X86, :CPU_TYPE_X86_64, :CPU_TYPE_ARM
53
+ private_constant :CPU_TYPE_SPARC, :CPU_TYPE_POWERPC, :CPU_TYPE_POWERPC64
41
54
 
42
55
  attach_function(
43
56
  :sysctl,
@@ -73,6 +86,8 @@ module Sys
73
86
  )
74
87
  end
75
88
 
89
+ private_constant :ClockInfo
90
+
76
91
  # Returns the cpu's architecture. On most systems this will be identical
77
92
  # to the CPU.machine method. On OpenBSD it will be identical to the CPU.model
78
93
  # method.
@@ -145,6 +160,8 @@ module Sys
145
160
  'Sparc'
146
161
  when CPU_TYPE_POWERPC, CPU_TYPE_POWERPC64
147
162
  'PowerPC'
163
+ when CPU_TYPE_ARM, CPU_TYPE_ARM64
164
+ 'ARM'
148
165
  else
149
166
  'Unknown'
150
167
  end
@@ -93,4 +93,21 @@ RSpec.describe Sys::CPU, :bsd => true do
93
93
  example 'num_cpu method does not accept any arguments' do
94
94
  expect{ described_class.num_cpu(0) }.to raise_error(ArgumentError)
95
95
  end
96
+
97
+ context "ffi methods and constants are private" do
98
+ example "ffi constants are private" do
99
+ constants = described_class.constants
100
+ expect(constants).not_to include(:CTL_HW)
101
+ expect(constants).not_to include(:CPU_TYPE_X86)
102
+ expect(constants).not_to include(:CPU_TYPE_X86_64)
103
+ expect(constants).not_to include(:HW_MACHINE)
104
+ expect(constants).not_to include(:ClockInfo)
105
+ end
106
+
107
+ example "ffi methods are private" do
108
+ methods = described_class.methods(false)
109
+ expect(methods).not_to include(:sysctl)
110
+ expect(methods).not_to include(:sysctlbyname)
111
+ end
112
+ end
96
113
  end
@@ -11,7 +11,7 @@ require 'rspec'
11
11
 
12
12
  RSpec.shared_examples Sys::CPU do
13
13
  example 'version number is set to the expected value' do
14
- expect(Sys::CPU::VERSION).to eq('1.0.5')
14
+ expect(Sys::CPU::VERSION).to eq('1.0.6')
15
15
  end
16
16
 
17
17
  example 'version number is frozen' do
data/sys-cpu.gemspec CHANGED
@@ -2,7 +2,7 @@ require 'rubygems'
2
2
 
3
3
  Gem::Specification.new do |spec|
4
4
  spec.name = 'sys-cpu'
5
- spec.version = '1.0.5'
5
+ spec.version = '1.0.6'
6
6
  spec.author = 'Daniel J. Berger'
7
7
  spec.email = 'djberg96@gmail.com'
8
8
  spec.license = 'Apache-2.0'
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,11 +1,11 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sys-cpu
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.5
4
+ version: 1.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel J. Berger
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain:
11
11
  - |
@@ -35,7 +35,7 @@ cert_chain:
35
35
  ORVCZpRuCPpmC8qmqxUnARDArzucjaclkxjLWvCVHeFa9UP7K3Nl9oTjJNv+7/jM
36
36
  WZs4eecIcUc4tKdHxcAJ0MO/Dkqq7hGaiHpwKY76wQ1+8xAh
37
37
  -----END CERTIFICATE-----
38
- date: 2022-08-10 00:00:00.000000000 Z
38
+ date: 2022-08-12 00:00:00.000000000 Z
39
39
  dependencies:
40
40
  - !ruby/object:Gem::Dependency
41
41
  name: ffi
@@ -159,7 +159,7 @@ metadata:
159
159
  source_code_uri: https://github.com/djberg96/sys-cpu
160
160
  wiki_uri: https://github.com/djberg96/sys-cpu/wiki
161
161
  rubygems_mfa_required: 'true'
162
- post_install_message:
162
+ post_install_message:
163
163
  rdoc_options: []
164
164
  require_paths:
165
165
  - lib
@@ -174,8 +174,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
174
174
  - !ruby/object:Gem::Version
175
175
  version: '0'
176
176
  requirements: []
177
- rubygems_version: 3.2.32
178
- signing_key:
177
+ rubygems_version: 3.3.15
178
+ signing_key:
179
179
  specification_version: 4
180
180
  summary: A Ruby interface for providing CPU information
181
181
  test_files:
metadata.gz.sig CHANGED
Binary file