sys-cpu 0.6.2-x86-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-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
@@ -0,0 +1,77 @@
1
+ #############################################################
2
+ # test_sys_cpu_bsd.rb
3
+ #
4
+ # The test case for sys-cpu on BSD flavors, including OS X.
5
+ #############################################################
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'
13
+ include Sys
14
+
15
+ class TC_Sys_CPU_BSD < Test::Unit::TestCase
16
+ def test_architecture
17
+ assert_respond_to(CPU, :architecture)
18
+ assert_nothing_raised{ CPU.architecture }
19
+ assert_kind_of(String, CPU.architecture)
20
+ end
21
+
22
+ def test_architecture_expected_errors
23
+ assert_raises(ArgumentError){ CPU.architecture(0) }
24
+ end
25
+
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) }
35
+ end
36
+
37
+ def test_load_avg
38
+ assert_respond_to(CPU, :load_avg)
39
+ assert_nothing_raised{ CPU.load_avg }
40
+ assert_kind_of(Array, CPU.load_avg)
41
+ assert_equal(3,CPU.load_avg.length)
42
+ end
43
+
44
+ def test_load_avg_expected_errors
45
+ assert_raises(ArgumentError){ CPU.load_avg(0) }
46
+ end
47
+
48
+ def test_machine
49
+ assert_respond_to(CPU, :machine)
50
+ assert_nothing_raised{ CPU.machine }
51
+ assert_kind_of(String, CPU.machine)
52
+ end
53
+
54
+ def test_machine_expected_errors
55
+ assert_raises(ArgumentError){ CPU.machine(0) }
56
+ end
57
+
58
+ def test_model
59
+ assert_respond_to(CPU, :model)
60
+ assert_nothing_raised{ CPU.model }
61
+ assert_kind_of(String, CPU.model)
62
+ end
63
+
64
+ def test_model_expected_errors
65
+ assert_raises(ArgumentError){ CPU.model(0) }
66
+ end
67
+
68
+ def test_num_cpu
69
+ assert_respond_to(CPU, :num_cpu)
70
+ assert_nothing_raised{ CPU.num_cpu }
71
+ assert_kind_of(Integer, CPU.num_cpu)
72
+ end
73
+
74
+ def test_num_cpu_expected_errors
75
+ assert_raises(ArgumentError){ CPU.num_cpu(0) }
76
+ end
77
+ end
@@ -0,0 +1,52 @@
1
+ #####################################################################
2
+ # test_sys_cpu_hpux.rb
3
+ #
4
+ # Test suite for the HP-UX platform. This should be run via the
5
+ # '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_HPUX < Test::Unit::TestCase
16
+ def test_cpu_freq
17
+ assert_respond_to(CPU, :freq)
18
+ assert_nothing_raised{ CPU.freq }
19
+ assert_nothing_raised{ CPU.freq(0) }
20
+ assert_kind_of(Integer, CPU.freq, 'Invalid Type')
21
+ end
22
+
23
+ def test_num_cpu
24
+ assert_respond_to(CPU, :num_cpu)
25
+ assert_nothing_raised{ CPU.num_cpu }
26
+ assert_kind_of(Integer, CPU.num_cpu, 'Invalid Type')
27
+ end
28
+
29
+ def test_num_active_cpu
30
+ assert_respond_to(CPU, :num_active_cpu)
31
+ assert_nothing_raised{ CPU.num_active_cpu }
32
+ assert_kind_of(Integer, CPU.num_active_cpu, 'Invalid Type')
33
+ end
34
+
35
+ def test_cpu_architecture
36
+ assert_respond_to(CPU, :architecture)
37
+ assert_nothing_raised{ CPU.architecture }
38
+ assert_kind_of(String, CPU.architecture, 'Invalid Type')
39
+ end
40
+
41
+ def test_load_avg
42
+ assert_respond_to(CPU, :load_avg)
43
+ assert_nothing_raised{ CPU.load_avg }
44
+ assert_nothing_raised{ CPU.load_avg(0) }
45
+ assert_nothing_raised{ CPU.load_avg{ |e| } }
46
+ assert_raises(ArgumentError){ CPU.load_avg(0){ } }
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')
51
+ end
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
@@ -0,0 +1,67 @@
1
+ ###########################################################
2
+ # test_sys_cpu_sunos.rb
3
+ #
4
+ # Test suite for sys-cpu on Solaris. This should be run
5
+ # via the 'rake test' task.
6
+ ###########################################################
7
+ require 'rubygems'
8
+ gem 'test-unit'
9
+
10
+ require 'sys/cpu'
11
+ require 'test/unit'
12
+ include Sys
13
+
14
+ class TC_Sys_CPU_SunOS < Test::Unit::TestCase
15
+ def test_cpu_freq
16
+ assert_respond_to(CPU, :freq)
17
+ assert_nothing_raised{ CPU.freq }
18
+ assert_nothing_raised{ CPU.freq(0) }
19
+ assert_kind_of(Integer, CPU.freq(0))
20
+ end
21
+
22
+ def test_cpu_type
23
+ assert_respond_to(CPU, :cpu_type)
24
+ assert_nothing_raised{ CPU.cpu_type }
25
+ assert_kind_of(String, CPU.cpu_type)
26
+ end
27
+
28
+ def test_fpu_type
29
+ assert_respond_to(CPU, :fpu_type)
30
+ assert_nothing_raised{ CPU.fpu_type }
31
+ assert_kind_of(String, CPU.fpu_type)
32
+ end
33
+
34
+ def test_load_avg
35
+ assert_respond_to(CPU, :load_avg)
36
+ assert_nothing_raised{ CPU.load_avg }
37
+ assert_kind_of(Array, CPU.load_avg)
38
+ assert_equal(3, CPU.load_avg.length)
39
+ assert_kind_of(Float, CPU.load_avg.first)
40
+ end
41
+
42
+ def test_cpu_model
43
+ assert_respond_to(CPU, :model)
44
+ assert_nothing_raised{ CPU.model }
45
+ assert_kind_of(String, CPU.model)
46
+ end
47
+
48
+ def test_num_cpu
49
+ assert_respond_to(CPU, :num_cpu)
50
+ assert_nothing_raised{ CPU.num_cpu }
51
+ assert_kind_of(Integer, CPU.num_cpu)
52
+ end
53
+
54
+ def test_state
55
+ assert_respond_to(CPU, :state)
56
+ assert_nothing_raised{ CPU.state }
57
+ assert_nothing_raised{ CPU.state(0) }
58
+ assert_kind_of(String, CPU.state(0))
59
+ end
60
+
61
+ def test_expected_errors
62
+ assert_raises(Sys::CPU::Error){ CPU.state(55) }
63
+ assert_raises(TypeError){ CPU.state('yo') }
64
+ assert_raises(Sys::CPU::Error){ CPU.freq(999) }
65
+ assert_raises(TypeError){ CPU.freq('yo') }
66
+ end
67
+ end
@@ -0,0 +1,18 @@
1
+ #######################################################################
2
+ # test_sys_cpu_version.rb
3
+ #
4
+ # The sole purpose of this test case is to verify the version number.
5
+ # This reduces the pain of having separate tests for the VERSION
6
+ # constant in every single test case.
7
+ #######################################################################
8
+ require 'rubygems'
9
+ gem 'test-unit'
10
+
11
+ require 'sys/cpu'
12
+ require 'test/unit'
13
+
14
+ class TC_Sys_CPU_VERSION < Test::Unit::TestCase
15
+ def test_version
16
+ assert_equal('0.6.2', Sys::CPU::VERSION)
17
+ end
18
+ end
@@ -0,0 +1,72 @@
1
+ ######################################################################
2
+ # test_sys_cpu_windows.rb
3
+ #
4
+ # Test suite for MS Windows systems. This should be run via the
5
+ # 'rake test' task.
6
+ ######################################################################
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'
14
+ include Sys
15
+
16
+ class TC_Sys_CPU_Windows < Test::Unit::TestCase
17
+ def self.startup
18
+ @@host = Socket.gethostname
19
+ end
20
+
21
+ def test_architecture
22
+ assert_respond_to(CPU, :architecture)
23
+ assert_nothing_raised{ CPU.architecture }
24
+ assert_nothing_raised{ CPU.architecture(@@host) }
25
+ assert_kind_of(String, CPU.architecture, 'Invalid Type')
26
+ end
27
+
28
+ def test_freq
29
+ assert_respond_to(CPU, :freq)
30
+ assert_nothing_raised{ CPU.freq }
31
+ assert_nothing_raised{ CPU.freq(0) }
32
+ assert_nothing_raised{ CPU.freq(0, @@host) }
33
+ assert_kind_of(Integer, CPU.freq, 'Invalid Type')
34
+ end
35
+
36
+ def test_model
37
+ assert_respond_to(CPU, :model)
38
+ assert_nothing_raised{ CPU.model }
39
+ assert_nothing_raised{ CPU.model(@@host) }
40
+ assert_kind_of(String, CPU.model, 'Invalid Type')
41
+ end
42
+
43
+ def test_num_cpu
44
+ assert_respond_to(CPU, :num_cpu)
45
+ assert_nothing_raised{ CPU.num_cpu }
46
+ assert_nothing_raised{ CPU.num_cpu(@@host) }
47
+ assert_kind_of(Integer, CPU.num_cpu, 'Invalid Type')
48
+ end
49
+
50
+ def test_type
51
+ assert_respond_to(CPU, :type)
52
+ assert_nothing_raised{ CPU.type }
53
+ assert_nothing_raised{ CPU.type(@@host) }
54
+ assert_kind_of(String, CPU.type, 'Invalid Type')
55
+ end
56
+
57
+ def test_load_avg
58
+ assert_respond_to(CPU, :load_avg)
59
+ assert_nothing_raised{ CPU.load_avg }
60
+ assert_nothing_raised{ CPU.load_avg(0, @@host) }
61
+ assert_kind_of(Integer, CPU.load_avg, 'Invalid Type')
62
+ end
63
+
64
+ def test_processors
65
+ assert_respond_to(CPU, :processors)
66
+ assert_nothing_raised{ CPU.processors{} }
67
+ end
68
+
69
+ def self.shutdown
70
+ @@host = nil
71
+ end
72
+ end
metadata ADDED
@@ -0,0 +1,97 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: sys-cpu
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.6.2
5
+ platform: x86-mingw32
6
+ authors:
7
+ - Daniel J. Berger
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2010-01-01 00:00:00 -07:00
13
+ default_executable:
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"
26
+ email: djberg96 at nospam at gmail dot com
27
+ executables: []
28
+
29
+ extensions: []
30
+
31
+ extra_rdoc_files:
32
+ - CHANGES
33
+ - README
34
+ - MANIFEST
35
+ - lib/windows/sys/cpu.rb
36
+ files:
37
+ - CHANGES
38
+ - doc/bsd.txt
39
+ - doc/hpux.txt
40
+ - doc/linux.txt
41
+ - doc/sunos.txt
42
+ - doc/windows.txt
43
+ - examples/example_sys_cpu_bsd.rb
44
+ - examples/example_sys_cpu_hpux.rb
45
+ - examples/example_sys_cpu_linux.rb
46
+ - examples/example_sys_cpu_sunos.rb
47
+ - examples/example_sys_cpu_windows.rb
48
+ - ext/bsd/bsd.c
49
+ - ext/extconf.rb
50
+ - ext/hpux/hpux.c
51
+ - ext/sunos/sunos.c
52
+ - ext/version.h
53
+ - install.rb
54
+ - lib/linux/sys/cpu.rb
55
+ - lib/windows/sys/cpu.rb
56
+ - MANIFEST
57
+ - Rakefile
58
+ - README
59
+ - sys-cpu.gemspec
60
+ - test/test_sys_cpu.rb
61
+ - test/test_sys_cpu_bsd.rb
62
+ - test/test_sys_cpu_hpux.rb
63
+ - test/test_sys_cpu_linux.rb
64
+ - test/test_sys_cpu_sunos.rb
65
+ - test/test_sys_cpu_version.rb
66
+ - test/test_sys_cpu_windows.rb
67
+ has_rdoc: true
68
+ homepage: http://www.rubyforge.org/projects/sysutils
69
+ licenses: []
70
+
71
+ post_install_message:
72
+ rdoc_options: []
73
+
74
+ require_paths:
75
+ - lib
76
+ - lib/windows
77
+ required_ruby_version: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - ">="
80
+ - !ruby/object:Gem::Version
81
+ version: "0"
82
+ version:
83
+ required_rubygems_version: !ruby/object:Gem::Requirement
84
+ requirements:
85
+ - - ">="
86
+ - !ruby/object:Gem::Version
87
+ version: "0"
88
+ version:
89
+ requirements: []
90
+
91
+ rubyforge_project: sysutils
92
+ rubygems_version: 1.3.5
93
+ signing_key:
94
+ specification_version: 3
95
+ summary: A Ruby interface for providing CPU information
96
+ test_files:
97
+ - test/test_sys_cpu.rb