sys-uname 0.8.3-x86-mswin32-60

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGES ADDED
@@ -0,0 +1,142 @@
1
+ == 0.8.3 - 26-Apr-2008
2
+ * Added an explicit "require 'time'" in the Windows version because recent
3
+ versions of Ruby now need it.
4
+ * Changed the way I do platform checks in the Rakefile.
5
+
6
+ == 0.8.2 - 22-Nov-2007
7
+ * Fixed an issue where Ruby no longer parsed a certain type of date that
8
+ MS Windows uses. See RubyForge Bug #10646 for more information.
9
+
10
+ == 0.8.1 - 29-Aug-2007
11
+ * Made a minor modification to the build script for Linux. It turns out Linux
12
+ has sysctl, but not the necessary mibs for the Uname.model method. Thanks go
13
+ to Mickey Knox (?) for the spot.
14
+ * Removed the install.rb file. The code from that program was integrated
15
+ directly into the Rakefile.
16
+
17
+ == 0.8.0 - 10-Apr-2007
18
+ * The Uname.model method should now work on most BSD platforms, not just OS X,
19
+ since it uses the sysctl() function behind the scenes.
20
+ * The 'id' method was changed to 'id_number' on HP-UX to avoid confusion with
21
+ the Object.id method.
22
+ * The UnameError class is now Uname::Error.
23
+ * Added a Rakefile. There are now tasks for building, testing and installing
24
+ this package.
25
+ * Removed some pre-setup code from the test suite that was no longer necessary
26
+ as a result of the Rake test task.
27
+
28
+ == 0.7.4 - 19-Nov-2006
29
+ * Internal layout changes, doc updates and gemspec improvements.
30
+ * No code changes.
31
+
32
+ == 0.7.3 - 30-Jul-2006
33
+ * Bug fix for 64 bit platforms.
34
+ * Minor modification of the extconf.rb file.
35
+
36
+ == 0.7.2 - 5-Jul-2006
37
+ * Removed '?' from the struct member names on MS Windows since these are no
38
+ longer legal.
39
+ * Removed duplicate definition of Uname.version on MS Windows (oops).
40
+ * Added a gemspec.
41
+ * Added inline rdoc documentation to the source files.
42
+
43
+ == 0.7.1 - 5-May-2005
44
+ * Removed the uname.rd file. The uname.txt file is rdoc friendly, so you
45
+ can autogenerate html from that file if you wish.
46
+ * Removed the version.h file - no longer needed now that the Windows version
47
+ is pure Ruby.
48
+ * Renamed test.rb to uname_test.rb
49
+ * Minor setup modifications to the test suite.
50
+ * This package is now hosted on RubyForge.
51
+
52
+ == 0.7.0 - 11-Jan-2004
53
+ * Scrapped the C version for Windows in favor of a pure Ruby version that uses
54
+ WMI + OLE. I highly recommend using Ruby 1.8.2 or later on Win32 systems.
55
+ Earlier versions may cause segfaults.
56
+ * Added the isa_list, hw_provider, hw_serial_number, srpc_domain and
57
+ dhcp_cache methods for Solaris.
58
+ * Added install.rb program for Windows, and modified extconf.rb to only run on
59
+ non-Windows systems.
60
+ * The 'examples' directory has been moved to the toplevel directory.
61
+ * Removed the INSTALL file. That information is now included in the README.
62
+ * Documentation updates.
63
+
64
+ == 0.6.1 - 25-Apr-2004
65
+ * Simplified extconf.rb script and installation instructions.
66
+ * Combined three test scripts into a single test script.
67
+ * Warranty information added.
68
+
69
+ == 0.6.0 - 25-Jun-2003
70
+ * Added HP-UX support, including the id() class method (HP-UX only)
71
+ * Fixed minor bug in extconf.rb (forgot 'require ftools' at top)
72
+ * Added HP-UX specific tests and support
73
+ * Made test.rb friendlier for folks without TestUnit installed
74
+
75
+ == 0.5.0 - 16-Jun-2003
76
+ * Added OS X support, including the "model" method. Thanks to Mike Hall
77
+ for the patch
78
+ * Removed VERSION() class method. Use the constant instead
79
+ * Moved rd documentation to its own file (under /doc directory)
80
+ * Added a version.h file under 'lib' to store VERSION info for
81
+ all source files
82
+ * Modified extconf.rb file to handle OS X support. In addition, moved
83
+ test.rb into a static file under /test, instead of dynamically
84
+ generating it
85
+ * Fixed up test suite. Added OS X specific tests and support. Should now
86
+ work with TestUnit 0.1.6 or later
87
+
88
+ == 0.4.1 - 7-Feb-2003
89
+ * Fixed C89 issue (again) - thanks go to Daniel Zepeda for the spot
90
+ * Fixed bugs in extconf.rb file (rescue clause, ftools)
91
+
92
+ == 0.4.0 - 6-Feb-2003
93
+ * MS Windows support!
94
+ * Added a test suite and automatic test.rb creation
95
+ * Documentation additions/fixes
96
+ * Internal directory layout and filename changes (Changelog -> CHANGES)
97
+
98
+ == 0.3.3 - 6-Jan-2003
99
+ * Made the code C89 compliant for older compilers. Thanks to Paul Brannan
100
+ for teaching me how to fix this in general.
101
+ * Moved README to doc/uname.txt
102
+ * Created an INSTALL file
103
+ * Added a copyright notice
104
+ * Added a VERSION class method
105
+ * Changed tarball name to reflect RAA package name
106
+ * Minor doc changes
107
+
108
+ == 0.3.2 - 8-Aug-2002
109
+ * Changed the struct name returned by the 'uname()' method from
110
+ "Uname::UnameStruct" to just "UnameStruct". This was to make it
111
+ compliant with future versions of Ruby. The extra namespace was
112
+ redundant anyway.
113
+ * I include the documentation now, instead of making you install rd2 :)
114
+
115
+ == 0.3.1 - 22-Jul-2002
116
+ * Added the 'uname' class method, which returns a struct that contains all
117
+ of the uname information
118
+ * Added a test script. Do 'ruby test.rb' to run it.
119
+ * If rd2 is installed on your system, the documentation is automatically
120
+ generated for you.
121
+ * Moved html documentation to 'doc' directory.
122
+ * Changed version number style to be consistent with other 'Sys' modules
123
+ * Now installs into 'Sys-Uname-x.x.x' directory (instead of just 'Uname')
124
+
125
+ == 0.03 - 6-June-2002
126
+ * rd style documentation now inline
127
+ * README.html is now uname.html - created via rdtool
128
+ * The 'platform()' and 'architecture()' methods have been added for Solaris
129
+ * You can now do an 'include Sys' to shorten your syntax
130
+ * The whole 'Sys' class has been removed. Delete your sys.so file if you
131
+ installed a previous version of Sys-Uname
132
+
133
+ == 0.02 - 3-June-2002
134
+ * Potentially fatal memory problems corrected.
135
+ * Should now build with C++ as well
136
+ * Thanks to Mike Hall for both the spot and the fix
137
+ * Added a Changelog file
138
+ * Added a README.html file
139
+ * Added a Manifest file
140
+
141
+ == 0.01 - 31-May-2002
142
+ * Initial release (unannounced)
data/MANIFEST ADDED
@@ -0,0 +1,11 @@
1
+ * MANIFEST
2
+ * CHANGES
3
+ * README
4
+ * Rakefile
5
+ * sys-uname.gemspec
6
+ * doc/uname.txt
7
+ * examples/uname_test.rb
8
+ * ext/extconf.rb
9
+ * ext/uname.c
10
+ * lib/sys/uname.rb
11
+ * test/tc_uname.rb
data/README ADDED
@@ -0,0 +1,37 @@
1
+ = Prerequisites
2
+ === Unix
3
+ Ruby 1.8.0 or later.
4
+ === MS Windows
5
+ Ruby 1.8.2 or later. Earlier versions segfault due to OLE bugs.
6
+ Active WMI service (normally on by default).
7
+
8
+ = Installation
9
+ rake test (optional)
10
+ rake install (non-gem) or rake install_gem (gems)
11
+
12
+ = Synopsis
13
+ require 'sys/uname'
14
+ include Sys
15
+
16
+ p Uname.uname
17
+
18
+ = Solaris Notes
19
+ Folks building this package on SunOS get two extra methods: architecture()
20
+ and platform()
21
+
22
+ = BSD flavors, including OS X
23
+ Users on BSD platforms get the extra Uname.model method.
24
+
25
+ = HP-UX Notes
26
+ HP-UX users get the extra Uname.id_number method. This is actually a
27
+ String, not a Fixnum, because that's how it's defined in the utsname
28
+ struct.
29
+
30
+ = MS Windows Notes
31
+ The C version for Windows has been completely scrapped in favor of an OLE
32
+ plus WMI approach. It is pure Ruby. Please see the MSDN documentation for
33
+ the Win32_OperatingSystem class for a complete list of what each of the
34
+ UnameStruct members mean.
35
+
36
+ = Documentation
37
+ For more details, see the 'uname.txt' file under the 'doc' directory.
data/Rakefile ADDED
@@ -0,0 +1,71 @@
1
+ require 'rake'
2
+ require 'rake/clean'
3
+ require 'rake/testtask'
4
+ require 'rbconfig'
5
+ include Config
6
+
7
+ desc "Clean the build files for the sys-uname source for UNIX systems"
8
+ task :clean do
9
+ Dir.chdir('ext') do
10
+ unless CONFIG['host_os'] =~ /mswin|windows/i
11
+ build_file = 'uname.' + Config::CONFIG['DLEXT']
12
+ rm "sys/#{build_file}" if File.exists?("sys/#{build_file}")
13
+ sh 'make distclean' if File.exists?(build_file)
14
+ end
15
+ end
16
+ end
17
+
18
+ desc "Build the sys-uname package on UNIX systems (but don't install it)"
19
+ task :build => [:clean] do
20
+ Dir.chdir('ext') do
21
+ unless CONFIG['host_os'] =~ /mswin|windows/i
22
+ ruby 'extconf.rb'
23
+ sh 'make'
24
+ build_file = 'uname.' + Config::CONFIG['DLEXT']
25
+ cp build_file, 'sys' # For testing
26
+ end
27
+ end
28
+ end
29
+
30
+ desc "Run the example program"
31
+ task :example => [:build] do
32
+ if CONFIG['host_os'] =~ /mswin|windows/i
33
+ sh 'ruby -Ilib examples/uname_test.rb'
34
+ else
35
+ sh 'ruby -Iext examples/uname_test.rb'
36
+ end
37
+ end
38
+
39
+ if CONFIG['host_os'] =~ /mswin|windows/i
40
+ desc "Install the sys-uname package (non-gem)"
41
+ task :install do
42
+ Dir.mkdir(dir) unless File.exists?(dir)
43
+ FileUtils.cp('lib/sys/uname.rb', dir, :verbose => true)
44
+ end
45
+ else
46
+ desc "Install the sys-uname package"
47
+ task :install => [:build] do
48
+ Dir.chdir('ext') do
49
+ sh 'make install'
50
+ end
51
+ end
52
+ end
53
+
54
+ desc "Install the sys-uname package as a gem"
55
+ task :install_gem do
56
+ ruby 'sys-uname.gemspec'
57
+ file = Dir['sys-uname*.gem'].first
58
+ sh "gem install #{file}"
59
+ end
60
+
61
+ desc "Run the test suite"
62
+ Rake::TestTask.new("test") do |t|
63
+ if CONFIG['host_os'] =~ /mswin|windows/i
64
+ t.libs << 'lib'
65
+ else
66
+ task :test => :build
67
+ t.libs << 'ext'
68
+ t.libs.delete('lib')
69
+ end
70
+ t.test_files = FileList['test/tc_uname.rb']
71
+ end
data/doc/uname.txt ADDED
@@ -0,0 +1,127 @@
1
+ == Description
2
+ A Ruby interface for getting operating system information. The name comes
3
+ from the Unix 'uname' command, but this library works on Windows as well.
4
+
5
+ == Synopsis
6
+ require 'sys/uname'
7
+ include Sys
8
+
9
+ # Unix
10
+ puts Uname.nodename => my_host
11
+ puts Uname.version => #1 Fri Oct 24 22:43:28 MDT 2003
12
+ puts Uname.sysname => Linux
13
+ puts Uname.machine => i686
14
+ puts Uname.release => 2.4.22-21mdk
15
+
16
+ p Uname.uname => Show all UnameStruct members
17
+
18
+ # Windows
19
+ u = Uname.uname
20
+ puts u.caption => 'Microsoft Windows XP Home Edition
21
+ puts u.csd_version => 'Service Pack 2'
22
+
23
+ == Constants
24
+ VERSION
25
+ The current version number of the sys-uname library. This is a String.
26
+
27
+ == Class Methods
28
+ Uname.sysname
29
+ Returns the operating system name. e.g. "SunOS"
30
+
31
+ Uname.nodename
32
+ Returns the nodename. This is usually, but not necessarily, the
33
+ same as the system's hostname.
34
+
35
+ You cannot currently set the nodename (root or otherwise). This may
36
+ be added in a future release.
37
+
38
+ Uname.machine
39
+ Returns the machine hardware type. e.g. "i686"
40
+
41
+ Uname.version
42
+ Returns the operating system version. e.g. "5.8". In the case of MS
43
+ Windows, it returns the version plus patch information, separated by
44
+ a hyphen, e.g. "2915-Service Pack 2".
45
+
46
+ Uname.release
47
+ Returns the operating system release. e.g. "2.2.16-3"
48
+
49
+ Uname.uname
50
+ Returns a struct of type UnameStruct that contains sysname, nodename,
51
+ machine, version, and release. On Solaris, it will also include
52
+ architecture and platform. On HP-UX, it will also include id_number.
53
+
54
+ MS Windows - there are many more, and different, fields in the struct.
55
+ Please see the MSDN documenation on the Win32_OperatingSystem WMI class
56
+ for a complete explanation of what each of these members mean.
57
+
58
+ == Solaris Only
59
+ Uname.architecture
60
+ Returns the instruction set architecture. e.g. "sparc"
61
+
62
+ Uname.platform
63
+ Returns the platform identifier. e.g. "SUNW,Sun-Blade-100"
64
+
65
+ Uname.isa_list
66
+ Returns a space separated string containing a list of all variant
67
+ instruction set architectures executable on the current system.
68
+
69
+ They are listed in order of performance, from best to worst.
70
+
71
+ Uname.hw_provider
72
+ Returns the name of the hardware manufacturer.
73
+
74
+ Uname.hw_serial_number
75
+ Returns the ASCII representation of the hardware-specific serial number
76
+ of the machine that executes the function.
77
+
78
+ Uname.srpc_domain
79
+ Returns the name of the Secure Remote Procedure Call domain, if any.
80
+
81
+ Uname.dhcp_cache
82
+ Returns a hexidecimal encoding, in String form, of the name of the
83
+ interface configured by boot(1M) followed by the DHCPACK reply from
84
+ the server.
85
+
86
+ == BSD Platforms Only (including OS X)
87
+ Uname.model
88
+ Returns the model type, e.g. "PowerBook5,1"
89
+
90
+ == HP-UX Only
91
+ Uname.id
92
+ Returns the id number, e.g. 234233587. This is a String, not a Fixnum.
93
+
94
+ == Notes
95
+ Not all of the information that you might be used to seeing with
96
+ a 'uname -a' is available. This may be added in future releases,
97
+ but since different implementations provide different information
98
+ (via different header files) it will be a bit of a pain.
99
+
100
+ Windows users - please see the MSDN documentation for the
101
+ Win32_OperatingSystem class for a complete list of what each of the
102
+ UnameStruct members mean.
103
+
104
+ == Known Bugs
105
+ None that I'm aware of. Please log any bugs on the project page at
106
+ http://www.rubyforge.org/projects/sysutils.
107
+
108
+ == Future Plans
109
+ Add additional info for Linux, Solaris, BSD.
110
+
111
+ == License
112
+ Ruby's
113
+
114
+ == Copyright
115
+ (C) 2002-2008 Daniel J. Berger
116
+ All Rights Reserved
117
+
118
+ == Warranty
119
+ This package is provided "as is" and without any express or
120
+ implied warranties, including, without limitation, the implied
121
+ warranties of merchantability and fitness for a particular purpose.
122
+
123
+ == Author
124
+ Daniel Berger
125
+
126
+ == See Also
127
+ uname(1) for unix, or WMI for MS Windows.
data/lib/sys/uname.rb ADDED
@@ -0,0 +1,464 @@
1
+ require 'win32ole'
2
+ require 'socket'
3
+ require 'time'
4
+
5
+ module Sys
6
+
7
+ # An interface for returning uname (platform) information.
8
+ class Uname
9
+ # This is the error raised if any of the Sys::Uname methods should fail.
10
+ class Error < StandardError; end
11
+
12
+ VERSION = '0.8.3'
13
+
14
+ fields = %w/
15
+ boot_device
16
+ build_number
17
+ build_type
18
+ caption
19
+ code_set
20
+ country_code
21
+ creation_class_name
22
+ cscreation_class_name
23
+ csd_version
24
+ cs_name
25
+ current_time_zone
26
+ debug
27
+ description
28
+ distributed
29
+ foreground_application_boost
30
+ free_physical_memory
31
+ free_space_in_paging_files
32
+ free_virtual_memory
33
+ install_date
34
+ last_bootup_time
35
+ local_date_time
36
+ locale
37
+ manufacturer
38
+ max_number_of_processes
39
+ max_process_memory_size
40
+ name
41
+ number_of_licensed_users
42
+ number_of_processes
43
+ number_of_users
44
+ organization
45
+ os_language
46
+ os_product_suite
47
+ os_type
48
+ other_type_description
49
+ plus_product_id
50
+ plus_version_number
51
+ primary
52
+ quantum_length
53
+ quantum_type
54
+ registered_user
55
+ serial_number
56
+ service_pack_major_version
57
+ service_pack_minor_version
58
+ size_stored_in_paging_files
59
+ status
60
+ system_device
61
+ system_directory
62
+ total_swap_space_size
63
+ total_virtual_memory_size
64
+ total_visible_memory_size
65
+ version
66
+ windows_directory
67
+ /
68
+
69
+ UnameStruct = Struct.new("UnameStruct", *fields)
70
+
71
+ #########################################################################
72
+ # The instance name is unpredictable, so we have to resort to using
73
+ # the 'InstancesOf' method to get the data we need, rather than
74
+ # including it as part of the connection.
75
+ #########################################################################
76
+
77
+ # Returns the version plus patch information of the operating system,
78
+ # separated by a hyphen, e.g. "2915-Service Pack 2".
79
+ #
80
+ def self.version(host=Socket.gethostname)
81
+ cs = "winmgmts://#{host}/root/cimv2"
82
+ begin
83
+ wmi = WIN32OLE.connect(cs)
84
+ rescue WIN32OLERuntimeError => e
85
+ raise Error, e
86
+ else
87
+ query = "select * from Win32_OperatingSystem"
88
+ wmi.InstancesOf("Win32_OperatingSystem").each{ |ole|
89
+ str = "#{ole.Version} #{ole.BuildNumber}-"
90
+ str << "#{ole.ServicePackMajorVersion}"
91
+ return str
92
+ }
93
+ end
94
+ end
95
+
96
+ # Returns the operating system name, e.g. "Microsoft Windows XP Home"
97
+ #
98
+ def self.sysname(host=Socket.gethostname)
99
+ cs = "winmgmts:{impersonationLevel=impersonate,(security)}"
100
+ cs << "//#{host}/root/cimv2"
101
+ begin
102
+ wmi = WIN32OLE.connect(cs)
103
+ rescue WIN32OLERuntimeError => e
104
+ raise Error, e
105
+ else
106
+ query = "select * from Win32_OperatingSystem"
107
+ wmi.InstancesOf("Win32_OperatingSystem").each{ |ole|
108
+ return ole.Caption
109
+ }
110
+ end
111
+ end
112
+
113
+ # Returns the nodename. This is usually, but not necessarily, the
114
+ # same as the system's hostname.
115
+ #
116
+ def self.nodename(host=Socket.gethostname)
117
+ cs = "winmgmts:{impersonationLevel=impersonate,(security)}"
118
+ cs << "//#{host}/root/cimv2"
119
+ begin
120
+ wmi = WIN32OLE.connect(cs)
121
+ rescue WIN32OLERuntimeError => e
122
+ raise Error, e
123
+ else
124
+ query = "select * from Win32_OperatingSystem"
125
+ wmi.InstancesOf("Win32_OperatingSystem").each{ |ole|
126
+ return ole.CSName
127
+ }
128
+ end
129
+ end
130
+
131
+ # Returns the machine hardware type. e.g. "i686".
132
+ #--
133
+ # This may or may not return the expected value because some CPU types
134
+ # were unknown to the OS when the OS was originally released. It
135
+ # appears that MS doesn't necessarily patch this, either.
136
+ #
137
+ def self.machine(cpu_num=0, host=Socket.gethostname)
138
+ cs = "winmgmts:{impersonationLevel=impersonate,(security)}"
139
+ cs << "//#{host}/root/cimv2:Win32_Processor='cpu#{cpu_num}'"
140
+ begin
141
+ wmi = WIN32OLE.connect(cs)
142
+ rescue WIN32OLERuntimeError => e
143
+ raise Error, e
144
+ else
145
+ # Convert a family number into the equivalent string
146
+ case wmi.Family
147
+ when 1
148
+ return "Other"
149
+ when 2
150
+ return "Unknown"
151
+ when 3
152
+ return "8086"
153
+ when 4
154
+ return "80286"
155
+ when 5
156
+ return "80386"
157
+ when 6
158
+ return "80486"
159
+ when 7
160
+ return "8087"
161
+ when 8
162
+ return "80287"
163
+ when 9
164
+ return "80387"
165
+ when 10
166
+ return "80487"
167
+ when 11
168
+ return "Pentium brand"
169
+ when 12
170
+ return "Pentium Pro"
171
+ when 13
172
+ return "Pentium II"
173
+ when 14
174
+ return "Pentium processor with MMX technology"
175
+ when 15
176
+ return "Celeron"
177
+ when 16
178
+ return "Pentium II Xeon"
179
+ when 17
180
+ return "Pentium III"
181
+ when 18
182
+ return "M1 Family"
183
+ when 19
184
+ return "M2 Family"
185
+ when 24
186
+ return "K5 Family"
187
+ when 25
188
+ return "K6 Family"
189
+ when 26
190
+ return "K6-2"
191
+ when 27
192
+ return "K6-3"
193
+ when 28
194
+ return "AMD Athlon Processor Family"
195
+ when 29
196
+ return "AMD Duron Processor"
197
+ when 30
198
+ return "AMD2900 Family"
199
+ when 31
200
+ return "K6-2+"
201
+ when 32
202
+ return "Power PC Family"
203
+ when 33
204
+ return "Power PC 601"
205
+ when 34
206
+ return "Power PC 603"
207
+ when 35
208
+ return "Power PC 603+"
209
+ when 36
210
+ return "Power PC 604"
211
+ when 37
212
+ return "Power PC 620"
213
+ when 38
214
+ return "Power PC X704"
215
+ when 39
216
+ return "Power PC 750"
217
+ when 48
218
+ return "Alpha Family"
219
+ when 49
220
+ return "Alpha 21064"
221
+ when 50
222
+ return "Alpha 21066"
223
+ when 51
224
+ return "Alpha 21164"
225
+ when 52
226
+ return "Alpha 21164PC"
227
+ when 53
228
+ return "Alpha 21164a"
229
+ when 54
230
+ return "Alpha 21264"
231
+ when 55
232
+ return "Alpha 21364"
233
+ when 64
234
+ return "MIPS Family"
235
+ when 65
236
+ return "MIPS R4000"
237
+ when 66
238
+ return "MIPS R4200"
239
+ when 67
240
+ return "MIPS R4400"
241
+ when 68
242
+ return "MIPS R4600"
243
+ when 69
244
+ return "MIPS R10000"
245
+ when 80
246
+ return "SPARC Family"
247
+ when 81
248
+ return "SuperSPARC"
249
+ when 82
250
+ return "microSPARC II"
251
+ when 83
252
+ return "microSPARC IIep"
253
+ when 84
254
+ return "UltraSPARC"
255
+ when 85
256
+ return "UltraSPARC II"
257
+ when 86
258
+ return "UltraSPARC IIi"
259
+ when 87
260
+ return "UltraSPARC III"
261
+ when 88
262
+ return "UltraSPARC IIIi"
263
+ when 96
264
+ return "68040"
265
+ when 97
266
+ return "68xxx Family"
267
+ when 98
268
+ return "68000"
269
+ when 99
270
+ return "68010"
271
+ when 100
272
+ return "68020"
273
+ when 101
274
+ return "68030"
275
+ when 112
276
+ return "Hobbit Family"
277
+ when 120
278
+ return "Crusoe TM5000 Family"
279
+ when 121
280
+ return "Crusoe TM3000 Family"
281
+ when 128
282
+ return "Weitek"
283
+ when 130
284
+ return "Itanium Processor"
285
+ when 144
286
+ return "PA-RISC Family"
287
+ when 145
288
+ return "PA-RISC 8500"
289
+ when 146
290
+ return "PA-RISC 8000"
291
+ when 147
292
+ return "PA-RISC 7300LC"
293
+ when 148
294
+ return "PA-RISC 7200"
295
+ when 149
296
+ return "PA-RISC 7100LC"
297
+ when 150
298
+ return "PA-RISC 7100"
299
+ when 160
300
+ return "V30 Family"
301
+ when 176
302
+ return "Pentium III Xeon�"
303
+ when 177
304
+ return "Pentium III Processor with Intel SpeedStep Technology"
305
+ when 178
306
+ return "Pentium 4"
307
+ when 179
308
+ return "Intel Xeon�"
309
+ when 180
310
+ return "AS400 Family"
311
+ when 181
312
+ return "Intel Xeon processor MP"
313
+ when 182
314
+ return "AMD AthlonXP Family"
315
+ when 183
316
+ return "AMD AthlonMP Family"
317
+ when 184
318
+ return "Intel Itanium 2"
319
+ when 185
320
+ return "AMD Opteron� Family"
321
+ when 190
322
+ return "K7"
323
+ when 200
324
+ return "IBM390 Family"
325
+ when 201
326
+ return "G4"
327
+ when 202
328
+ return "G5"
329
+ when 250
330
+ return "i860"
331
+ when 251
332
+ return "i960"
333
+ when 260
334
+ return "SH-3"
335
+ when 261
336
+ return "SH-4"
337
+ when 280
338
+ return "ARM"
339
+ when 281
340
+ return "StrongARM"
341
+ when 300
342
+ return "6x86"
343
+ when 301
344
+ return "MediaGX"
345
+ when 302
346
+ return "MII"
347
+ when 320
348
+ return "WinChip"
349
+ when 350
350
+ return "DSP"
351
+ when 500
352
+ return "Video Processor"
353
+ else
354
+ return "Unknown"
355
+ end
356
+ end
357
+ end
358
+
359
+ # Returns the release number, e.g. 5.1.2600.
360
+ #
361
+ def self.release(host=Socket.gethostname)
362
+ cs = "winmgmts://#{host}/root/cimv2"
363
+ begin
364
+ wmi = WIN32OLE.connect(cs)
365
+ rescue WIN32OLERuntimeError => e
366
+ raise Error, e
367
+ else
368
+ query = "select * from Win32_OperatingSystem"
369
+ wmi.InstancesOf("Win32_OperatingSystem").each{ |ole|
370
+ return ole.Version
371
+ }
372
+ end
373
+ end
374
+
375
+ # Returns a struct of type UnameStruct that contains sysname, nodename,
376
+ # machine, version, and release, as well as a plethora of other fields.
377
+ # Please see the MSDN documentation for what each of these fields mean.
378
+ #
379
+ def self.uname(host=Socket.gethostname)
380
+ cs = "winmgmts://#{host}/root/cimv2"
381
+ begin
382
+ wmi = WIN32OLE.connect(cs)
383
+ rescue WIN32OLERuntimeError => e
384
+ raise Error, e
385
+ else
386
+ query = "select * from Win32_OperatingSystem"
387
+ wmi.InstancesOf("Win32_OperatingSystem").each{ |os|
388
+ return UnameStruct.new(
389
+ os.BootDevice,
390
+ os.BuildNumber,
391
+ os.BuildType,
392
+ os.Caption,
393
+ os.CodeSet,
394
+ os.CountryCode,
395
+ os.CreationClassName,
396
+ os.CSCreationClassName,
397
+ os.CSDVersion,
398
+ os.CSName,
399
+ os.CurrentTimeZone,
400
+ os.Debug,
401
+ os.Description,
402
+ os.Distributed,
403
+ os.ForegroundApplicationBoost,
404
+ self.convert(os.FreePhysicalMemory),
405
+ self.convert(os.FreeSpaceInPagingFiles),
406
+ self.convert(os.FreeVirtualMemory),
407
+ self.parse_ms_date(os.InstallDate),
408
+ self.parse_ms_date(os.LastBootUpTime),
409
+ self.parse_ms_date(os.LocalDateTime),
410
+ os.Locale,
411
+ os.Manufacturer,
412
+ os.MaxNumberOfProcesses,
413
+ self.convert(os.MaxProcessMemorySize),
414
+ os.Name,
415
+ os.NumberOfLicensedUsers,
416
+ os.NumberOfProcesses,
417
+ os.NumberOfUsers,
418
+ os.Organization,
419
+ os.OSLanguage,
420
+ os.OSProductSuite,
421
+ os.OSType,
422
+ os.OtherTypeDescription,
423
+ os.PlusProductID,
424
+ os.PlusVersionNumber,
425
+ os.Primary,
426
+ os.QuantumLength,
427
+ os.QuantumType,
428
+ os.RegisteredUser,
429
+ os.SerialNumber,
430
+ os.ServicePackMajorVersion,
431
+ os.ServicePackMinorVersion,
432
+ self.convert(os.SizeStoredInPagingFiles),
433
+ os.Status,
434
+ os.SystemDevice,
435
+ os.SystemDirectory,
436
+ self.convert(os.TotalSwapSpaceSize),
437
+ self.convert(os.TotalVirtualMemorySize),
438
+ self.convert(os.TotalVisibleMemorySize),
439
+ os.Version,
440
+ os.WindowsDirectory
441
+ )
442
+ }
443
+ end
444
+ end
445
+
446
+ private
447
+
448
+ # Converts a string in the format '20040703074625.015625-360' into a
449
+ # Ruby Time object.
450
+ #
451
+ def self.parse_ms_date(str)
452
+ return if str.nil?
453
+ return Time.parse(str.split('.')[0])
454
+ end
455
+
456
+ # There is a bug in win32ole where uint64 types are returned as a
457
+ # String rather than a Fixnum/Bignum. This deals with that for now.
458
+ #
459
+ def self.convert(str)
460
+ return nil if str.nil? # Don't turn nil into 0
461
+ return str.to_i
462
+ end
463
+ end
464
+ end