sys-uname 0.9.0 → 0.9.1

Sign up to get free protection for your applications and to get access to all the features.
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.
@@ -109,10 +109,10 @@ Uname.id
109
109
  Add additional info for Linux, Solaris, BSD.
110
110
 
111
111
  == License
112
- Ruby's
112
+ Artistic 2.0
113
113
 
114
114
  == Copyright
115
- (C) 2002-2012 Daniel J. Berger
115
+ (C) 2002-2013 Daniel J. Berger
116
116
  All Rights Reserved
117
117
 
118
118
  == Warranty
@@ -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('c')
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.0'
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
@@ -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
- VERSION = '0.9.0'
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,
@@ -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.0'
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 Config::CONFIG['host_os'] =~ /mswin|windows|dos|mingw|cygwin/i
17
+ if File::ALT_SEPARATOR
18
18
  spec.require_paths = ['lib', 'lib/windows']
19
19
  else
20
20
  spec.require_paths = ['lib', 'lib/unix']
@@ -1,23 +1,20 @@
1
1
  ##############################################################################
2
2
  # test_sys_uname.rb
3
3
  #
4
- # Test suite for the sys-uname package. This test suite should be run via
5
- # the 'rake test' task.
4
+ # Test suite for the sys-uname library. Run 'rake test' to execute tests.
6
5
  ##############################################################################
7
- gem 'test-unit'
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 TC_Uname < Test::Unit::TestCase
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.0', Uname::VERSION)
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,50 +1,45 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: sys-uname
3
- version: !ruby/object:Gem::Version
4
- hash: 59
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.9.1
5
5
  prerelease:
6
- segments:
7
- - 0
8
- - 9
9
- - 0
10
- version: 0.9.0
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - Daniel J. Berger
14
9
  autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
-
18
- date: 2011-12-08 00:00:00 Z
19
- dependencies:
20
- - !ruby/object:Gem::Dependency
12
+ date: 2013-01-04 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
21
15
  name: ffi
22
- prerelease: false
23
- requirement: &id001 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
24
17
  none: false
25
- requirements:
26
- - - ">="
27
- - !ruby/object:Gem::Version
28
- hash: 23
29
- segments:
30
- - 1
31
- - 0
32
- - 0
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
33
21
  version: 1.0.0
34
22
  type: :runtime
35
- version_requirements: *id001
36
- description: " The sys-uname library provides an interface for gathering information\n about your current platform. The library is named after the Unix 'uname'\n command but also works on MS Windows. Available information includes\n OS name, OS version, system name and so on. Additional information is\n available for certain platforms.\n"
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: 1.0.0
30
+ description: ! " The sys-uname library provides an interface for gathering information\n
31
+ \ about your current platform. The library is named after the Unix 'uname'\n command
32
+ but also works on MS Windows. Available information includes\n OS name, OS version,
33
+ system name and so on. Additional information is\n available for certain platforms.\n"
37
34
  email: djberg96@gmail.com
38
35
  executables: []
39
-
40
36
  extensions: []
41
-
42
- extra_rdoc_files:
37
+ extra_rdoc_files:
43
38
  - CHANGES
44
39
  - README
45
40
  - MANIFEST
46
41
  - doc/uname.txt
47
- files:
42
+ files:
48
43
  - CHANGES
49
44
  - doc/uname.txt
50
45
  - examples/uname_test.rb
@@ -56,38 +51,30 @@ files:
56
51
  - sys-uname.gemspec
57
52
  - test/test_sys_uname.rb
58
53
  homepage: http://www.rubyforge.org/projects/sysutils
59
- licenses: []
60
-
54
+ licenses:
55
+ - Artistic 2.0
61
56
  post_install_message:
62
57
  rdoc_options: []
63
-
64
- require_paths:
58
+ require_paths:
65
59
  - lib
66
60
  - lib/unix
67
- required_ruby_version: !ruby/object:Gem::Requirement
61
+ required_ruby_version: !ruby/object:Gem::Requirement
68
62
  none: false
69
- requirements:
70
- - - ">="
71
- - !ruby/object:Gem::Version
72
- hash: 3
73
- segments:
74
- - 0
75
- version: "0"
76
- required_rubygems_version: !ruby/object:Gem::Requirement
63
+ requirements:
64
+ - - ! '>='
65
+ - !ruby/object:Gem::Version
66
+ version: '0'
67
+ required_rubygems_version: !ruby/object:Gem::Requirement
77
68
  none: false
78
- requirements:
79
- - - ">="
80
- - !ruby/object:Gem::Version
81
- hash: 3
82
- segments:
83
- - 0
84
- version: "0"
69
+ requirements:
70
+ - - ! '>='
71
+ - !ruby/object:Gem::Version
72
+ version: '0'
85
73
  requirements: []
86
-
87
74
  rubyforge_project: sysutils
88
- rubygems_version: 1.8.10
75
+ rubygems_version: 1.8.24
89
76
  signing_key:
90
77
  specification_version: 3
91
78
  summary: An interface for returning uname (platform) information
92
- test_files:
79
+ test_files:
93
80
  - test/test_sys_uname.rb