linux-kstat 0.2.6-universal-linux → 0.2.8-universal-linux

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d5fd1d292dd974e197bf8ac06ca71f017e35ab7b98b434b59fa813362a5656f2
4
- data.tar.gz: 025522376653a48dc026ecb97c8d709e290618c1d117b39409d3cb7aca4baa77
3
+ metadata.gz: e193e5bb9555bf697c749f74f73d5cc9d0ead99072235e027f97d9f1fed4645d
4
+ data.tar.gz: 1377fdf553ee873d8acbd40c849e55205467e443c3e41ebf697a3dcf62f9b6ab
5
5
  SHA512:
6
- metadata.gz: d8de3c37e3b6d2cf5f6ca39f1c2259446ec7a09f05e9169eff2c4c7db1eee555eeee02c87f4711bc09cde564d0b769553c8b77f914e911936120746274ab8150
7
- data.tar.gz: ca8949524b8995249dfdb0d85cc7d9a853a14c596c35c6986d08919abf49ddb8ac6e3ec662677cfef85182a8ee19355c0e804a3d6d95e4fc237d5b665a7ad55b
6
+ metadata.gz: f2c0c13badaaaeac7de87d4c60df7d653bb739705c3a7289b709dd7f99001c8c49172429693c32a1d2983a3b793cc6efbe13917056fa9b5a25ae4fb4fe79d5d0
7
+ data.tar.gz: cadfd737b379423f7f05d7a0509b7fbfd7a7d77053bda59bd732f74d50d4b3f35652bbd867653fd0a3c2b8be2ec93b6ab994fbc9ba4d7d007ddca9e1e09ef958
checksums.yaml.gz.sig CHANGED
Binary file
data/CHANGES.md CHANGED
@@ -1,3 +1,13 @@
1
+ ## 0.2.8 - 13-Jun-2025
2
+ * Minor optimization where I avoid making repeated calls.
3
+ * Add a keys method delegator.
4
+
5
+ ## 0.2.7 - 20-Apr-2024
6
+ * Rubocop updates.
7
+ * Spec updates.
8
+ * Gemspec updates.
9
+ * Documentation and other miscellaneous project updates.
10
+
1
11
  ## 0.2.6 - 10-Dec-2020
2
12
  * Specify an rspec version for the development dependency.
3
13
  * Minor updates to gemspec, Rakefile.
data/Gemfile ADDED
@@ -0,0 +1,2 @@
1
+ source 'https://rubygems.org'
2
+ gemspec
data/MANIFEST.md CHANGED
@@ -1,6 +1,7 @@
1
1
  * CHANGES.md
2
2
  * README.md
3
3
  * MANIFEST.md
4
+ * Gemfile
4
5
  * Rakefile
5
6
  * linux-kstat.gemspec
6
7
  * certs/djberg96_pub.pem
data/README.md CHANGED
@@ -1,3 +1,5 @@
1
+ [![Ruby](https://github.com/djberg96/linux-kstat/actions/workflows/ruby.yml/badge.svg)](https://github.com/djberg96/linux-kstat/actions/workflows/ruby.yml)
2
+
1
3
  ## Description
2
4
 
3
5
  A Ruby library for gathering Linux kernel statistics out of `/proc/stat`.
@@ -6,6 +8,9 @@ A Ruby library for gathering Linux kernel statistics out of `/proc/stat`.
6
8
 
7
9
  `gem install linux-kstat`
8
10
 
11
+ ## Adding the trusted cert
12
+ `gem cert --add <(curl -Ls https://raw.githubusercontent.com/djberg96/linux-kstat/main/certs/djberg96_pub.pem)`
13
+
9
14
  ### Bundler
10
15
 
11
16
  If you have trouble install this gem via bundler, please try this:
@@ -15,7 +20,7 @@ If you have trouble install this gem via bundler, please try this:
15
20
  Then attempt to install again.
16
21
 
17
22
  ## Synopsis
18
- ```
23
+ ```ruby
19
24
  # require 'linux-kstat' will also work
20
25
  require 'linux/kstat'
21
26
 
@@ -49,7 +54,7 @@ Apache-2.0
49
54
 
50
55
  ## Copyright
51
56
 
52
- (C) 2003-2020 Daniel J. Berger
57
+ (C) 2003-2024 Daniel J. Berger
53
58
  All Rights Reserved.`
54
59
 
55
60
  ## Warranty
data/Rakefile CHANGED
@@ -1,14 +1,15 @@
1
1
  require 'rake'
2
2
  require 'rake/clean'
3
3
  require 'rspec/core/rake_task'
4
+ require 'rubocop/rake_task'
4
5
 
5
- CLEAN.include('**/*.gem', '**/*.rbc')
6
+ CLEAN.include('**/*.gem', '**/*.rbc', '**/*.lock')
6
7
 
7
8
  namespace :gem do
8
9
  desc 'Build the linux-kstat gem'
9
10
  task :create => [:clean] do
10
11
  require 'rubygems/package'
11
- spec = eval(IO.read('linux-kstat.gemspec'))
12
+ spec = Gem::Specification.load('linux-kstat.gemspec')
12
13
  spec.signing_key = File.join(Dir.home, '.ssh', 'gem-private_key.pem')
13
14
  Gem::Package.build(spec)
14
15
  end
@@ -24,8 +25,15 @@ namespace :gem do
24
25
  end
25
26
  end
26
27
 
28
+ RuboCop::RakeTask.new
29
+
27
30
  RSpec::Core::RakeTask.new(:spec) do |t|
28
31
  t.pattern = ['spec/*.rb']
29
32
  end
30
33
 
34
+ # Clean up afterwards
35
+ Rake::Task[:spec].enhance do
36
+ Rake::Task[:clean].invoke
37
+ end
38
+
31
39
  task :default => :spec
data/lib/linux/kstat.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'forwardable'
2
4
 
3
5
  # The Linux module serves as a namespace only.
@@ -7,13 +9,14 @@ module Linux
7
9
  extend Forwardable
8
10
 
9
11
  # The version of the linux-kstat library
10
- VERSION = '0.2.6'.freeze
12
+ VERSION = '0.2.8'
11
13
 
12
14
  # :stopdoc:
13
15
 
14
16
  # Delegate the the [] and inspect methods to the @hash variable
15
17
  def_delegator(:@hash, :[])
16
18
  def_delegator(:@hash, :inspect)
19
+ def_delegator(:@hash, :keys)
17
20
 
18
21
  # :startdoc:
19
22
 
@@ -52,31 +55,32 @@ module Linux
52
55
  def get_proc_stat_info
53
56
  hash = {}
54
57
 
55
- IO.readlines('/proc/stat').each{ |line|
58
+ File.readlines('/proc/stat').each do |line|
56
59
  info = line.split
60
+ next if info.empty?
61
+ key = info.first.to_sym
62
+
57
63
  unless info.empty?
58
64
  if info.first =~ /^cpu/i
59
- hash[info.first.to_sym] = {
60
- :user => info[1].to_i,
61
- :nice => info[2].to_i,
62
- :system => info[3].to_i,
63
- :idle => info[4].to_i,
64
- :iowait => info[5].to_i,
65
- :irq => info[6].to_i,
66
- :softirq => info[7].to_i,
67
- :steal => info[8].to_i,
68
- :guest => info[9].to_i,
65
+ hash[key] = {
66
+ :user => info[1].to_i,
67
+ :nice => info[2].to_i,
68
+ :system => info[3].to_i,
69
+ :idle => info[4].to_i,
70
+ :iowait => info[5].to_i,
71
+ :irq => info[6].to_i,
72
+ :softirq => info[7].to_i,
73
+ :steal => info[8].to_i,
74
+ :guest => info[9].to_i,
69
75
  :guest_nice => info[10].to_i
70
76
  }
77
+ elsif info.size > 2
78
+ hash[key] = info[1..-1].map(&:to_i)
71
79
  else
72
- if info.size > 2
73
- hash[info.first.to_sym] = info[1..-1].map{ |e| e.to_i }
74
- else
75
- hash[info.first.to_sym] = info[1].to_i
76
- end
80
+ hash[key] = info[1].to_i
77
81
  end
78
82
  end
79
- }
83
+ end
80
84
 
81
85
  hash
82
86
  end
data/lib/linux-kstat.rb CHANGED
@@ -1 +1,3 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative 'linux/kstat'
data/linux-kstat.gemspec CHANGED
@@ -2,26 +2,36 @@ require 'rubygems'
2
2
 
3
3
  Gem::Specification.new do |gem|
4
4
  gem.name = 'linux-kstat'
5
- gem.version = '0.2.6'
5
+ gem.version = '0.2.8'
6
6
  gem.license = 'Apache-2.0'
7
7
  gem.author = 'Daniel J. Berger'
8
8
  gem.email = 'djberg96@gmail.com'
9
- gem.platform = Gem::Platform.new('universal-linux')
10
9
  gem.homepage = 'https://github.com/djberg96/linux-kstat'
11
10
  gem.summary = 'Ruby interface for Linux kernel stats in /proc/stat'
12
11
  gem.test_files = Dir['spec/*_spec.rb']
13
12
  gem.files = Dir['**/*'].reject{ |f| f.include?('git') }
14
13
  gem.cert_chain = ['certs/djberg96_pub.pem']
15
14
 
15
+ gem.add_development_dependency('rake')
16
+ gem.add_development_dependency('rubocop')
17
+ gem.add_development_dependency('rubocop-rspec')
16
18
  gem.add_development_dependency('rspec', '~> 3.9')
17
19
 
20
+ # Don't build this gem with Java-based implementations
21
+ if RUBY_ENGINE !~ /truffleruby|jruby/i
22
+ gem.platform = Gem::Platform.new(['universal', 'linux'])
23
+ end
24
+
18
25
  gem.metadata = {
19
- 'homepage_uri' => 'https://github.com/djberg96/linux-kstat',
20
- 'bug_tracker_uri' => 'https://github.com/djberg96/linux-kstat/issues',
21
- 'changelog_uri' => 'https://github.com/djberg96/linux-kstat/blob/master/CHANGES',
22
- 'documentation_uri' => 'https://github.com/djberg96/linux-kstat/wiki',
23
- 'source_code_uri' => 'https://github.com/djberg96/linux-kstat',
24
- 'wiki_uri' => 'https://github.com/djberg96/linux-kstat/wiki'
26
+ 'homepage_uri' => 'https://github.com/djberg96/linux-kstat',
27
+ 'bug_tracker_uri' => 'https://github.com/djberg96/linux-kstat/issues',
28
+ 'changelog_uri' => 'https://github.com/djberg96/linux-kstat/blob/master/CHANGES.md',
29
+ 'documentation_uri' => 'https://github.com/djberg96/linux-kstat/wiki',
30
+ 'source_code_uri' => 'https://github.com/djberg96/linux-kstat',
31
+ 'wiki_uri' => 'https://github.com/djberg96/linux-kstat/wiki',
32
+ 'rubygems_mfa_required' => 'true',
33
+ 'github_repo' => 'https://github.com/djberg96/linux-kstat',
34
+ 'funding_uri' => 'https://github.com/sponsors/djberg96'
25
35
  }
26
36
 
27
37
  gem.description = <<-EOF
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  #######################################################################
2
4
  # linux_kstat_spec.rb
3
5
  #
@@ -7,30 +9,36 @@ require 'rspec'
7
9
  require 'linux/kstat'
8
10
 
9
11
  describe Linux::Kstat do
10
- let(:kstat){ Linux::Kstat.new }
12
+ let(:kstat){ described_class.new }
11
13
 
12
- context "constants" do
13
- it "defines a version constant that is set to the expected value" do
14
- expect(Linux::Kstat::VERSION).to eql('0.2.6')
14
+ context 'constants' do
15
+ it 'defines a version constant that is set to the expected value' do
16
+ expect(Linux::Kstat::VERSION).to eql('0.2.8')
15
17
  expect(Linux::Kstat::VERSION).to be_frozen
16
18
  end
17
19
  end
18
20
 
19
- context "hash access" do
20
- it "allows hash style key access" do
21
- expect(subject).to respond_to(:[])
22
- expect{ subject[:cpu] }.to_not raise_error
23
- expect(subject[:cpu].keys.size).to eql(10)
21
+ context 'hash access' do
22
+ it 'allows hash style key access' do
23
+ expect(kstat).to respond_to(:[])
24
+ expect{ kstat[:cpu] }.not_to raise_error
25
+ expect(kstat[:cpu].keys.size).to be(10)
26
+ end
27
+
28
+ it 'contains the expected keys and value types' do
29
+ expect(kstat[:cpu]).to be_a(Hash)
30
+ expect(kstat[:btime]).to be_a(Numeric)
31
+ expect(kstat[:intr]).to be_a(Array)
24
32
  end
25
33
 
26
- it "contains the expected keys and value types" do
27
- expect(kstat[:cpu]).to be_kind_of(Hash)
28
- expect(kstat[:btime]).to be_kind_of(Numeric)
29
- expect(kstat[:intr]).to be_kind_of(Array)
34
+ it 'delegates the keys method' do
35
+ expect(kstat).to respond_to(:keys)
36
+ expect(kstat.keys).to be_a(Array)
37
+ expect(kstat.keys).to include(:cpu)
30
38
  end
31
39
 
32
- it "does not allow key assignment" do
33
- expect{ subject[:cpu] = 'test' }.to raise_error(NoMethodError)
40
+ it 'does not allow key assignment' do
41
+ expect{ kstat[:cpu] = 'test' }.to raise_error(NoMethodError)
34
42
  end
35
43
  end
36
44
  end
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,11 +1,10 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: linux-kstat
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.6
4
+ version: 0.2.8
5
5
  platform: universal-linux
6
6
  authors:
7
7
  - Daniel J. Berger
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain:
11
10
  - |
@@ -35,8 +34,50 @@ cert_chain:
35
34
  ORVCZpRuCPpmC8qmqxUnARDArzucjaclkxjLWvCVHeFa9UP7K3Nl9oTjJNv+7/jM
36
35
  WZs4eecIcUc4tKdHxcAJ0MO/Dkqq7hGaiHpwKY76wQ1+8xAh
37
36
  -----END CERTIFICATE-----
38
- date: 2020-12-10 00:00:00.000000000 Z
37
+ date: 2025-06-13 00:00:00.000000000 Z
39
38
  dependencies:
39
+ - !ruby/object:Gem::Dependency
40
+ name: rake
41
+ requirement: !ruby/object:Gem::Requirement
42
+ requirements:
43
+ - - ">="
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ type: :development
47
+ prerelease: false
48
+ version_requirements: !ruby/object:Gem::Requirement
49
+ requirements:
50
+ - - ">="
51
+ - !ruby/object:Gem::Version
52
+ version: '0'
53
+ - !ruby/object:Gem::Dependency
54
+ name: rubocop
55
+ requirement: !ruby/object:Gem::Requirement
56
+ requirements:
57
+ - - ">="
58
+ - !ruby/object:Gem::Version
59
+ version: '0'
60
+ type: :development
61
+ prerelease: false
62
+ version_requirements: !ruby/object:Gem::Requirement
63
+ requirements:
64
+ - - ">="
65
+ - !ruby/object:Gem::Version
66
+ version: '0'
67
+ - !ruby/object:Gem::Dependency
68
+ name: rubocop-rspec
69
+ requirement: !ruby/object:Gem::Requirement
70
+ requirements:
71
+ - - ">="
72
+ - !ruby/object:Gem::Version
73
+ version: '0'
74
+ type: :development
75
+ prerelease: false
76
+ version_requirements: !ruby/object:Gem::Requirement
77
+ requirements:
78
+ - - ">="
79
+ - !ruby/object:Gem::Version
80
+ version: '0'
40
81
  - !ruby/object:Gem::Dependency
41
82
  name: rspec
42
83
  requirement: !ruby/object:Gem::Requirement
@@ -60,6 +101,7 @@ extensions: []
60
101
  extra_rdoc_files: []
61
102
  files:
62
103
  - CHANGES.md
104
+ - Gemfile
63
105
  - LICENSE
64
106
  - MANIFEST.md
65
107
  - README.md
@@ -75,11 +117,13 @@ licenses:
75
117
  metadata:
76
118
  homepage_uri: https://github.com/djberg96/linux-kstat
77
119
  bug_tracker_uri: https://github.com/djberg96/linux-kstat/issues
78
- changelog_uri: https://github.com/djberg96/linux-kstat/blob/master/CHANGES
120
+ changelog_uri: https://github.com/djberg96/linux-kstat/blob/master/CHANGES.md
79
121
  documentation_uri: https://github.com/djberg96/linux-kstat/wiki
80
122
  source_code_uri: https://github.com/djberg96/linux-kstat
81
123
  wiki_uri: https://github.com/djberg96/linux-kstat/wiki
82
- post_install_message:
124
+ rubygems_mfa_required: 'true'
125
+ github_repo: https://github.com/djberg96/linux-kstat
126
+ funding_uri: https://github.com/sponsors/djberg96
83
127
  rdoc_options: []
84
128
  require_paths:
85
129
  - lib
@@ -94,8 +138,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
94
138
  - !ruby/object:Gem::Version
95
139
  version: '0'
96
140
  requirements: []
97
- rubygems_version: 3.0.3
98
- signing_key:
141
+ rubygems_version: 3.6.1
99
142
  specification_version: 4
100
143
  summary: Ruby interface for Linux kernel stats in /proc/stat
101
144
  test_files:
metadata.gz.sig CHANGED
Binary file