sys-cpu 0.8.0 → 1.0.0

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.
@@ -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,25 +2,34 @@ require 'rubygems'
2
2
 
3
3
  Gem::Specification.new do |spec|
4
4
  spec.name = 'sys-cpu'
5
- spec.version = '0.8.0'
5
+ spec.version = '1.0.0'
6
6
  spec.author = 'Daniel J. Berger'
7
7
  spec.email = 'djberg96@gmail.com'
8
- spec.license = 'Apache 2.0'
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
 
15
- spec.extra_rdoc_files = ['CHANGES', 'README', 'MANIFEST']
15
+ spec.extra_rdoc_files = Dir['*.rdoc']
16
16
 
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
+
25
+ spec.metadata = {
26
+ 'homepage_uri' => 'https://github.com/djberg96/sys-cpu',
27
+ 'bug_tracker_uri' => 'https://github.com/djberg96/sys-cpu/issues',
28
+ 'changelog_uri' => 'https://github.com/djberg96/sys-cpu/blob/ffi/CHANGES.rdoc',
29
+ 'documentation_uri' => 'https://github.com/djberg96/sys-cpu/wiki',
30
+ 'source_code_uri' => 'https://github.com/djberg96/sys-cpu',
31
+ 'wiki_uri' => 'https://github.com/djberg96/sys-cpu/wiki'
32
+ }
24
33
 
25
34
  spec.description = <<-EOF
26
35
  The sys-cpu library provides an interface for gathering information
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.8.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: 2018-10-17 00:00:00.000000000 Z
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,56 +87,64 @@ email: djberg96@gmail.com
87
87
  executables: []
88
88
  extensions: []
89
89
  extra_rdoc_files:
90
- - CHANGES
91
- - README
92
- - MANIFEST
90
+ - CHANGES.rdoc
91
+ - MANIFEST.rdoc
92
+ - README.rdoc
93
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
94
105
  - certs
95
106
  - certs/djberg96_pub.pem
96
- - CHANGES
97
- - doc
98
- - doc/bsd.txt
99
- - doc/hpux.txt
100
- - doc/linux.txt
101
- - doc/sunos.txt
102
- - doc/windows.txt
103
107
  - examples
104
- - examples/example_sys_cpu_bsd.rb
105
- - examples/example_sys_cpu_hpux.rb
106
108
  - examples/example_sys_cpu_linux.rb
109
+ - examples/example_sys_cpu_hpux.rb
107
110
  - examples/example_sys_cpu_sunos.rb
111
+ - examples/example_sys_cpu_bsd.rb
108
112
  - examples/example_sys_cpu_windows.rb
109
- - install.rb
113
+ - sys-cpu.gemspec
110
114
  - lib
111
115
  - lib/sys
112
- - lib/sys/cpu.rb
113
- - lib/sys/linux
114
- - lib/sys/linux/sys
115
- - lib/sys/linux/sys/cpu.rb
116
116
  - lib/sys/unix
117
117
  - lib/sys/unix/sys
118
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
119
123
  - lib/sys/windows
120
124
  - lib/sys/windows/sys
121
125
  - lib/sys/windows/sys/cpu.rb
122
126
  - lib/sys-cpu.rb
123
- - MANIFEST
124
- - Rakefile
125
- - README
126
- - sys-cpu.gemspec
127
- - test
128
- - test/test_sys_cpu.rb
129
- - test/test_sys_cpu_bsd.rb
130
- - test/test_sys_cpu_hpux.rb
131
- - test/test_sys_cpu_linux.rb
132
- - test/test_sys_cpu_sunos.rb
133
- - test/test_sys_cpu_version.rb
134
- - test/test_sys_cpu_windows.rb
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
135
137
  homepage: https://github.com/djberg96/sys-cpu
136
138
  licenses:
137
- - Apache 2.0
138
- metadata: {}
139
- post_install_message:
139
+ - Apache-2.0
140
+ metadata:
141
+ homepage_uri: https://github.com/djberg96/sys-cpu
142
+ bug_tracker_uri: https://github.com/djberg96/sys-cpu/issues
143
+ changelog_uri: https://github.com/djberg96/sys-cpu/blob/ffi/CHANGES.rdoc
144
+ documentation_uri: https://github.com/djberg96/sys-cpu/wiki
145
+ source_code_uri: https://github.com/djberg96/sys-cpu
146
+ wiki_uri: https://github.com/djberg96/sys-cpu/wiki
147
+ post_install_message:
140
148
  rdoc_options: []
141
149
  require_paths:
142
150
  - lib
@@ -151,10 +159,15 @@ required_rubygems_version: !ruby/object:Gem::Requirement
151
159
  - !ruby/object:Gem::Version
152
160
  version: '0'
153
161
  requirements: []
154
- rubyforge_project:
155
- rubygems_version: 2.7.6
156
- signing_key:
162
+ rubygems_version: 3.1.4
163
+ signing_key:
157
164
  specification_version: 4
158
165
  summary: A Ruby interface for providing CPU information
159
166
  test_files:
160
- - 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