sys-cpu 0.6.4-universal-mingw32 → 1.3.0-universal-mingw32
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 +7 -0
- checksums.yaml.gz.sig +5 -0
- data/{CHANGES → CHANGES.md} +121 -18
- data/Gemfile +2 -0
- data/LICENSE +177 -0
- data/MANIFEST.md +27 -0
- data/README.md +83 -0
- data/Rakefile +28 -65
- data/certs/djberg96_pub.pem +26 -0
- data/doc/bsd.md +58 -0
- data/doc/linux.md +46 -0
- data/doc/windows.txt +2 -2
- data/examples/example_sys_cpu_windows.rb +5 -4
- data/install.rb +3 -3
- data/lib/sys/cpu.rb +28 -0
- data/lib/sys/darwin/sys/cpu.rb +326 -0
- data/lib/sys/linux/sys/cpu.rb +243 -0
- data/lib/sys/unix/sys/cpu.rb +407 -0
- data/lib/sys/windows/sys/cpu.rb +957 -0
- data/lib/sys-cpu.rb +3 -0
- data/spec/spec_helper.rb +12 -0
- data/spec/sys_cpu_bsd_spec.rb +139 -0
- data/spec/sys_cpu_hpux_spec.rb +75 -0
- data/spec/sys_cpu_linux_spec.rb +78 -0
- data/spec/sys_cpu_shared.rb +24 -0
- data/spec/sys_cpu_windows_spec.rb +87 -0
- data/sys-cpu.gemspec +35 -38
- data.tar.gz.sig +0 -0
- metadata +174 -90
- metadata.gz.sig +0 -0
- data/MANIFEST +0 -29
- data/README +0 -73
- data/doc/bsd.txt +0 -49
- data/doc/linux.txt +0 -41
- data/doc/sunos.txt +0 -56
- data/examples/example_sys_cpu_sunos.rb +0 -21
- data/ext/bsd/bsd.c +0 -331
- data/ext/extconf.rb +0 -26
- data/ext/hpux/hpux.c +0 -219
- data/ext/sunos/sunos.c +0 -281
- data/ext/version.h +0 -2
- data/lib/linux/sys/cpu.rb +0 -122
- data/lib/windows/sys/cpu.rb +0 -790
- data/test/test_sys_cpu.rb +0 -23
- data/test/test_sys_cpu_bsd.rb +0 -76
- data/test/test_sys_cpu_hpux.rb +0 -52
- data/test/test_sys_cpu_linux.rb +0 -34
- data/test/test_sys_cpu_sunos.rb +0 -67
- data/test/test_sys_cpu_version.rb +0 -18
- data/test/test_sys_cpu_windows.rb +0 -72
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 3ed3eb6526955feac0f22910510c331f53ea4403c57704b5447a454844e6babe
|
|
4
|
+
data.tar.gz: 553b2c3277735f33854a0fce9bae604d78f0a8bfd69a99445790029c57e444d1
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 8e010e63702c53d65362a693a10cb5c7c666c6b01e15e706a4c9d9e1a479bd8d423cd6e5b45455b5357cf43c92fb43c2a284cb127d6ae1b93f653348edc39933
|
|
7
|
+
data.tar.gz: 111893487c0a6e188ef6473c99909b0c88fb1bb36adc7d44ce85c9391e7e9395ab7cafaecac8e41507e996f7cf6065a34399a528551c80a392102ae2787361d5
|
checksums.yaml.gz.sig
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
�5�R�?* @e[����,+���7� ��,��C�Z�#ѻ�n(�Ѩ;�E��
|
|
2
|
+
�Z~r�"~�.j��Sn���a��łթ&<���9��#�ݰ�bN
|
|
3
|
+
v��b"�jq���ƚ0̞#t�[������sq�vם�y��+T�*
|
|
4
|
+
�"D��<�lq����W�U��M�c����w!�U�$�=&
|
|
5
|
+
� �EG$����[�G�+�9o���{��-�A��u���죝<�ξ��5�� ���RW�L�%A�"������5��-4���8�5��l��`��S�x6���z}z�,VY�-�!a�����'NI
|
|
6
|
ӨD�߿��|h��d��zF�e�2Տ/����Ʊ�y��Yj�#��0���g�����
|
data/{CHANGES → CHANGES.md}
RENAMED
|
@@ -1,4 +1,107 @@
|
|
|
1
|
-
|
|
1
|
+
## 1.3.0 - 24-Mar-2026
|
|
2
|
+
* Added the cpu_usage method.
|
|
3
|
+
|
|
4
|
+
## 1.2.0 - 17-Feb-2026
|
|
5
|
+
* The win32ole gem is now a dependency since Ruby 4.x no longer bundles it.
|
|
6
|
+
* The freq method was updated for BSD platforms on aarch64. It now defaults
|
|
7
|
+
to the hardclock timer value as a best guess.
|
|
8
|
+
* The architecture method now recognizes ARM64 on Windows.
|
|
9
|
+
|
|
10
|
+
## 1.1.0 - 9-Jun-2024
|
|
11
|
+
* Removed Solaris support.
|
|
12
|
+
* Added DragonflyBSD support.
|
|
13
|
+
* Fixed example task.
|
|
14
|
+
* Made some constants private in the generic Unix code that should
|
|
15
|
+
have been private.
|
|
16
|
+
* The architecture method on Linux will now interpret values 4, 5
|
|
17
|
+
and 15. If it's not any of those values it will return 'Unknown'.
|
|
18
|
+
|
|
19
|
+
## 1.0.6 - 12-Aug-2022
|
|
20
|
+
* The Sys::CPU.model method will now return "ARM" for machines using an
|
|
21
|
+
ARM-based processor instead of "Unknown".
|
|
22
|
+
|
|
23
|
+
## 1.0.5 - 10-Aug-2022
|
|
24
|
+
* Updated the cpu detection handling for Mac M1 systems. Thanks go to
|
|
25
|
+
Julien W for the spot.
|
|
26
|
+
|
|
27
|
+
## 1.0.4 - 10-Jun-2022
|
|
28
|
+
* The OSX code for the CPU.freq method was updated for arm64 systems.
|
|
29
|
+
* Some refactoring to the specs and uses shared examples now.
|
|
30
|
+
* Now makes the new method a private class method. The constructor was never
|
|
31
|
+
meant to be used with this library, so now it's explicitly forbidden.
|
|
32
|
+
* Added rubocop and rubocop-rspec as development dependencies, as well as
|
|
33
|
+
a rubocop rake task, and applied some suggested changes.
|
|
34
|
+
* Fixed the global Gemfile source issue. Just use the gemspec.
|
|
35
|
+
* Added some new cpu families for Windows.
|
|
36
|
+
* Added a respond_to_missing? method to the Linux version since it uses
|
|
37
|
+
method_missing.
|
|
38
|
+
* The MS Windows version now assumes Ruby 2.0 or later.
|
|
39
|
+
|
|
40
|
+
## 1.0.3 - 28-Jan-2021
|
|
41
|
+
* The code for OSX was split out into its own source file. This was partly for
|
|
42
|
+
ease of maintenance, but also because there was confusion with the
|
|
43
|
+
processor_info function. The original function was only aimed at Solaris, but
|
|
44
|
+
it turns out OSX has its own, different implementation. This caused segfaults.
|
|
45
|
+
|
|
46
|
+
## 1.0.2 - 25-Jan-2021
|
|
47
|
+
* Fixed issues where things that were meant to be private weren't actually private.
|
|
48
|
+
|
|
49
|
+
## 1.0.1 - 20-Dec-2020
|
|
50
|
+
* Switched from rdoc to markdown.
|
|
51
|
+
|
|
52
|
+
## 1.0.0 - 23-Oct-2020
|
|
53
|
+
* Fixed a bug in the Windows version where the attempt to convert the ConfigManagerErrorCode
|
|
54
|
+
to a string was busted. Coincidentally, this also exposed a core bug in JRuby (see PR #6443).
|
|
55
|
+
Thanks go to G. Gibson for reporting the issue.
|
|
56
|
+
* Switched the tests from test-unit to rspec.
|
|
57
|
+
|
|
58
|
+
## 0.9.0 - 12-May-2020
|
|
59
|
+
* Added explicit freq, architecture, num_cpu and model methods to the Linux
|
|
60
|
+
version in an effort to create a common interface across platforms.
|
|
61
|
+
* Modified the Linux version so that method_missing will raise a NoMethodError
|
|
62
|
+
if you try to call access an attribute that doesn't exist.
|
|
63
|
+
* Some updates to the Linux tests.
|
|
64
|
+
|
|
65
|
+
## 0.8.3 - 18-Mar-2020
|
|
66
|
+
* Properly include a LICENSE file as per the Apache-2.0 license.
|
|
67
|
+
|
|
68
|
+
## 0.8.2 - 14-Jan-2020
|
|
69
|
+
* Added explicit .rdoc extension to README, CHANGES and MANIFEST files.
|
|
70
|
+
* Fixed license name in README.
|
|
71
|
+
|
|
72
|
+
## 0.8.1 - 4-Nov-2018
|
|
73
|
+
* Added metadata to the gemspec.
|
|
74
|
+
* Fixed missing hyphen in license name.
|
|
75
|
+
|
|
76
|
+
## 0.8.0 - 17-Oct-2018
|
|
77
|
+
* Switched license to Apache 2.0.
|
|
78
|
+
* Updated documentation for the cpu_stats method on Linux.
|
|
79
|
+
* The VERSION constant is now frozen.
|
|
80
|
+
* Now uses require_relative internally where needed.
|
|
81
|
+
|
|
82
|
+
## 0.7.2 - 5-Sep-2015
|
|
83
|
+
* Replaced a global array with a constant in the Linux version. Thanks go
|
|
84
|
+
to Yorick Peterse for the patch.
|
|
85
|
+
* Added method comments back to the Unix version.
|
|
86
|
+
* Added a sys-cpu.rb stub file for your convenience.
|
|
87
|
+
* This gem is now signed.
|
|
88
|
+
|
|
89
|
+
## 0.7.1 - 2-May-2013
|
|
90
|
+
* Added a workaround for a win32ole bug in the Windows version.
|
|
91
|
+
* Reorganized code so that there is now a single gem rather than three
|
|
92
|
+
separate platform gems.
|
|
93
|
+
* Updated test-unit dependency which let me simplify the test files a bit.
|
|
94
|
+
|
|
95
|
+
## 0.7.0 - 14-Dec-2011
|
|
96
|
+
* Code base now uses FFI. However, HP-UX is not currently supported.
|
|
97
|
+
HP-UX users should continue to use the 0.6.x version. Note that
|
|
98
|
+
the code base remains unchanged on Linux and Windows.
|
|
99
|
+
* The cpu_type method has been replaced with the architecture method
|
|
100
|
+
on Solaris to keep the interface more in line with other platforms.
|
|
101
|
+
* The type method has been changed to cpu_type on Windows.
|
|
102
|
+
* Some Rakefile and test suite updates.
|
|
103
|
+
|
|
104
|
+
## 0.6.4 - 27-Sep-2011
|
|
2
105
|
* The CPU.freq method now works on OSX.
|
|
3
106
|
* The CPU.model method on OSX has been altered. Previously it
|
|
4
107
|
returned the machine model. However, the information is limited.
|
|
@@ -6,7 +109,7 @@
|
|
|
6
109
|
* The Linux and Windows gems now have a 'universal' architecture.
|
|
7
110
|
* Refactored the clean task in the Rakefile.
|
|
8
111
|
|
|
9
|
-
|
|
112
|
+
## 0.6.3 - 9-Oct-2010
|
|
10
113
|
* Fixed a bug in the install.rb file and refactored it a bit. Thanks go
|
|
11
114
|
to Di-an Jan for the spot. Note, however, that this file will eventually
|
|
12
115
|
be removed and/or integrated into the Linux source file.
|
|
@@ -14,7 +117,7 @@
|
|
|
14
117
|
* Fixed and updated the CPU.architecture method on MS Windows to handle IA64
|
|
15
118
|
and x64 architectures.
|
|
16
119
|
|
|
17
|
-
|
|
120
|
+
## 0.6.2 - 1-Jan-2010
|
|
18
121
|
* Fixed a bug in the cpu_freq function (which would only be noticed on
|
|
19
122
|
certain platforms in cases where the CPU.freq method failed). Thanks
|
|
20
123
|
go to Edho P Arief for the spot.
|
|
@@ -27,13 +130,13 @@
|
|
|
27
130
|
* Test files renamed.
|
|
28
131
|
* Added test-unit 2.x as a development dependency.
|
|
29
132
|
|
|
30
|
-
|
|
133
|
+
## 0.6.1 - 4-Jan-2009
|
|
31
134
|
* Fix for OS X 10.5.x. Thanks go to Victor Costan for the spot and the patch.
|
|
32
135
|
* Updated the gemspec and some other minor changes.
|
|
33
136
|
* On MS Windows the impersonation level is now explicitly set to 'impersonate'
|
|
34
137
|
to avoid issues where systems might be using an older version of WMI.
|
|
35
138
|
|
|
36
|
-
|
|
139
|
+
## 0.6.0 - 26-Apr-2007
|
|
37
140
|
* Added support for most BSD flavors, including OS X. The freebsd.c file is
|
|
38
141
|
now just bsd.c.
|
|
39
142
|
* The CPU.type method for Solaris has been changed to CPU.cpu_type to avoid
|
|
@@ -45,7 +148,7 @@
|
|
|
45
148
|
* Improved RDoc comments in the C source files.
|
|
46
149
|
* Changed CPUError to CPU::Error.
|
|
47
150
|
|
|
48
|
-
|
|
151
|
+
## 0.5.5 - 17-Nov-2006
|
|
49
152
|
* Fixed a bug in the Linux version where there could be a key but no
|
|
50
153
|
associated value, causing a String#strip! call to fail. Now the value is
|
|
51
154
|
simply left at nil.
|
|
@@ -55,14 +158,14 @@
|
|
|
55
158
|
* Modified the gemspec so that it sets the platform properly for Linux
|
|
56
159
|
and Windows.
|
|
57
160
|
|
|
58
|
-
|
|
161
|
+
## 0.5.4 - 12-Jul-2006
|
|
59
162
|
* Added a gemspec (and a gem on RubyForge).
|
|
60
163
|
* The CPU.architecture method on HP-UX now returns nil if it cannot be
|
|
61
164
|
determined instead of "Unknown" for consistency with the other
|
|
62
165
|
platforms.
|
|
63
166
|
* Inlined the RDoc and made some minor cosmetic source code changes.
|
|
64
167
|
|
|
65
|
-
|
|
168
|
+
## 0.5.3 - 4-May-2006
|
|
66
169
|
* Fixed in a bug in the Solaris version where CPU.load_avg returned bad values
|
|
67
170
|
when compiled in 64 bit mode. Thanks go to James Hranicky for the spot and
|
|
68
171
|
both James Hranicky and Peter Tribble (via comp.unix.solaris) for patches.
|
|
@@ -70,7 +173,7 @@
|
|
|
70
173
|
which test suite to run. All platforms now use 'ts_all.rb', which will run
|
|
71
174
|
the appropriate test case behind the scenes.
|
|
72
175
|
|
|
73
|
-
|
|
176
|
+
## 0.5.2 - 24-Jun-2005
|
|
74
177
|
* Bug fixed on Linux where empty lines could cause problems. This affected
|
|
75
178
|
both the install.rb and linux.rb files, though it only seems to have been
|
|
76
179
|
an issue on the 2.6+ kernel.
|
|
@@ -79,7 +182,7 @@
|
|
|
79
182
|
is the only entry.
|
|
80
183
|
* Added a sample program for Linux under the 'examples' directory.
|
|
81
184
|
|
|
82
|
-
|
|
185
|
+
## 0.5.1 - 5-May-2005
|
|
83
186
|
* Fixed a potential bug in the FreeBSD version of CPU.model.
|
|
84
187
|
* Eliminated some warnings in the FreeBSD version.
|
|
85
188
|
* Moved examples directory to the toplevel package directory.
|
|
@@ -92,7 +195,7 @@
|
|
|
92
195
|
doc/linux.txt.
|
|
93
196
|
* Some $LOAD_PATH setup changes in the unit tests.
|
|
94
197
|
|
|
95
|
-
|
|
198
|
+
## 0.5.0 - 26-Jun-2004
|
|
96
199
|
* Now requires Ruby 1.8.0 or later.
|
|
97
200
|
* FreeBSD support added.
|
|
98
201
|
* Replaced 'CPUException' with 'CPUError'
|
|
@@ -106,7 +209,7 @@
|
|
|
106
209
|
* The .html files have been removed. You can generate the html on your own
|
|
107
210
|
if you like.
|
|
108
211
|
|
|
109
|
-
|
|
212
|
+
## 0.4.0 - 18-Sep-2003
|
|
110
213
|
* Added MS Windows support
|
|
111
214
|
* Changed some method names. The "cpu" has been dropped from most method
|
|
112
215
|
names. See documentation for details.
|
|
@@ -118,14 +221,14 @@
|
|
|
118
221
|
* Minor API change for the load_avg() method on HP-UX. It now accepts a
|
|
119
222
|
CPU number as an argument.
|
|
120
223
|
|
|
121
|
-
|
|
224
|
+
## 0.3.1 - 16-Jul-2003
|
|
122
225
|
* Fixed a bug in the Solaris version that was using up and not
|
|
123
226
|
freeing file descriptors.
|
|
124
227
|
* Added html doc for Solaris under doc directory.
|
|
125
228
|
* Minor changes to test_hpux.rb and test_sunos.rb
|
|
126
229
|
* Minor README changes.
|
|
127
230
|
|
|
128
|
-
|
|
231
|
+
## 0.3.0 - 30-Jun-2003
|
|
129
232
|
* Added HP-UX support
|
|
130
233
|
* Removed the VERSION class method. Use the constant instead
|
|
131
234
|
* Changed license to "Artistic"
|
|
@@ -134,7 +237,7 @@
|
|
|
134
237
|
* Modified extconf.rb, moving some of the dynamic test generation
|
|
135
238
|
into separate files
|
|
136
239
|
|
|
137
|
-
|
|
240
|
+
## 0.2.2 - 25-Mar-2003
|
|
138
241
|
* fpu_type and cpu_type now return nil if not found (Solaris)
|
|
139
242
|
* CPUException is now a direct subclass of StandardError
|
|
140
243
|
* Modified extconf.rb script
|
|
@@ -142,19 +245,19 @@
|
|
|
142
245
|
* Added another test to the solaris test suite
|
|
143
246
|
* Important note added to INSTALL file
|
|
144
247
|
|
|
145
|
-
|
|
248
|
+
## 0.2.1 - 12-Mar-2003
|
|
146
249
|
* Added the cpu_stats() class method for Linux, which contains the
|
|
147
250
|
data from the 'cpu' lines of /proc/stat
|
|
148
251
|
* Minor fix for extconf.rb (thanks Michael Granger)
|
|
149
252
|
* Some tests added to Linux test suite
|
|
150
253
|
* MANIFEST correction
|
|
151
254
|
|
|
152
|
-
|
|
255
|
+
## 0.2.0 - 13-Feb-2003
|
|
153
256
|
* Linux support added (pure Ruby only)
|
|
154
257
|
* Many changes to extconf.rb to support Linux version
|
|
155
258
|
* sys-uname prerequisite dropped
|
|
156
259
|
* rd2 documentation now kept separate from source
|
|
157
260
|
|
|
158
|
-
|
|
261
|
+
## 0.1.0 - 3-Feb-2003
|
|
159
262
|
* Initial release
|
|
160
263
|
* Currently supports Solaris (only)
|
data/Gemfile
ADDED
data/LICENSE
ADDED
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
data/MANIFEST.md
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
* install.rb
|
|
2
|
+
* LICENSE
|
|
3
|
+
* MANIFEST.md
|
|
4
|
+
* CHANGES.md
|
|
5
|
+
* Rakefile
|
|
6
|
+
* README.md
|
|
7
|
+
* sys-cpu.gemspec
|
|
8
|
+
* certs/djberg96_pub.pem
|
|
9
|
+
* doc/bsd.txt
|
|
10
|
+
* doc/hpux.txt
|
|
11
|
+
* doc/linux.txt
|
|
12
|
+
* doc/windows.txt
|
|
13
|
+
* examples/example_sys_cpu_freebsd.rb
|
|
14
|
+
* examples/example_sys_cpu_hpux.rb
|
|
15
|
+
* examples/example_sys_cpu_linux.rb
|
|
16
|
+
* examples/example_sys_cpu_windows.rb
|
|
17
|
+
* lib/sys/cpu.rb
|
|
18
|
+
* lib/sys/darwin/sys/cpu.rb
|
|
19
|
+
* lib/sys/linux/sys/cpu.rb
|
|
20
|
+
* lib/sys/unix/sys/cpu.rb
|
|
21
|
+
* lib/sys/windows/sys/cpu.rb
|
|
22
|
+
* spec/spec_helper.rb
|
|
23
|
+
* spec/sys_cpu_spec.rb
|
|
24
|
+
* spec/sys_cpu_bsd_spec.rb
|
|
25
|
+
* spec/sys_cpu_hpux_spec.rb
|
|
26
|
+
* spec/sys_cpu_linux_spec.rb
|
|
27
|
+
* spec/sys_cpu_windows_spec.rb
|
data/README.md
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
[](https://github.com/djberg96/sys-cpu/actions/workflows/ruby.yml)
|
|
2
|
+
|
|
3
|
+
* Linux
|
|
4
|
+
* Windows
|
|
5
|
+
* OSX
|
|
6
|
+
* DragonflyBSD
|
|
7
|
+
|
|
8
|
+
## Description
|
|
9
|
+
A Ruby interface for getting cpu information.
|
|
10
|
+
|
|
11
|
+
## Installation
|
|
12
|
+
`gem install sys-cpu`
|
|
13
|
+
|
|
14
|
+
## Adding the trusted cert
|
|
15
|
+
`gem cert --add <(curl -Ls https://raw.githubusercontent.com/djberg96/sys-cpu/main/certs/djberg96_pub.pem)`
|
|
16
|
+
|
|
17
|
+
## Notes
|
|
18
|
+
### Solaris
|
|
19
|
+
There is no `processors` iterative method for multi-cpu systems. I was going to
|
|
20
|
+
add this originally, but since Solaris is basically dead at this point I've
|
|
21
|
+
dropped the idea.
|
|
22
|
+
|
|
23
|
+
### OS X
|
|
24
|
+
The `CPU.model` method returns very limited information. I do not yet know
|
|
25
|
+
how to get more detailed information.
|
|
26
|
+
|
|
27
|
+
### Linux
|
|
28
|
+
This is pure Ruby. This version reads information out of /proc/cpuinfo and
|
|
29
|
+
/proc/loadavg, so if /proc isn't mounted it won't work.
|
|
30
|
+
|
|
31
|
+
The key-value information in /proc/cpuinfo is stored internally (i.e. in
|
|
32
|
+
memory) as an array of hashes when you first `require` this package. This
|
|
33
|
+
overhead is exceptionally minimal, given that your average cpuinfo file
|
|
34
|
+
contains less than 1k of text (and I don't store whitespace or newlines).
|
|
35
|
+
|
|
36
|
+
The text documentation for Linux is dynamically generated during the
|
|
37
|
+
build process because the fields vary depending on your setup. So, don't
|
|
38
|
+
look at it until *after* you've installed it. You will see a doc/linux.txt
|
|
39
|
+
file after you run `rake install` (via install.rb).
|
|
40
|
+
|
|
41
|
+
### HP-UX
|
|
42
|
+
Unlike other platforms, you can get load averages for an individual cpu in
|
|
43
|
+
multi-cpu systems. See documentation for more details.
|
|
44
|
+
|
|
45
|
+
Note that version 0.7.x and later will not work on HP-UX because of the
|
|
46
|
+
switch to FFI and the lack of a testing platform. However, version 0.6.x
|
|
47
|
+
will work just fine.
|
|
48
|
+
|
|
49
|
+
### MS Windows
|
|
50
|
+
This is a pure Ruby implementation using the win32ole package + WMI. The C
|
|
51
|
+
version has been scrapped.
|
|
52
|
+
|
|
53
|
+
As of version 0.5.0, the `CPU.usage` method has been removed in favor of the
|
|
54
|
+
`CPU.load_avg` method. This does not (currently) use a perf counter, so there
|
|
55
|
+
is no longer any delay. Also, the `processors` method has been added and the
|
|
56
|
+
`supported` method has been dropped. See the documentation for other changes.
|
|
57
|
+
|
|
58
|
+
## Acknowledgements
|
|
59
|
+
Thanks go to the MPlayer team for some source code that helped me on
|
|
60
|
+
certain versions of FreeBSD in the original C version.
|
|
61
|
+
|
|
62
|
+
## Known Bugs
|
|
63
|
+
None that I'm aware of. Please report bugs on the project page at:
|
|
64
|
+
|
|
65
|
+
https://github.com/djberg96/sys-cpu
|
|
66
|
+
|
|
67
|
+
## Future Plans
|
|
68
|
+
* Add iterative `CPU.processors` method.
|
|
69
|
+
* Add more information in general, such as what `prtdiag` shows.
|
|
70
|
+
|
|
71
|
+
## License
|
|
72
|
+
Apache-2.0
|
|
73
|
+
|
|
74
|
+
## Copyright
|
|
75
|
+
(C) 2003-2026 Daniel J. Berger, All Rights Reserved
|
|
76
|
+
|
|
77
|
+
## Warranty
|
|
78
|
+
This package is provided "as is" and without any express or
|
|
79
|
+
implied warranties, including, without limitation, the implied
|
|
80
|
+
warranties of merchantability and fitness for a particular purpose.
|
|
81
|
+
|
|
82
|
+
## Author
|
|
83
|
+
Daniel J. Berger
|
data/Rakefile
CHANGED
|
@@ -1,89 +1,52 @@
|
|
|
1
1
|
require 'rake'
|
|
2
2
|
require 'rake/clean'
|
|
3
|
-
require 'rake/testtask'
|
|
4
3
|
require 'rbconfig'
|
|
5
|
-
|
|
4
|
+
require 'rspec/core/rake_task'
|
|
5
|
+
require 'rubocop/rake_task'
|
|
6
|
+
include RbConfig
|
|
6
7
|
|
|
7
|
-
CLEAN.include(
|
|
8
|
-
'**/*.gem', # Gem files
|
|
9
|
-
'**/*.rbc', # Rubinius
|
|
10
|
-
'ext/cpu.c', # Temporary file
|
|
11
|
-
'**/*.o', # C object file
|
|
12
|
-
'**/*.log', # Ruby extension build log
|
|
13
|
-
'**/Makefile', # C Makefile
|
|
14
|
-
'**/conftest.dSYM', # OS X build directory
|
|
15
|
-
"**/*.#{CONFIG['DLEXT']}" # C shared object
|
|
16
|
-
)
|
|
17
|
-
|
|
18
|
-
desc "Build the sys-cpu library on UNIX systems"
|
|
19
|
-
task :build => [:clean] do
|
|
20
|
-
Dir.chdir('ext') do
|
|
21
|
-
unless CONFIG['host_os'] =~ /mswin|win32|mingw|cygwin|dos|windows|linux/i
|
|
22
|
-
ruby 'extconf.rb'
|
|
23
|
-
sh 'make'
|
|
24
|
-
build_file = 'cpu.' + CONFIG['DLEXT']
|
|
25
|
-
Dir.mkdir('sys') unless File.exists?('sys')
|
|
26
|
-
FileUtils.cp(build_file, 'sys')
|
|
27
|
-
end
|
|
28
|
-
end
|
|
29
|
-
end
|
|
8
|
+
CLEAN.include('**/*.gem', '**/*.rbc', '**/*.rbx', '**/*.lock')
|
|
30
9
|
|
|
31
10
|
namespace 'gem' do
|
|
32
11
|
desc "Create the sys-cpu gem"
|
|
33
12
|
task :create => [:clean] do
|
|
34
|
-
|
|
35
|
-
Gem::
|
|
13
|
+
require 'rubygems/package'
|
|
14
|
+
spec = Gem::Specification.load('sys-cpu.gemspec')
|
|
15
|
+
spec.signing_key = File.join(Dir.home, '.ssh', 'gem-private_key.pem')
|
|
16
|
+
Gem::Package.build(spec)
|
|
36
17
|
end
|
|
37
18
|
|
|
38
19
|
desc "Install the sys-cpu gem"
|
|
39
20
|
task :install => [:create] do
|
|
40
21
|
file = Dir["*.gem"].first
|
|
41
|
-
sh "gem install #{file}"
|
|
22
|
+
sh "gem install -l #{file}"
|
|
42
23
|
end
|
|
43
24
|
end
|
|
44
25
|
|
|
45
26
|
desc "Run the example program"
|
|
46
|
-
task :example => [:
|
|
47
|
-
Dir.mkdir('sys') unless File.exists?('sys')
|
|
48
|
-
if CONFIG['host_os'] =~ /mswin|win32|mingw|cygwin|dos|windows|linux/i
|
|
49
|
-
if CONFIG['host_os'].match('linux')
|
|
50
|
-
cp 'lib/linux/sys/cpu.rb', 'sys'
|
|
51
|
-
else
|
|
52
|
-
cp 'lib/windows/sys/cpu.rb', 'sys'
|
|
53
|
-
end
|
|
54
|
-
else
|
|
55
|
-
build_file = 'ext/cpu.' + CONFIG['DLEXT']
|
|
56
|
-
cp build_file, 'sys'
|
|
57
|
-
end
|
|
58
|
-
|
|
27
|
+
task :example => [:clean] do
|
|
59
28
|
case CONFIG['host_os']
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
29
|
+
when /bsd|darwin|osx|dragonfly/i
|
|
30
|
+
file = "examples/example_sys_cpu_bsd.rb"
|
|
31
|
+
sh "ruby -Ilib #{file}"
|
|
32
|
+
when /hpux/i
|
|
33
|
+
file = "examples/example_sys_cpu_hpux.rb"
|
|
34
|
+
sh "ruby -Ilib #{file}"
|
|
35
|
+
when /linux/i
|
|
36
|
+
file = "examples/example_sys_cpu_linux.rb"
|
|
37
|
+
sh "ruby -Ilib #{file}"
|
|
38
|
+
when /windows|win32|cygwin|mingw|dos/i
|
|
39
|
+
file = "examples/example_sys_cpu_windows.rb"
|
|
40
|
+
sh "ruby -Ilib #{file}"
|
|
70
41
|
end
|
|
71
|
-
sh "ruby -I. -Iext -Ilib #{file}"
|
|
72
42
|
end
|
|
73
43
|
|
|
74
|
-
|
|
75
|
-
if CONFIG['host_os'] =~ /mswin|win32|mingw|cygwin|dos|windows/i
|
|
76
|
-
t.libs << 'lib/windows'
|
|
77
|
-
elsif CONFIG['host_os'] =~ /linux/i
|
|
78
|
-
t.libs << 'lib/linux'
|
|
79
|
-
else
|
|
80
|
-
task :test => :build
|
|
81
|
-
t.libs << 'ext'
|
|
82
|
-
t.libs.delete('lib')
|
|
83
|
-
end
|
|
44
|
+
RuboCop::RakeTask.new
|
|
84
45
|
|
|
85
|
-
|
|
86
|
-
|
|
46
|
+
desc "Run the test suite"
|
|
47
|
+
RSpec::Core::RakeTask.new(:spec) do |t|
|
|
48
|
+
t.verbose = false
|
|
49
|
+
t.rspec_opts = '-f documentation -w'
|
|
87
50
|
end
|
|
88
51
|
|
|
89
|
-
task :default => :
|
|
52
|
+
task :default => :spec
|