sys-uname 0.9.2 → 1.0.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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 634e16ee327f71855ae5beb73f403d3d9801969a
4
+ data.tar.gz: 51c9a68e6caaed60bd4795e0a800ca55500a8d03
5
+ SHA512:
6
+ metadata.gz: 92410aef8438e64c17fd2f055f2015d7d013ee15915bc36511193df3156e66e962e2638caee2a818452b6c5facc43b56d67c84fd5124538723aeb22d0816c1d0
7
+ data.tar.gz: 89ddf92b1a4d5a0dcbe8dce8f944f42115d179f69508c7f473ac2cfc23063440e37d1068f39ecd779f3b9e6201a7f4b55d2b463d29a9f8a4d48a98cba9601d74
data/CHANGES CHANGED
@@ -1,3 +1,13 @@
1
+ == 1.0.0 - 19-Aug-2015
2
+ * Added a sys-uname.rb shim so that you can require this library with
3
+ "sys-uname" or "sys/uname".
4
+ * Added the architecture method for MS Windows.
5
+ * Added a Sys::Platform class that adds several boolean methods to check
6
+ your operating system. It also adds the ARCH, OS, and IMPL constants
7
+ to simulate, and ultimately replace, the old "Platform" gem.
8
+ * There is now just a single gem, instead of a separate gem for Windows
9
+ and Unix, so you shouldn't need to worry about platform checking.
10
+
1
11
  == 0.9.2 - 1-May-2013
2
12
  * Added a workaround for a win32ole thread bug. Thanks go to Tianlong Wu
3
13
  for the spot.
data/README CHANGED
@@ -12,10 +12,16 @@
12
12
  gem install sys-uname --platform universal-mingw32
13
13
 
14
14
  = Synopsis
15
- require 'sys/uname'
16
- include Sys
15
+ require 'sys/uname' # require 'sys-uname' works, too
16
+
17
+ # You now have Sys::Uname and Sys::Platform classes available.
17
18
 
18
- p Uname.uname
19
+ # Get full information about your system
20
+ p Sys::Uname.uname
21
+
22
+ # Check individual platform details about your system
23
+ p Sys::Platform.linux? # => true
24
+ p Sys::Platform::ARCH # => :x86_46
19
25
 
20
26
  = Solaris Notes
21
27
  Users on SunOS get several extra methods: architecture, platform,
@@ -31,9 +37,18 @@
31
37
 
32
38
  = MS Windows Notes
33
39
  The C version for Windows has been completely scrapped in favor of an OLE
34
- plus WMI approach. It is pure Ruby. Please see the MSDN documentation for
40
+ plus WMI approach. It is pure Ruby. Please see the MSDN documentation for
35
41
  the Win32_OperatingSystem class for a complete list of what each of the
36
42
  UnameStruct members mean.
37
43
 
44
+ = The Platform Class
45
+ This was added both as a nicer way to check simple information about your
46
+ system, and as a replacement for the old 'Platform' gem which is no longer
47
+ maintained.
48
+
49
+ = Future Plans
50
+ I may dump the "Uname" portion of this library, and rename the project
51
+ to just sys-platform.
52
+
38
53
  = Documentation
39
54
  For more details, see the 'uname.txt' file under the 'doc' directory.
data/Rakefile CHANGED
@@ -17,17 +17,13 @@ end
17
17
  namespace :gem do
18
18
  desc "Create the sys-uname gem"
19
19
  task :create => [:clean] do
20
+ require 'rubygems/package'
20
21
  spec = eval(IO.read('sys-uname.gemspec'))
21
-
22
- if File::ALT_SEPARATOR
23
- spec.platform = Gem::Platform::new(['universal', 'mingw32'])
24
- end
25
-
26
- Gem::Builder.new(spec).build
22
+ Gem::Package.build(spec)
27
23
  end
28
24
 
29
25
  desc "Install the sys-uname gem"
30
- task :install => [:build] do
26
+ task :install => [:create] do
31
27
  file = Dir["*.gem"].first
32
28
  sh "gem install #{file}"
33
29
  end
@@ -35,12 +31,6 @@ end
35
31
 
36
32
  desc "Run the test suite"
37
33
  Rake::TestTask.new("test") do |t|
38
- if File::ALT_SEPARATOR
39
- t.libs << 'lib/windows'
40
- else
41
- t.libs << 'lib/unix'
42
- end
43
-
44
34
  t.warning = true
45
35
  t.verbose = true
46
36
  end
@@ -0,0 +1 @@
1
+ require_relative 'sys/uname'
@@ -0,0 +1,54 @@
1
+ module Sys
2
+ class Platform
3
+ # The CPU architecture
4
+ ARCH = File::ALT_SEPARATOR ? Uname.architecture.to_sym : Uname.machine.to_sym
5
+
6
+ # Returns a basic OS family, either :windows or :unix
7
+ OS = File::ALT_SEPARATOR ? :windows : :unix
8
+
9
+ # Returns the OS type, :macosx, :linux, :mingw32, etc
10
+ IMPL = case Uname.sysname
11
+ when /darwin|mac/i
12
+ :macosx
13
+ when /mingw|windows/i
14
+ require 'rbconfig'
15
+ RbConfig::CONFIG['host_os'].split('_').first.to_sym
16
+ when /linux/i
17
+ :linux
18
+ when /sunos|solaris/i
19
+ :solaris
20
+ when /bsd/i
21
+ :bsd
22
+ end
23
+
24
+ # Returns whether or not you're on a Windows OS
25
+ def self.windows?
26
+ Uname.sysname =~ /microsoft/i ? true : false
27
+ end
28
+
29
+ # Returns whether or not you're on a Unixy (non-Windows) OS
30
+ def self.unix?
31
+ Uname.sysname !~ /microsoft/i ? true : false
32
+ end
33
+
34
+ # Returns whether or not you're on a mac, i.e. OSX
35
+ def self.mac?
36
+ Uname.sysname =~ /darwin|mac/i ? true : false
37
+ end
38
+
39
+ # Returns whether or not you're on Linux
40
+ def self.linux?
41
+ Uname.sysname =~ /linux/i ? true : false
42
+ end
43
+
44
+ # Returns whether or not you're on Solaris
45
+ def self.solaris?
46
+ Uname.sysname =~ /sunos|solaris/i ? true : false
47
+ end
48
+
49
+ # Returns whether or not you're on any BSD platform
50
+ def self.bsd?
51
+ Uname.sysname =~ /bsd/i ? true : false
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,7 @@
1
+ if File::ALT_SEPARATOR
2
+ require_relative 'windows/uname'
3
+ else
4
+ require_relative 'unix/uname'
5
+ end
6
+
7
+ require_relative 'platform'
@@ -13,7 +13,7 @@ module Sys
13
13
  class Error < StandardError; end
14
14
 
15
15
  # The version of the sys-uname library
16
- VERSION = '0.9.2'
16
+ VERSION = '1.0.0'
17
17
 
18
18
  # :stopdoc
19
19
 
@@ -20,7 +20,7 @@ module Sys
20
20
  class Error < StandardError; end
21
21
 
22
22
  # The version of the sys-uname library.
23
- VERSION = '0.9.2'
23
+ VERSION = '1.0.0'
24
24
 
25
25
  fields = %w[
26
26
  boot_device
@@ -135,6 +135,35 @@ module Sys
135
135
  end
136
136
  end
137
137
 
138
+ # Returns the CPU architecture, e.g. "x86"
139
+ #
140
+ def self.architecture(cpu_num=0, host=Socket.gethostname)
141
+ cs = "winmgmts:{impersonationLevel=impersonate,(security)}"
142
+ cs << "//#{host}/root/cimv2:Win32_Processor='cpu#{cpu_num}'"
143
+ begin
144
+ wmi = WIN32OLE.connect(cs)
145
+ rescue WIN32OLERuntimeError => e
146
+ raise Error, e
147
+ else
148
+ case wmi.Architecture
149
+ when 0
150
+ "x86"
151
+ when 1
152
+ "mips"
153
+ when 2
154
+ "alpha"
155
+ when 3
156
+ "powerpc"
157
+ when 6
158
+ "ia64"
159
+ when 9
160
+ "x86_64"
161
+ else
162
+ "unknown"
163
+ end
164
+ end
165
+ end
166
+
138
167
  # Returns the machine hardware type. e.g. "i686".
139
168
  #--
140
169
  # This may or may not return the expected value because some CPU types
@@ -285,10 +314,16 @@ module Sys
285
314
  return "Crusoe TM5000 Family"
286
315
  when 121
287
316
  return "Crusoe TM3000 Family"
317
+ when 122
318
+ return "Efficeon TM8000 Family"
288
319
  when 128
289
320
  return "Weitek"
290
321
  when 130
291
322
  return "Itanium Processor"
323
+ when 131
324
+ return "AMD Athlon 64 Processor Family"
325
+ when 132
326
+ return "AMD Opteron Processor Family"
292
327
  when 144
293
328
  return "PA-RISC Family"
294
329
  when 145
@@ -327,12 +362,18 @@ module Sys
327
362
  return "AMD Opteron Family"
328
363
  when 190
329
364
  return "K7"
365
+ when 198
366
+ return "Intel Core i7-2760QM"
330
367
  when 200
331
368
  return "IBM390 Family"
332
369
  when 201
333
370
  return "G4"
334
371
  when 202
335
372
  return "G5"
373
+ when 203
374
+ return "G6"
375
+ when 204
376
+ return "z/Architecture Base"
336
377
  when 250
337
378
  return "i860"
338
379
  when 251
@@ -1,25 +1,19 @@
1
1
  require 'rubygems'
2
2
 
3
3
  Gem::Specification.new do |spec|
4
- spec.name = 'sys-uname'
5
- spec.version = '0.9.2'
6
- spec.author = 'Daniel J. Berger'
7
- spec.email = 'djberg96@gmail.com'
8
- spec.homepage = 'http://www.rubyforge.org/projects/sysutils'
9
- spec.summary = 'An interface for returning uname (platform) information'
10
- spec.test_file = 'test/test_sys_uname.rb'
11
- spec.license = 'Artistic 2.0'
12
- spec.files = Dir['**/*'].reject{ |f| f.include?('git') }
4
+ spec.name = 'sys-uname'
5
+ spec.version = '1.0.0'
6
+ spec.author = 'Daniel J. Berger'
7
+ spec.email = 'djberg96@gmail.com'
8
+ spec.homepage = 'http://github.com/djberg96/sys-uname'
9
+ spec.summary = 'An interface for returning uname (platform) information'
10
+ spec.license = 'Artistic 2.0'
11
+ spec.files = Dir['**/*'].reject{ |f| f.include?('git') }
12
+ spec.test_files = FileList['test/test_sys_uname.rb', 'test/test_sys_platform.rb']
13
13
 
14
14
  spec.extra_rdoc_files = ['CHANGES', 'README', 'MANIFEST', 'doc/uname.txt']
15
- spec.rubyforge_project = 'sysutils'
16
15
 
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
16
+ spec.add_dependency('ffi', '>= 1.0.0')
23
17
 
24
18
  spec.description = <<-EOF
25
19
  The sys-uname library provides an interface for gathering information
@@ -0,0 +1,70 @@
1
+ ##############################################################################
2
+ # test_sys_platform.rb
3
+ #
4
+ # Test suite for the Sys::Platform class.
5
+ ##############################################################################
6
+ require 'test-unit'
7
+ require 'sys/uname'
8
+ require 'rbconfig'
9
+
10
+ class TC_Sys_Platform < Test::Unit::TestCase
11
+ def self.startup
12
+ @@host_os = RbConfig::CONFIG['host_os']
13
+ @@windows = @@host_os =~ /mingw|mswin|windows/i ? true : false
14
+ end
15
+
16
+ test "the ARCH constant is defined" do
17
+ assert_kind_of(Symbol, Sys::Platform::ARCH)
18
+ end
19
+
20
+ test "the OS constant is defined" do
21
+ assert_kind_of(Symbol, Sys::Platform::OS)
22
+ end
23
+
24
+ test "the IMPL constant is defined" do
25
+ assert_kind_of(Symbol, Sys::Platform::IMPL)
26
+ end
27
+
28
+ test "the mac? method is defined and returns a boolean" do
29
+ assert_respond_to(Sys::Platform, :mac?)
30
+ assert_boolean(Sys::Platform.mac?)
31
+ end
32
+
33
+ test "the windows? method is defined and returns a boolean" do
34
+ assert_respond_to(Sys::Platform, :windows?)
35
+ assert_boolean(Sys::Platform.windows?)
36
+ end
37
+
38
+ test "the windows? method returns the expected value" do
39
+ assert_equal(Sys::Platform.windows?, @@windows)
40
+ end
41
+
42
+ test "the unix? method is defined and returns a boolean" do
43
+ assert_respond_to(Sys::Platform, :unix?)
44
+ assert_boolean(Sys::Platform.unix?)
45
+ end
46
+
47
+ test "the unix? method returns the expected value" do
48
+ assert_equal(Sys::Platform.unix?, !@@windows)
49
+ end
50
+
51
+ test "the solaris? method is defined and returns a boolean" do
52
+ assert_respond_to(Sys::Platform, :solaris?)
53
+ assert_boolean(Sys::Platform.solaris?)
54
+ end
55
+
56
+ test "the linux? method is defined and returns a boolean" do
57
+ assert_respond_to(Sys::Platform, :linux?)
58
+ assert_boolean(Sys::Platform.linux?)
59
+ end
60
+
61
+ test "the bsd? method is defined and returns a boolean" do
62
+ assert_respond_to(Sys::Platform, :bsd?)
63
+ assert_boolean(Sys::Platform.bsd?)
64
+ end
65
+
66
+ def self.shutdown
67
+ @@host_os = nil
68
+ @@windows = nil
69
+ end
70
+ end
@@ -14,7 +14,7 @@ class TC_Sys_Uname < Test::Unit::TestCase
14
14
  end
15
15
 
16
16
  test "version constant is set to expected value" do
17
- assert_equal('0.9.2', Uname::VERSION)
17
+ assert_equal('1.0.0', Uname::VERSION)
18
18
  end
19
19
 
20
20
  test "machine singleton method works as expected" do
@@ -210,7 +210,7 @@ class TC_Sys_Uname < Test::Unit::TestCase
210
210
 
211
211
  def test_csd_version
212
212
  assert_nothing_raised{ Uname.uname.csd_version }
213
- assert_kind_of(String, Uname.uname.csd_version)
213
+ assert_kind_of([String, NilClass], Uname.uname.csd_version)
214
214
  end
215
215
 
216
216
  def test_cs_name
metadata CHANGED
@@ -1,36 +1,35 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sys-uname
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.2
5
- prerelease:
4
+ version: 1.0.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Daniel J. Berger
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-05-01 00:00:00.000000000 Z
11
+ date: 2015-08-19 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: ffi
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ! '>='
17
+ - - ">="
20
18
  - !ruby/object:Gem::Version
21
19
  version: 1.0.0
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ! '>='
24
+ - - ">="
28
25
  - !ruby/object:Gem::Version
29
26
  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"
27
+ description: |2
28
+ The sys-uname library provides an interface for gathering information
29
+ about your current platform. The library is named after the Unix 'uname'
30
+ command but also works on MS Windows. Available information includes
31
+ OS name, OS version, system name and so on. Additional information is
32
+ available for certain platforms.
34
33
  email: djberg96@gmail.com
35
34
  executables: []
36
35
  extensions: []
@@ -41,40 +40,43 @@ extra_rdoc_files:
41
40
  - doc/uname.txt
42
41
  files:
43
42
  - CHANGES
44
- - doc/uname.txt
45
- - examples/uname_test.rb
46
- - lib/unix/sys/uname.rb
47
- - lib/windows/sys/uname.rb
48
43
  - MANIFEST
49
- - Rakefile
50
44
  - README
45
+ - Rakefile
46
+ - doc/uname.txt
47
+ - examples/uname_test.rb
48
+ - lib/sys-uname.rb
49
+ - lib/sys/platform.rb
50
+ - lib/sys/uname.rb
51
+ - lib/sys/unix/uname.rb
52
+ - lib/sys/windows/uname.rb
51
53
  - sys-uname.gemspec
54
+ - test/test_sys_platform.rb
52
55
  - test/test_sys_uname.rb
53
- homepage: http://www.rubyforge.org/projects/sysutils
56
+ homepage: http://github.com/djberg96/sys-uname
54
57
  licenses:
55
58
  - Artistic 2.0
59
+ metadata: {}
56
60
  post_install_message:
57
61
  rdoc_options: []
58
62
  require_paths:
59
63
  - lib
60
- - lib/unix
61
64
  required_ruby_version: !ruby/object:Gem::Requirement
62
- none: false
63
65
  requirements:
64
- - - ! '>='
66
+ - - ">="
65
67
  - !ruby/object:Gem::Version
66
68
  version: '0'
67
69
  required_rubygems_version: !ruby/object:Gem::Requirement
68
- none: false
69
70
  requirements:
70
- - - ! '>='
71
+ - - ">="
71
72
  - !ruby/object:Gem::Version
72
73
  version: '0'
73
74
  requirements: []
74
- rubyforge_project: sysutils
75
- rubygems_version: 1.8.23
75
+ rubyforge_project:
76
+ rubygems_version: 2.4.5
76
77
  signing_key:
77
- specification_version: 3
78
+ specification_version: 4
78
79
  summary: An interface for returning uname (platform) information
79
80
  test_files:
80
81
  - test/test_sys_uname.rb
82
+ - test/test_sys_platform.rb