sys-cpu 0.9.0 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 465bd2540877db4c141949b95fb9c2d011497f532a9325d604da521ab98b878a
4
- data.tar.gz: 27e1124d09070b074db611e9d392a32739f15554841ba0fe0b51c865414e592b
3
+ metadata.gz: ff79a5d15ea499890892863713cf8b78d1e827f8d78e9baa3e637cea4aa1e732
4
+ data.tar.gz: e6d43e161f5f990cf6b5e7a3270ee3037eb052496b8712d1bbe4fc3e06a19f38
5
5
  SHA512:
6
- metadata.gz: aece81104122383014b5e396a499550d3da21dadfb06846881786eb0898f2402452fe90a2f9c30a86ce89dbd6fad4bc16dfa9b0beafe3aa80cb8c120c3fbab05
7
- data.tar.gz: 33e149e2e2ba7723609dc89ebb095f6df6496f7c2f4ef17656e2373fd004c88d51c3d75b3fec74dcaabcdd663289c00757771bd759869122c6935a4c3b972f75
6
+ metadata.gz: f23ba676b4100b4c8f2c01413965d9ffb67ed19746cf017dab2ece8cc5fb31b460fc04d75180dc4c5da647ee8e48934777d05720023e03e2aeb93213543458fe
7
+ data.tar.gz: 5c0b800fb4a1097f775378120775987c7b86a05728d68882b08432cd1b443ffc36b717360f6486797c091959c0b9102316f3967ab62fd297db1af679d3b83e08
Binary file
data.tar.gz.sig CHANGED
@@ -1 +1 @@
1
- MVonL`����fo`dm;���`�n�
1
+ +:s�u��vu�HA;&�4�K�ж��xԭ�H��j8����g7u�z�,����C�+Q7&C\r��QW�\��i��FrR�uL=�N� \Hړ^��1���S�G���6���Ô�/AafG����>Ìe�Jg�S^9�=�4��N�a��݈� �� 4!�U�xh�22��N
@@ -1,3 +1,9 @@
1
+ == 1.0.0 - 23-Oct-2020
2
+ * Fixed a bug in the Windows version where the attempt to convert the ConfigManagerErrorCode
3
+ to a string was busted. Coincidentally, this also exposed a core bug in JRuby (see PR #6443).
4
+ Thanks go to G. Gibson for reporting the issue.
5
+ * Switched the tests from test-unit to rspec.
6
+
1
7
  == 0.9.0 - 12-May-2020
2
8
  * Added explicit freq, architecture, num_cpu and model methods to the Linux
3
9
  version in an effort to create a common interface across platforms.
data/Gemfile ADDED
@@ -0,0 +1,7 @@
1
+ source 'https://rubygems.org' do
2
+ gem 'ffi', '~> 1.1'
3
+ group 'test' do
4
+ gem 'rake'
5
+ gem 'rspec', '~> 3.9'
6
+ end
7
+ end
@@ -20,9 +20,10 @@
20
20
  * lib/sys/linux/sys/cpu.rb
21
21
  * lib/sys/unix/sys/cpu.rb
22
22
  * lib/sys/windows/sys/cpu.rb
23
- * test/test_sys_cpu.rb
24
- * test/test_sys_cpu_bsd.rb
25
- * test/test_sys_cpu_hpux.rb
26
- * test/test_sys_cpu_sunos.rb
27
- * test/test_sys_cpu_linux.rb
28
- * test/test_sys_cpu_windows.rb
23
+ * spec/spec_helper.rb
24
+ * spec/sys_cpu_spec.rb
25
+ * spec/sys_cpu_bsd_spec.rb
26
+ * spec/sys_cpu_hpux_spec.rb
27
+ * spec/sys_cpu_linux_spec.rb
28
+ * spec/sys_cpu_sunos_spec.rb
29
+ * spec/sys_cpu_windows_spec.rb
data/Rakefile CHANGED
@@ -1,10 +1,10 @@
1
1
  require 'rake'
2
2
  require 'rake/clean'
3
- require 'rake/testtask'
4
3
  require 'rbconfig'
4
+ require 'rspec/core/rake_task'
5
5
  include RbConfig
6
6
 
7
- CLEAN.include('**/*.gem', '**/*.rbc', '**/*.rbx')
7
+ CLEAN.include('**/*.gem', '**/*.rbc', '**/*.rbx', '**/*.lock')
8
8
 
9
9
  namespace 'gem' do
10
10
  desc "Create the sys-cpu gem"
@@ -44,9 +44,7 @@ task :example => [:clean] do
44
44
 
45
45
  end
46
46
 
47
- Rake::TestTask.new do |t|
48
- t.libs << 'test'
49
- t.test_files = FileList['test/test_sys_cpu.rb']
50
- end
47
+ desc "Run the test suite"
48
+ RSpec::Core::RakeTask.new(:spec)
51
49
 
52
- task :default => :test
50
+ task :default => :spec
@@ -5,7 +5,7 @@ require 'rbconfig'
5
5
  module Sys
6
6
  class CPU
7
7
  # The version of the sys-cpu gem.
8
- VERSION = '0.9.0'.freeze
8
+ VERSION = '1.0.0'.freeze
9
9
  end
10
10
  end
11
11
 
@@ -278,7 +278,7 @@ module Sys
278
278
  # Note that this value returns nil on my system.
279
279
  #
280
280
  def self.get_cmec(num)
281
- case
281
+ case num
282
282
  when 0
283
283
  str = "The device is working properly."
284
284
  return str
@@ -0,0 +1,9 @@
1
+ require 'rspec'
2
+
3
+ RSpec.configure do |config|
4
+ config.filter_run_excluding(:bsd) if RbConfig::CONFIG['host_os'] !~ /bsd|darwin|mach|osx/i
5
+ config.filter_run_excluding(:sunos) if RbConfig::CONFIG['host_os'] !~ /sunos|solaris/i
6
+ config.filter_run_excluding(:windows) if RbConfig::CONFIG['host_os'] !~ /mswin|win32|dos|mingw|cygwin/i
7
+ config.filter_run_excluding(:hpux) if RbConfig::CONFIG['host_os'] !~ /hpux/i
8
+ config.filter_run_excluding(:linux) if RbConfig::CONFIG['host_os'] !~ /linux/i
9
+ end
@@ -0,0 +1,94 @@
1
+ #############################################################
2
+ # test_sys_cpu_bsd.rb
3
+ #
4
+ # The test case for sys-cpu on BSD flavors, including OS X.
5
+ #############################################################
6
+ require 'sys/cpu'
7
+ require 'spec_helper'
8
+
9
+ RSpec.describe Sys::CPU, :bsd => true do
10
+ example "architecture method basic functionality" do
11
+ expect(Sys::CPU).to respond_to(:architecture)
12
+ expect{ Sys::CPU.architecture }.not_to raise_error
13
+ end
14
+
15
+ example "architecture method returns a sane value" do
16
+ expect(Sys::CPU.architecture).to be_kind_of(String)
17
+ expect(Sys::CPU.architecture.size).to be > 0
18
+ end
19
+
20
+ example "architecture method does not accept any arguments" do
21
+ expect{ Sys::CPU.architecture(0) }.to raise_error(ArgumentError)
22
+ end
23
+
24
+ example "freq method basic functionality" do
25
+ expect(Sys::CPU).to respond_to(:freq)
26
+ expect{ Sys::CPU.freq }.not_to raise_error
27
+ end
28
+
29
+ example "freq method returns expected value" do
30
+ expect(Sys::CPU.freq).to be_kind_of(Integer)
31
+ expect(Sys::CPU.freq).to be > 0
32
+ end
33
+
34
+ example "freq method does not accept any arguments" do
35
+ expect{ Sys::CPU.freq(0) }.to raise_error(ArgumentError)
36
+ end
37
+
38
+ example "load_avg method basic functionality" do
39
+ expect(Sys::CPU).to respond_to(:load_avg)
40
+ expect{ Sys::CPU.load_avg }.not_to raise_error
41
+ end
42
+
43
+ example "load_avg returns the expected results" do
44
+ expect(Sys::CPU.load_avg).to be_kind_of(Array)
45
+ expect(Sys::CPU.load_avg.length).to eq(3)
46
+ expect(Sys::CPU.load_avg[0]).to be_kind_of(Float)
47
+ end
48
+
49
+ example "load_avg does not accept any arguments" do
50
+ expect{ Sys::CPU.load_avg(0) }.to raise_error(ArgumentError)
51
+ end
52
+
53
+ example "machine method basic functionality" do
54
+ expect(Sys::CPU).to respond_to(:machine)
55
+ expect{ Sys::CPU.machine }.not_to raise_error
56
+ end
57
+
58
+ example "machine method returns sane value" do
59
+ expect(Sys::CPU.machine).to be_kind_of(String)
60
+ expect(Sys::CPU.machine.size).to be > 0
61
+ end
62
+
63
+ example "machine method does not accept any arguments" do
64
+ expect{ Sys::CPU.machine(0) }.to raise_error(ArgumentError)
65
+ end
66
+
67
+ example "model method basic functionality" do
68
+ expect(Sys::CPU).to respond_to(:model)
69
+ expect{ Sys::CPU.model }.not_to raise_error
70
+ end
71
+
72
+ example "model method returns sane value" do
73
+ expect(Sys::CPU.model).to be_kind_of(String)
74
+ expect(Sys::CPU.model.length).to be > 0
75
+ end
76
+
77
+ example "model method does not accept any arguments" do
78
+ expect{ Sys::CPU.model(0) }.to raise_error(ArgumentError)
79
+ end
80
+
81
+ example "num_cpu method basic functionality" do
82
+ expect(Sys::CPU).to respond_to(:num_cpu)
83
+ expect{ Sys::CPU.num_cpu }.not_to raise_error
84
+ end
85
+
86
+ example "num_cpu method returns expected value" do
87
+ expect(Sys::CPU.num_cpu).to be_kind_of(Integer)
88
+ expect(Sys::CPU.num_cpu).to be > 0
89
+ end
90
+
91
+ example "num_cpu method does not accept any arguments" do
92
+ expect{ Sys::CPU.num_cpu(0) }.to raise_error(ArgumentError)
93
+ end
94
+ end
@@ -0,0 +1,50 @@
1
+ #####################################################################
2
+ # sys_cpu_hpux_spec.rb
3
+ #
4
+ # Test suite for the HP-UX platform. This should be run via the
5
+ # 'rake test' task.
6
+ #####################################################################
7
+ require 'sys/cpu'
8
+ require 'spec_helper'
9
+
10
+ RSpec.describe Sys::CPU, :hpux => true do
11
+ example "cpu_freq" do
12
+ expect(Sys::CPU).to respond_to(:freq)
13
+ expect{ Sys::CPU.freq }.not_to raise_error
14
+ expect{ Sys::CPU.freq(0) }.not_to raise_error
15
+ expect(Sys::CPU.freq).to be_kind_of(Integer)
16
+ end
17
+
18
+ example "num_cpu" do
19
+ expect(Sys::CPU).to respond_to(:num_cpu)
20
+ expect{ Sys::CPU.num_cpu }.not_to raise_error
21
+ expect(Sys::CPU.num_cpu).to be_kind_of(Integer)
22
+ end
23
+
24
+ example "num_active_cpu" do
25
+ expect(Sys::CPU).to respond_to(:num_active_cpu)
26
+ expect{ Sys::CPU.num_active_cpu }.not_to raise_error
27
+ expect(Sys::CPU.num_active_cpu).to be_kind_of(Integer)
28
+ end
29
+
30
+ example "cpu_architecture" do
31
+ expect(Sys::CPU).to respond_to(:architecture)
32
+ expect{ Sys::CPU.architecture }.not_to raise_error
33
+ expect(Sys::CPU.architecture).to be_kind_of(String)
34
+ end
35
+
36
+ example "load_avg sanity check" do
37
+ expect(Sys::CPU).to respond_to(:load_avg)
38
+ expect{ Sys::CPU.load_avg }.not_to raise_error
39
+ expect{ Sys::CPU.load_avg(0) }.not_to raise_error
40
+ expect{ Sys::CPU.load_avg{ |e| }.not_to raise_error }
41
+ expect{ Sys::CPU.load_avg(0){ }.to raise_error(ArgumentError) }
42
+ end
43
+
44
+ example "load_avg expected results" do
45
+ expect(Sys::CPU.load_avg).to be_kind_of(Array)
46
+ expect(Sys::CPU.load_avg(0)).to be_kind_of(Array)
47
+ expect(Sys::CPU.load_avg.length).to eq(3)
48
+ expect(Sys::CPU.load_avg(0).length).to eq(3)
49
+ end
50
+ end
@@ -0,0 +1,53 @@
1
+ ###########################################################
2
+ # sys_cpu_linux_spec.rb
3
+ #
4
+ # Specs for sys-cpu for Linux. This should be run via
5
+ # the 'rake spec' task.
6
+ ###########################################################
7
+ require 'sys/cpu'
8
+ require 'spec_helper'
9
+
10
+ RSpec.describe Sys::CPU, :linux => true do
11
+ example "dynamic methods are defined as expected" do
12
+ expect{
13
+ Sys::CPU.processors{ |cs|
14
+ cs.members.each{ |m| cs[m].to_s }
15
+ }
16
+ }.not_to raise_error
17
+ end
18
+
19
+ example "load average works as expected" do
20
+ expect{ Sys::CPU.load_avg }.not_to raise_error
21
+ expect(Sys::CPU.load_avg.length).to eq(3)
22
+ end
23
+
24
+ example "cpu_stats works as expected" do
25
+ expect{ Sys::CPU.cpu_stats }.not_to raise_error
26
+ expect(Sys::CPU.cpu_stats).to be_kind_of(Hash)
27
+ expect(Sys::CPU.cpu_stats['cpu0'].length).to be >= 4
28
+ end
29
+
30
+ example "architecture works as expected" do
31
+ expect{ Sys::CPU.architecture }.not_to raise_error
32
+ expect(Sys::CPU.architecture).to be_kind_of(String)
33
+ end
34
+
35
+ example "model works as expected" do
36
+ expect{ Sys::CPU.model }.not_to raise_error
37
+ expect(Sys::CPU.model).to be_kind_of(String)
38
+ end
39
+
40
+ example "freq works as expected" do
41
+ expect{ Sys::CPU.freq }.not_to raise_error
42
+ expect(Sys::CPU.freq).to be_kind_of(Numeric)
43
+ end
44
+
45
+ example "num_cpu works as expected" do
46
+ expect{ Sys::CPU.num_cpu }.not_to raise_error
47
+ expect(Sys::CPU.num_cpu).to be_kind_of(Numeric)
48
+ end
49
+
50
+ example "bogus methods are not picked up by method_missing" do
51
+ expect{Sys::CPU.bogus }.to raise_error(NoMethodError)
52
+ end
53
+ end
@@ -0,0 +1,18 @@
1
+ #######################################################################
2
+ # sys_cpu_spec.rb
3
+ #
4
+ # Only shared specs go here. Everything else goes into its own tagged
5
+ # spec file.
6
+ #######################################################################
7
+ require 'sys/cpu'
8
+ require 'rspec'
9
+
10
+ RSpec.describe Sys::CPU::VERSION do
11
+ example "version number is set to the expected value" do
12
+ expect(Sys::CPU::VERSION).to eq('1.0.0')
13
+ end
14
+
15
+ example "version number is frozen" do
16
+ expect(Sys::CPU::VERSION).to be_frozen
17
+ end
18
+ end
@@ -0,0 +1,80 @@
1
+ ###########################################################
2
+ # sys_cpu_sunos_spec.rb
3
+ #
4
+ # Test suite for sys-cpu on Solaris. This should be run
5
+ # via the 'rake spec' task.
6
+ ###########################################################
7
+ require 'sys/cpu'
8
+ require 'spec_helper'
9
+
10
+ RSpec.describe Sys::CPU, :sunos => true do
11
+ example "freq method basic functionality" do
12
+ expect(Sys::CPU).to respond_to(:freq)
13
+ expect{ Sys::CPU.freq }.not_to raise_error
14
+ end
15
+
16
+ example "freq method does not accept any arguments" do
17
+ expect{ Sys::CPU.freq(0) }.to raise_error(ArgumentError)
18
+ end
19
+
20
+ example "freq method returns a sane value" do
21
+ expect(Sys::CPU.freq).to be_kind_of(Integer)
22
+ expect(Sys::CPU.freq).to be > 100
23
+ end
24
+
25
+ example "fpu_type basic functionality" do
26
+ expect(Sys::CPU).to respond_to(:fpu_type)
27
+ expect{ Sys::CPU.fpu_type }.not_to raise_error
28
+ end
29
+
30
+ example "fpu_type returns a sane value" do
31
+ expect(Sys::CPU.fpu_type).to be_kind_of(String)
32
+ expect(Sys::CPU.fpu_type).not_to be_empty
33
+ end
34
+
35
+ example "load_avg basic functionality" do
36
+ expect(Sys::CPU).to respond_to(:load_avg)
37
+ expect{ Sys::CPU.load_avg }.not_to raise_error
38
+ end
39
+
40
+ example "load_avg method returns the expected values" do
41
+ expect(Sys::CPU.load_avg).to be_kind_of(Array)
42
+ expect(Sys::CPU.load_avg.length).to eq(3)
43
+ expect(Sys::CPU.load_avg.first).to be_kind_of(Float)
44
+ end
45
+
46
+ example "model method basic functionality" do
47
+ expect(Sys::CPU).to respond_to(:model)
48
+ expect{ Sys::CPU.model }.not_to raise_error
49
+ end
50
+
51
+ example "model method returns a sane value" do
52
+ expect(Sys::CPU.model).to be_kind_of(String)
53
+ expect(Sys::CPU.model).not_to be_empty
54
+ end
55
+
56
+ example "num_cpu method basic functionalty" do
57
+ expect(Sys::CPU).to respond_to(:num_cpu)
58
+ expect{ Sys::CPU.num_cpu }.not_to raise_error
59
+ end
60
+
61
+ example "num_cpu method returns a sane value" do
62
+ expect(Sys::CPU.num_cpu).to be_kind_of(Integer)
63
+ expect(Sys::CPU.num_cpu).to be > 0
64
+ end
65
+
66
+ example "state basic functionality" do
67
+ expect(Sys::CPU).to respond_to(:state)
68
+ expect{ Sys::CPU.state }.not_to raise_error
69
+ end
70
+
71
+ example "state method accepts one optional argument" do
72
+ expect{ Sys::CPU.state(0) }.not_to raise_error
73
+ expect{ Sys::CPU.state(0,0) }.to raise_error(ArgumentError)
74
+ end
75
+
76
+ example "state method returns a sane value" do
77
+ expect(Sys::CPU.state(0)).to be_kind_of(String)
78
+ expect(Sys::CPU.state.empty?).to be false
79
+ end
80
+ end
@@ -0,0 +1,61 @@
1
+ ######################################################################
2
+ # sys_cpu_windows_spec.rb
3
+ #
4
+ # Test suite for MS Windows systems. This should be run via the
5
+ # 'rake test' task.
6
+ ######################################################################
7
+ require 'spec_helper'
8
+ require 'sys/cpu'
9
+ require 'socket'
10
+
11
+ RSpec.describe Sys::CPU, :windows => true do
12
+ let(:host) { Socket.gethostname }
13
+
14
+ example "architecture" do
15
+ expect(Sys::CPU).to respond_to(:architecture)
16
+ expect{ Sys::CPU.architecture }.not_to raise_error
17
+ expect{ Sys::CPU.architecture(host) }.not_to raise_error
18
+ expect(Sys::CPU.architecture).to be_kind_of(String)
19
+ end
20
+
21
+ example "freq" do
22
+ expect(Sys::CPU).to respond_to(:freq)
23
+ expect{ Sys::CPU.freq }.not_to raise_error
24
+ expect{ Sys::CPU.freq(0) }.not_to raise_error
25
+ expect{ Sys::CPU.freq(0, host) }.not_to raise_error
26
+ expect(Sys::CPU.freq).to be_kind_of(Integer)
27
+ end
28
+
29
+ example "model" do
30
+ expect(Sys::CPU).to respond_to(:model)
31
+ expect{ Sys::CPU.model }.not_to raise_error
32
+ expect{ Sys::CPU.model(host) }.not_to raise_error
33
+ expect(Sys::CPU.model).to be_kind_of(String)
34
+ end
35
+
36
+ example "num_cpu" do
37
+ expect(Sys::CPU).to respond_to(:num_cpu)
38
+ expect{ Sys::CPU.num_cpu }.not_to raise_error
39
+ expect{ Sys::CPU.num_cpu(host) }.not_to raise_error
40
+ expect(Sys::CPU.num_cpu).to be_kind_of(Integer)
41
+ end
42
+
43
+ example "cpu_type" do
44
+ expect(Sys::CPU).to respond_to(:cpu_type)
45
+ expect{ Sys::CPU.cpu_type }.not_to raise_error
46
+ expect{ Sys::CPU.cpu_type(host) }.not_to raise_error
47
+ expect(Sys::CPU.cpu_type).to be_kind_of(String)
48
+ end
49
+
50
+ example "load_avg" do
51
+ expect(Sys::CPU).to respond_to(:load_avg)
52
+ expect{ Sys::CPU.load_avg }.not_to raise_error
53
+ expect{ Sys::CPU.load_avg(0, host) }.not_to raise_error
54
+ expect(Sys::CPU.load_avg).to be_kind_of(Integer)
55
+ end
56
+
57
+ example "processors" do
58
+ expect(Sys::CPU).to respond_to(:processors)
59
+ expect{ Sys::CPU.processors{}.not_to raise_error }
60
+ end
61
+ end
@@ -2,13 +2,13 @@ require 'rubygems'
2
2
 
3
3
  Gem::Specification.new do |spec|
4
4
  spec.name = 'sys-cpu'
5
- spec.version = '0.9.0'
5
+ spec.version = '1.0.0'
6
6
  spec.author = 'Daniel J. Berger'
7
7
  spec.email = 'djberg96@gmail.com'
8
8
  spec.license = 'Apache-2.0'
9
9
  spec.homepage = 'https://github.com/djberg96/sys-cpu'
10
10
  spec.summary = 'A Ruby interface for providing CPU information'
11
- spec.test_file = 'test/test_sys_cpu.rb'
11
+ spec.test_files = Dir['spec/*.rb']
12
12
  spec.files = Dir['**/*'].reject{ |f| f.include?('git') }
13
13
  spec.cert_chain = ['certs/djberg96_pub.pem']
14
14
 
@@ -17,10 +17,10 @@ Gem::Specification.new do |spec|
17
17
  # The ffi dependency is only relevent for the Unix version. Given the
18
18
  # ubiquity of ffi these days, I felt a bogus dependency on ffi for Windows
19
19
  # and Linux was worth the tradeoff of not having to create 3 separate gems.
20
- spec.add_dependency('ffi')
20
+ spec.add_dependency('ffi', '~> 1.1')
21
21
 
22
- spec.add_development_dependency('test-unit')
23
22
  spec.add_development_dependency('rake')
23
+ spec.add_development_dependency('rspec', '~> 3.9')
24
24
 
25
25
  spec.metadata = {
26
26
  'homepage_uri' => 'https://github.com/djberg96/sys-cpu',
metadata CHANGED
@@ -1,11 +1,11 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sys-cpu
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.0
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel J. Berger
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain:
11
11
  - |
@@ -35,24 +35,24 @@ cert_chain:
35
35
  ORVCZpRuCPpmC8qmqxUnARDArzucjaclkxjLWvCVHeFa9UP7K3Nl9oTjJNv+7/jM
36
36
  WZs4eecIcUc4tKdHxcAJ0MO/Dkqq7hGaiHpwKY76wQ1+8xAh
37
37
  -----END CERTIFICATE-----
38
- date:
38
+ date:
39
39
  dependencies:
40
40
  - !ruby/object:Gem::Dependency
41
41
  name: ffi
42
42
  requirement: !ruby/object:Gem::Requirement
43
43
  requirements:
44
- - - ">="
44
+ - - "~>"
45
45
  - !ruby/object:Gem::Version
46
- version: '0'
46
+ version: '1.1'
47
47
  type: :runtime
48
48
  prerelease: false
49
49
  version_requirements: !ruby/object:Gem::Requirement
50
50
  requirements:
51
- - - ">="
51
+ - - "~>"
52
52
  - !ruby/object:Gem::Version
53
- version: '0'
53
+ version: '1.1'
54
54
  - !ruby/object:Gem::Dependency
55
- name: test-unit
55
+ name: rake
56
56
  requirement: !ruby/object:Gem::Requirement
57
57
  requirements:
58
58
  - - ">="
@@ -66,19 +66,19 @@ dependencies:
66
66
  - !ruby/object:Gem::Version
67
67
  version: '0'
68
68
  - !ruby/object:Gem::Dependency
69
- name: rake
69
+ name: rspec
70
70
  requirement: !ruby/object:Gem::Requirement
71
71
  requirements:
72
- - - ">="
72
+ - - "~>"
73
73
  - !ruby/object:Gem::Version
74
- version: '0'
74
+ version: '3.9'
75
75
  type: :development
76
76
  prerelease: false
77
77
  version_requirements: !ruby/object:Gem::Requirement
78
78
  requirements:
79
- - - ">="
79
+ - - "~>"
80
80
  - !ruby/object:Gem::Version
81
- version: '0'
81
+ version: '3.9'
82
82
  description: |2
83
83
  The sys-cpu library provides an interface for gathering information
84
84
  about your system's processor(s). Information includes speed, type,
@@ -87,52 +87,53 @@ email: djberg96@gmail.com
87
87
  executables: []
88
88
  extensions: []
89
89
  extra_rdoc_files:
90
- - README.rdoc
91
- - MANIFEST.rdoc
92
90
  - CHANGES.rdoc
93
- files:
91
+ - MANIFEST.rdoc
94
92
  - README.rdoc
93
+ files:
94
+ - install.rb
95
+ - LICENSE
96
+ - spec
97
+ - spec/spec_helper.rb
98
+ - spec/sys_cpu_bsd_spec.rb
99
+ - spec/sys_cpu_sunos_spec.rb
100
+ - spec/sys_cpu_hpux_spec.rb
101
+ - spec/sys_cpu_linux_spec.rb
102
+ - spec/sys_cpu_windows_spec.rb
103
+ - spec/sys_cpu_spec.rb
104
+ - Rakefile
105
+ - certs
106
+ - certs/djberg96_pub.pem
95
107
  - examples
96
- - examples/example_sys_cpu_sunos.rb
97
- - examples/example_sys_cpu_windows.rb
98
- - examples/example_sys_cpu_hpux.rb
99
108
  - examples/example_sys_cpu_linux.rb
109
+ - examples/example_sys_cpu_hpux.rb
110
+ - examples/example_sys_cpu_sunos.rb
100
111
  - examples/example_sys_cpu_bsd.rb
112
+ - examples/example_sys_cpu_windows.rb
101
113
  - sys-cpu.gemspec
102
- - MANIFEST.rdoc
103
- - certs
104
- - certs/djberg96_pub.pem
105
- - test
106
- - test/test_sys_cpu_bsd.rb
107
- - test/test_sys_cpu_version.rb
108
- - test/test_sys_cpu.rb
109
- - test/test_sys_cpu_windows.rb
110
- - test/test_sys_cpu_sunos.rb
111
- - test/test_sys_cpu_hpux.rb
112
- - test/test_sys_cpu_linux.rb
113
- - doc
114
- - doc/linux.txt
115
- - doc/windows.txt
116
- - doc/sunos.txt
117
- - doc/hpux.txt
118
- - doc/bsd.txt
119
- - install.rb
120
- - LICENSE
121
114
  - lib
122
- - lib/sys-cpu.rb
123
115
  - lib/sys
124
- - lib/sys/cpu.rb
125
- - lib/sys/linux
126
- - lib/sys/linux/sys
127
- - lib/sys/linux/sys/cpu.rb
128
116
  - lib/sys/unix
129
117
  - lib/sys/unix/sys
130
118
  - lib/sys/unix/sys/cpu.rb
119
+ - lib/sys/linux
120
+ - lib/sys/linux/sys
121
+ - lib/sys/linux/sys/cpu.rb
122
+ - lib/sys/cpu.rb
131
123
  - lib/sys/windows
132
124
  - lib/sys/windows/sys
133
125
  - lib/sys/windows/sys/cpu.rb
134
- - Rakefile
126
+ - lib/sys-cpu.rb
135
127
  - CHANGES.rdoc
128
+ - Gemfile
129
+ - doc
130
+ - doc/linux.txt
131
+ - doc/sunos.txt
132
+ - doc/windows.txt
133
+ - doc/bsd.txt
134
+ - doc/hpux.txt
135
+ - MANIFEST.rdoc
136
+ - README.rdoc
136
137
  homepage: https://github.com/djberg96/sys-cpu
137
138
  licenses:
138
139
  - Apache-2.0
@@ -143,7 +144,7 @@ metadata:
143
144
  documentation_uri: https://github.com/djberg96/sys-cpu/wiki
144
145
  source_code_uri: https://github.com/djberg96/sys-cpu
145
146
  wiki_uri: https://github.com/djberg96/sys-cpu/wiki
146
- post_install_message:
147
+ post_install_message:
147
148
  rdoc_options: []
148
149
  require_paths:
149
150
  - lib
@@ -158,9 +159,15 @@ required_rubygems_version: !ruby/object:Gem::Requirement
158
159
  - !ruby/object:Gem::Version
159
160
  version: '0'
160
161
  requirements: []
161
- rubygems_version: 3.0.6
162
- signing_key:
162
+ rubygems_version: 3.1.4
163
+ signing_key:
163
164
  specification_version: 4
164
165
  summary: A Ruby interface for providing CPU information
165
166
  test_files:
166
- - test/test_sys_cpu.rb
167
+ - spec/spec_helper.rb
168
+ - spec/sys_cpu_bsd_spec.rb
169
+ - spec/sys_cpu_sunos_spec.rb
170
+ - spec/sys_cpu_hpux_spec.rb
171
+ - spec/sys_cpu_linux_spec.rb
172
+ - spec/sys_cpu_windows_spec.rb
173
+ - spec/sys_cpu_spec.rb
metadata.gz.sig CHANGED
Binary file
@@ -1,23 +0,0 @@
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 RbConfig::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,97 +0,0 @@
1
- #############################################################
2
- # test_sys_cpu_bsd.rb
3
- #
4
- # The test case for sys-cpu on BSD flavors, including OS X.
5
- #############################################################
6
- require 'sys/cpu'
7
- require 'rbconfig'
8
- require 'test-unit'
9
- require 'test_sys_cpu_version'
10
- include Sys
11
-
12
- class TC_Sys_CPU_BSD < Test::Unit::TestCase
13
- test "architecture method basic functionality" do
14
- assert_respond_to(CPU, :architecture)
15
- assert_nothing_raised{ CPU.architecture }
16
- end
17
-
18
- test "architecture method returns a sane value" do
19
- assert_kind_of(String, CPU.architecture)
20
- assert_true(CPU.architecture.size > 0)
21
- end
22
-
23
- test "architecture method does not accept any arguments" do
24
- assert_raises(ArgumentError){ CPU.architecture(0) }
25
- end
26
-
27
- test "freq method basic functionality" do
28
- assert_respond_to(CPU, :freq)
29
- assert_nothing_raised{ CPU.freq }
30
- end
31
-
32
- test "freq method returns expected value" do
33
- assert_kind_of(Integer, CPU.freq)
34
- assert_true(CPU.freq > 0)
35
- end
36
-
37
- test "freq method does not accept any arguments" do
38
- assert_raises(ArgumentError){ CPU.freq(0) }
39
- end
40
-
41
- test "load_avg method basic functionality" do
42
- assert_respond_to(CPU, :load_avg)
43
- assert_nothing_raised{ CPU.load_avg }
44
- end
45
-
46
- test "load_avg returns the expected results" do
47
- assert_kind_of(Array, CPU.load_avg)
48
- assert_equal(3, CPU.load_avg.length)
49
- assert_kind_of(Float, CPU.load_avg[0])
50
- end
51
-
52
- test "load_avg does not accept any arguments" do
53
- assert_raises(ArgumentError){ CPU.load_avg(0) }
54
- end
55
-
56
- test "machine method basic functionality" do
57
- assert_respond_to(CPU, :machine)
58
- assert_nothing_raised{ CPU.machine }
59
- end
60
-
61
- test "machine method returns sane value" do
62
- assert_kind_of(String, CPU.machine)
63
- assert_true(CPU.machine.size > 0)
64
- end
65
-
66
- test "machine method does not accept any arguments" do
67
- assert_raises(ArgumentError){ CPU.machine(0) }
68
- end
69
-
70
- test "model method basic functionality" do
71
- assert_respond_to(CPU, :model)
72
- assert_nothing_raised{ CPU.model }
73
- end
74
-
75
- test "model method returns sane value" do
76
- assert_kind_of(String, CPU.model)
77
- assert_true(CPU.model.length > 0)
78
- end
79
-
80
- test "model method does not accept any arguments" do
81
- assert_raises(ArgumentError){ CPU.model(0) }
82
- end
83
-
84
- test "num_cpu method basic functionality" do
85
- assert_respond_to(CPU, :num_cpu)
86
- assert_nothing_raised{ CPU.num_cpu }
87
- end
88
-
89
- test "num_cpu method returns expected value" do
90
- assert_kind_of(Integer, CPU.num_cpu)
91
- assert_true(CPU.num_cpu > 0)
92
- end
93
-
94
- test "num_cpu method does not accept any arguments" do
95
- assert_raises(ArgumentError){ CPU.num_cpu(0) }
96
- end
97
- end
@@ -1,49 +0,0 @@
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 'sys/cpu'
8
- require 'test-unit'
9
- require 'test_sys_cpu_version'
10
- include Sys
11
-
12
- class TC_Sys_CPU_HPUX < Test::Unit::TestCase
13
- def test_cpu_freq
14
- assert_respond_to(CPU, :freq)
15
- assert_nothing_raised{ CPU.freq }
16
- assert_nothing_raised{ CPU.freq(0) }
17
- assert_kind_of(Integer, CPU.freq, 'Invalid Type')
18
- end
19
-
20
- def test_num_cpu
21
- assert_respond_to(CPU, :num_cpu)
22
- assert_nothing_raised{ CPU.num_cpu }
23
- assert_kind_of(Integer, CPU.num_cpu, 'Invalid Type')
24
- end
25
-
26
- def test_num_active_cpu
27
- assert_respond_to(CPU, :num_active_cpu)
28
- assert_nothing_raised{ CPU.num_active_cpu }
29
- assert_kind_of(Integer, CPU.num_active_cpu, 'Invalid Type')
30
- end
31
-
32
- def test_cpu_architecture
33
- assert_respond_to(CPU, :architecture)
34
- assert_nothing_raised{ CPU.architecture }
35
- assert_kind_of(String, CPU.architecture, 'Invalid Type')
36
- end
37
-
38
- def test_load_avg
39
- assert_respond_to(CPU, :load_avg)
40
- assert_nothing_raised{ CPU.load_avg }
41
- assert_nothing_raised{ CPU.load_avg(0) }
42
- assert_nothing_raised{ CPU.load_avg{ |e| } }
43
- 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')
48
- end
49
- end
@@ -1,54 +0,0 @@
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 'sys/cpu'
8
- require 'test-unit'
9
- require 'test_sys_cpu_version'
10
-
11
- class TC_Sys_CPU_Linux < Test::Unit::TestCase
12
- test "dynamic methods are defined as expected" do
13
- assert_nothing_raised{
14
- Sys::CPU.processors{ |cs|
15
- cs.members.each{ |m| cs[m].to_s }
16
- }
17
- }
18
- end
19
-
20
- test "load average works as expected" do
21
- assert_nothing_raised{ Sys::CPU.load_avg }
22
- assert_equal(3, Sys::CPU.load_avg.length)
23
- end
24
-
25
- test "cpu_stats works as expected" do
26
- assert_nothing_raised{ Sys::CPU.cpu_stats }
27
- assert_kind_of(Hash, Sys::CPU.cpu_stats)
28
- assert_true(Sys::CPU.cpu_stats['cpu0'].length >= 4)
29
- end
30
-
31
- test "architecture works as expected" do
32
- assert_nothing_raised{ Sys::CPU.architecture }
33
- assert_kind_of(String, Sys::CPU.architecture)
34
- end
35
-
36
- test "model works as expected" do
37
- assert_nothing_raised{ Sys::CPU.model }
38
- assert_kind_of(String, Sys::CPU.model)
39
- end
40
-
41
- test "freq works as expected" do
42
- assert_nothing_raised{ Sys::CPU.freq }
43
- assert_kind_of(Numeric, Sys::CPU.freq)
44
- end
45
-
46
- test "num_cpu works as expected" do
47
- assert_nothing_raised{ Sys::CPU.num_cpu }
48
- assert_kind_of(Numeric, Sys::CPU.num_cpu)
49
- end
50
-
51
- test "bogus methods are not picked up by method_missing" do
52
- assert_raise(NoMethodError){ Sys::CPU.bogus }
53
- end
54
- end
@@ -1,81 +0,0 @@
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 'sys/cpu'
8
- require 'test-unit'
9
- include Sys
10
-
11
- class TC_Sys_CPU_SunOS < Test::Unit::TestCase
12
- test "freq method basic functionality" do
13
- assert_respond_to(CPU, :freq)
14
- assert_nothing_raised{ CPU.freq }
15
- end
16
-
17
- test "freq method does not accept any arguments" do
18
- assert_raise(ArgumentError){ CPU.freq(0) }
19
- end
20
-
21
- test "freq method returns a sane value" do
22
- assert_kind_of(Integer, CPU.freq)
23
- assert_true(CPU.freq > 100)
24
- end
25
-
26
- test "fpu_type basic functionality" do
27
- assert_respond_to(CPU, :fpu_type)
28
- assert_nothing_raised{ CPU.fpu_type }
29
- end
30
-
31
- test "fpu_type returns a sane value" do
32
- assert_kind_of(String, CPU.fpu_type)
33
- assert_false(CPU.fpu_type.empty?)
34
- end
35
-
36
- test "load_avg basic functionality" do
37
- assert_respond_to(CPU, :load_avg)
38
- assert_nothing_raised{ CPU.load_avg }
39
- end
40
-
41
- test "load_avg method returns the expected values" do
42
- assert_kind_of(Array, CPU.load_avg)
43
- assert_equal(3, CPU.load_avg.length)
44
- assert_kind_of(Float, CPU.load_avg.first)
45
- end
46
-
47
- test "model method basic functionality" do
48
- assert_respond_to(CPU, :model)
49
- assert_nothing_raised{ CPU.model }
50
- end
51
-
52
- test "model method returns a sane value" do
53
- assert_kind_of(String, CPU.model)
54
- assert_false(CPU.model.empty?)
55
- end
56
-
57
- test "num_cpu method basic functionalty" do
58
- assert_respond_to(CPU, :num_cpu)
59
- assert_nothing_raised{ CPU.num_cpu }
60
- end
61
-
62
- test "num_cpu method returns a sane value" do
63
- assert_kind_of(Integer, CPU.num_cpu)
64
- assert_true(CPU.num_cpu > 0)
65
- end
66
-
67
- test "state basic functionality" do
68
- assert_respond_to(CPU, :state)
69
- assert_nothing_raised{ CPU.state }
70
- end
71
-
72
- test "state method accepts one optional argument" do
73
- assert_nothing_raised{ CPU.state(0) }
74
- assert_raise(ArgumentError){ CPU.state(0,0) }
75
- end
76
-
77
- test "state method returns a sane value" do
78
- assert_kind_of(String, CPU.state(0))
79
- assert_false(CPU.state.empty?)
80
- end
81
- end
@@ -1,19 +0,0 @@
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 'sys/cpu'
9
- require 'test-unit'
10
-
11
- class TC_Sys_CPU_VERSION < Test::Unit::TestCase
12
- test "version number is set to the expected value" do
13
- assert_equal('0.9.0', Sys::CPU::VERSION)
14
- end
15
-
16
- test "version number is frozen" do
17
- assert_true(Sys::CPU::VERSION.frozen?)
18
- end
19
- end
@@ -1,72 +0,0 @@
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_cpu_type
51
- assert_respond_to(CPU, :cpu_type)
52
- assert_nothing_raised{ CPU.cpu_type }
53
- assert_nothing_raised{ CPU.cpu_type(@@host) }
54
- assert_kind_of(String, CPU.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