sys-uname 1.2.1 → 1.2.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/{CHANGES.rdoc → CHANGES.md} +48 -35
- data/Gemfile +2 -0
- data/{MANIFEST.rdoc → MANIFEST.md} +2 -1
- data/README.md +68 -0
- data/Rakefile +6 -4
- data/doc/uname.rdoc +1 -1
- data/lib/sys/platform.rb +17 -13
- data/lib/sys/uname.rb +3 -1
- data/lib/sys/unix/uname.rb +20 -35
- data/lib/sys/windows/uname.rb +221 -237
- data/lib/sys-uname.rb +2 -0
- data/spec/spec_helper.rb +12 -0
- data/spec/sys_platform_spec.rb +32 -38
- data/spec/sys_uname_spec.rb +141 -137
- data/sys-uname.gemspec +14 -9
- data.tar.gz.sig +0 -0
- metadata +68 -32
- metadata.gz.sig +0 -0
- data/README.rdoc +0 -51
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: da53561b44caf45c227aad7130b9b120e9bbdd3cd35b665ecf527b8a7ad51996
|
4
|
+
data.tar.gz: ce041695020d00b6eeacb5861fc39268a84a6bc4f586f3c2576f2b4e599816d7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dd826360df12898bb135c2a442c475cbf209c1dae207b290214af3ae8130eaaed41800c2744942908ac11469c4ec9c7d2bebbd25bf112041148c629b502431d3
|
7
|
+
data.tar.gz: bd9cdeff9d5459e7c66e86b280c6f19f046812bfdb3abb05b8c874cfd535df3895f8ad3198026df3ac2f845690bc85dd0b9ab939212b6563c95071215e011453
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/{CHANGES.rdoc → CHANGES.md}
RENAMED
@@ -1,34 +1,47 @@
|
|
1
|
-
|
1
|
+
## 1.2.3 - 9-Apr-2023
|
2
|
+
* Added rubygems_mfa_required and github_repo to metadata.
|
3
|
+
* Miscellaneous rubocop related updates.
|
4
|
+
* Fixed one test for Windows.
|
5
|
+
* The rubocop and rubocop-rspec gems are now development dependencies.
|
6
|
+
* Now assumes Ruby 2.0 or later.
|
7
|
+
|
8
|
+
## 1.2.2 - 30-Oct-2020
|
9
|
+
* Added a Gemfile.
|
10
|
+
* The ffi dependency is now slightly more restrictive.
|
11
|
+
* Added rake as a development dependency (which it really always was).
|
12
|
+
* Switched from rdoc to markdown because github wouldn't render it properly.
|
13
|
+
|
14
|
+
## 1.2.1 - 17-Mar-2020
|
2
15
|
* Properly include a LICENSE file as per the Apache-2.0 license.
|
3
16
|
|
4
|
-
|
17
|
+
## 1.2.0 - 5-Jan-2020
|
5
18
|
* Changed test suite from test-unit to rspec, which was also added as a
|
6
19
|
development dependency.
|
7
20
|
* Several new fields were added to the returned object on Windows. The fields
|
8
21
|
are encryption_level, product_type, suite_mask and system_drive.
|
9
22
|
|
10
|
-
|
23
|
+
## 1.1.1 - 10-Dec-2019
|
11
24
|
* Renamed various text files to include explicit .rdoc extension so that
|
12
25
|
they show up more nicely on github.
|
13
26
|
|
14
|
-
|
27
|
+
## 1.1.0 - 29-Aug-2019
|
15
28
|
* Changed license to Apache-2.0.
|
16
29
|
* Updated the doc/uname.txt file.
|
17
30
|
* Minor test updates.
|
18
31
|
|
19
|
-
|
32
|
+
## 1.0.4 - 4-Nov-2018
|
20
33
|
* Added metadata to the gemspec.
|
21
34
|
* Updated the cert, which will expire in about 10 years.
|
22
35
|
|
23
|
-
|
36
|
+
## 1.0.3 - 31-Oct-2016
|
24
37
|
* Updated the gem cert. It will expire on 31-Oct-2019.
|
25
38
|
* Minor updates to the Rakefile and gemspec.
|
26
39
|
|
27
|
-
|
40
|
+
## 1.0.2 - 3-Sep-2015
|
28
41
|
* The gem is now signed.
|
29
42
|
* Modified gemspec and Rakefile to support signing.
|
30
43
|
|
31
|
-
|
44
|
+
## 1.0.1 - 19-Aug-2015
|
32
45
|
* Modified Platform::IMPL so that it does not include "32" as part of the
|
33
46
|
symbol name. This isn't useful since it's the same on 32 or 64-bit Windows.
|
34
47
|
* Reorganized code a bit so that the VERSION constant is in a single place.
|
@@ -36,7 +49,7 @@
|
|
36
49
|
as Uname::VERSION.
|
37
50
|
* Added a test for Sys::Platform::IMPL on Windows.
|
38
51
|
|
39
|
-
|
52
|
+
## 1.0.0 - 19-Aug-2015
|
40
53
|
* Added a sys-uname.rb shim so that you can require this library with
|
41
54
|
"sys-uname" or "sys/uname".
|
42
55
|
* Added the architecture method for MS Windows.
|
@@ -46,32 +59,32 @@
|
|
46
59
|
* There is now just a single gem, instead of a separate gem for Windows
|
47
60
|
and Unix, so you shouldn't need to worry about platform checking.
|
48
61
|
|
49
|
-
|
62
|
+
## 0.9.2 - 1-May-2013
|
50
63
|
* Added a workaround for a win32ole thread bug. Thanks go to Tianlong Wu
|
51
64
|
for the spot.
|
52
65
|
* Altered platform handling slightly for Windows in the Rakefile.
|
53
66
|
|
54
|
-
|
67
|
+
## 0.9.1 - 3-Jan-2013
|
55
68
|
* Made FFI functions private.
|
56
69
|
* Properly alias uname FFI function.
|
57
70
|
* Fixed the QuantumLength and QuantumType bug again (see 0.8.4), which I
|
58
71
|
somehow accidentally reintroduced.
|
59
72
|
|
60
|
-
|
73
|
+
## 0.9.0 - 8-Dec-2011
|
61
74
|
* Conversion to FFI.
|
62
75
|
* Added some additional methods and information for Solaris.
|
63
76
|
* Minor tweaks for 1.9 to silence warnings.
|
64
77
|
|
65
|
-
|
78
|
+
## 0.8.6 - 2-Sep-2011
|
66
79
|
* Fixed a failing test for Ruby 1.9.x.
|
67
80
|
* The gemspec for Windows is now 'universal'.
|
68
81
|
* Some minor doc updates.
|
69
82
|
|
70
|
-
|
83
|
+
## 0.8.5 - 11-Dec-2010
|
71
84
|
* Removed some non-ascii characters that somehow made it into the source.
|
72
85
|
* Some updates to the Rakefile, including a default task.
|
73
86
|
|
74
|
-
|
87
|
+
## 0.8.4 - 29-Jan-2010
|
75
88
|
* Bug fix for Windows 7, which appears to have removed the QuantumLength and
|
76
89
|
QuantumType members of the Win32_OperatingSystem class. Thanks go to Mark
|
77
90
|
Seymour for the spot. RubyForge bug # 27645.
|
@@ -80,23 +93,23 @@
|
|
80
93
|
now all inlined within the Rakefile build task itself.
|
81
94
|
* Minor doc updates and some code reformatting.
|
82
95
|
|
83
|
-
|
96
|
+
## 0.8.3 - 26-Apr-2008
|
84
97
|
* Added an explicit "require 'time'" in the Windows version because recent
|
85
98
|
versions of Ruby now need it.
|
86
99
|
* Changed the way I do platform checks in the Rakefile.
|
87
100
|
|
88
|
-
|
101
|
+
## 0.8.2 - 22-Nov-2007
|
89
102
|
* Fixed an issue where Ruby no longer parsed a certain type of date that
|
90
103
|
MS Windows uses. See RubyForge Bug #10646 for more information.
|
91
104
|
|
92
|
-
|
105
|
+
## 0.8.1 - 29-Aug-2007
|
93
106
|
* Made a minor modification to the build script for Linux. It turns out Linux
|
94
107
|
has sysctl, but not the necessary mibs for the Uname.model method. Thanks go
|
95
108
|
to Mickey Knox (?) for the spot.
|
96
109
|
* Removed the install.rb file. The code from that program was integrated
|
97
110
|
directly into the Rakefile.
|
98
111
|
|
99
|
-
|
112
|
+
## 0.8.0 - 10-Apr-2007
|
100
113
|
* The Uname.model method should now work on most BSD platforms, not just OS X,
|
101
114
|
since it uses the sysctl() function behind the scenes.
|
102
115
|
* The 'id' method was changed to 'id_number' on HP-UX to avoid confusion with
|
@@ -107,22 +120,22 @@
|
|
107
120
|
* Removed some pre-setup code from the test suite that was no longer necessary
|
108
121
|
as a result of the Rake test task.
|
109
122
|
|
110
|
-
|
123
|
+
## 0.7.4 - 19-Nov-2006
|
111
124
|
* Internal layout changes, doc updates and gemspec improvements.
|
112
125
|
* No code changes.
|
113
126
|
|
114
|
-
|
127
|
+
## 0.7.3 - 30-Jul-2006
|
115
128
|
* Bug fix for 64 bit platforms.
|
116
129
|
* Minor modification of the extconf.rb file.
|
117
130
|
|
118
|
-
|
131
|
+
## 0.7.2 - 5-Jul-2006
|
119
132
|
* Removed '?' from the struct member names on MS Windows since these are no
|
120
133
|
longer legal.
|
121
134
|
* Removed duplicate definition of Uname.version on MS Windows (oops).
|
122
135
|
* Added a gemspec.
|
123
136
|
* Added inline rdoc documentation to the source files.
|
124
137
|
|
125
|
-
|
138
|
+
## 0.7.1 - 5-May-2005
|
126
139
|
* Removed the uname.rd file. The uname.txt file is rdoc friendly, so you
|
127
140
|
can autogenerate html from that file if you wish.
|
128
141
|
* Removed the version.h file - no longer needed now that the Windows version
|
@@ -131,7 +144,7 @@
|
|
131
144
|
* Minor setup modifications to the test suite.
|
132
145
|
* This package is now hosted on RubyForge.
|
133
146
|
|
134
|
-
|
147
|
+
## 0.7.0 - 11-Jan-2004
|
135
148
|
* Scrapped the C version for Windows in favor of a pure Ruby version that uses
|
136
149
|
WMI + OLE. I highly recommend using Ruby 1.8.2 or later on Win32 systems.
|
137
150
|
Earlier versions may cause segfaults.
|
@@ -143,18 +156,18 @@
|
|
143
156
|
* Removed the INSTALL file. That information is now included in the README.
|
144
157
|
* Documentation updates.
|
145
158
|
|
146
|
-
|
159
|
+
## 0.6.1 - 25-Apr-2004
|
147
160
|
* Simplified extconf.rb script and installation instructions.
|
148
161
|
* Combined three test scripts into a single test script.
|
149
162
|
* Warranty information added.
|
150
163
|
|
151
|
-
|
164
|
+
## 0.6.0 - 25-Jun-2003
|
152
165
|
* Added HP-UX support, including the id() class method (HP-UX only)
|
153
166
|
* Fixed minor bug in extconf.rb (forgot 'require ftools' at top)
|
154
167
|
* Added HP-UX specific tests and support
|
155
168
|
* Made test.rb friendlier for folks without TestUnit installed
|
156
169
|
|
157
|
-
|
170
|
+
## 0.5.0 - 16-Jun-2003
|
158
171
|
* Added OS X support, including the "model" method. Thanks to Mike Hall
|
159
172
|
for the patch
|
160
173
|
* Removed VERSION() class method. Use the constant instead
|
@@ -167,17 +180,17 @@
|
|
167
180
|
* Fixed up test suite. Added OS X specific tests and support. Should now
|
168
181
|
work with TestUnit 0.1.6 or later
|
169
182
|
|
170
|
-
|
183
|
+
## 0.4.1 - 7-Feb-2003
|
171
184
|
* Fixed C89 issue (again) - thanks go to Daniel Zepeda for the spot
|
172
185
|
* Fixed bugs in extconf.rb file (rescue clause, ftools)
|
173
186
|
|
174
|
-
|
187
|
+
## 0.4.0 - 6-Feb-2003
|
175
188
|
* MS Windows support!
|
176
189
|
* Added a test suite and automatic test.rb creation
|
177
190
|
* Documentation additions/fixes
|
178
191
|
* Internal directory layout and filename changes (Changelog -> CHANGES)
|
179
192
|
|
180
|
-
|
193
|
+
## 0.3.3 - 6-Jan-2003
|
181
194
|
* Made the code C89 compliant for older compilers. Thanks to Paul Brannan
|
182
195
|
for teaching me how to fix this in general.
|
183
196
|
* Moved README to doc/uname.txt
|
@@ -187,14 +200,14 @@
|
|
187
200
|
* Changed tarball name to reflect RAA package name
|
188
201
|
* Minor doc changes
|
189
202
|
|
190
|
-
|
203
|
+
## 0.3.2 - 8-Aug-2002
|
191
204
|
* Changed the struct name returned by the 'uname()' method from
|
192
205
|
"Uname::UnameStruct" to just "UnameStruct". This was to make it
|
193
206
|
compliant with future versions of Ruby. The extra namespace was
|
194
207
|
redundant anyway.
|
195
208
|
* I include the documentation now, instead of making you install rd2 :)
|
196
209
|
|
197
|
-
|
210
|
+
## 0.3.1 - 22-Jul-2002
|
198
211
|
* Added the 'uname' class method, which returns a struct that contains all
|
199
212
|
of the uname information
|
200
213
|
* Added a test script. Do 'ruby test.rb' to run it.
|
@@ -204,7 +217,7 @@
|
|
204
217
|
* Changed version number style to be consistent with other 'Sys' modules
|
205
218
|
* Now installs into 'Sys-Uname-x.x.x' directory (instead of just 'Uname')
|
206
219
|
|
207
|
-
|
220
|
+
## 0.03 - 6-June-2002
|
208
221
|
* rd style documentation now inline
|
209
222
|
* README.html is now uname.html - created via rdtool
|
210
223
|
* The 'platform()' and 'architecture()' methods have been added for Solaris
|
@@ -212,7 +225,7 @@
|
|
212
225
|
* The whole 'Sys' class has been removed. Delete your sys.so file if you
|
213
226
|
installed a previous version of Sys-Uname
|
214
227
|
|
215
|
-
|
228
|
+
## 0.02 - 3-June-2002
|
216
229
|
* Potentially fatal memory problems corrected.
|
217
230
|
* Should now build with C++ as well
|
218
231
|
* Thanks to Mike Hall for both the spot and the fix
|
@@ -220,5 +233,5 @@
|
|
220
233
|
* Added a README.html file
|
221
234
|
* Added a Manifest file
|
222
235
|
|
223
|
-
|
236
|
+
## 0.01 - 31-May-2002
|
224
237
|
* Initial release (unannounced)
|
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,68 @@
|
|
1
|
+
[![Ruby](https://github.com/djberg96/sys-uname/actions/workflows/ruby.yml/badge.svg)](https://github.com/djberg96/sys-uname/actions/workflows/ruby.yml)
|
2
|
+
|
3
|
+
## Description
|
4
|
+
A cross-platform Ruby interface for getting operating system information. The name
|
5
|
+
comes from the Unix 'uname' command, but this library works on MS Windows as well.
|
6
|
+
|
7
|
+
## Prerequisites
|
8
|
+
ffi 1.0 or later
|
9
|
+
|
10
|
+
## Installation
|
11
|
+
`gem install sys-uname`
|
12
|
+
|
13
|
+
## Adding the trusted cert
|
14
|
+
`gem cert --add <(curl -Ls https://raw.githubusercontent.com/djberg96/sys-uname/main/certs/djberg96_pub.pem)`
|
15
|
+
|
16
|
+
## Synopsis
|
17
|
+
```ruby
|
18
|
+
require 'sys/uname' # require 'sys-uname' works, too
|
19
|
+
|
20
|
+
# You now have Sys::Uname and Sys::Platform classes available.
|
21
|
+
|
22
|
+
# Get full information about your system
|
23
|
+
p Sys::Uname.uname
|
24
|
+
|
25
|
+
# Check individual platform details about your system
|
26
|
+
p Sys::Platform.linux? # => true
|
27
|
+
p Sys::Platform::ARCH # => :x86_64
|
28
|
+
```
|
29
|
+
|
30
|
+
## Solaris Notes
|
31
|
+
Users on SunOS get several extra methods:
|
32
|
+
|
33
|
+
* architecture
|
34
|
+
* platform
|
35
|
+
* hw_serial
|
36
|
+
* hw_provider
|
37
|
+
* srpc_domain
|
38
|
+
* isa_list
|
39
|
+
* dhcp_cache
|
40
|
+
|
41
|
+
Note that Solaris is essentially a dead OS at this point, so it will not be
|
42
|
+
supported going forward, and will likely be dropped in the next major release.
|
43
|
+
|
44
|
+
## BSD flavors, including OS X
|
45
|
+
Users on BSD platforms get the extra `Uname.model` method.
|
46
|
+
|
47
|
+
## HP-UX Notes
|
48
|
+
HP-UX users get the extra `Uname.id_number` method. This is actually a
|
49
|
+
String, not a Fixnum, because that's how it's defined in the utsname
|
50
|
+
struct.
|
51
|
+
|
52
|
+
## MS Windows Notes
|
53
|
+
The C version for Windows has been completely scrapped in favor of an OLE
|
54
|
+
plus WMI approach. It is pure Ruby. Please see the MSDN documentation for
|
55
|
+
the `Win32_OperatingSystem` class for a complete list of what each of the
|
56
|
+
UnameStruct members mean.
|
57
|
+
|
58
|
+
## The Platform Class
|
59
|
+
This was added both as a nicer way to check simple information about your
|
60
|
+
system, and as a replacement for the old 'Platform' gem which is no longer
|
61
|
+
maintained.
|
62
|
+
|
63
|
+
## Future Plans
|
64
|
+
I may dump the "Uname" portion of this library, and rename the project
|
65
|
+
to just sys-platform.
|
66
|
+
|
67
|
+
## Documentation
|
68
|
+
For more details, see the 'uname.rdoc' file under the 'doc' directory.
|
data/Rakefile
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
require 'rake'
|
2
|
-
require 'rake/testtask'
|
3
2
|
require 'rake/clean'
|
4
3
|
require 'rbconfig'
|
5
4
|
require 'rspec/core/rake_task'
|
5
|
+
require 'rubocop/rake_task'
|
6
6
|
|
7
|
-
CLEAN.include("**/*.rbc", "**/*.rbx", "**/*.gem")
|
7
|
+
CLEAN.include("**/*.rbc", "**/*.rbx", "**/*.gem", "**/*.lock")
|
8
8
|
|
9
9
|
desc "Run the example program"
|
10
10
|
task :example do
|
@@ -19,9 +19,9 @@ namespace :gem do
|
|
19
19
|
desc "Create the sys-uname gem"
|
20
20
|
task :create => [:clean] do
|
21
21
|
require 'rubygems/package'
|
22
|
-
spec =
|
22
|
+
spec = Gem::Specification.load('sys-uname.gemspec')
|
23
23
|
spec.signing_key = File.join(Dir.home, '.ssh', 'gem-private_key.pem')
|
24
|
-
Gem::Package.build(spec
|
24
|
+
Gem::Package.build(spec)
|
25
25
|
end
|
26
26
|
|
27
27
|
desc "Install the sys-uname gem"
|
@@ -31,6 +31,8 @@ namespace :gem do
|
|
31
31
|
end
|
32
32
|
end
|
33
33
|
|
34
|
+
RuboCop::RakeTask.new
|
35
|
+
|
34
36
|
desc "Run the test suite"
|
35
37
|
RSpec::Core::RakeTask.new(:spec)
|
36
38
|
|
data/doc/uname.rdoc
CHANGED
data/lib/sys/platform.rb
CHANGED
@@ -1,4 +1,8 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# The Sys module is a namespace only.
|
1
4
|
module Sys
|
5
|
+
# The Platform class provides singleton methods to tell you what OS you're on.
|
2
6
|
class Platform
|
3
7
|
# The CPU architecture
|
4
8
|
ARCH = File::ALT_SEPARATOR ? Uname.architecture.to_sym : Uname.machine.to_sym
|
@@ -8,18 +12,18 @@ module Sys
|
|
8
12
|
|
9
13
|
# Returns the OS type, :macosx, :linux, :mingw32, etc
|
10
14
|
IMPL = case Uname.sysname
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
15
|
+
when /darwin|mac/i
|
16
|
+
:macosx
|
17
|
+
when /mingw|windows/i
|
18
|
+
require 'rbconfig'
|
19
|
+
RbConfig::CONFIG['host_os'].split('_').first[/[a-z]+/i].downcase.to_sym
|
20
|
+
when /linux/i
|
21
|
+
:linux
|
22
|
+
when /sunos|solaris/i
|
23
|
+
:solaris
|
24
|
+
when /bsd/i
|
25
|
+
:bsd
|
26
|
+
end
|
23
27
|
|
24
28
|
# Returns whether or not you're on a Windows OS
|
25
29
|
def self.windows?
|
@@ -28,7 +32,7 @@ module Sys
|
|
28
32
|
|
29
33
|
# Returns whether or not you're on a Unixy (non-Windows) OS
|
30
34
|
def self.unix?
|
31
|
-
Uname.sysname
|
35
|
+
Uname.sysname =~ /microsoft/i ? false : true
|
32
36
|
end
|
33
37
|
|
34
38
|
# Returns whether or not you're on a mac, i.e. OSX
|
data/lib/sys/uname.rb
CHANGED
data/lib/sys/unix/uname.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'ffi'
|
2
4
|
require 'rbconfig'
|
3
5
|
require 'ostruct'
|
@@ -30,7 +32,7 @@ module Sys
|
|
30
32
|
private_class_method :uname_c
|
31
33
|
|
32
34
|
begin
|
33
|
-
attach_function :sysctl, [
|
35
|
+
attach_function :sysctl, %i[pointer uint pointer pointer pointer size_t], :int
|
34
36
|
private_class_method :sysctl
|
35
37
|
|
36
38
|
CTL_HW = 6 # Generic hardware/cpu
|
@@ -40,7 +42,7 @@ module Sys
|
|
40
42
|
end
|
41
43
|
|
42
44
|
begin
|
43
|
-
attach_function :sysinfo, [
|
45
|
+
attach_function :sysinfo, %i[int pointer long], :long
|
44
46
|
private_class_method :sysinfo
|
45
47
|
|
46
48
|
SI_SYSNAME = 1 # OS name
|
@@ -59,6 +61,7 @@ module Sys
|
|
59
61
|
# Ignore. Not suppored.
|
60
62
|
end
|
61
63
|
|
64
|
+
# FFI class passed to the underlying C uname function.
|
62
65
|
class UnameFFIStruct < FFI::Struct
|
63
66
|
members = [
|
64
67
|
:sysname, [:char, BUFSIZE],
|
@@ -68,13 +71,8 @@ module Sys
|
|
68
71
|
:machine, [:char, BUFSIZE]
|
69
72
|
]
|
70
73
|
|
71
|
-
if RbConfig::CONFIG['host_os'] =~ /linux/i
|
72
|
-
|
73
|
-
end
|
74
|
-
|
75
|
-
if RbConfig::CONFIG['host_os'] =~ /hpux/i
|
76
|
-
members.push(:__id_number, [:char, BUFSIZE])
|
77
|
-
end
|
74
|
+
members.push(:domainname, [:char, BUFSIZE]) if RbConfig::CONFIG['host_os'] =~ /linux/i
|
75
|
+
members.push(:__id_number, [:char, BUFSIZE]) if RbConfig::CONFIG['host_os'] =~ /hpux/i
|
78
76
|
|
79
77
|
layout(*members)
|
80
78
|
end
|
@@ -87,13 +85,8 @@ module Sys
|
|
87
85
|
machine
|
88
86
|
]
|
89
87
|
|
90
|
-
if RbConfig::CONFIG['host_os'] =~ /linux/i
|
91
|
-
|
92
|
-
end
|
93
|
-
|
94
|
-
if RbConfig::CONFIG['host_os'] =~ /hpux/i
|
95
|
-
fields.push('id_number')
|
96
|
-
end
|
88
|
+
fields.push('domainname') if RbConfig::CONFIG['host_os'] =~ /linux/i
|
89
|
+
fields.push('id_number') if RbConfig::CONFIG['host_os'] =~ /hpux/i
|
97
90
|
|
98
91
|
if RbConfig::CONFIG['host_os'] =~ /sunos|solaris/i
|
99
92
|
fields.push(
|
@@ -107,13 +100,13 @@ module Sys
|
|
107
100
|
)
|
108
101
|
end
|
109
102
|
|
110
|
-
if RbConfig::CONFIG['host_os'] =~ /darwin|bsd/i
|
111
|
-
|
112
|
-
|
103
|
+
fields.push('model') if RbConfig::CONFIG['host_os'] =~ /darwin|bsd/i
|
104
|
+
|
105
|
+
private_constant :UnameFFIStruct
|
113
106
|
|
114
107
|
# :startdoc:
|
115
108
|
|
116
|
-
UnameStruct = Struct.new(
|
109
|
+
UnameStruct = Struct.new('UnameStruct', *fields)
|
117
110
|
|
118
111
|
# Returns a struct that contains the sysname, nodename, machine, version
|
119
112
|
# and release of your system.
|
@@ -133,9 +126,7 @@ module Sys
|
|
133
126
|
def self.uname
|
134
127
|
utsname = UnameFFIStruct.new
|
135
128
|
|
136
|
-
if uname_c(utsname) < 0
|
137
|
-
raise Error, "uname() function call failed"
|
138
|
-
end
|
129
|
+
raise Error, 'uname() function call failed' if uname_c(utsname) < 0
|
139
130
|
|
140
131
|
struct = UnameStruct.new
|
141
132
|
struct[:sysname] = utsname[:sysname].to_s
|
@@ -144,9 +135,7 @@ module Sys
|
|
144
135
|
struct[:version] = utsname[:version].to_s
|
145
136
|
struct[:machine] = utsname[:machine].to_s
|
146
137
|
|
147
|
-
if RbConfig::CONFIG['host_os'] =~ /darwin|bsd/i
|
148
|
-
struct[:model] = get_model()
|
149
|
-
end
|
138
|
+
struct[:model] = get_model() if RbConfig::CONFIG['host_os'] =~ /darwin|bsd/i
|
150
139
|
|
151
140
|
if RbConfig::CONFIG['host_os'] =~ /sunos|solaris/i
|
152
141
|
struct[:architecture] = get_si(SI_ARCHITECTURE)
|
@@ -165,21 +154,17 @@ module Sys
|
|
165
154
|
struct[:machine] = get_si(SI_MACHINE) if struct.machine.empty?
|
166
155
|
end
|
167
156
|
|
168
|
-
if RbConfig::CONFIG['host_os'] =~ /hpux/i
|
169
|
-
struct[:id_number] = utsname[:__id_number].to_s
|
170
|
-
end
|
157
|
+
struct[:id_number] = utsname[:__id_number].to_s if RbConfig::CONFIG['host_os'] =~ /hpux/i
|
171
158
|
|
172
|
-
if RbConfig::CONFIG['host_os'] =~ /linux/i
|
173
|
-
struct[:domainname] = utsname[:domainname].to_s
|
174
|
-
end
|
159
|
+
struct[:domainname] = utsname[:domainname].to_s if RbConfig::CONFIG['host_os'] =~ /linux/i
|
175
160
|
|
176
161
|
# Let's add a members method that works for testing and compatibility
|
177
162
|
if struct.members.nil?
|
178
|
-
struct.instance_eval
|
163
|
+
struct.instance_eval <<-RUBY, __FILE__, __LINE__ + 1
|
179
164
|
def members
|
180
|
-
@table.keys.map
|
165
|
+
@table.keys.map(&:to_s)
|
181
166
|
end
|
182
|
-
|
167
|
+
RUBY
|
183
168
|
end
|
184
169
|
|
185
170
|
struct.freeze
|