sys-memory 0.1.0 → 0.1.2

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: eb58ad679007156871e4cc8b3906546c10a634a04537b69b6021c9b83a7be18b
4
- data.tar.gz: 464f3d02c1e96915808772ac2d66652d62c956a05f03054e246af893e8316a64
3
+ metadata.gz: a0f9fcf7bd91e41d398ad63d7aa5d62bf34a14a377700cd380696b9ba7fa6a48
4
+ data.tar.gz: 95deeb86473d5350521df7149a2c5ccc6343d72cbac104e28d72e8cecfe7b850
5
5
  SHA512:
6
- metadata.gz: d5125dcc2e250ba8d4e4e513901321b397fd473f1934e5c7d3155bdda00ee5c75cd51d2e90e2cd7b7797d97279699237a3b574004f00f63a4bb2bb2788ed9f3a
7
- data.tar.gz: 472f13e448c5ce16c7750a88f93e65283b22fce862bbe2c010210fbca2be2b0465bdd7c82dae4c08457773f026da10ccd5ac3157cf4c5c334c1daeb8f77dca42
6
+ metadata.gz: 7d461e046325569a7f9c3ddd25a285ed192c28512a777f7e2f3d4e44db4e9eb2768275162b7db8b41af61fdece3e1049f75554362b43e0b85b47a9c3063d3a63
7
+ data.tar.gz: ec8e318290a6c405240269323f0f3a97a0e1c0a650041006d899f58fd4d0760871df32d02b9634b0288284d8579ef38003d706ae1290675f7a7c556a93f67639
checksums.yaml.gz.sig CHANGED
Binary file
data/CHANGES.md ADDED
@@ -0,0 +1,12 @@
1
+ ## 0.1.2 - 9-Apr-2023
2
+ * Added rubocop and rubocop-rspec as development dependencies.
3
+ * Minor updates based on rubocop suggestions.
4
+ * Added metadata.
5
+
6
+ ## 0.1.1 - 3-Nov-2021
7
+ * Make activesupport a development dependency, not a regular dependency.
8
+ Thanks go to deberle for the spot.
9
+ * Some rubocop updates.
10
+
11
+ ## 0.1.0 - 16-Aug-2021
12
+ * Initial release.
data/MANIFEST.md ADDED
@@ -0,0 +1,14 @@
1
+ * CHANGES.md
2
+ * Gemfile
3
+ * LICENSE
4
+ * MANIFEST.md
5
+ * README.md
6
+ * Rakefile
7
+ * sys-memory.gemspec
8
+ * certs/djberg96_pub.pem
9
+ * lib/sys-memory.rb
10
+ * lib/sys/version.rb
11
+ * lib/sys/linux/memory.rb
12
+ * lib/sys/osx/memory.rb
13
+ * lib/sys/windows/memory.rb
14
+ * spec/sys_memory_spec.rb
data/README.md CHANGED
@@ -1,3 +1,5 @@
1
+ [![Ruby](https://github.com/djberg96/sys-memory/actions/workflows/ruby.yml/badge.svg)](https://github.com/djberg96/sys-memory/actions/workflows/ruby.yml)
2
+
1
3
  ## Description
2
4
  A Ruby interface for getting memory information.
3
5
 
@@ -9,8 +11,11 @@ A Ruby interface for getting memory information.
9
11
  ## Installation
10
12
  `gem install sys-memory`
11
13
 
14
+ ## Adding the trusted cert
15
+ `gem cert --add <(curl -Ls https://raw.githubusercontent.com/djberg96/sys-memory/main/certs/djberg96_pub.pem)`
16
+
12
17
  ## Synopsis
13
- ```
18
+ ```ruby
14
19
  require 'sys-memory'
15
20
 
16
21
  p Sys::Memory.memory # Hash of all information
@@ -21,13 +26,10 @@ p Sys::Memory.total(extended: true) # Total memory, include swap
21
26
 
22
27
  There's also the `free`, `used` and `load` module methods.
23
28
 
24
- ## Adding the trusted cert
25
- `gem cert --add <(curl -Ls https://raw.githubusercontent.com/djberg96/sys-memory/ffi/certs/djberg96_pub.pem)`
26
-
27
29
  ## Notes
28
30
  I realize there are some philosophical differences about what constitutes
29
- "available memory". I've tried to accomodate both of the approaches to it
30
- that I saw debated online. In short, you can choose to include swap memory
31
+ "available memory". I've tried to accomodate both of the common approaches to
32
+ it that I saw debated online. In short, you can choose to include swap memory
31
33
  as part of memory calculations or not as you see fit via an optional argument.
32
34
 
33
35
  You can also just use `Sys::Memory.memory` and collate the various hash data
@@ -36,13 +38,13 @@ pieces as you see fit.
36
38
  ## Known Bugs
37
39
  None that I'm aware of. Please report bugs on the project page at:
38
40
 
39
- https://github.com/djberg96/sys-cpu
41
+ https://github.com/djberg96/sys-memory
40
42
 
41
43
  ## License
42
44
  Apache-2.0
43
45
 
44
46
  ## Copyright
45
- (C) 2021 Daniel J. Berger, All Rights Reserved
47
+ (C) 2021-2023 Daniel J. Berger, All Rights Reserved
46
48
 
47
49
  ## Warranty
48
50
  This package is provided "as is" and without any express or
data/Rakefile CHANGED
@@ -1,6 +1,7 @@
1
1
  require 'rake'
2
2
  require 'rake/clean'
3
3
  require 'rspec/core/rake_task'
4
+ require 'rubocop/rake_task'
4
5
 
5
6
  CLEAN.include('**/*.gem', '**/*.rbc', '**/*.rbx', '**/*.lock')
6
7
 
@@ -22,4 +23,6 @@ namespace 'gem' do
22
23
  end
23
24
  end
24
25
 
26
+ RuboCop::RakeTask.new
27
+
25
28
  task :default => :spec
@@ -1,6 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ # The Sys module serves as a namespace only.
3
4
  module Sys
5
+ # The Memory module provides various functions that return information
6
+ # regarding the memory on your system.
4
7
  module Memory
5
8
  MEMORY_FILE = '/proc/meminfo'
6
9
  MEMINFO_REGEX = /(.*)?:\s+?(\d+)/.freeze
@@ -15,7 +18,7 @@ module Sys
15
18
  def memory
16
19
  hash = {}
17
20
 
18
- IO.foreach(MEMORY_FILE) do |line|
21
+ File.foreach(MEMORY_FILE) do |line|
19
22
  key, value = MEMINFO_REGEX.match(line.chomp).captures
20
23
  hash[key] = value.to_i
21
24
  end
@@ -59,5 +62,5 @@ module Sys
59
62
  end
60
63
 
61
64
  module_function :memory, :total, :free, :used, :load
62
- end
63
- end
65
+ end # Memory
66
+ end # Sys
data/lib/sys/version.rb CHANGED
@@ -3,6 +3,6 @@
3
3
  module Sys
4
4
  module Memory
5
5
  # The version of the sys-memory library.
6
- VERSION = '0.1.0'
6
+ VERSION = '0.1.2'
7
7
  end
8
8
  end
@@ -1,13 +1,14 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ # The Sys module serves as a namespace only.
3
4
  module Sys
5
+ # The Memory module provides various functions that return information
6
+ # regarding the memory on your system.
4
7
  module Memory
5
8
  require 'ffi'
6
9
  extend FFI::Library
7
10
  ffi_lib 'kernel32'
8
11
 
9
- private
10
-
11
12
  typedef :uint32, :dword
12
13
  typedef :uint64, :dwordlong
13
14
 
@@ -25,7 +26,10 @@ module Sys
25
26
  )
26
27
  end
27
28
 
29
+ private_constant :MemoryStatusEx
30
+
28
31
  attach_function :GlobalMemoryStatusEx, [MemoryStatusEx], :bool
32
+ private_class_method :GlobalMemoryStatusEx
29
33
 
30
34
  ffi_lib 'psapi'
31
35
 
@@ -48,9 +52,10 @@ module Sys
48
52
  )
49
53
  end
50
54
 
51
- attach_function :GetPerformanceInfo, [PerformanceInformation, :dword], :bool
55
+ private_constant :PerformanceInformation
52
56
 
53
- public
57
+ attach_function :GetPerformanceInfo, [PerformanceInformation, :dword], :bool
58
+ private_class_method :GetPerformanceInfo
54
59
 
55
60
  # Obtain detailed memory information about your host in the form of a hash.
56
61
  # Note that the exact nature of this hash is largely dependent on your
@@ -121,10 +126,10 @@ module Sys
121
126
  # A number between 0 and 100 that specifies the approximate percentage of
122
127
  # physical memory that is in use.
123
128
  #
124
- # If the +extended+ option is set to true then swap memory is included in
125
- # the calculation.
129
+ # On MS Windows the +extended+ option is ignored, but present for interface
130
+ # compatibility with other platforms.
126
131
  #
127
- def load(extended: false)
132
+ def load(_extended: false)
128
133
  memory['MemoryLoad']
129
134
  end
130
135
 
@@ -1,10 +1,12 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'active_support/core_ext/numeric/bytes'
2
4
  require 'sys-memory'
3
5
 
4
6
  RSpec.describe Sys::Memory do
5
7
  context 'Sys::Memory::VERSION' do
6
8
  example 'the version constant is set to the expected value' do
7
- expect(described_class::VERSION).to eq('0.1.0')
9
+ expect(described_class::VERSION).to eq('0.1.2')
8
10
  expect(described_class::VERSION).to be_frozen
9
11
  end
10
12
  end
data/sys-memory.gemspec CHANGED
@@ -2,7 +2,7 @@ require 'rubygems'
2
2
 
3
3
  Gem::Specification.new do |spec|
4
4
  spec.name = 'sys-memory'
5
- spec.version = '0.1.0'
5
+ spec.version = '0.1.2'
6
6
  spec.author = 'Daniel J. Berger'
7
7
  spec.email = 'djberg96@gmail.com'
8
8
  spec.license = 'Apache-2.0'
@@ -12,20 +12,22 @@ 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
- spec.add_dependency('ffi', "~> 1.1")
18
- spec.add_dependency('activesupport', "~> 6.0")
19
- spec.add_development_dependency('rspec', "~> 3.9")
20
- spec.add_development_dependency('rake', "~> 13.0")
15
+ spec.add_dependency('ffi', '~> 1.1')
16
+ spec.add_development_dependency('activesupport', '~> 6.0')
17
+ spec.add_development_dependency('rspec', '~> 3.9')
18
+ spec.add_development_dependency('rake', '~> 13.0')
19
+ spec.add_development_dependency('rubocop')
20
+ spec.add_development_dependency('rubocop-rspec')
21
21
 
22
22
  spec.metadata = {
23
- 'homepage_uri' => 'https://github.com/djberg96/sys-memory',
24
- 'bug_tracker_uri' => 'https://github.com/djberg96/sys-memory/issues',
25
- 'changelog_uri' => 'https://github.com/djberg96/sys-memory/blob/main/CHANGES.md',
26
- 'documentation_uri' => 'https://github.com/djberg96/sys-memory/wiki',
27
- 'source_code_uri' => 'https://github.com/djberg96/sys-memory',
28
- 'wiki_uri' => 'https://github.com/djberg96/sys-memory/wiki'
23
+ 'homepage_uri' => 'https://github.com/djberg96/sys-memory',
24
+ 'bug_tracker_uri' => 'https://github.com/djberg96/sys-memory/issues',
25
+ 'changelog_uri' => 'https://github.com/djberg96/sys-memory/blob/main/CHANGES.md',
26
+ 'documentation_uri' => 'https://github.com/djberg96/sys-memory/wiki',
27
+ 'source_code_uri' => 'https://github.com/djberg96/sys-memory',
28
+ 'wiki_uri' => 'https://github.com/djberg96/sys-memory/wiki',
29
+ 'rubygems_mfa_required' => 'true',
30
+ 'github_repo' => 'https://github.com/djberg96/sys-memory'
29
31
  }
30
32
 
31
33
  spec.description = <<-EOF
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,11 +1,11 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sys-memory
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.2
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,7 +35,7 @@ cert_chain:
35
35
  ORVCZpRuCPpmC8qmqxUnARDArzucjaclkxjLWvCVHeFa9UP7K3Nl9oTjJNv+7/jM
36
36
  WZs4eecIcUc4tKdHxcAJ0MO/Dkqq7hGaiHpwKY76wQ1+8xAh
37
37
  -----END CERTIFICATE-----
38
- date: 2021-08-16 00:00:00.000000000 Z
38
+ date: 2023-04-10 00:00:00.000000000 Z
39
39
  dependencies:
40
40
  - !ruby/object:Gem::Dependency
41
41
  name: ffi
@@ -58,7 +58,7 @@ dependencies:
58
58
  - - "~>"
59
59
  - !ruby/object:Gem::Version
60
60
  version: '6.0'
61
- type: :runtime
61
+ type: :development
62
62
  prerelease: false
63
63
  version_requirements: !ruby/object:Gem::Requirement
64
64
  requirements:
@@ -93,6 +93,34 @@ dependencies:
93
93
  - - "~>"
94
94
  - !ruby/object:Gem::Version
95
95
  version: '13.0'
96
+ - !ruby/object:Gem::Dependency
97
+ name: rubocop
98
+ requirement: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - ">="
101
+ - !ruby/object:Gem::Version
102
+ version: '0'
103
+ type: :development
104
+ prerelease: false
105
+ version_requirements: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - ">="
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ - !ruby/object:Gem::Dependency
111
+ name: rubocop-rspec
112
+ requirement: !ruby/object:Gem::Requirement
113
+ requirements:
114
+ - - ">="
115
+ - !ruby/object:Gem::Version
116
+ version: '0'
117
+ type: :development
118
+ prerelease: false
119
+ version_requirements: !ruby/object:Gem::Requirement
120
+ requirements:
121
+ - - ">="
122
+ - !ruby/object:Gem::Version
123
+ version: '0'
96
124
  description: |2
97
125
  The sys-memory library provides an interface for gathering information
98
126
  about your system's memory. Information includes total physical memory,
@@ -102,8 +130,10 @@ executables: []
102
130
  extensions: []
103
131
  extra_rdoc_files: []
104
132
  files:
133
+ - CHANGES.md
105
134
  - Gemfile
106
135
  - LICENSE
136
+ - MANIFEST.md
107
137
  - README.md
108
138
  - Rakefile
109
139
  - certs/djberg96_pub.pem
@@ -125,7 +155,9 @@ metadata:
125
155
  documentation_uri: https://github.com/djberg96/sys-memory/wiki
126
156
  source_code_uri: https://github.com/djberg96/sys-memory
127
157
  wiki_uri: https://github.com/djberg96/sys-memory/wiki
128
- post_install_message:
158
+ rubygems_mfa_required: 'true'
159
+ github_repo: https://github.com/djberg96/sys-memory
160
+ post_install_message:
129
161
  rdoc_options: []
130
162
  require_paths:
131
163
  - lib
@@ -140,8 +172,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
140
172
  - !ruby/object:Gem::Version
141
173
  version: '0'
142
174
  requirements: []
143
- rubygems_version: 3.2.25
144
- signing_key:
175
+ rubygems_version: 3.3.26
176
+ signing_key:
145
177
  specification_version: 4
146
178
  summary: A Ruby interface for providing memory information
147
179
  test_files:
metadata.gz.sig CHANGED
Binary file