total 0.4.1 → 0.4.2

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: 1544c84099426fc46d27ade2e50eaeec04fc7a77c93497bb1860d9f08c129c1c
4
- data.tar.gz: a6a0e21d9f9bba86d4ba04cbb900253c39fa84c06b90393b7c3c7b91aa4a5115
3
+ metadata.gz: a09c73bd6eb08ba1ff1b9f87907d768cb5aca567b0f2c8fe47f45cbdff31cbce
4
+ data.tar.gz: 1aa129e661d5ad4b8719b80f3d328704e572e3846b9a505fe408a68d8b1799a9
5
5
  SHA512:
6
- metadata.gz: 00d630bf7f7b4305a0e8040a69e001829e621306baac1e7850cdc31f0fb5ce17702b7448d7b56c2848c9c460427d9e58218d24bfa645ff51ac02231c1d34e780
7
- data.tar.gz: 0f11604a32386733c6966c042a847b1a0e6d963b3e3a816df58b6021a0949bc26046997998263bf991dde2feac89918fb9f77c78ac0c3246ff22ea2bc65ca051
6
+ metadata.gz: 0b4cc5299be631e3c352a49acbfd0474d23083635fc4eee45a7b787b811e7a158ac75916cadb31fbb84af274c55a7a65fb466d6d2f046a38e60afaeead577d7e
7
+ data.tar.gz: 4b97727372ff53336e7a7d7ab553112aeed7d2798b78b2eed5dcfec0b313f3b409825bc172f29f04a568f1b0a65b001bdc71d4ad32b9649635e838d286aedf31
data/Gemfile CHANGED
@@ -1,24 +1,19 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright (c) 2018-2023 Yegor Bugayenko
4
- #
5
- # Permission is hereby granted, free of charge, to any person obtaining a copy
6
- # of this software and associated documentation files (the 'Software'), to deal
7
- # in the Software without restriction, including without limitation the rights
8
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- # copies of the Software, and to permit persons to whom the Software is
10
- # furnished to do so, subject to the following conditions:
11
- #
12
- # The above copyright notice and this permission notice shall be included in all
13
- # copies or substantial portions of the Software.
14
- #
15
- # THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- # SOFTWARE.
3
+ # SPDX-FileCopyrightText: Copyright (c) 2018-2025 Yegor Bugayenko
4
+ # SPDX-License-Identifier: MIT
22
5
 
23
6
  source 'https://rubygems.org'
24
7
  gemspec
8
+
9
+ gem 'codecov', '~>0.6.0', require: false
10
+ gem 'minitest', '~>5.18.0', require: false
11
+ gem 'mutex_m', '~>0.3', require: false
12
+ gem 'ostruct', '~>0.6', require: false
13
+ gem 'rake', '~>13.0.6', require: false
14
+ gem 'rdoc', '~>6.5.0', require: false
15
+ gem 'rubocop', '~>1.75.0', require: false
16
+ gem 'rubocop-minitest', '~>0.38', require: false
17
+ gem 'rubocop-performance', '~>1.25', require: false
18
+ gem 'rubocop-rake', '~>0.7', require: false
19
+ gem 'rubocop-rspec', '~>3.7.0', require: false
data/Gemfile.lock ADDED
@@ -0,0 +1,96 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ total (0.0.0)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ ast (2.4.3)
10
+ codecov (0.6.0)
11
+ simplecov (>= 0.15, < 0.22)
12
+ date (3.5.0)
13
+ docile (1.4.1)
14
+ json (2.16.0)
15
+ language_server-protocol (3.17.0.5)
16
+ lint_roller (1.1.0)
17
+ minitest (5.18.1)
18
+ mutex_m (0.3.0)
19
+ ostruct (0.6.3)
20
+ parallel (1.27.0)
21
+ parser (3.3.10.0)
22
+ ast (~> 2.4.1)
23
+ racc
24
+ prism (1.6.0)
25
+ psych (5.2.6)
26
+ date
27
+ stringio
28
+ racc (1.8.1)
29
+ rainbow (3.1.1)
30
+ rake (13.0.6)
31
+ rdoc (6.5.1.1)
32
+ psych (>= 4.0.0)
33
+ regexp_parser (2.11.3)
34
+ rubocop (1.75.8)
35
+ json (~> 2.3)
36
+ language_server-protocol (~> 3.17.0.2)
37
+ lint_roller (~> 1.1.0)
38
+ parallel (~> 1.10)
39
+ parser (>= 3.3.0.2)
40
+ rainbow (>= 2.2.2, < 4.0)
41
+ regexp_parser (>= 2.9.3, < 3.0)
42
+ rubocop-ast (>= 1.44.0, < 2.0)
43
+ ruby-progressbar (~> 1.7)
44
+ unicode-display_width (>= 2.4.0, < 4.0)
45
+ rubocop-ast (1.48.0)
46
+ parser (>= 3.3.7.2)
47
+ prism (~> 1.4)
48
+ rubocop-minitest (0.38.2)
49
+ lint_roller (~> 1.1)
50
+ rubocop (>= 1.75.0, < 2.0)
51
+ rubocop-ast (>= 1.38.0, < 2.0)
52
+ rubocop-performance (1.26.1)
53
+ lint_roller (~> 1.1)
54
+ rubocop (>= 1.75.0, < 2.0)
55
+ rubocop-ast (>= 1.47.1, < 2.0)
56
+ rubocop-rake (0.7.1)
57
+ lint_roller (~> 1.1)
58
+ rubocop (>= 1.72.1)
59
+ rubocop-rspec (3.7.0)
60
+ lint_roller (~> 1.1)
61
+ rubocop (~> 1.72, >= 1.72.1)
62
+ ruby-progressbar (1.13.0)
63
+ simplecov (0.21.2)
64
+ docile (~> 1.1)
65
+ simplecov-html (~> 0.11)
66
+ simplecov_json_formatter (~> 0.1)
67
+ simplecov-html (0.13.2)
68
+ simplecov_json_formatter (0.1.4)
69
+ stringio (3.1.8)
70
+ unicode-display_width (3.2.0)
71
+ unicode-emoji (~> 4.1)
72
+ unicode-emoji (4.1.0)
73
+
74
+ PLATFORMS
75
+ arm64-darwin-22
76
+ arm64-darwin-23
77
+ arm64-darwin-24
78
+ x64-mingw-ucrt
79
+ x86_64-linux
80
+
81
+ DEPENDENCIES
82
+ codecov (~> 0.6.0)
83
+ minitest (~> 5.18.0)
84
+ mutex_m (~> 0.3)
85
+ ostruct (~> 0.6)
86
+ rake (~> 13.0.6)
87
+ rdoc (~> 6.5.0)
88
+ rubocop (~> 1.75.0)
89
+ rubocop-minitest (~> 0.38)
90
+ rubocop-performance (~> 1.25)
91
+ rubocop-rake (~> 0.7)
92
+ rubocop-rspec (~> 3.7.0)
93
+ total!
94
+
95
+ BUNDLED WITH
96
+ 2.5.16
data/LICENSE.txt CHANGED
@@ -1,6 +1,6 @@
1
1
  (The MIT License)
2
2
 
3
- Copyright (c) 2019-2022 Yegor Bugayenko
3
+ Copyright (c) 2018-2025 Yegor Bugayenko
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the 'Software'), to deal
data/LICENSES/MIT.txt ADDED
@@ -0,0 +1,21 @@
1
+ (The MIT License)
2
+
3
+ Copyright (c) 2018-2025 Yegor Bugayenko
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the 'Software'), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md CHANGED
@@ -1,24 +1,23 @@
1
- <img src="/logo.svg" width="64px"/>
1
+ # Get Total Memory Size
2
2
 
3
- [![Managed by Zerocracy](https://www.0crat.com/badge/C3RFVLU72.svg)](https://www.0crat.com/p/C3RFVLU72)
4
3
  [![EO principles respected here](https://www.elegantobjects.org/badge.svg)](https://www.elegantobjects.org)
5
- [![DevOps By Rultor.com](http://www.rultor.com/b/yegor256/total)](http://www.rultor.com/p/yegor256/total)
4
+ [![DevOps By Rultor.com](https://www.rultor.com/b/yegor256/total)](https://www.rultor.com/p/yegor256/total)
6
5
  [![We recommend RubyMine](https://www.elegantobjects.org/rubymine.svg)](https://www.jetbrains.com/ruby/)
7
6
 
8
7
  [![rake](https://github.com/yegor256/total/actions/workflows/rake.yml/badge.svg)](https://github.com/yegor256/total/actions/workflows/rake.yml)
9
- [![Gem Version](https://badge.fury.io/rb/total.svg)](http://badge.fury.io/rb/total)
8
+ [![Gem Version](https://badge.fury.io/rb/total.svg)](https://badge.fury.io/rb/total)
10
9
  [![Maintainability](https://api.codeclimate.com/v1/badges/6e08ce63e597f241ccc7/maintainability)](https://codeclimate.com/github/yegor256/total/maintainability)
11
- [![Yard Docs](http://img.shields.io/badge/yard-docs-blue.svg)](http://rubydoc.info/github/yegor256/total/master/frames)
10
+ [![Yard Docs](https://img.shields.io/badge/yard-docs-blue.svg)](https://rubydoc.info/github/yegor256/total/master/frames)
12
11
  [![License](https://img.shields.io/badge/license-MIT-green.svg)](https://github.com/yegor256/total/sibit/master/LICENSE.txt)
13
12
  [![Test Coverage](https://img.shields.io/codecov/c/github/yegor256/total.svg)](https://codecov.io/github/yegor256/total?branch=master)
14
13
  [![Hits-of-Code](https://hitsofcode.com/github/yegor256/total)](https://hitsofcode.com/view/github/yegor256/total)
15
14
 
16
- Total is a Ruby gem to detect the total amount of memory in the system.
15
+ This Ruby gem helps you detect the total amount of memory in the system.
17
16
 
18
17
  First, install it:
19
18
 
20
19
  ```bash
21
- $ gem install total
20
+ gem install total
22
21
  ```
23
22
 
24
23
  Then, use it like this:
@@ -30,13 +29,14 @@ puts Total::Mem.new.bytes
30
29
 
31
30
  The following platforms are supported:
32
31
 
33
- * MacOSX
34
- * Linux
35
- * FreeBSD
36
- * <del>Windows</del> ([help wanted](https://github.com/yegor256/total/issues/3))
32
+ * MacOSX
33
+ * Linux
34
+ * FreeBSD
35
+ * Windows (including MSYS2/MinGW, MSVC, and Cygwin environments)
37
36
 
38
- If the platform is not recognized or is not supported, `Total::CantDetect` exception
39
- will be raised. You should catch it and proceed accordingly, for example:
37
+ If the platform is not recognized or is not supported,
38
+ the `Total::CantDetect` exception is raised.
39
+ You catch it and proceed accordingly, for example:
40
40
 
41
41
  ```ruby
42
42
  def total_mb
@@ -46,21 +46,23 @@ rescue Total::CantDetect
46
46
  end
47
47
  ```
48
48
 
49
- This code will return the actual memory size in Mb, if it can be detected,
50
- or 512 otherwise.
49
+ This code returns the actual memory size in Mb,
50
+ if it can be detected, or 512 otherwise.
51
51
 
52
52
  That's it.
53
53
 
54
54
  ## How to contribute
55
55
 
56
- Read [these guidelines](https://www.yegor256.com/2014/04/15/github-guidelines.html).
57
- Make sure you build is green before you contribute
58
- your pull request. You will need to have [Ruby](https://www.ruby-lang.org/en/) 2.3+ and
56
+ Read these [guidelines].
57
+ Make sure your build is green before you contribute your pull request.
58
+ You need to have [Ruby](https://www.ruby-lang.org/en/) 2.3+ and
59
59
  [Bundler](https://bundler.io/) installed. Then:
60
60
 
61
- ```
62
- $ bundle update
63
- $ bundle exec rake
61
+ ```bash
62
+ bundle update
63
+ bundle exec rake
64
64
  ```
65
65
 
66
66
  If it's clean and you don't see any error messages, submit your pull request.
67
+
68
+ [guidelines]: https://www.yegor256.com/2014/04/15/github-guidelines.html
data/REUSE.toml ADDED
@@ -0,0 +1,36 @@
1
+ # SPDX-FileCopyrightText: Copyright (c) 2025 Yegor Bugayenko
2
+ # SPDX-License-Identifier: MIT
3
+
4
+ version = 1
5
+ [[annotations]]
6
+ path = [
7
+ ".DS_Store",
8
+ ".gitattributes",
9
+ ".gitignore",
10
+ ".pdd",
11
+ "**.json",
12
+ "**.md",
13
+ "**.png",
14
+ "**.svg",
15
+ "**.txt",
16
+ "**/.DS_Store",
17
+ "**/.gitignore",
18
+ "**/.pdd",
19
+ "**/*.csv",
20
+ "**/*.jpg",
21
+ "**/*.json",
22
+ "**/*.md",
23
+ "**/*.pdf",
24
+ "**/*.png",
25
+ "**/*.svg",
26
+ "**/*.txt",
27
+ "**/*.vm",
28
+ "**/CNAME",
29
+ "**/Gemfile.lock",
30
+ "Gemfile.lock",
31
+ "README.md",
32
+ "renovate.json",
33
+ ]
34
+ precedence = "override"
35
+ SPDX-FileCopyrightText = "Copyright (c) 2025 Yegor Bugayenko"
36
+ SPDX-License-Identifier = "MIT"
data/Rakefile CHANGED
@@ -1,24 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright (c) 2018-2023 Yegor Bugayenko
4
- #
5
- # Permission is hereby granted, free of charge, to any person obtaining a copy
6
- # of this software and associated documentation files (the 'Software'), to deal
7
- # in the Software without restriction, including without limitation the rights
8
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- # copies of the Software, and to permit persons to whom the Software is
10
- # furnished to do so, subject to the following conditions:
11
- #
12
- # The above copyright notice and this permission notice shall be included in all
13
- # copies or substantial portions of the Software.
14
- #
15
- # THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- # SOFTWARE.
3
+ # SPDX-FileCopyrightText: Copyright (c) 2018-2025 Yegor Bugayenko
4
+ # SPDX-License-Identifier: MIT
22
5
 
23
6
  require 'rubygems'
24
7
  require 'rake'
@@ -57,11 +40,3 @@ RuboCop::RakeTask.new(:rubocop) do |task|
57
40
  task.fail_on_error = true
58
41
  task.requires << 'rubocop-rspec'
59
42
  end
60
-
61
- task :copyright do
62
- sh "grep -q -r '2018-#{Date.today.strftime('%Y')}' \
63
- --include '*.rb' \
64
- --include '*.txt' \
65
- --include 'Rakefile' \
66
- ."
67
- end
data/lib/total/freebsd.rb CHANGED
@@ -1,31 +1,12 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # (The MIT License)
4
- #
5
- # Copyright (c) 2018-2023 Yegor Bugayenko
6
- #
7
- # Permission is hereby granted, free of charge, to any person obtaining a copy
8
- # of this software and associated documentation files (the 'Software'), to deal
9
- # in the Software without restriction, including without limitation the rights
10
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
- # copies of the Software, and to permit persons to whom the Software is
12
- # furnished to do so, subject to the following conditions:
13
- #
14
- # The above copyright notice and this permission notice shall be included in all
15
- # copies or substantial portions of the Software.
16
- #
17
- # THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23
- # SOFTWARE.
3
+ # SPDX-FileCopyrightText: Copyright (c) 2018-2025 Yegor Bugayenko
4
+ # SPDX-License-Identifier: MIT
24
5
 
25
6
  # FreeBSD specific.
26
7
  #
27
8
  # Author:: Yegor Bugayenko (yegor256@gmail.com)
28
- # Copyright:: Copyright (c) 2018-2023 Yegor Bugayenko
9
+ # Copyright:: Copyright (c) 2018-2025 Yegor Bugayenko
29
10
  # License:: MIT
30
11
  module Total
31
12
  # FreeBSD specifics.
data/lib/total/linux.rb CHANGED
@@ -1,31 +1,12 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # (The MIT License)
4
- #
5
- # Copyright (c) 2018-2023 Yegor Bugayenko
6
- #
7
- # Permission is hereby granted, free of charge, to any person obtaining a copy
8
- # of this software and associated documentation files (the 'Software'), to deal
9
- # in the Software without restriction, including without limitation the rights
10
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
- # copies of the Software, and to permit persons to whom the Software is
12
- # furnished to do so, subject to the following conditions:
13
- #
14
- # The above copyright notice and this permission notice shall be included in all
15
- # copies or substantial portions of the Software.
16
- #
17
- # THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23
- # SOFTWARE.
3
+ # SPDX-FileCopyrightText: Copyright (c) 2018-2025 Yegor Bugayenko
4
+ # SPDX-License-Identifier: MIT
24
5
 
25
6
  # Linux specific.
26
7
  #
27
8
  # Author:: Yegor Bugayenko (yegor256@gmail.com)
28
- # Copyright:: Copyright (c) 2018-2023 Yegor Bugayenko
9
+ # Copyright:: Copyright (c) 2018-2025 Yegor Bugayenko
29
10
  # License:: MIT
30
11
  module Total
31
12
  # Linux specifics.
data/lib/total/osx.rb CHANGED
@@ -1,31 +1,12 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # (The MIT License)
4
- #
5
- # Copyright (c) 2018-2023 Yegor Bugayenko
6
- #
7
- # Permission is hereby granted, free of charge, to any person obtaining a copy
8
- # of this software and associated documentation files (the 'Software'), to deal
9
- # in the Software without restriction, including without limitation the rights
10
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
- # copies of the Software, and to permit persons to whom the Software is
12
- # furnished to do so, subject to the following conditions:
13
- #
14
- # The above copyright notice and this permission notice shall be included in all
15
- # copies or substantial portions of the Software.
16
- #
17
- # THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23
- # SOFTWARE.
3
+ # SPDX-FileCopyrightText: Copyright (c) 2018-2025 Yegor Bugayenko
4
+ # SPDX-License-Identifier: MIT
24
5
 
25
6
  # OSX specific.
26
7
  #
27
8
  # Author:: Yegor Bugayenko (yegor256@gmail.com)
28
- # Copyright:: Copyright (c) 2018-2023 Yegor Bugayenko
9
+ # Copyright:: Copyright (c) 2018-2025 Yegor Bugayenko
29
10
  # License:: MIT
30
11
  module Total
31
12
  # OSX specifics.
data/lib/total/version.rb CHANGED
@@ -1,33 +1,14 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # (The MIT License)
4
- #
5
- # Copyright (c) 2018-2023 Yegor Bugayenko
6
- #
7
- # Permission is hereby granted, free of charge, to any person obtaining a copy
8
- # of this software and associated documentation files (the 'Software'), to deal
9
- # in the Software without restriction, including without limitation the rights
10
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
- # copies of the Software, and to permit persons to whom the Software is
12
- # furnished to do so, subject to the following conditions:
13
- #
14
- # The above copyright notice and this permission notice shall be included in all
15
- # copies or substantial portions of the Software.
16
- #
17
- # THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23
- # SOFTWARE.
3
+ # SPDX-FileCopyrightText: Copyright (c) 2018-2025 Yegor Bugayenko
4
+ # SPDX-License-Identifier: MIT
24
5
 
25
6
  # Version of it.
26
7
  #
27
8
  # Author:: Yegor Bugayenko (yegor256@gmail.com)
28
- # Copyright:: Copyright (c) 2018-2023 Yegor Bugayenko
9
+ # Copyright:: Copyright (c) 2018-2025 Yegor Bugayenko
29
10
  # License:: MIT
30
11
  module Total
31
12
  # Current version of the library.
32
- VERSION = '0.4.1'
13
+ VERSION = '0.4.2'
33
14
  end
@@ -0,0 +1,101 @@
1
+ # frozen_string_literal: true
2
+
3
+ # SPDX-FileCopyrightText: Copyright (c) 2018-2025 Yegor Bugayenko
4
+ # SPDX-License-Identifier: MIT
5
+
6
+ # Windows specific.
7
+ #
8
+ # Author:: Yegor Bugayenko (yegor256@gmail.com)
9
+ # Copyright:: Copyright (c) 2018-2025 Yegor Bugayenko
10
+ # License:: MIT
11
+ module Total
12
+ # Windows specifics.
13
+ class Windows
14
+ # Detects the total physical memory available on Windows systems.
15
+ #
16
+ # This method attempts to determine the system's total RAM using multiple
17
+ # detection strategies to ensure compatibility across different Windows
18
+ # environments and configurations.
19
+ #
20
+ # Detection methods (tried in order):
21
+ # 1. **wmic**: Windows Management Instrumentation Command-line tool
22
+ # - Most reliable on traditional Windows installations
23
+ # - Uses: `wmic computersystem get TotalPhysicalMemory /value`
24
+ # 2. **PowerShell**: Windows PowerShell with WMI queries
25
+ # - Available on Windows 7+ and MSYS2 environments
26
+ # - Uses: `Get-WmiObject -Class Win32_ComputerSystem`
27
+ # 3. **systeminfo**: Built-in Windows system information utility
28
+ # - Fallback method for restricted environments
29
+ # - Parses output to extract memory information in MB/GB format
30
+ #
31
+ # @return [Integer] the total amount of physical memory in bytes
32
+ # @raise [CantDetect] if all detection methods fail or are unavailable
33
+ #
34
+ # @example Typical usage
35
+ # windows = Total::Windows.new
36
+ # total_memory = windows.memory
37
+ # puts "Total RAM: #{total_memory / (1024**3)} GB"
38
+ #
39
+ # @note This method requires at least one of the Windows utilities
40
+ # (wmic, powershell.exe, or systeminfo) to be available in the system PATH
41
+ def memory
42
+ try_wmic || try_powershell || try_systeminfo ||
43
+ raise(CantDetect, 'Can\'t detect memory size via wmic, PowerShell, or systeminfo')
44
+ end
45
+
46
+ private
47
+
48
+ # Try to get memory using wmic command
49
+ # @return [Integer, nil] memory in bytes or nil if failed
50
+ def try_wmic
51
+ output = `wmic computersystem get TotalPhysicalMemory /value 2>NUL`.strip
52
+ output.split("\n").each do |line|
53
+ next unless line.start_with?('TotalPhysicalMemory=')
54
+ memory_bytes = line.split('=')[1].to_i
55
+ return memory_bytes if memory_bytes.positive?
56
+ end
57
+ nil
58
+ rescue StandardError
59
+ nil
60
+ end
61
+
62
+ # Try to get memory using PowerShell
63
+ # @return [Integer, nil] memory in bytes or nil if failed
64
+ def try_powershell
65
+ command = 'powershell.exe -Command "Get-WmiObject -Class Win32_ComputerSystem | ' \
66
+ 'Select-Object -ExpandProperty TotalPhysicalMemory" 2>NUL'
67
+ output = `#{command}`.strip
68
+ memory_bytes = output.to_i
69
+ return memory_bytes if memory_bytes.positive?
70
+ nil
71
+ rescue StandardError
72
+ nil
73
+ end
74
+
75
+ # Try to get memory using systeminfo command
76
+ # @return [Integer, nil] memory in bytes or nil if failed
77
+ def try_systeminfo
78
+ output = `systeminfo 2>NUL`.strip
79
+ output.split("\n").each do |line|
80
+ next unless line =~ /Total Physical Memory:\s*(.+)/i
81
+ return parse_memory_string(::Regexp.last_match(1).strip)
82
+ end
83
+ nil
84
+ rescue StandardError
85
+ nil
86
+ end
87
+
88
+ # Parse memory string from systeminfo output
89
+ # @param memory_str [String] memory string like "16,384 MB" or "16.384 MB"
90
+ # @return [Integer, nil] memory in bytes or nil if parsing failed
91
+ def parse_memory_string(memory_str)
92
+ if memory_str =~ /([0-9,.\s]+)\s*MB/i
93
+ memory_mb = ::Regexp.last_match(1).gsub(/[,\s]/, '').to_f
94
+ (memory_mb * 1024 * 1024).to_i
95
+ elsif memory_str =~ /([0-9,.\s]+)\s*GB/i
96
+ memory_gb = ::Regexp.last_match(1).gsub(/[,\s]/, '').to_f
97
+ (memory_gb * 1024 * 1024 * 1024).to_i
98
+ end
99
+ end
100
+ end
101
+ end
data/lib/total.rb CHANGED
@@ -1,30 +1,12 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # (The MIT License)
4
- #
5
- # Copyright (c) 2018-2023 Yegor Bugayenko
6
- #
7
- # Permission is hereby granted, free of charge, to any person obtaining a copy
8
- # of this software and associated documentation files (the 'Software'), to deal
9
- # in the Software without restriction, including without limitation the rights
10
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
- # copies of the Software, and to permit persons to whom the Software is
12
- # furnished to do so, subject to the following conditions:
13
- #
14
- # The above copyright notice and this permission notice shall be included in all
15
- # copies or substantial portions of the Software.
16
- #
17
- # THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23
- # SOFTWARE.
3
+ # SPDX-FileCopyrightText: Copyright (c) 2018-2025 Yegor Bugayenko
4
+ # SPDX-License-Identifier: MIT
24
5
 
25
6
  require_relative 'total/linux'
26
7
  require_relative 'total/freebsd'
27
8
  require_relative 'total/osx'
9
+ require_relative 'total/windows'
28
10
 
29
11
  # Total is a simple class to detect the total amount of memory in the system.
30
12
  #
@@ -35,7 +17,7 @@ require_relative 'total/osx'
35
17
  # {README}[https://github.com/yegor256/total/blob/master/README.md] file.
36
18
  #
37
19
  # Author:: Yegor Bugayenko (yegor256@gmail.com)
38
- # Copyright:: Copyright (c) 2018-2023 Yegor Bugayenko
20
+ # Copyright:: Copyright (c) 2018-2025 Yegor Bugayenko
39
21
  # License:: MIT
40
22
  module Total
41
23
  # When it's impossible to detect something.
@@ -55,6 +37,7 @@ module Total
55
37
  return Total::OSX.new if RUBY_PLATFORM.include?('darwin')
56
38
  return Total::Linux.new if RUBY_PLATFORM.include?('linux')
57
39
  return Total::FreeBSD.new if RUBY_PLATFORM.include?('freebsd')
40
+ return Total::Windows.new if RUBY_PLATFORM =~ /mingw|mswin|cygwin|ucrt/
58
41
  raise CantDetect, "Can't detect operating system: #{RUBY_PLATFORM}"
59
42
  end
60
43
  end
data/logo.svg CHANGED
@@ -16,4 +16,4 @@
16
16
  </g>
17
17
  </g>
18
18
  </g>
19
- </svg>
19
+ </svg>
data/total.gemspec CHANGED
@@ -1,26 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # (The MIT License)
4
- #
5
- # Copyright (c) 2018-2023 Yegor Bugayenko
6
- #
7
- # Permission is hereby granted, free of charge, to any person obtaining a copy
8
- # of this software and associated documentation files (the 'Software'), to deal
9
- # in the Software without restriction, including without limitation the rights
10
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
- # copies of the Software, and to permit persons to whom the Software is
12
- # furnished to do so, subject to the following conditions:
13
- #
14
- # The above copyright notice and this permission notice shall be included in all
15
- # copies or substantial portions of the Software.
16
- #
17
- # THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23
- # SOFTWARE.
3
+ # SPDX-FileCopyrightText: Copyright (c) 2018-2025 Yegor Bugayenko
4
+ # SPDX-License-Identifier: MIT
24
5
 
25
6
  require 'English'
26
7
  lib = File.expand_path('lib', __dir__)
@@ -36,15 +17,9 @@ Gem::Specification.new do |s|
36
17
  s.description = 'Get total memory size of the system'
37
18
  s.authors = ['Yegor Bugayenko']
38
19
  s.email = 'yegor256@gmail.com'
39
- s.homepage = 'http://github.com/yegor256/total'
40
- s.files = `git ls-files`.split($RS)
20
+ s.homepage = 'https://github.com/yegor256/total'
21
+ s.files = `git ls-files | grep -v -E '^(test/|\\.|renovate)'`.split($RS)
41
22
  s.rdoc_options = ['--charset=UTF-8']
42
23
  s.extra_rdoc_files = ['README.md']
43
- s.add_development_dependency 'codecov', '0.6.0'
44
- s.add_development_dependency 'minitest', '5.18.0'
45
- s.add_development_dependency 'rake', '13.0.6'
46
- s.add_development_dependency 'rdoc', '6.5.0'
47
- s.add_development_dependency 'rubocop', '1.48.1'
48
- s.add_development_dependency 'rubocop-rspec', '2.19.0'
49
24
  s.metadata['rubygems_mfa_required'] = 'true'
50
25
  end
metadata CHANGED
@@ -1,99 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: total
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yegor Bugayenko
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2023-03-17 00:00:00.000000000 Z
12
- dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: codecov
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - '='
18
- - !ruby/object:Gem::Version
19
- version: 0.6.0
20
- type: :development
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - '='
25
- - !ruby/object:Gem::Version
26
- version: 0.6.0
27
- - !ruby/object:Gem::Dependency
28
- name: minitest
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - '='
32
- - !ruby/object:Gem::Version
33
- version: 5.18.0
34
- type: :development
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - '='
39
- - !ruby/object:Gem::Version
40
- version: 5.18.0
41
- - !ruby/object:Gem::Dependency
42
- name: rake
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - '='
46
- - !ruby/object:Gem::Version
47
- version: 13.0.6
48
- type: :development
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - '='
53
- - !ruby/object:Gem::Version
54
- version: 13.0.6
55
- - !ruby/object:Gem::Dependency
56
- name: rdoc
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - '='
60
- - !ruby/object:Gem::Version
61
- version: 6.5.0
62
- type: :development
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - '='
67
- - !ruby/object:Gem::Version
68
- version: 6.5.0
69
- - !ruby/object:Gem::Dependency
70
- name: rubocop
71
- requirement: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - '='
74
- - !ruby/object:Gem::Version
75
- version: 1.48.1
76
- type: :development
77
- prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - '='
81
- - !ruby/object:Gem::Version
82
- version: 1.48.1
83
- - !ruby/object:Gem::Dependency
84
- name: rubocop-rspec
85
- requirement: !ruby/object:Gem::Requirement
86
- requirements:
87
- - - '='
88
- - !ruby/object:Gem::Version
89
- version: 2.19.0
90
- type: :development
91
- prerelease: false
92
- version_requirements: !ruby/object:Gem::Requirement
93
- requirements:
94
- - - '='
95
- - !ruby/object:Gem::Version
96
- version: 2.19.0
10
+ date: 1980-01-02 00:00:00.000000000 Z
11
+ dependencies: []
97
12
  description: Get total memory size of the system
98
13
  email: yegor256@gmail.com
99
14
  executables: []
@@ -101,37 +16,26 @@ extensions: []
101
16
  extra_rdoc_files:
102
17
  - README.md
103
18
  files:
104
- - ".0pdd.yml"
105
- - ".github/workflows/codecov.yml"
106
- - ".github/workflows/pdd.yml"
107
- - ".github/workflows/rake.yml"
108
- - ".github/workflows/xcop.yml"
109
- - ".gitignore"
110
- - ".pdd"
111
- - ".rubocop.yml"
112
- - ".rultor.yml"
113
19
  - Gemfile
20
+ - Gemfile.lock
114
21
  - LICENSE.txt
22
+ - LICENSES/MIT.txt
115
23
  - README.md
24
+ - REUSE.toml
116
25
  - Rakefile
117
26
  - lib/total.rb
118
27
  - lib/total/freebsd.rb
119
28
  - lib/total/linux.rb
120
29
  - lib/total/osx.rb
121
30
  - lib/total/version.rb
31
+ - lib/total/windows.rb
122
32
  - logo.svg
123
- - test/test__helper.rb
124
- - test/test_total.rb
125
- - test/total/test_freebsd.rb
126
- - test/total/test_linux.rb
127
- - test/total/test_osx.rb
128
33
  - total.gemspec
129
- homepage: http://github.com/yegor256/total
34
+ homepage: https://github.com/yegor256/total
130
35
  licenses:
131
36
  - MIT
132
37
  metadata:
133
38
  rubygems_mfa_required: 'true'
134
- post_install_message:
135
39
  rdoc_options:
136
40
  - "--charset=UTF-8"
137
41
  require_paths:
@@ -147,8 +51,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
147
51
  - !ruby/object:Gem::Version
148
52
  version: '0'
149
53
  requirements: []
150
- rubygems_version: 3.1.2
151
- signing_key:
54
+ rubygems_version: 3.6.9
152
55
  specification_version: 4
153
56
  summary: Total memory calculator in Ruby
154
57
  test_files: []
data/.0pdd.yml DELETED
@@ -1,9 +0,0 @@
1
- errors:
2
- - yegor256@gmail.com
3
- # alerts:
4
- # github:
5
- # - yegor256
6
-
7
- tags:
8
- - pdd
9
- - bug
@@ -1,20 +0,0 @@
1
- ---
2
- name: codecov
3
- on:
4
- push:
5
- branches:
6
- - master
7
- jobs:
8
- codecov:
9
- runs-on: ubuntu-20.04
10
- steps:
11
- - uses: actions/checkout@v3
12
- - uses: actions/setup-ruby@v1
13
- with:
14
- ruby-version: 2.7
15
- - run: bundle update
16
- - run: bundle exec rake
17
- - uses: codecov/codecov-action@v3
18
- with:
19
- file: coverage/.resultset.json
20
- fail_ci_if_error: true
@@ -1,15 +0,0 @@
1
- ---
2
- name: pdd
3
- "on":
4
- push:
5
- branches:
6
- - master
7
- pull_request:
8
- branches:
9
- - master
10
- jobs:
11
- pdd:
12
- runs-on: ubuntu-20.04
13
- steps:
14
- - uses: actions/checkout@v3
15
- - uses: g4s8/pdd-action@master
@@ -1,24 +0,0 @@
1
- ---
2
- name: rake
3
- on:
4
- push:
5
- branches:
6
- - master
7
- pull_request:
8
- branches:
9
- - master
10
- jobs:
11
- test:
12
- name: test
13
- strategy:
14
- matrix:
15
- os: [ubuntu-20.04]
16
- ruby: [2.6]
17
- runs-on: ${{ matrix.os }}
18
- steps:
19
- - uses: actions/checkout@v3
20
- - uses: ruby/setup-ruby@v1
21
- with:
22
- ruby-version: ${{ matrix.ruby }}
23
- - run: bundle update
24
- - run: bundle exec rake
@@ -1,17 +0,0 @@
1
- ---
2
- name: xcop
3
- "on":
4
- push:
5
- branches:
6
- - master
7
- pull_request:
8
- branches:
9
- - master
10
- jobs:
11
- xcop:
12
- runs-on: ubuntu-20.04
13
- steps:
14
- - uses: actions/checkout@v3
15
- - uses: g4s8/xcop-action@master
16
- with:
17
- files: '**/*.xml'
data/.gitignore DELETED
@@ -1,6 +0,0 @@
1
- Gemfile.lock
2
- *.gem
3
- .bundle/
4
- .DS_Store
5
- rdoc/
6
- coverage/
data/.pdd DELETED
@@ -1,5 +0,0 @@
1
- --source=.
2
- --verbose
3
- --rule min-words:20
4
- --rule min-estimate:15
5
- --rule max-estimate:90
data/.rubocop.yml DELETED
@@ -1,22 +0,0 @@
1
- AllCops:
2
- NewCops: enable
3
- DisplayCopNames: true
4
- TargetRubyVersion: 2.3
5
- SuggestExtensions: false
6
-
7
- Layout/EmptyLineAfterGuardClause:
8
- Enabled: false
9
- Layout/MultilineMethodCallIndentation:
10
- Enabled: false
11
- Metrics/AbcSize:
12
- Max: 50
13
- Metrics/MethodLength:
14
- Max: 30
15
- Metrics/CyclomaticComplexity:
16
- Max: 10
17
- Metrics/PerceivedComplexity:
18
- Max: 10
19
- Metrics/ParameterLists:
20
- Max: 10
21
- Layout/ParameterAlignment:
22
- Enabled: false
data/.rultor.yml DELETED
@@ -1,19 +0,0 @@
1
- docker:
2
- image: yegor256/rultor-image:1.9.1
3
- assets:
4
- rubygems.yml: yegor256/home#assets/rubygems.yml
5
- install: |
6
- pdd -f /dev/null
7
- sudo bundle install --no-color "--gemfile=$(pwd)/Gemfile"
8
- release:
9
- script: |-
10
- bundle exec rake clean test rubocop copyright
11
- sed -i "s/0\.0\.0/${tag}/g" lib/total/version.rb
12
- git add lib/total/version.rb
13
- git commit -m "version set to ${tag}"
14
- gem build total.gemspec
15
- chmod 0600 ../rubygems.yml
16
- gem push *.gem --config-file ../rubygems.yml
17
- merge:
18
- script: |-
19
- bundle exec rake clean test rubocop copyright
data/test/test__helper.rb DELETED
@@ -1,32 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # Copyright (c) 2018-2023 Yegor Bugayenko
4
- #
5
- # Permission is hereby granted, free of charge, to any person obtaining a copy
6
- # of this software and associated documentation files (the 'Software'), to deal
7
- # in the Software without restriction, including without limitation the rights
8
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- # copies of the Software, and to permit persons to whom the Software is
10
- # furnished to do so, subject to the following conditions:
11
- #
12
- # The above copyright notice and this permission notice shall be included in all
13
- # copies or substantial portions of the Software.
14
- #
15
- # THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFINGEMENT. IN NO EVENT SHALL THE
18
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- # SOFTWARE.
22
-
23
- $stdout.sync = true
24
-
25
- require 'simplecov'
26
- SimpleCov.start
27
- if ENV['CI'] == 'true'
28
- require 'codecov'
29
- SimpleCov.formatter = SimpleCov::Formatter::Codecov
30
- end
31
-
32
- require 'minitest/autorun'
data/test/test_total.rb DELETED
@@ -1,38 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # (The MIT License)
4
- #
5
- # Copyright (c) 2018-2023 Yegor Bugayenko
6
- #
7
- # Permission is hereby granted, free of charge, to any person obtaining a copy
8
- # of this software and associated documentation files (the 'Software'), to deal
9
- # in the Software without restriction, including without limitation the rights
10
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
- # copies of the Software, and to permit persons to whom the Software is
12
- # furnished to do so, subject to the following conditions:
13
- #
14
- # The above copyright notice and this permission notice shall be included in all
15
- # copies or substantial portions of the Software.
16
- #
17
- # THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23
- # SOFTWARE.
24
-
25
- require 'minitest/autorun'
26
- require_relative '../lib/total'
27
-
28
- # Total test.
29
- # Author:: Yegor Bugayenko (yegor256@gmail.com)
30
- # Copyright:: Copyright (c) 2018-2023 Yegor Bugayenko
31
- # License:: MIT
32
- class TotalTest < Minitest::Test
33
- def test_simple_fetch
34
- mem = Total::Mem.new
35
- assert(!mem.bytes.nil?)
36
- assert(mem.bytes > 1024 * 1024)
37
- end
38
- end
@@ -1,46 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # (The MIT License)
4
- #
5
- # Copyright (c) 2018-2023 Yegor Bugayenko
6
- #
7
- # Permission is hereby granted, free of charge, to any person obtaining a copy
8
- # of this software and associated documentation files (the 'Software'), to deal
9
- # in the Software without restriction, including without limitation the rights
10
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
- # copies of the Software, and to permit persons to whom the Software is
12
- # furnished to do so, subject to the following conditions:
13
- #
14
- # The above copyright notice and this permission notice shall be included in all
15
- # copies or substantial portions of the Software.
16
- #
17
- # THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23
- # SOFTWARE.
24
-
25
- require 'minitest/autorun'
26
- require_relative '../../lib/total/freebsd'
27
-
28
- # FreeBSD test.
29
- # Author:: Yegor Bugayenko (yegor256@gmail.com)
30
- # Copyright:: Copyright (c) 2018-2023 Yegor Bugayenko
31
- # License:: MIT
32
- class FreeBSDTest < Minitest::Test
33
- def test_fetch_memory_size
34
- skip unless RUBY_PLATFORM.include?('freebsd')
35
- freebsd = Total::FreeBSD.new
36
- assert(!freebsd.memory.nil?)
37
- assert(freebsd.memory > 1024 * 1024)
38
- end
39
-
40
- def test_crashes_when_cant_detect
41
- skip if RUBY_PLATFORM.include?('freebsd')
42
- assert_raises Total::CantDetect do
43
- Total::FreeBSD.new.memory
44
- end
45
- end
46
- end
@@ -1,46 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # (The MIT License)
4
- #
5
- # Copyright (c) 2018-2023 Yegor Bugayenko
6
- #
7
- # Permission is hereby granted, free of charge, to any person obtaining a copy
8
- # of this software and associated documentation files (the 'Software'), to deal
9
- # in the Software without restriction, including without limitation the rights
10
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
- # copies of the Software, and to permit persons to whom the Software is
12
- # furnished to do so, subject to the following conditions:
13
- #
14
- # The above copyright notice and this permission notice shall be included in all
15
- # copies or substantial portions of the Software.
16
- #
17
- # THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23
- # SOFTWARE.
24
-
25
- require 'minitest/autorun'
26
- require_relative '../../lib/total/linux'
27
-
28
- # Linux test.
29
- # Author:: Yegor Bugayenko (yegor256@gmail.com)
30
- # Copyright:: Copyright (c) 2018-2023 Yegor Bugayenko
31
- # License:: MIT
32
- class LinuxTest < Minitest::Test
33
- def test_fetch_memory_size
34
- skip unless RUBY_PLATFORM.include?('linux')
35
- linux = Total::Linux.new
36
- assert(!linux.memory.nil?)
37
- assert(linux.memory > 1024 * 1024)
38
- end
39
-
40
- def test_crashes_when_cant_detect
41
- skip if RUBY_PLATFORM.include?('linux')
42
- assert_raises Total::CantDetect do
43
- Total::Linux.new.memory
44
- end
45
- end
46
- end
@@ -1,46 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # (The MIT License)
4
- #
5
- # Copyright (c) 2018-2023 Yegor Bugayenko
6
- #
7
- # Permission is hereby granted, free of charge, to any person obtaining a copy
8
- # of this software and associated documentation files (the 'Software'), to deal
9
- # in the Software without restriction, including without limitation the rights
10
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
- # copies of the Software, and to permit persons to whom the Software is
12
- # furnished to do so, subject to the following conditions:
13
- #
14
- # The above copyright notice and this permission notice shall be included in all
15
- # copies or substantial portions of the Software.
16
- #
17
- # THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23
- # SOFTWARE.
24
-
25
- require 'minitest/autorun'
26
- require_relative '../../lib/total/osx'
27
-
28
- # OSX test.
29
- # Author:: Yegor Bugayenko (yegor256@gmail.com)
30
- # Copyright:: Copyright (c) 2018-2023 Yegor Bugayenko
31
- # License:: MIT
32
- class OSXTest < Minitest::Test
33
- def test_fetch_memory_size
34
- skip unless RUBY_PLATFORM.include?('darwin')
35
- linux = Total::OSX.new
36
- assert(!linux.memory.nil?)
37
- assert(linux.memory > 1024 * 1024)
38
- end
39
-
40
- def test_crashes_when_cant_detect
41
- skip if RUBY_PLATFORM.include?('darwin')
42
- assert_raises Total::CantDetect do
43
- Total::OSX.new.memory
44
- end
45
- end
46
- end