sys-uname 0.8.6 → 0.9.0

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