sys-cpu 0.6.1-x86-linux → 0.6.2-x86-linux

Sign up to get free protection for your applications and to get access to all the features.
data/sys-cpu.gemspec ADDED
@@ -0,0 +1,47 @@
1
+ require 'rubygems'
2
+
3
+ Gem::Specification.new do |spec|
4
+ spec.name = 'sys-cpu'
5
+ spec.version = '0.6.2'
6
+ spec.author = 'Daniel J. Berger'
7
+ spec.email = 'djberg96 at nospam at gmail dot com'
8
+ spec.homepage = 'http://www.rubyforge.org/projects/sysutils'
9
+ spec.platform = Gem::Platform::RUBY
10
+ spec.summary = 'A Ruby interface for providing CPU information'
11
+ spec.has_rdoc = true
12
+ spec.test_file = 'test/test_sys_cpu.rb'
13
+ spec.files = Dir['**/*'].reject{ |f| f.include?('CVS') }
14
+
15
+ spec.rubyforge_project = 'sysutils'
16
+ spec.extra_rdoc_files = ['CHANGES', 'README', 'MANIFEST']
17
+
18
+ spec.add_development_dependency('test-unit', '>= 2.0.3')
19
+
20
+ spec.description = <<-EOF
21
+ The sys-cpu library provides an interface for gathering information
22
+ about your system's processor(s). Information includes speed, type,
23
+ and load average.
24
+ EOF
25
+
26
+ case Config::CONFIG['host_os']
27
+ when /hpux/i
28
+ spec.extra_rdoc_files += ['ext/hpux/hpux.c']
29
+ when /sunos|solaris/i
30
+ spec.extra_rdoc_files += ['ext/sunos/sunos.c']
31
+ when /bsd|darwin|mach|osx/i
32
+ spec.extra_rdoc_files += ['ext/bsd/bsd.c']
33
+ end
34
+
35
+ case Config::CONFIG['host_os']
36
+ when /mswin|dos|windows|win32|mingw|cygwin/i
37
+ spec.require_paths = ['lib', 'lib/windows']
38
+ spec.extra_rdoc_files << 'lib/windows/sys/cpu.rb'
39
+ spec.platform = Gem::Platform::CURRENT
40
+ when /linux/i
41
+ spec.require_paths = ['lib', 'lib/linux']
42
+ spec.extra_rdoc_files << 'lib/linux/sys/cpu.rb'
43
+ spec.platform = Gem::Platform::CURRENT
44
+ else
45
+ spec.extensions = ['ext/extconf.rb']
46
+ end
47
+ end
@@ -0,0 +1,23 @@
1
+ #######################################################################
2
+ # test_sys_cpu.rb
3
+ #
4
+ # This isn't a test file, just a file that require's the appropriate
5
+ # test file base on the platform you're on.
6
+ #######################################################################
7
+ require 'rbconfig'
8
+ require 'test_sys_cpu_version'
9
+
10
+ case Config::CONFIG['host_os']
11
+ when /bsd|darwin|mach|osx/i
12
+ require 'test_sys_cpu_bsd'
13
+ when /hpux/i
14
+ require 'test_sys_cpu_hpux'
15
+ when /linux/i
16
+ require 'test_sys_cpu_linux'
17
+ when /sunos|solaris/i
18
+ require 'test_sys_cpu_sunos'
19
+ when /mswin|win32|dos|mingw|cygwin/i
20
+ require 'test_sys_cpu_windows'
21
+ else
22
+ raise "Platform not supported"
23
+ end
@@ -1,28 +1,37 @@
1
1
  #############################################################
2
- # tc_bsd.rb
2
+ # test_sys_cpu_bsd.rb
3
3
  #
4
4
  # The test case for sys-cpu on BSD flavors, including OS X.
5
5
  #############################################################
6
- require "sys/cpu"
7
- require "test/unit"
8
- require "tc_version"
6
+ require 'rubygems'
7
+ gem 'test-unit'
8
+
9
+ require 'sys/cpu'
10
+ require 'rbconfig'
11
+ require 'test/unit'
12
+ require 'test_sys_cpu_version'
9
13
  include Sys
10
14
 
11
- class TC_BSD < Test::Unit::TestCase
15
+ class TC_Sys_CPU_BSD < Test::Unit::TestCase
12
16
  def test_architecture
13
17
  assert_respond_to(CPU, :architecture)
14
18
  assert_nothing_raised{ CPU.architecture }
15
19
  assert_kind_of(String, CPU.architecture)
20
+ end
21
+
22
+ def test_architecture_expected_errors
16
23
  assert_raises(ArgumentError){ CPU.architecture(0) }
17
24
  end
18
25
 
19
- unless RUBY_PLATFORM.match('darwin')
20
- def test_cpu_freq
21
- assert_respond_to(CPU, :freq)
22
- assert_nothing_raised{ CPU.freq }
23
- assert_kind_of(Integer, CPU.freq)
24
- assert_raises(ArgumentError){ CPU.freq(0) }
25
- end
26
+ def test_cpu_freq
27
+ omit_if(Config::CONFIG['host_os'] =~ /darwin/i, 'CPU.freq test skipped on OS X')
28
+ assert_respond_to(CPU, :freq)
29
+ assert_nothing_raised{ CPU.freq }
30
+ assert_kind_of(Integer, CPU.freq)
31
+ end
32
+
33
+ def test_cpu_freq_expected_errors
34
+ assert_raises(ArgumentError){ CPU.freq(0) }
26
35
  end
27
36
 
28
37
  def test_load_avg
@@ -30,6 +39,9 @@ class TC_BSD < Test::Unit::TestCase
30
39
  assert_nothing_raised{ CPU.load_avg }
31
40
  assert_kind_of(Array, CPU.load_avg)
32
41
  assert_equal(3,CPU.load_avg.length)
42
+ end
43
+
44
+ def test_load_avg_expected_errors
33
45
  assert_raises(ArgumentError){ CPU.load_avg(0) }
34
46
  end
35
47
 
@@ -37,6 +49,9 @@ class TC_BSD < Test::Unit::TestCase
37
49
  assert_respond_to(CPU, :machine)
38
50
  assert_nothing_raised{ CPU.machine }
39
51
  assert_kind_of(String, CPU.machine)
52
+ end
53
+
54
+ def test_machine_expected_errors
40
55
  assert_raises(ArgumentError){ CPU.machine(0) }
41
56
  end
42
57
 
@@ -44,6 +59,9 @@ class TC_BSD < Test::Unit::TestCase
44
59
  assert_respond_to(CPU, :model)
45
60
  assert_nothing_raised{ CPU.model }
46
61
  assert_kind_of(String, CPU.model)
62
+ end
63
+
64
+ def test_model_expected_errors
47
65
  assert_raises(ArgumentError){ CPU.model(0) }
48
66
  end
49
67
 
@@ -51,6 +69,9 @@ class TC_BSD < Test::Unit::TestCase
51
69
  assert_respond_to(CPU, :num_cpu)
52
70
  assert_nothing_raised{ CPU.num_cpu }
53
71
  assert_kind_of(Integer, CPU.num_cpu)
72
+ end
73
+
74
+ def test_num_cpu_expected_errors
54
75
  assert_raises(ArgumentError){ CPU.num_cpu(0) }
55
76
  end
56
77
  end
@@ -1,38 +1,41 @@
1
1
  #####################################################################
2
- # tc_hpux.rb
2
+ # test_sys_cpu_hpux.rb
3
3
  #
4
4
  # Test suite for the HP-UX platform. This should be run via the
5
5
  # 'rake test' task.
6
6
  #####################################################################
7
- require "sys/cpu"
8
- require "test/unit"
9
- require "tc_version"
7
+ require 'rubygems'
8
+ gem 'test-unit'
9
+
10
+ require 'sys/cpu'
11
+ require 'test/unit'
12
+ require 'test_sys_cpu_version'
10
13
  include Sys
11
14
 
12
- class TC_HPUX < Test::Unit::TestCase
15
+ class TC_Sys_CPU_HPUX < Test::Unit::TestCase
13
16
  def test_cpu_freq
14
17
  assert_respond_to(CPU, :freq)
15
18
  assert_nothing_raised{ CPU.freq }
16
19
  assert_nothing_raised{ CPU.freq(0) }
17
- assert_kind_of(Integer, CPU.freq, "Invalid Type")
20
+ assert_kind_of(Integer, CPU.freq, 'Invalid Type')
18
21
  end
19
22
 
20
23
  def test_num_cpu
21
24
  assert_respond_to(CPU, :num_cpu)
22
25
  assert_nothing_raised{ CPU.num_cpu }
23
- assert_kind_of(Integer, CPU.num_cpu, "Invalid Type")
26
+ assert_kind_of(Integer, CPU.num_cpu, 'Invalid Type')
24
27
  end
25
28
 
26
29
  def test_num_active_cpu
27
30
  assert_respond_to(CPU, :num_active_cpu)
28
31
  assert_nothing_raised{ CPU.num_active_cpu }
29
- assert_kind_of(Integer, CPU.num_active_cpu, "Invalid Type")
32
+ assert_kind_of(Integer, CPU.num_active_cpu, 'Invalid Type')
30
33
  end
31
34
 
32
35
  def test_cpu_architecture
33
36
  assert_respond_to(CPU, :architecture)
34
37
  assert_nothing_raised{ CPU.architecture }
35
- assert_kind_of(String, CPU.architecture, "Invalid Type")
38
+ assert_kind_of(String, CPU.architecture, 'Invalid Type')
36
39
  end
37
40
 
38
41
  def test_load_avg
@@ -41,9 +44,9 @@ class TC_HPUX < Test::Unit::TestCase
41
44
  assert_nothing_raised{ CPU.load_avg(0) }
42
45
  assert_nothing_raised{ CPU.load_avg{ |e| } }
43
46
  assert_raises(ArgumentError){ CPU.load_avg(0){ } }
44
- assert_kind_of(Array, CPU.load_avg, "Invalid Type")
45
- assert_kind_of(Array, CPU.load_avg(0), "Invalid Type")
46
- assert_equal(3, CPU.load_avg.length, "Bad number of elements")
47
- assert_equal(3, CPU.load_avg(0).length, "Bad number of elements")
47
+ assert_kind_of(Array, CPU.load_avg, 'Invalid Type')
48
+ assert_kind_of(Array, CPU.load_avg(0), 'Invalid Type')
49
+ assert_equal(3, CPU.load_avg.length, 'Bad number of elements')
50
+ assert_equal(3, CPU.load_avg(0).length, 'Bad number of elements')
48
51
  end
49
52
  end
@@ -0,0 +1,34 @@
1
+ ###########################################################
2
+ # test_sys_cpu_linux.rb
3
+ #
4
+ # Test Suite for sys-cpu for Linux. This should be run via
5
+ # the 'rake test' task.
6
+ ###########################################################
7
+ require 'rubygems'
8
+ gem 'test-unit'
9
+
10
+ require 'sys/cpu'
11
+ require 'test/unit'
12
+ require 'test_sys_cpu_version'
13
+ include Sys
14
+
15
+ class TC_Sys_CPU_Linux < Test::Unit::TestCase
16
+ def test_all_dynamic_methods
17
+ assert_nothing_raised{
18
+ CPU.processors{ |cs|
19
+ cs.members.each{ |m| cs[m].to_s }
20
+ }
21
+ }
22
+ end
23
+
24
+ def test_load_avg
25
+ assert_nothing_raised{ CPU.load_avg }
26
+ assert_equal(3, CPU.load_avg.length)
27
+ end
28
+
29
+ def test_cpu_stats
30
+ assert_nothing_raised{ CPU.cpu_stats }
31
+ assert_kind_of(Hash, CPU.cpu_stats)
32
+ assert_equal(true, CPU.cpu_stats['cpu0'].length >= 4)
33
+ end
34
+ end
@@ -1,15 +1,17 @@
1
1
  ###########################################################
2
- # tc_sunos.rb
2
+ # test_sys_cpu_sunos.rb
3
3
  #
4
4
  # Test suite for sys-cpu on Solaris. This should be run
5
5
  # via the 'rake test' task.
6
6
  ###########################################################
7
- require "sys/cpu"
8
- require "test/unit"
9
- require "tc_version"
7
+ require 'rubygems'
8
+ gem 'test-unit'
9
+
10
+ require 'sys/cpu'
11
+ require 'test/unit'
10
12
  include Sys
11
13
 
12
- class TC_SunOS < Test::Unit::TestCase
14
+ class TC_Sys_CPU_SunOS < Test::Unit::TestCase
13
15
  def test_cpu_freq
14
16
  assert_respond_to(CPU, :freq)
15
17
  assert_nothing_raised{ CPU.freq }
@@ -56,10 +58,10 @@ class TC_SunOS < Test::Unit::TestCase
56
58
  assert_kind_of(String, CPU.state(0))
57
59
  end
58
60
 
59
- def test_exceptions
61
+ def test_expected_errors
60
62
  assert_raises(Sys::CPU::Error){ CPU.state(55) }
61
- assert_raises(TypeError){ CPU.state("yo") }
63
+ assert_raises(TypeError){ CPU.state('yo') }
62
64
  assert_raises(Sys::CPU::Error){ CPU.freq(999) }
63
- assert_raises(TypeError){ CPU.freq("yo") }
65
+ assert_raises(TypeError){ CPU.freq('yo') }
64
66
  end
65
67
  end
@@ -1,15 +1,18 @@
1
1
  #######################################################################
2
- # tc_version.rb
2
+ # test_sys_cpu_version.rb
3
3
  #
4
4
  # The sole purpose of this test case is to verify the version number.
5
5
  # This reduces the pain of having separate tests for the VERSION
6
6
  # constant in every single test case.
7
7
  #######################################################################
8
+ require 'rubygems'
9
+ gem 'test-unit'
10
+
8
11
  require 'sys/cpu'
9
12
  require 'test/unit'
10
13
 
11
14
  class TC_Sys_CPU_VERSION < Test::Unit::TestCase
12
15
  def test_version
13
- assert_equal('0.6.1', Sys::CPU::VERSION)
16
+ assert_equal('0.6.2', Sys::CPU::VERSION)
14
17
  end
15
18
  end
@@ -1,61 +1,64 @@
1
1
  ######################################################################
2
- # tc_windows.rb
2
+ # test_sys_cpu_windows.rb
3
3
  #
4
4
  # Test suite for MS Windows systems. This should be run via the
5
5
  # 'rake test' task.
6
6
  ######################################################################
7
- require "test/unit"
8
- require "sys/cpu"
9
- require "tc_version"
10
- require "socket"
7
+ require 'rubygems'
8
+ gem 'test-unit'
9
+
10
+ require 'test/unit'
11
+ require 'sys/cpu'
12
+ require 'test_sys_cpu_version'
13
+ require 'socket'
11
14
  include Sys
12
15
 
13
- class TC_Windows_CPU < Test::Unit::TestCase
14
- def setup
15
- @host = Socket.gethostname
16
+ class TC_Sys_CPU_Windows < Test::Unit::TestCase
17
+ def self.startup
18
+ @@host = Socket.gethostname
16
19
  end
17
20
 
18
21
  def test_architecture
19
22
  assert_respond_to(CPU, :architecture)
20
23
  assert_nothing_raised{ CPU.architecture }
21
- assert_nothing_raised{ CPU.architecture(@host) }
22
- assert_kind_of(String, CPU.architecture, "Invalid Type")
24
+ assert_nothing_raised{ CPU.architecture(@@host) }
25
+ assert_kind_of(String, CPU.architecture, 'Invalid Type')
23
26
  end
24
27
 
25
28
  def test_freq
26
29
  assert_respond_to(CPU, :freq)
27
30
  assert_nothing_raised{ CPU.freq }
28
31
  assert_nothing_raised{ CPU.freq(0) }
29
- assert_nothing_raised{ CPU.freq(0, @host) }
30
- assert_kind_of(Integer, CPU.freq, "Invalid Type")
32
+ assert_nothing_raised{ CPU.freq(0, @@host) }
33
+ assert_kind_of(Integer, CPU.freq, 'Invalid Type')
31
34
  end
32
35
 
33
36
  def test_model
34
37
  assert_respond_to(CPU, :model)
35
38
  assert_nothing_raised{ CPU.model }
36
- assert_nothing_raised{ CPU.model(@host) }
37
- assert_kind_of(String, CPU.model, "Invalid Type")
39
+ assert_nothing_raised{ CPU.model(@@host) }
40
+ assert_kind_of(String, CPU.model, 'Invalid Type')
38
41
  end
39
42
 
40
43
  def test_num_cpu
41
44
  assert_respond_to(CPU, :num_cpu)
42
45
  assert_nothing_raised{ CPU.num_cpu }
43
- assert_nothing_raised{ CPU.num_cpu(@host) }
44
- assert_kind_of(Integer, CPU.num_cpu, "Invalid Type")
46
+ assert_nothing_raised{ CPU.num_cpu(@@host) }
47
+ assert_kind_of(Integer, CPU.num_cpu, 'Invalid Type')
45
48
  end
46
49
 
47
50
  def test_type
48
51
  assert_respond_to(CPU, :type)
49
52
  assert_nothing_raised{ CPU.type }
50
- assert_nothing_raised{ CPU.type(@host) }
51
- assert_kind_of(String, CPU.type, "Invalid Type")
53
+ assert_nothing_raised{ CPU.type(@@host) }
54
+ assert_kind_of(String, CPU.type, 'Invalid Type')
52
55
  end
53
56
 
54
57
  def test_load_avg
55
58
  assert_respond_to(CPU, :load_avg)
56
59
  assert_nothing_raised{ CPU.load_avg }
57
- assert_nothing_raised{ CPU.load_avg(0, @host) }
58
- assert_kind_of(Integer, CPU.load_avg, "Invalid Type")
60
+ assert_nothing_raised{ CPU.load_avg(0, @@host) }
61
+ assert_kind_of(Integer, CPU.load_avg, 'Invalid Type')
59
62
  end
60
63
 
61
64
  def test_processors
@@ -63,7 +66,7 @@ class TC_Windows_CPU < Test::Unit::TestCase
63
66
  assert_nothing_raised{ CPU.processors{} }
64
67
  end
65
68
 
66
- def teardown
67
- @host = nil
69
+ def self.shutdown
70
+ @@host = nil
68
71
  end
69
72
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sys-cpu
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.1
4
+ version: 0.6.2
5
5
  platform: x86-linux
6
6
  authors:
7
7
  - Daniel J. Berger
@@ -9,11 +9,20 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-12-13 00:00:00 -07:00
12
+ date: 2010-04-23 00:00:00 -06:00
13
13
  default_executable:
14
- dependencies: []
15
-
16
- description: A Ruby interface for providing CPU information
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: test-unit
17
+ type: :development
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: 2.0.3
24
+ version:
25
+ description: " The sys-cpu library provides an interface for gathering information\n about your system's processor(s). Information includes speed, type,\n and load average.\n"
17
26
  email: djberg96 at nospam at gmail dot com
18
27
  executables: []
19
28
 
@@ -23,36 +32,53 @@ extra_rdoc_files:
23
32
  - CHANGES
24
33
  - README
25
34
  - MANIFEST
26
- - lib/sys/cpu.rb
35
+ - lib/linux/sys/cpu.rb
27
36
  files:
37
+ - MANIFEST
38
+ - examples/example_sys_cpu_sunos.rb
39
+ - examples/example_sys_cpu_hpux.rb
40
+ - examples/example_sys_cpu_bsd.rb
41
+ - examples/example_sys_cpu_linux.rb
42
+ - examples/example_sys_cpu_windows.rb
43
+ - README
44
+ - CHANGES
45
+ - Rakefile
46
+ - lib/windows/sys/cpu.rb
47
+ - lib/linux/sys/cpu.rb
48
+ - install.rb
49
+ - test/test_sys_cpu_bsd.rb
50
+ - test/test_sys_cpu_hpux.rb
51
+ - test/test_sys_cpu_linux.rb
52
+ - test/test_sys_cpu_windows.rb
53
+ - test/test_sys_cpu_sunos.rb
54
+ - test/test_sys_cpu_version.rb
55
+ - test/test_sys_cpu.rb
56
+ - sys-cpu.gemspec
28
57
  - doc/bsd.txt
29
58
  - doc/windows.txt
30
59
  - doc/sunos.txt
31
60
  - doc/linux.txt
32
61
  - doc/hpux.txt
33
- - test/tc_cpu.rb
34
- - test/tc_linux.rb
35
- - test/tc_hpux.rb
36
- - test/tc_sunos.rb
37
- - test/tc_bsd.rb
38
- - test/tc_version.rb
39
- - test/tc_windows.rb
40
- - CHANGES
41
- - README
42
- - MANIFEST
43
- - lib/sys/cpu.rb
62
+ - ext/bsd/bsd.c
63
+ - ext/version.h
64
+ - ext/extconf.rb
65
+ - ext/hpux/hpux.c
66
+ - ext/sunos/sunos.c
44
67
  has_rdoc: true
45
68
  homepage: http://www.rubyforge.org/projects/sysutils
69
+ licenses: []
70
+
46
71
  post_install_message:
47
72
  rdoc_options: []
48
73
 
49
74
  require_paths:
50
75
  - lib
76
+ - lib/linux
51
77
  required_ruby_version: !ruby/object:Gem::Requirement
52
78
  requirements:
53
79
  - - ">="
54
80
  - !ruby/object:Gem::Version
55
- version: 1.8.2
81
+ version: "0"
56
82
  version:
57
83
  required_rubygems_version: !ruby/object:Gem::Requirement
58
84
  requirements:
@@ -63,9 +89,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
63
89
  requirements: []
64
90
 
65
91
  rubyforge_project: sysutils
66
- rubygems_version: 1.3.1
92
+ rubygems_version: 1.3.5
67
93
  signing_key:
68
- specification_version: 2
94
+ specification_version: 3
69
95
  summary: A Ruby interface for providing CPU information
70
96
  test_files:
71
- - test/tc_linux.rb
97
+ - test/test_sys_cpu.rb