sys-cpu 1.0.1 → 1.0.4

Sign up to get free protection for your applications and to get access to all the features.
data/lib/sys-cpu.rb CHANGED
@@ -1 +1,3 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative 'sys/cpu'
data/spec/spec_helper.rb CHANGED
@@ -1,6 +1,10 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'rspec'
4
+ require 'sys_cpu_shared'
2
5
 
3
6
  RSpec.configure do |config|
7
+ config.include_context(Sys::CPU)
4
8
  config.filter_run_excluding(:bsd) if RbConfig::CONFIG['host_os'] !~ /bsd|darwin|mach|osx/i
5
9
  config.filter_run_excluding(:sunos) if RbConfig::CONFIG['host_os'] !~ /sunos|solaris/i
6
10
  config.filter_run_excluding(:windows) if RbConfig::CONFIG['host_os'] !~ /mswin|win32|dos|mingw|cygwin/i
@@ -1,94 +1,96 @@
1
+ # frozen_string_literal: true
2
+
1
3
  #############################################################
2
- # test_sys_cpu_bsd.rb
4
+ # sys_cpu_bsd_spec.rb
3
5
  #
4
- # The test case for sys-cpu on BSD flavors, including OS X.
6
+ # Specs for sys-cpu on BSD flavors, including OS X.
5
7
  #############################################################
6
8
  require 'sys/cpu'
7
9
  require 'spec_helper'
8
10
 
9
11
  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
12
+ example 'architecture method basic functionality' do
13
+ expect(described_class).to respond_to(:architecture)
14
+ expect{ described_class.architecture }.not_to raise_error
13
15
  end
14
16
 
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
17
+ example 'architecture method returns a sane value' do
18
+ expect(described_class.architecture).to be_kind_of(String)
19
+ expect(described_class.architecture.size).to be > 0
18
20
  end
19
21
 
20
- example "architecture method does not accept any arguments" do
21
- expect{ Sys::CPU.architecture(0) }.to raise_error(ArgumentError)
22
+ example 'architecture method does not accept any arguments' do
23
+ expect{ described_class.architecture(0) }.to raise_error(ArgumentError)
22
24
  end
23
25
 
24
- example "freq method basic functionality" do
25
- expect(Sys::CPU).to respond_to(:freq)
26
- expect{ Sys::CPU.freq }.not_to raise_error
26
+ example 'freq method basic functionality' do
27
+ expect(described_class).to respond_to(:freq)
28
+ expect{ described_class.freq }.not_to raise_error
27
29
  end
28
30
 
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
31
+ example 'freq method returns expected value' do
32
+ expect(described_class.freq).to be_kind_of(Integer)
33
+ expect(described_class.freq).to be > 0
32
34
  end
33
35
 
34
- example "freq method does not accept any arguments" do
35
- expect{ Sys::CPU.freq(0) }.to raise_error(ArgumentError)
36
+ example 'freq method does not accept any arguments' do
37
+ expect{ described_class.freq(0) }.to raise_error(ArgumentError)
36
38
  end
37
39
 
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
40
+ example 'load_avg method basic functionality' do
41
+ expect(described_class).to respond_to(:load_avg)
42
+ expect{ described_class.load_avg }.not_to raise_error
41
43
  end
42
44
 
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)
45
+ example 'load_avg returns the expected results' do
46
+ expect(described_class.load_avg).to be_kind_of(Array)
47
+ expect(described_class.load_avg.length).to eq(3)
48
+ expect(described_class.load_avg[0]).to be_kind_of(Float)
47
49
  end
48
50
 
49
- example "load_avg does not accept any arguments" do
50
- expect{ Sys::CPU.load_avg(0) }.to raise_error(ArgumentError)
51
+ example 'load_avg does not accept any arguments' do
52
+ expect{ described_class.load_avg(0) }.to raise_error(ArgumentError)
51
53
  end
52
54
 
53
- example "machine method basic functionality" do
54
- expect(Sys::CPU).to respond_to(:machine)
55
- expect{ Sys::CPU.machine }.not_to raise_error
55
+ example 'machine method basic functionality' do
56
+ expect(described_class).to respond_to(:machine)
57
+ expect{ described_class.machine }.not_to raise_error
56
58
  end
57
59
 
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
60
+ example 'machine method returns sane value' do
61
+ expect(described_class.machine).to be_kind_of(String)
62
+ expect(described_class.machine.size).to be > 0
61
63
  end
62
64
 
63
- example "machine method does not accept any arguments" do
64
- expect{ Sys::CPU.machine(0) }.to raise_error(ArgumentError)
65
+ example 'machine method does not accept any arguments' do
66
+ expect{ described_class.machine(0) }.to raise_error(ArgumentError)
65
67
  end
66
68
 
67
- example "model method basic functionality" do
68
- expect(Sys::CPU).to respond_to(:model)
69
- expect{ Sys::CPU.model }.not_to raise_error
69
+ example 'model method basic functionality' do
70
+ expect(described_class).to respond_to(:model)
71
+ expect{ described_class.model }.not_to raise_error
70
72
  end
71
73
 
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
74
+ example 'model method returns sane value' do
75
+ expect(described_class.model).to be_kind_of(String)
76
+ expect(described_class.model.length).to be > 0
75
77
  end
76
78
 
77
- example "model method does not accept any arguments" do
78
- expect{ Sys::CPU.model(0) }.to raise_error(ArgumentError)
79
+ example 'model method does not accept any arguments' do
80
+ expect{ described_class.model(0) }.to raise_error(ArgumentError)
79
81
  end
80
82
 
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
83
+ example 'num_cpu method basic functionality' do
84
+ expect(described_class).to respond_to(:num_cpu)
85
+ expect{ described_class.num_cpu }.not_to raise_error
84
86
  end
85
87
 
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
88
+ example 'num_cpu method returns expected value' do
89
+ expect(described_class.num_cpu).to be_kind_of(Integer)
90
+ expect(described_class.num_cpu).to be > 0
89
91
  end
90
92
 
91
- example "num_cpu method does not accept any arguments" do
92
- expect{ Sys::CPU.num_cpu(0) }.to raise_error(ArgumentError)
93
+ example 'num_cpu method does not accept any arguments' do
94
+ expect{ described_class.num_cpu(0) }.to raise_error(ArgumentError)
93
95
  end
94
96
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  #####################################################################
2
4
  # sys_cpu_hpux_spec.rb
3
5
  #
@@ -8,43 +10,46 @@ require 'sys/cpu'
8
10
  require 'spec_helper'
9
11
 
10
12
  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)
13
+ example 'cpu_freq' do
14
+ expect(described_class).to respond_to(:freq)
15
+ expect{ described_class.freq }.not_to raise_error
16
+ expect{ described_class.freq(0) }.not_to raise_error
17
+ expect(described_class.freq).to be_kind_of(Integer)
18
+ end
19
+
20
+ example 'num_cpu' do
21
+ expect(described_class).to respond_to(:num_cpu)
22
+ expect{ described_class.num_cpu }.not_to raise_error
23
+ expect(described_class.num_cpu).to be_kind_of(Integer)
16
24
  end
17
25
 
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)
26
+ example 'num_active_cpu' do
27
+ expect(described_class).to respond_to(:num_active_cpu)
28
+ expect{ described_class.num_active_cpu }.not_to raise_error
29
+ expect(described_class.num_active_cpu).to be_kind_of(Integer)
22
30
  end
23
31
 
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)
32
+ example 'cpu_architecture' do
33
+ expect(described_class).to respond_to(:architecture)
34
+ expect{ described_class.architecture }.not_to raise_error
35
+ expect(described_class.architecture).to be_kind_of(String)
28
36
  end
29
37
 
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)
38
+ example 'load_avg basic sanity check' do
39
+ expect(described_class).to respond_to(:load_avg)
40
+ expect{ described_class.load_avg }.not_to raise_error
34
41
  end
35
42
 
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) }
43
+ example 'load_avg with arguments and/or block sanity check' do
44
+ expect{ described_class.load_avg(0) }.not_to raise_error
45
+ expect{ described_class.load_avg{} }.not_to raise_error
46
+ expect{ described_class.load_avg(0){} }.to raise_error(ArgumentError)
42
47
  end
43
48
 
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
+ example 'load_avg expected results' do
50
+ expect(described_class.load_avg).to be_kind_of(Array)
51
+ expect(described_class.load_avg(0)).to be_kind_of(Array)
52
+ expect(described_class.load_avg.length).to eq(3)
53
+ expect(described_class.load_avg(0).length).to eq(3)
49
54
  end
50
55
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  ###########################################################
2
4
  # sys_cpu_linux_spec.rb
3
5
  #
@@ -8,46 +10,50 @@ require 'sys/cpu'
8
10
  require 'spec_helper'
9
11
 
10
12
  RSpec.describe Sys::CPU, :linux => true do
11
- example "dynamic methods are defined as expected" do
12
- expect{
13
- Sys::CPU.processors{ |cs|
13
+ example 'dynamic methods are defined as expected' do
14
+ expect do
15
+ described_class.processors do |cs|
14
16
  cs.members.each{ |m| cs[m].to_s }
15
- }
16
- }.not_to raise_error
17
+ end
18
+ end.not_to raise_error
19
+ end
20
+
21
+ example 'load average works as expected' do
22
+ expect{ described_class.load_avg }.not_to raise_error
23
+ expect(described_class.load_avg.length).to eq(3)
17
24
  end
18
25
 
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)
26
+ example 'cpu_stats works as expected' do
27
+ expect{ described_class.cpu_stats }.not_to raise_error
28
+ expect(described_class.cpu_stats).to be_kind_of(Hash)
29
+ expect(described_class.cpu_stats['cpu0'].length).to be >= 4
22
30
  end
23
31
 
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
32
+ example 'architecture works as expected' do
33
+ expect{ described_class.architecture }.not_to raise_error
34
+ expect(described_class.architecture).to be_kind_of(String)
28
35
  end
29
36
 
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)
37
+ example 'model works as expected' do
38
+ expect{ described_class.model }.not_to raise_error
39
+ expect(described_class.model).to be_kind_of(String)
33
40
  end
34
41
 
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)
42
+ example 'freq works as expected' do
43
+ expect{ described_class.freq }.not_to raise_error
44
+ expect(described_class.freq).to be_kind_of(Numeric)
38
45
  end
39
46
 
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)
47
+ example 'num_cpu works as expected' do
48
+ expect{ described_class.num_cpu }.not_to raise_error
49
+ expect(described_class.num_cpu).to be_kind_of(Numeric)
43
50
  end
44
51
 
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)
52
+ example 'bogus methods are not picked up by method_missing' do
53
+ expect{ described_class.bogus }.to raise_error(NoMethodError)
48
54
  end
49
55
 
50
- example "bogus methods are not picked up by method_missing" do
51
- expect{Sys::CPU.bogus }.to raise_error(NoMethodError)
56
+ example 'constructor is private' do
57
+ expect{ described_class.new }.to raise_error(NoMethodError)
52
58
  end
53
59
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  #######################################################################
2
4
  # sys_cpu_spec.rb
3
5
  #
@@ -7,12 +9,16 @@
7
9
  require 'sys/cpu'
8
10
  require 'rspec'
9
11
 
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.1')
12
+ RSpec.shared_examples Sys::CPU do
13
+ example 'version number is set to the expected value' do
14
+ expect(Sys::CPU::VERSION).to eq('1.0.4')
13
15
  end
14
16
 
15
- example "version number is frozen" do
17
+ example 'version number is frozen' do
16
18
  expect(Sys::CPU::VERSION).to be_frozen
17
19
  end
20
+
21
+ example 'constructor is private' do
22
+ expect{ described_class.new }.to raise_error(NoMethodError)
23
+ end
18
24
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  ###########################################################
2
4
  # sys_cpu_sunos_spec.rb
3
5
  #
@@ -8,73 +10,73 @@ require 'sys/cpu'
8
10
  require 'spec_helper'
9
11
 
10
12
  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
13
+ example 'freq method basic functionality' do
14
+ expect(described_class).to respond_to(:freq)
15
+ expect{ described_class.freq }.not_to raise_error
14
16
  end
15
17
 
16
- example "freq method does not accept any arguments" do
17
- expect{ Sys::CPU.freq(0) }.to raise_error(ArgumentError)
18
+ example 'freq method does not accept any arguments' do
19
+ expect{ described_class.freq(0) }.to raise_error(ArgumentError)
18
20
  end
19
21
 
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
22
+ example 'freq method returns a sane value' do
23
+ expect(described_class.freq).to be_kind_of(Integer)
24
+ expect(described_class.freq).to be > 100
23
25
  end
24
26
 
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
27
+ example 'fpu_type basic functionality' do
28
+ expect(described_class).to respond_to(:fpu_type)
29
+ expect{ described_class.fpu_type }.not_to raise_error
28
30
  end
29
31
 
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
32
+ example 'fpu_type returns a sane value' do
33
+ expect(described_class.fpu_type).to be_kind_of(String)
34
+ expect(described_class.fpu_type).not_to be_empty
33
35
  end
34
36
 
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
37
+ example 'load_avg basic functionality' do
38
+ expect(described_class).to respond_to(:load_avg)
39
+ expect{ described_class.load_avg }.not_to raise_error
38
40
  end
39
41
 
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)
42
+ example 'load_avg method returns the expected values' do
43
+ expect(described_class.load_avg).to be_kind_of(Array)
44
+ expect(described_class.load_avg.length).to eq(3)
45
+ expect(described_class.load_avg.first).to be_kind_of(Float)
44
46
  end
45
47
 
46
- example "model method basic functionality" do
47
- expect(Sys::CPU).to respond_to(:model)
48
- expect{ Sys::CPU.model }.not_to raise_error
48
+ example 'model method basic functionality' do
49
+ expect(described_class).to respond_to(:model)
50
+ expect{ described_class.model }.not_to raise_error
49
51
  end
50
52
 
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
53
+ example 'model method returns a sane value' do
54
+ expect(described_class.model).to be_kind_of(String)
55
+ expect(described_class.model).not_to be_empty
54
56
  end
55
57
 
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
58
+ example 'num_cpu method basic functionalty' do
59
+ expect(described_class).to respond_to(:num_cpu)
60
+ expect{ described_class.num_cpu }.not_to raise_error
59
61
  end
60
62
 
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
63
+ example 'num_cpu method returns a sane value' do
64
+ expect(described_class.num_cpu).to be_kind_of(Integer)
65
+ expect(described_class.num_cpu).to be > 0
64
66
  end
65
67
 
66
- example "state basic functionality" do
67
- expect(Sys::CPU).to respond_to(:state)
68
- expect{ Sys::CPU.state }.not_to raise_error
68
+ example 'state basic functionality' do
69
+ expect(described_class).to respond_to(:state)
70
+ expect{ described_class.state }.not_to raise_error
69
71
  end
70
72
 
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)
73
+ example 'state method accepts one optional argument' do
74
+ expect{ described_class.state(0) }.not_to raise_error
75
+ expect{ described_class.state(0, 0) }.to raise_error(ArgumentError)
74
76
  end
75
77
 
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
78
+ example 'state method returns a sane value' do
79
+ expect(described_class.state(0)).to be_kind_of(String)
80
+ expect(described_class.state.empty?).to be false
79
81
  end
80
82
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  ######################################################################
2
4
  # sys_cpu_windows_spec.rb
3
5
  #
@@ -11,51 +13,54 @@ require 'socket'
11
13
  RSpec.describe Sys::CPU, :windows => true do
12
14
  let(:host) { Socket.gethostname }
13
15
 
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)
16
+ example 'architecture' do
17
+ expect(described_class).to respond_to(:architecture)
18
+ expect{ described_class.architecture }.not_to raise_error
19
+ expect{ described_class.architecture(host) }.not_to raise_error
20
+ expect(described_class.architecture).to be_kind_of(String)
21
+ end
22
+
23
+ example 'freq basic functionality' do
24
+ expect(described_class).to respond_to(:freq)
25
+ expect{ described_class.freq }.not_to raise_error
26
+ expect(described_class.freq).to be_kind_of(Integer)
19
27
  end
20
28
 
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)
29
+ example 'freq with arguments' do
30
+ expect{ described_class.freq(0) }.not_to raise_error
31
+ expect{ described_class.freq(0, host) }.not_to raise_error
27
32
  end
28
33
 
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
+ example 'model' do
35
+ expect(described_class).to respond_to(:model)
36
+ expect{ described_class.model }.not_to raise_error
37
+ expect{ described_class.model(host) }.not_to raise_error
38
+ expect(described_class.model).to be_kind_of(String)
34
39
  end
35
40
 
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
+ example 'num_cpu' do
42
+ expect(described_class).to respond_to(:num_cpu)
43
+ expect{ described_class.num_cpu }.not_to raise_error
44
+ expect{ described_class.num_cpu(host) }.not_to raise_error
45
+ expect(described_class.num_cpu).to be_kind_of(Integer)
41
46
  end
42
47
 
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
+ example 'cpu_type' do
49
+ expect(described_class).to respond_to(:cpu_type)
50
+ expect{ described_class.cpu_type }.not_to raise_error
51
+ expect{ described_class.cpu_type(host) }.not_to raise_error
52
+ expect(described_class.cpu_type).to be_kind_of(String)
48
53
  end
49
54
 
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
+ example 'load_avg' do
56
+ expect(described_class).to respond_to(:load_avg)
57
+ expect{ described_class.load_avg }.not_to raise_error
58
+ expect{ described_class.load_avg(0, host) }.not_to raise_error
59
+ expect(described_class.load_avg).to be_kind_of(Integer).or be_kind_of(NilClass)
55
60
  end
56
61
 
57
- example "processors" do
58
- expect(Sys::CPU).to respond_to(:processors)
59
- expect{ Sys::CPU.processors{}.not_to raise_error }
62
+ example 'processors' do
63
+ expect(described_class).to respond_to(:processors)
64
+ expect{ described_class.processors{} }.not_to raise_error
60
65
  end
61
66
  end
data/sys-cpu.gemspec CHANGED
@@ -2,7 +2,7 @@ require 'rubygems'
2
2
 
3
3
  Gem::Specification.new do |spec|
4
4
  spec.name = 'sys-cpu'
5
- spec.version = '1.0.1'
5
+ spec.version = '1.0.4'
6
6
  spec.author = 'Daniel J. Berger'
7
7
  spec.email = 'djberg96@gmail.com'
8
8
  spec.license = 'Apache-2.0'
@@ -12,20 +12,20 @@ Gem::Specification.new do |spec|
12
12
  spec.files = Dir['**/*'].reject{ |f| f.include?('git') }
13
13
  spec.cert_chain = ['certs/djberg96_pub.pem']
14
14
 
15
- spec.extra_rdoc_files = Dir['*.rdoc']
16
-
17
15
  # The ffi dependency is only relevent for the Unix version. Given the
18
16
  # ubiquity of ffi these days, I felt a bogus dependency on ffi for Windows
19
17
  # and Linux was worth the tradeoff of not having to create 3 separate gems.
20
18
  spec.add_dependency('ffi', '~> 1.1')
21
19
 
22
20
  spec.add_development_dependency('rake')
21
+ spec.add_development_dependency('rubocop')
23
22
  spec.add_development_dependency('rspec', '~> 3.9')
23
+ spec.add_development_dependency('rubocop-rspec')
24
24
 
25
25
  spec.metadata = {
26
26
  'homepage_uri' => 'https://github.com/djberg96/sys-cpu',
27
27
  'bug_tracker_uri' => 'https://github.com/djberg96/sys-cpu/issues',
28
- 'changelog_uri' => 'https://github.com/djberg96/sys-cpu/blob/ffi/CHANGES.md',
28
+ 'changelog_uri' => 'https://github.com/djberg96/sys-cpu/blob/main/CHANGES.md',
29
29
  'documentation_uri' => 'https://github.com/djberg96/sys-cpu/wiki',
30
30
  'source_code_uri' => 'https://github.com/djberg96/sys-cpu',
31
31
  'wiki_uri' => 'https://github.com/djberg96/sys-cpu/wiki'
data.tar.gz.sig CHANGED
Binary file