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