sys-uname 0.8.6-universal-mingw32

Sign up to get free protection for your applications and to get access to all the features.
data/sys-uname.gemspec ADDED
@@ -0,0 +1,27 @@
1
+ require 'rubygems'
2
+
3
+ Gem::Specification.new do |spec|
4
+ spec.name = 'sys-uname'
5
+ spec.version = '0.8.6'
6
+ spec.license = 'Artistic 2.0'
7
+ spec.author = 'Daniel J. Berger'
8
+ spec.email = 'djberg96@gmail.com'
9
+ spec.homepage = 'http://www.rubyforge.org/projects/sysutils'
10
+ spec.platform = Gem::Platform::RUBY
11
+ spec.summary = 'An interface for returning system platform information'
12
+ spec.test_file = 'test/test_sys_uname.rb'
13
+ spec.files = Dir['**/*'].reject{ |f| f.include?('git') }
14
+
15
+ spec.extra_rdoc_files = ['CHANGES', 'README', 'MANIFEST', 'doc/uname.txt']
16
+ spec.rubyforge_project = 'sysutils'
17
+
18
+ spec.add_development_dependency('test-unit', '>= 2.1.0')
19
+
20
+ spec.description = <<-EOF
21
+ The sys-uname library provides an interface for gathering information
22
+ about your current platform. The library is named after the Unix 'uname'
23
+ command but also works on MS Windows. Available information includes
24
+ OS name, OS version, system name and so on. Additional information is
25
+ available for certain platforms.
26
+ EOF
27
+ end
@@ -0,0 +1,453 @@
1
+ ##############################################################################
2
+ # test_sys_uname.rb
3
+ #
4
+ # Tests for the sys-uname library. This test suite should be run via the
5
+ # 'rake test' task.
6
+ ##############################################################################
7
+ require 'rubygems'
8
+ gem 'test-unit'
9
+
10
+ require 'test/unit'
11
+ require 'sys/uname'
12
+ require 'rbconfig'
13
+ include Sys
14
+
15
+ class TC_Sys_Uname < Test::Unit::TestCase
16
+ def self.startup
17
+ @@host_os = Config::CONFIG['host_os']
18
+ end
19
+
20
+ def test_version_constant
21
+ assert_not_nil(Uname::VERSION)
22
+ assert_nothing_raised{ Uname::VERSION }
23
+ assert_kind_of(String, Uname::VERSION)
24
+ assert_equal('0.8.6', Uname::VERSION)
25
+ end
26
+
27
+ def test_machine
28
+ assert_respond_to(Uname, :machine)
29
+ assert_nothing_raised{ Uname.machine }
30
+ assert_kind_of(String, Uname.machine)
31
+ end
32
+
33
+ def test_version_method
34
+ assert_respond_to(Uname, :version)
35
+ assert_nothing_raised{ Uname.version }
36
+ assert_kind_of(String, Uname.version)
37
+ end
38
+
39
+ def test_nodename
40
+ assert_respond_to(Uname, :nodename)
41
+ assert_nothing_raised{ Uname.nodename }
42
+ assert_kind_of(String, Uname.nodename)
43
+ end
44
+
45
+ def test_release
46
+ assert_respond_to(Uname, :release)
47
+ assert_nothing_raised{ Uname.release }
48
+ assert_kind_of(String, Uname.release)
49
+ end
50
+
51
+ def test_sysname
52
+ assert_respond_to(Uname, :sysname)
53
+ assert_nothing_raised{ Uname.sysname }
54
+ assert_kind_of(String, Uname.sysname, 'Invalid Type')
55
+ end
56
+
57
+ def test_architecture
58
+ omit_unless(@@host_os =~ /sunos|solaris/i, "Solaris only")
59
+ assert_respond_to(Uname, :architecture)
60
+ assert_nothing_raised{ Uname.architecture }
61
+ assert_kind_of(String, Uname.architecture)
62
+ end
63
+
64
+ def test_platform
65
+ omit_unless(@@host_os =~ /sunos|solaris/i, "Solaris only")
66
+ assert_respond_to(Uname, :platform)
67
+ assert_nothing_raised{ Uname.platform }
68
+ assert_kind_of(String, Uname.platform)
69
+ end
70
+
71
+ def test_isa_list
72
+ omit_unless(@@host_os =~ /sunos|solaris/i, "Solaris only")
73
+ assert_respond_to(Uname, :isa_list)
74
+ assert_nothing_raised{ Uname.isa_list }
75
+ assert_kind_of(String, Uname.isa_list)
76
+ end
77
+
78
+ def test_hw_provider
79
+ omit_unless(@@host_os =~ /sunos|solaris/i, "Solaris only")
80
+ assert_respond_to(Uname,:hw_provider)
81
+ assert_nothing_raised{ Uname.hw_provider }
82
+ assert_kind_of(String, Uname.hw_provider)
83
+ end
84
+
85
+ def test_hw_serial_number
86
+ omit_unless(@@host_os =~ /sunos|solaris/i, "Solaris only")
87
+ assert_respond_to(Uname, :hw_serial_number)
88
+ assert_nothing_raised{ Uname.hw_serial_number }
89
+ assert_kind_of(Integer, Uname.hw_serial_number)
90
+ end
91
+
92
+ def test_srpc_domain
93
+ omit_unless(@@host_os =~ /sunos|solaris/i, "Solaris only")
94
+ assert_respond_to(Uname, :srpc_domain)
95
+ assert_nothing_raised{ Uname.srpc_domain }
96
+ assert_kind_of(String, Uname.srpc_domain)
97
+ end
98
+
99
+ def test_dhcp_cache
100
+ omit_unless(@@host_os =~ /sunos|solaris/i, "Solaris only")
101
+ assert_respond_to(Uname, :dhcp_cache)
102
+ assert_nothing_raised{ Uname.dhcp_cache }
103
+ assert_kind_of(String, Uname.dhcp_cache)
104
+ end
105
+
106
+ def test_model
107
+ omit_unless(@@host_os =~ /darwin|powerpc|bsd|mach/i, "BSD/Darwin only")
108
+ assert_respond_to(Uname, :model)
109
+ assert_nothing_raised{ Uname.model }
110
+ assert_kind_of(String, Uname.model)
111
+ end
112
+
113
+ def test_id_number
114
+ omit_unless(@@host_os =~ /hpux/i, "HP-UX only")
115
+ assert_respond_to(Uname, :id_number)
116
+ assert_nothing_raised{ Uname.id_number }
117
+ assert_kind_of(String, Uname.id_number)
118
+ end
119
+
120
+ def test_uname_struct
121
+ members = %w/sysname nodename machine version release/
122
+ case Config::CONFIG['host_os']
123
+ when /sunos|solaris/i
124
+ members.push('architecture','platform')
125
+ when /powerpc|darwin/i
126
+ members.push('model')
127
+ when /hpux/i
128
+ members.push('id')
129
+ when /win32|mingw|cygwin|dos/i
130
+ members = %w/
131
+ boot_device build_number build_type caption code_set country_code
132
+ creation_class_name cscreation_class_name csd_version cs_name
133
+ current_time_zone debug description distributed
134
+ foreground_application_boost free_physical_memory
135
+ free_space_in_paging_files free_virtual_memory
136
+ install_date last_bootup_time local_date_time locale
137
+ manufacturer max_number_of_processes max_process_memory_size
138
+ name number_of_licensed_users number_of_processes
139
+ number_of_users organization os_language os_product_suite
140
+ os_type other_type_description plus_product_id
141
+ plus_version_number primary quantum_length quantum_type
142
+ registered_user serial_number service_pack_major_version
143
+ service_pack_minor_version size_stored_in_paging_files
144
+ status system_device system_directory total_swap_space_size
145
+ total_virtual_memory_size total_visible_memory_size version
146
+ windows_directory
147
+ /
148
+ end
149
+ assert_nothing_raised{ Uname.uname }
150
+ assert_kind_of(Struct, Uname.uname)
151
+
152
+ if RUBY_VERSION.to_f >= 1.9
153
+ members = members.map{ |e| e.to_sym }
154
+ end
155
+
156
+ assert_equal(members, Uname.uname.members)
157
+ end
158
+
159
+ # The following tests are win32 only
160
+ if Config::CONFIG['host_os'] =~ /mswin|windows/i
161
+ def test_boot_device
162
+ assert_nothing_raised{ Uname.uname.boot_device }
163
+ assert_kind_of(String, Uname.uname.boot_device)
164
+ end
165
+
166
+ def test_build_number
167
+ assert_nothing_raised{ Uname.uname.build_number }
168
+ assert_kind_of(String, Uname.uname.build_number)
169
+ end
170
+
171
+ def test_build_type
172
+ assert_nothing_raised{ Uname.uname.build_type }
173
+ assert_kind_of(String, Uname.uname.build_type)
174
+ end
175
+
176
+ def test_caption
177
+ assert_nothing_raised{ Uname.uname.caption }
178
+ assert_kind_of(String, Uname.uname.caption)
179
+ end
180
+
181
+ def test_code_set
182
+ assert_nothing_raised{ Uname.uname.code_set }
183
+ assert_kind_of(String, Uname.uname.code_set)
184
+ end
185
+
186
+ def test_country_code
187
+ assert_nothing_raised{ Uname.uname.country_code }
188
+ assert_kind_of(String, Uname.uname.country_code)
189
+ end
190
+
191
+ def test_creation_class_name
192
+ assert_nothing_raised{ Uname.uname.creation_class_name }
193
+ assert_kind_of(String, Uname.uname.creation_class_name)
194
+ end
195
+
196
+ def test_cscreation_class_name
197
+ assert_nothing_raised{ Uname.uname.cscreation_class_name }
198
+ assert_kind_of(String, Uname.uname.cscreation_class_name)
199
+ end
200
+
201
+ def test_csd_version
202
+ assert_nothing_raised{ Uname.uname.csd_version }
203
+ assert_kind_of(String, Uname.uname.csd_version)
204
+ end
205
+
206
+ def test_cs_name
207
+ assert_nothing_raised{ Uname.uname.cs_name }
208
+ assert_kind_of(String, Uname.uname.cs_name)
209
+ end
210
+
211
+ def test_current_time_zone
212
+ assert_nothing_raised{ Uname.uname.current_time_zone }
213
+ assert_kind_of(Fixnum, Uname.uname.current_time_zone)
214
+ end
215
+
216
+ def test_debug
217
+ assert_nothing_raised{ Uname.uname.debug }
218
+ assert_boolean(Uname.uname.debug)
219
+ end
220
+
221
+ def test_description
222
+ assert_nothing_raised{ Uname.uname.description }
223
+ assert_kind_of(String, Uname.uname.description)
224
+ end
225
+
226
+ def test_distributed
227
+ assert_nothing_raised{ Uname.uname.distributed }
228
+ assert_boolean(Uname.uname.distributed)
229
+ end
230
+
231
+ # Not yet supported - WinXP or later only
232
+ #def test_encryption_level
233
+ # assert_nothing_raised{ Uname.uname.encryption_level }
234
+ # assert_kind_of(Fixnum,Uname.uname.encryption_level)
235
+ #end
236
+
237
+ def test_foreground_application_boost
238
+ assert_nothing_raised{ Uname.uname.foreground_application_boost }
239
+ assert_kind_of(Fixnum, Uname.uname.foreground_application_boost)
240
+ end
241
+
242
+ def test_free_physical_memory
243
+ assert_nothing_raised{ Uname.uname.free_physical_memory }
244
+ assert_kind_of(Fixnum, Uname.uname.free_physical_memory)
245
+ end
246
+
247
+ def test_free_space_in_paging_files
248
+ assert_nothing_raised{ Uname.uname.free_space_in_paging_files }
249
+ assert_kind_of(Fixnum, Uname.uname.free_space_in_paging_files)
250
+ end
251
+
252
+ def test_free_virtual_memory
253
+ assert_nothing_raised{ Uname.uname.free_virtual_memory}
254
+ assert_kind_of(Fixnum, Uname.uname.free_virtual_memory)
255
+ end
256
+
257
+ def test_install_date
258
+ assert_nothing_raised{ Uname.uname.install_date}
259
+ assert_kind_of(Time, Uname.uname.install_date)
260
+ end
261
+
262
+ # Not yet supported - WinXP or later only
263
+ #def test_large_system_cache
264
+ # assert_nothing_raised{ Uname.uname.large_system_cache}
265
+ # assert_kind_of(Time,Uname.uname.large_system_cache)
266
+ #end
267
+
268
+ def test_last_bootup_time
269
+ assert_nothing_raised{ Uname.uname.last_bootup_time}
270
+ assert_kind_of(Time, Uname.uname.last_bootup_time)
271
+ end
272
+
273
+ def test_local_date_time
274
+ assert_nothing_raised{ Uname.uname.local_date_time}
275
+ assert_kind_of(Time, Uname.uname.local_date_time)
276
+ end
277
+
278
+ def test_locale
279
+ assert_nothing_raised{ Uname.uname.locale}
280
+ assert_kind_of(String, Uname.uname.locale)
281
+ end
282
+
283
+ def test_manufacturer
284
+ assert_nothing_raised{ Uname.uname.manufacturer}
285
+ assert_kind_of(String, Uname.uname.manufacturer)
286
+ end
287
+
288
+ def test_max_number_of_processes
289
+ assert_nothing_raised{ Uname.uname.max_number_of_processes}
290
+ assert_kind_of(Fixnum, Uname.uname.max_number_of_processes)
291
+ end
292
+
293
+ def test_max_process_memory_size
294
+ assert_nothing_raised{ Uname.uname.max_process_memory_size}
295
+ assert_kind_of(Integer, Uname.uname.max_process_memory_size)
296
+ end
297
+
298
+ def test_name
299
+ assert_nothing_raised{ Uname.uname.name}
300
+ assert_kind_of(String, Uname.uname.name)
301
+ end
302
+
303
+ # Fails on Win XP Pro - returns nil - reason unknown
304
+ #def test_number_of_licensed_users
305
+ # assert_nothing_raised{ Uname.uname.number_of_licensed_users}
306
+ # assert_kind_of(Fixnum,Uname.uname.number_of_licensed_users)
307
+ #end
308
+
309
+ def test_number_of_processes
310
+ assert_nothing_raised{ Uname.uname.number_of_processes}
311
+ assert_kind_of(Fixnum, Uname.uname.number_of_processes)
312
+ end
313
+
314
+ def test_number_of_users
315
+ assert_nothing_raised{ Uname.uname.number_of_users}
316
+ assert_kind_of(Fixnum, Uname.uname.number_of_users)
317
+ end
318
+
319
+ def test_organization
320
+ assert_nothing_raised{ Uname.uname.organization}
321
+ assert_kind_of(String, Uname.uname.organization)
322
+ end
323
+
324
+ # Eventually replace Fixnum with a string (?)
325
+ def test_os_language
326
+ assert_nothing_raised{ Uname.uname.os_language}
327
+ assert_kind_of(Fixnum, Uname.uname.os_language)
328
+ end
329
+
330
+ # Fails on Win XP Pro - returns nil - reason unknown
331
+ #def test_os_product_suite
332
+ # assert_nothing_raised{ Uname.uname.os_product_suite}
333
+ # assert_kind_of(Fixnum,Uname.uname.os_product_suite)
334
+ #end
335
+
336
+ def test_os_type
337
+ assert_nothing_raised{ Uname.uname.os_type}
338
+ assert_kind_of(Fixnum, Uname.uname.os_type)
339
+ end
340
+
341
+ # Fails?
342
+ #def test_other_type_restriction
343
+ # assert_nothing_raised{ Uname.uname.other_type_restriction}
344
+ # assert_kind_of(Fixnum,Uname.uname.other_type_restriction)
345
+ #end
346
+
347
+ # Might be nil
348
+ def test_plus_product_id
349
+ assert_nothing_raised{ Uname.uname.plus_product_id}
350
+ end
351
+
352
+ # Might be nil
353
+ def test_plus_version_number
354
+ assert_nothing_raised{ Uname.uname.plus_version_number}
355
+ end
356
+
357
+ def test_primary
358
+ assert_nothing_raised{ Uname.uname.primary}
359
+ assert_boolean(Uname.uname.primary)
360
+ end
361
+
362
+ # Not yet supported - WinXP or later only
363
+ # def test_product_type
364
+ # assert_nothing_raised{ Uname.uname.product_type}
365
+ # assert_kind_of(Fixnum,Uname.uname.product_type)
366
+ # end
367
+
368
+ def test_quantum_length
369
+ assert_nothing_raised{ Uname.uname.quantum_length}
370
+ assert_kind_of(Fixnum, Uname.uname.quantum_length)
371
+ end
372
+
373
+ def test_quantum_type
374
+ assert_nothing_raised{ Uname.uname.quantum_type}
375
+ assert_kind_of(Fixnum, Uname.uname.quantum_type)
376
+ end
377
+
378
+ def test_registered_user
379
+ assert_nothing_raised{ Uname.uname.registered_user}
380
+ assert_kind_of(String, Uname.uname.registered_user)
381
+ end
382
+
383
+ def test_serial_number
384
+ assert_nothing_raised{ Uname.uname.serial_number}
385
+ assert_kind_of(String, Uname.uname.serial_number)
386
+ end
387
+
388
+ # This is nil on NT 4
389
+ def test_service_pack_major_version
390
+ assert_nothing_raised{ Uname.uname.service_pack_major_version}
391
+ assert_kind_of(Fixnum, Uname.uname.service_pack_major_version)
392
+ end
393
+
394
+ # This is nil on NT 4
395
+ def test_service_pack_major_version
396
+ assert_nothing_raised{ Uname.uname.service_pack_minor_version}
397
+ assert_kind_of(Fixnum, Uname.uname.service_pack_minor_version)
398
+ end
399
+
400
+ def test_status
401
+ assert_nothing_raised{ Uname.uname.status}
402
+ assert_kind_of(String, Uname.uname.status)
403
+ end
404
+
405
+ # Not yet supported - WinXP or later only
406
+ #def test_suite_mask
407
+ # assert_nothing_raised{ Uname.uname.suite_mask}
408
+ # assert_kind_of(String,Uname.uname.suite_mask)
409
+ #end
410
+
411
+ def test_system_device
412
+ assert_nothing_raised{ Uname.uname.system_device}
413
+ assert_kind_of(String, Uname.uname.system_device)
414
+ end
415
+
416
+ def test_system_directory
417
+ assert_nothing_raised{ Uname.uname.system_directory}
418
+ assert_kind_of(String, Uname.uname.system_directory)
419
+ end
420
+
421
+ # Not yet supported - WinXP or later only
422
+ #def test_system_drive
423
+ # assert_nothing_raised{ Uname.uname.system_drive}
424
+ # assert_kind_of(String,Uname.uname.system_drive)
425
+ #end
426
+
427
+ # Fails on Win XP Pro - returns nil - reason unknown
428
+ #def test_total_swap_space_size
429
+ # assert_nothing_raised{ Uname.uname.total_swap_space_size}
430
+ # assert_kind_of(Fixnum,Uname.uname.total_swap_space_size)
431
+ #end
432
+
433
+ def test_total_virtual_memory_size
434
+ assert_nothing_raised{ Uname.uname.total_virtual_memory_size}
435
+ assert_kind_of(Fixnum, Uname.uname.total_virtual_memory_size)
436
+ end
437
+
438
+ def test_total_visible_memory_size
439
+ assert_nothing_raised{ Uname.uname.total_visible_memory_size}
440
+ assert_kind_of(Fixnum, Uname.uname.total_visible_memory_size)
441
+ end
442
+
443
+ def test_version
444
+ assert_nothing_raised{ Uname.uname.version}
445
+ assert_kind_of(String, Uname.uname.version)
446
+ end
447
+
448
+ def test_windows_directory
449
+ assert_nothing_raised{ Uname.uname.windows_directory}
450
+ assert_kind_of(String, Uname.uname.windows_directory)
451
+ end
452
+ end
453
+ end