sys-memory 0.1.0 → 0.1.1

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: f6014e85718322e00ceadeef11991f2c92f131f0636d492d3cdb592a9beb284e
4
+ data.tar.gz: ab327c8145c1875e85152addbd497c01ca7a85838465410cb4cb2cdbd77043cb
5
5
  SHA512:
6
- metadata.gz: d5125dcc2e250ba8d4e4e513901321b397fd473f1934e5c7d3155bdda00ee5c75cd51d2e90e2cd7b7797d97279699237a3b574004f00f63a4bb2bb2788ed9f3a
7
- data.tar.gz: 472f13e448c5ce16c7750a88f93e65283b22fce862bbe2c010210fbca2be2b0465bdd7c82dae4c08457773f026da10ccd5ac3157cf4c5c334c1daeb8f77dca42
6
+ metadata.gz: dbc032f49449629c05cb0f8e8370b70f429c96a4e7dcbc082bfc18f16279fbedc8ef14766e98d3005ef49fc5694e6a0897b9741eac95e5dc5baeb934b1f1df41
7
+ data.tar.gz: f462319e9dec783d20c2f084b4c41e936c12f71948352582fe73e7de3fa26f69a639e18b850eab3dfdc0e35a30f1ba7d4a01b11bb0965b0c22118bf972df8899
checksums.yaml.gz.sig CHANGED
Binary file
data/CHANGES.md ADDED
@@ -0,0 +1,7 @@
1
+ ## 0.1.1 - 3-Nov-2021
2
+ * Make activesupport a development dependency, not a regular dependency.
3
+ Thanks go to deberle for the spot.
4
+ * Some rubocop updates.
5
+
6
+ ## 0.1.0 - 16-Aug-2021
7
+ * Initial release.
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,9 +26,6 @@ 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
31
  "available memory". I've tried to accomodate both of the approaches to it
@@ -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.1'
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.1')
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.1'
6
6
  spec.author = 'Daniel J. Berger'
7
7
  spec.email = 'djberg96@gmail.com'
8
8
  spec.license = 'Apache-2.0'
@@ -12,10 +12,8 @@ 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
  spec.add_dependency('ffi', "~> 1.1")
18
- spec.add_dependency('activesupport', "~> 6.0")
16
+ spec.add_development_dependency('activesupport', "~> 6.0")
19
17
  spec.add_development_dependency('rspec', "~> 3.9")
20
18
  spec.add_development_dependency('rake', "~> 13.0")
21
19
 
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.1
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: 2021-12-03 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:
@@ -102,6 +102,7 @@ executables: []
102
102
  extensions: []
103
103
  extra_rdoc_files: []
104
104
  files:
105
+ - CHANGES.md
105
106
  - Gemfile
106
107
  - LICENSE
107
108
  - README.md
@@ -125,7 +126,7 @@ metadata:
125
126
  documentation_uri: https://github.com/djberg96/sys-memory/wiki
126
127
  source_code_uri: https://github.com/djberg96/sys-memory
127
128
  wiki_uri: https://github.com/djberg96/sys-memory/wiki
128
- post_install_message:
129
+ post_install_message:
129
130
  rdoc_options: []
130
131
  require_paths:
131
132
  - lib
@@ -140,8 +141,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
140
141
  - !ruby/object:Gem::Version
141
142
  version: '0'
142
143
  requirements: []
143
- rubygems_version: 3.2.25
144
- signing_key:
144
+ rubygems_version: 3.2.32
145
+ signing_key:
145
146
  specification_version: 4
146
147
  summary: A Ruby interface for providing memory information
147
148
  test_files:
metadata.gz.sig CHANGED
Binary file