sys-uname 0.9.0-x86-mingw32 → 0.9.1-x86-mingw32
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +6 -0
- data/doc/uname.txt +2 -2
- data/lib/unix/sys/uname.rb +12 -9
- data/lib/windows/sys/uname.rb +4 -8
- data/sys-uname.gemspec +3 -3
- data/test/test_sys_uname.rb +15 -9
- metadata +5 -4
data/CHANGES
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
== 0.9.1 - 3-Jan-2013
|
2
|
+
* Made FFI functions private.
|
3
|
+
* Properly alias uname FFI function.
|
4
|
+
* Fixed the QuantumLength and QuantumType bug again (see 0.8.4), which I
|
5
|
+
somehow accidentally reintroduced.
|
6
|
+
|
1
7
|
== 0.9.0 - 8-Dec-2011
|
2
8
|
* Conversion to FFI.
|
3
9
|
* Added some additional methods and information for Solaris.
|
data/doc/uname.txt
CHANGED
@@ -109,10 +109,10 @@ Uname.id
|
|
109
109
|
Add additional info for Linux, Solaris, BSD.
|
110
110
|
|
111
111
|
== License
|
112
|
-
|
112
|
+
Artistic 2.0
|
113
113
|
|
114
114
|
== Copyright
|
115
|
-
(C) 2002-
|
115
|
+
(C) 2002-2013 Daniel J. Berger
|
116
116
|
All Rights Reserved
|
117
117
|
|
118
118
|
== Warranty
|
data/lib/unix/sys/uname.rb
CHANGED
@@ -7,13 +7,13 @@ module Sys
|
|
7
7
|
# The Uname class encapsulates information about the system.
|
8
8
|
class Uname
|
9
9
|
extend FFI::Library
|
10
|
-
ffi_lib
|
10
|
+
ffi_lib FFI::Library::LIBC
|
11
11
|
|
12
12
|
# Error raised if the uname() function fails.
|
13
13
|
class Error < StandardError; end
|
14
14
|
|
15
15
|
# The version of the sys-uname library
|
16
|
-
VERSION = '0.9.
|
16
|
+
VERSION = '0.9.1'
|
17
17
|
|
18
18
|
# :stopdoc
|
19
19
|
|
@@ -29,10 +29,13 @@ module Sys
|
|
29
29
|
BUFSIZE = 256
|
30
30
|
end
|
31
31
|
|
32
|
-
attach_function :uname, [:pointer], :int
|
32
|
+
attach_function :uname_c, :uname, [:pointer], :int
|
33
|
+
private_class_method :uname_c
|
33
34
|
|
34
35
|
begin
|
35
36
|
attach_function :sysctl, [:pointer, :uint, :pointer, :pointer, :pointer, :size_t], :int
|
37
|
+
private_class_method :sysctl
|
38
|
+
|
36
39
|
CTL_HW = 6 # Generic hardware/cpu
|
37
40
|
HW_MODEL = 2 # Specific machine model
|
38
41
|
rescue FFI::NotFoundError
|
@@ -41,6 +44,8 @@ module Sys
|
|
41
44
|
|
42
45
|
begin
|
43
46
|
attach_function :sysinfo, [:int, :pointer, :long], :long
|
47
|
+
private_class_method :sysinfo
|
48
|
+
|
44
49
|
SI_SYSNAME = 1 # OS name
|
45
50
|
SI_HOSTNAME = 2 # Node name
|
46
51
|
SI_RELEASE = 3 # Operating system release
|
@@ -57,12 +62,6 @@ module Sys
|
|
57
62
|
# Ignore. Not suppored.
|
58
63
|
end
|
59
64
|
|
60
|
-
# Temporarily remove the uname method to avoid function name conflict
|
61
|
-
class << self
|
62
|
-
alias :uname_c :uname
|
63
|
-
remove_method :uname
|
64
|
-
end
|
65
|
-
|
66
65
|
class UnameFFIStruct < FFI::Struct
|
67
66
|
members = [
|
68
67
|
:sysname, [:char, BUFSIZE],
|
@@ -316,6 +315,8 @@ module Sys
|
|
316
315
|
buf.strip
|
317
316
|
end
|
318
317
|
|
318
|
+
private_class_method :get_model
|
319
|
+
|
319
320
|
# Returns the various sysinfo information based on +flag+.
|
320
321
|
#
|
321
322
|
def self.get_si(flag)
|
@@ -323,5 +324,7 @@ module Sys
|
|
323
324
|
sysinfo(flag, buf, BUFSIZE)
|
324
325
|
buf.strip
|
325
326
|
end
|
327
|
+
|
328
|
+
private_class_method :get_si
|
326
329
|
end
|
327
330
|
end
|
data/lib/windows/sys/uname.rb
CHANGED
@@ -11,7 +11,8 @@ module Sys
|
|
11
11
|
# This is the error raised if any of the Sys::Uname methods should fail.
|
12
12
|
class Error < StandardError; end
|
13
13
|
|
14
|
-
|
14
|
+
# The version of the sys-uname library.
|
15
|
+
VERSION = '0.9.1'
|
15
16
|
|
16
17
|
fields = %w[
|
17
18
|
boot_device
|
@@ -85,7 +86,6 @@ module Sys
|
|
85
86
|
rescue WIN32OLERuntimeError => e
|
86
87
|
raise Error, e
|
87
88
|
else
|
88
|
-
query = "select * from Win32_OperatingSystem"
|
89
89
|
wmi.InstancesOf("Win32_OperatingSystem").each{ |ole|
|
90
90
|
str = "#{ole.Version} #{ole.BuildNumber}-"
|
91
91
|
str << "#{ole.ServicePackMajorVersion}"
|
@@ -104,7 +104,6 @@ module Sys
|
|
104
104
|
rescue WIN32OLERuntimeError => e
|
105
105
|
raise Error, e
|
106
106
|
else
|
107
|
-
query = "select * from Win32_OperatingSystem"
|
108
107
|
wmi.InstancesOf("Win32_OperatingSystem").each{ |ole|
|
109
108
|
return ole.Caption
|
110
109
|
}
|
@@ -122,7 +121,6 @@ module Sys
|
|
122
121
|
rescue WIN32OLERuntimeError => e
|
123
122
|
raise Error, e
|
124
123
|
else
|
125
|
-
query = "select * from Win32_OperatingSystem"
|
126
124
|
wmi.InstancesOf("Win32_OperatingSystem").each{ |ole|
|
127
125
|
return ole.CSName
|
128
126
|
}
|
@@ -366,7 +364,6 @@ module Sys
|
|
366
364
|
rescue WIN32OLERuntimeError => e
|
367
365
|
raise Error, e
|
368
366
|
else
|
369
|
-
query = "select * from Win32_OperatingSystem"
|
370
367
|
wmi.InstancesOf("Win32_OperatingSystem").each{ |ole|
|
371
368
|
return ole.Version
|
372
369
|
}
|
@@ -384,7 +381,6 @@ module Sys
|
|
384
381
|
rescue WIN32OLERuntimeError => e
|
385
382
|
raise Error, e
|
386
383
|
else
|
387
|
-
query = "select * from Win32_OperatingSystem"
|
388
384
|
wmi.InstancesOf("Win32_OperatingSystem").each{ |os|
|
389
385
|
return UnameStruct.new(
|
390
386
|
os.BootDevice,
|
@@ -424,8 +420,8 @@ module Sys
|
|
424
420
|
os.PlusProductID,
|
425
421
|
os.PlusVersionNumber,
|
426
422
|
os.Primary,
|
427
|
-
os.QuantumLength,
|
428
|
-
os.QuantumType,
|
423
|
+
os.respond_to?(:QuantumLength) ? os.QuantumLength : nil,
|
424
|
+
os.respond_to?(:QuantumType) ? os.QuantumType : nil,
|
429
425
|
os.RegisteredUser,
|
430
426
|
os.SerialNumber,
|
431
427
|
os.ServicePackMajorVersion,
|
data/sys-uname.gemspec
CHANGED
@@ -2,19 +2,19 @@ require 'rubygems'
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |spec|
|
4
4
|
spec.name = 'sys-uname'
|
5
|
-
spec.version = '0.9.
|
5
|
+
spec.version = '0.9.1'
|
6
6
|
spec.author = 'Daniel J. Berger'
|
7
7
|
spec.email = 'djberg96@gmail.com'
|
8
8
|
spec.homepage = 'http://www.rubyforge.org/projects/sysutils'
|
9
|
-
spec.platform = Gem::Platform::RUBY
|
10
9
|
spec.summary = 'An interface for returning uname (platform) information'
|
11
10
|
spec.test_file = 'test/test_sys_uname.rb'
|
11
|
+
spec.license = 'Artistic 2.0'
|
12
12
|
spec.files = Dir['**/*'].reject{ |f| f.include?('git') }
|
13
13
|
|
14
14
|
spec.extra_rdoc_files = ['CHANGES', 'README', 'MANIFEST', 'doc/uname.txt']
|
15
15
|
spec.rubyforge_project = 'sysutils'
|
16
16
|
|
17
|
-
if
|
17
|
+
if File::ALT_SEPARATOR
|
18
18
|
spec.require_paths = ['lib', 'lib/windows']
|
19
19
|
else
|
20
20
|
spec.require_paths = ['lib', 'lib/unix']
|
data/test/test_sys_uname.rb
CHANGED
@@ -1,23 +1,20 @@
|
|
1
1
|
##############################################################################
|
2
2
|
# test_sys_uname.rb
|
3
3
|
#
|
4
|
-
# Test suite for the sys-uname
|
5
|
-
# the 'rake test' task.
|
4
|
+
# Test suite for the sys-uname library. Run 'rake test' to execute tests.
|
6
5
|
##############################################################################
|
7
|
-
|
8
|
-
require 'test/unit'
|
9
|
-
|
6
|
+
require 'test-unit'
|
10
7
|
require 'sys/uname'
|
11
8
|
require 'rbconfig'
|
12
9
|
include Sys
|
13
10
|
|
14
|
-
class
|
11
|
+
class TC_Sys_Uname < Test::Unit::TestCase
|
15
12
|
def self.startup
|
16
13
|
@@host_os = RbConfig::CONFIG['host_os']
|
17
14
|
end
|
18
15
|
|
19
16
|
test "version constant is set to expected value" do
|
20
|
-
assert_equal('0.9.
|
17
|
+
assert_equal('0.9.1', Uname::VERSION)
|
21
18
|
end
|
22
19
|
|
23
20
|
test "machine singleton method works as expected" do
|
@@ -160,6 +157,15 @@ class TC_Uname < Test::Unit::TestCase
|
|
160
157
|
assert_equal(members.sort, Uname.uname.members.sort)
|
161
158
|
end
|
162
159
|
|
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'))
|
167
|
+
end
|
168
|
+
|
163
169
|
# The following tests are win32 only
|
164
170
|
if File::ALT_SEPARATOR
|
165
171
|
def test_boot_device
|
@@ -371,12 +377,12 @@ class TC_Uname < Test::Unit::TestCase
|
|
371
377
|
|
372
378
|
def test_quantum_length
|
373
379
|
assert_nothing_raised{ Uname.uname.quantum_length}
|
374
|
-
assert_kind_of(Fixnum, Uname.uname.quantum_length)
|
380
|
+
assert_kind_of([Fixnum, NilClass], Uname.uname.quantum_length)
|
375
381
|
end
|
376
382
|
|
377
383
|
def test_quantum_type
|
378
384
|
assert_nothing_raised{ Uname.uname.quantum_type}
|
379
|
-
assert_kind_of(Fixnum, Uname.uname.quantum_type)
|
385
|
+
assert_kind_of([Fixnum, NilClass], Uname.uname.quantum_type)
|
380
386
|
end
|
381
387
|
|
382
388
|
def test_registered_user
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sys-uname
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.1
|
5
5
|
prerelease:
|
6
6
|
platform: x86-mingw32
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2013-01-04 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: ! " The sys-uname library provides an interface for gathering information\n
|
15
15
|
\ about your current platform. The library is named after the Unix 'uname'\n command
|
@@ -35,7 +35,8 @@ files:
|
|
35
35
|
- sys-uname.gemspec
|
36
36
|
- test/test_sys_uname.rb
|
37
37
|
homepage: http://www.rubyforge.org/projects/sysutils
|
38
|
-
licenses:
|
38
|
+
licenses:
|
39
|
+
- Artistic 2.0
|
39
40
|
post_install_message:
|
40
41
|
rdoc_options: []
|
41
42
|
require_paths:
|
@@ -55,7 +56,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
55
56
|
version: '0'
|
56
57
|
requirements: []
|
57
58
|
rubyforge_project: sysutils
|
58
|
-
rubygems_version: 1.
|
59
|
+
rubygems_version: 1.8.24
|
59
60
|
signing_key:
|
60
61
|
specification_version: 3
|
61
62
|
summary: An interface for returning uname (platform) information
|