sys-cpu 0.6.4-universal-mingw32

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,50 @@
1
+ require 'rubygems'
2
+
3
+ Gem::Specification.new do |spec|
4
+ spec.name = 'sys-cpu'
5
+ spec.version = '0.6.4'
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.test_file = 'test/test_sys_cpu.rb'
12
+ spec.files = Dir['**/*'].reject{ |f| f.include?('git') }
13
+
14
+ spec.rubyforge_project = 'sysutils'
15
+ spec.extra_rdoc_files = ['CHANGES', 'README', 'MANIFEST']
16
+
17
+ spec.add_development_dependency('test-unit', '>= 2.1.2')
18
+
19
+ spec.description = <<-EOF
20
+ The sys-cpu library provides an interface for gathering information
21
+ about your system's processor(s). Information includes speed, type,
22
+ and load average.
23
+ EOF
24
+
25
+ case Config::CONFIG['host_os']
26
+ when /hpux/i
27
+ spec.extra_rdoc_files += ['ext/hpux/hpux.c']
28
+ when /sunos|solaris/i
29
+ spec.extra_rdoc_files += ['ext/sunos/sunos.c']
30
+ when /bsd|darwin|mach|osx/i
31
+ spec.extra_rdoc_files += ['ext/bsd/bsd.c']
32
+ end
33
+
34
+ case Config::CONFIG['host_os']
35
+ when /mswin|dos|windows|win32|mingw|cygwin/i
36
+ spec.require_paths = ['lib', 'lib/windows']
37
+ spec.extra_rdoc_files << 'lib/windows/sys/cpu.rb'
38
+ spec.platform = Gem::Platform::CURRENT
39
+ spec.platform.cpu = 'universal'
40
+ spec.platform.version = nil
41
+ spec.original_platform = spec.platform
42
+ when /linux/i
43
+ spec.require_paths = ['lib', 'lib/linux']
44
+ spec.extra_rdoc_files << 'lib/linux/sys/cpu.rb'
45
+ spec.platform = Gem::Platform.new('universal-linux')
46
+ spec.original_platform = spec.platform
47
+ else
48
+ spec.extensions = ['ext/extconf.rb']
49
+ end
50
+ 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,76 @@
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
+ assert_respond_to(CPU, :freq)
28
+ assert_nothing_raised{ CPU.freq }
29
+ assert_kind_of(Integer, CPU.freq)
30
+ end
31
+
32
+ def test_cpu_freq_expected_errors
33
+ assert_raises(ArgumentError){ CPU.freq(0) }
34
+ end
35
+
36
+ def test_load_avg
37
+ assert_respond_to(CPU, :load_avg)
38
+ assert_nothing_raised{ CPU.load_avg }
39
+ assert_kind_of(Array, CPU.load_avg)
40
+ assert_equal(3,CPU.load_avg.length)
41
+ end
42
+
43
+ def test_load_avg_expected_errors
44
+ assert_raises(ArgumentError){ CPU.load_avg(0) }
45
+ end
46
+
47
+ def test_machine
48
+ assert_respond_to(CPU, :machine)
49
+ assert_nothing_raised{ CPU.machine }
50
+ assert_kind_of(String, CPU.machine)
51
+ end
52
+
53
+ def test_machine_expected_errors
54
+ assert_raises(ArgumentError){ CPU.machine(0) }
55
+ end
56
+
57
+ def test_model
58
+ assert_respond_to(CPU, :model)
59
+ assert_nothing_raised{ CPU.model }
60
+ assert_kind_of(String, CPU.model)
61
+ end
62
+
63
+ def test_model_expected_errors
64
+ assert_raises(ArgumentError){ CPU.model(0) }
65
+ end
66
+
67
+ def test_num_cpu
68
+ assert_respond_to(CPU, :num_cpu)
69
+ assert_nothing_raised{ CPU.num_cpu }
70
+ assert_kind_of(Integer, CPU.num_cpu)
71
+ end
72
+
73
+ def test_num_cpu_expected_errors
74
+ assert_raises(ArgumentError){ CPU.num_cpu(0) }
75
+ end
76
+ 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.4', 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,113 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: sys-cpu
3
+ version: !ruby/object:Gem::Version
4
+ hash: 15
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 6
9
+ - 4
10
+ version: 0.6.4
11
+ platform: universal-mingw32
12
+ authors:
13
+ - Daniel J. Berger
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2011-09-27 00:00:00 Z
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: test-unit
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ none: false
25
+ requirements:
26
+ - - ">="
27
+ - !ruby/object:Gem::Version
28
+ hash: 15
29
+ segments:
30
+ - 2
31
+ - 1
32
+ - 2
33
+ version: 2.1.2
34
+ type: :development
35
+ version_requirements: *id001
36
+ 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"
37
+ email: djberg96 at nospam at gmail dot com
38
+ executables: []
39
+
40
+ extensions: []
41
+
42
+ extra_rdoc_files:
43
+ - CHANGES
44
+ - README
45
+ - MANIFEST
46
+ - lib/windows/sys/cpu.rb
47
+ files:
48
+ - CHANGES
49
+ - doc/bsd.txt
50
+ - doc/hpux.txt
51
+ - doc/linux.txt
52
+ - doc/sunos.txt
53
+ - doc/windows.txt
54
+ - examples/example_sys_cpu_bsd.rb
55
+ - examples/example_sys_cpu_hpux.rb
56
+ - examples/example_sys_cpu_linux.rb
57
+ - examples/example_sys_cpu_sunos.rb
58
+ - examples/example_sys_cpu_windows.rb
59
+ - ext/bsd/bsd.c
60
+ - ext/extconf.rb
61
+ - ext/hpux/hpux.c
62
+ - ext/sunos/sunos.c
63
+ - ext/version.h
64
+ - install.rb
65
+ - lib/linux/sys/cpu.rb
66
+ - lib/windows/sys/cpu.rb
67
+ - MANIFEST
68
+ - Rakefile
69
+ - README
70
+ - sys-cpu.gemspec
71
+ - test/test_sys_cpu.rb
72
+ - test/test_sys_cpu_bsd.rb
73
+ - test/test_sys_cpu_hpux.rb
74
+ - test/test_sys_cpu_linux.rb
75
+ - test/test_sys_cpu_sunos.rb
76
+ - test/test_sys_cpu_version.rb
77
+ - test/test_sys_cpu_windows.rb
78
+ homepage: http://www.rubyforge.org/projects/sysutils
79
+ licenses: []
80
+
81
+ post_install_message:
82
+ rdoc_options: []
83
+
84
+ require_paths:
85
+ - lib
86
+ - lib/windows
87
+ required_ruby_version: !ruby/object:Gem::Requirement
88
+ none: false
89
+ requirements:
90
+ - - ">="
91
+ - !ruby/object:Gem::Version
92
+ hash: 3
93
+ segments:
94
+ - 0
95
+ version: "0"
96
+ required_rubygems_version: !ruby/object:Gem::Requirement
97
+ none: false
98
+ requirements:
99
+ - - ">="
100
+ - !ruby/object:Gem::Version
101
+ hash: 3
102
+ segments:
103
+ - 0
104
+ version: "0"
105
+ requirements: []
106
+
107
+ rubyforge_project: sysutils
108
+ rubygems_version: 1.8.10
109
+ signing_key:
110
+ specification_version: 3
111
+ summary: A Ruby interface for providing CPU information
112
+ test_files:
113
+ - test/test_sys_cpu.rb