hackmac 1.8.8 → 1.9.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.
- checksums.yaml +4 -4
- data/CHANGES.md +26 -0
- data/VERSION +1 -1
- data/hackmac.gemspec +5 -5
- data/lib/hackmac/config.rb +1 -0
- data/lib/hackmac/github_source.rb +2 -0
- data/lib/hackmac/graph/display/cell.rb +48 -0
- data/lib/hackmac/graph/display.rb +3 -46
- data/lib/hackmac/graph/formatters.rb +111 -0
- data/lib/hackmac/graph.rb +43 -136
- data/lib/hackmac/version.rb +1 -1
- data/lib/hackmac.rb +10 -0
- metadata +6 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: a3965cb839d08ac229629f87ffe259ff8b0ac39a084b25ce2530b2a0eedfab10
|
|
4
|
+
data.tar.gz: ff2e1a574431fc027ae09fabf3c31eb41b0c16df1f9f5825995cca48123c8b6e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: '018e26bd422ca4405ff37e00719f1238251bb993dbd323cb34351cee6397f378ce3f4972596b26e3987f01ac5fa199f1e8381a2cb24f2fb6cfc29a87254830af'
|
|
7
|
+
data.tar.gz: d805a9175d7667ff349883b55d120e1d78f0b039af493afd829906e2cc15ac65e0fc153df4eb1454c0d1745f20ce0f05eaa91246a9dcfbe21dec3089555309f6
|
data/CHANGES.md
CHANGED
|
@@ -2,6 +2,32 @@
|
|
|
2
2
|
|
|
3
3
|
## 2025-10-15 v1.8.8
|
|
4
4
|
|
|
5
|
+
### Features
|
|
6
|
+
|
|
7
|
+
* Enhanced `Hackmac::Graph` with better terminal graphics using Unicode block
|
|
8
|
+
characters (`▀`) for 2px vertical resolution.
|
|
9
|
+
|
|
10
|
+
### Refactorings
|
|
11
|
+
|
|
12
|
+
* Extracted `Hackmac::Graph::Formatters` module into its own file
|
|
13
|
+
(`lib/hackmac/graph/formatters.rb`).
|
|
14
|
+
* Moved `Hackmac::Graph::Display::Cell` class to a dedicated file
|
|
15
|
+
(`lib/hackmac/graph/display/cell.rb`).
|
|
16
|
+
* Refactored `Hackmac::Graph` rendering logic:
|
|
17
|
+
* Introduced `draw_graph` private method to encapsulate graph drawing
|
|
18
|
+
logic.
|
|
19
|
+
* Added `data_range` helper method for calculating data range.
|
|
20
|
+
* Simplified `start_loop` by removing redundant code and leveraging new
|
|
21
|
+
helper methods.
|
|
22
|
+
|
|
23
|
+
### Documentation
|
|
24
|
+
|
|
25
|
+
* Added detailed documentation for all public methods in `Hackmac::Graph` and
|
|
26
|
+
related modules.
|
|
27
|
+
* Included usage examples for `Hackmac::Graph::Formatters`.
|
|
28
|
+
|
|
29
|
+
## 2025-10-15 v1.8.8
|
|
30
|
+
|
|
5
31
|
- Handle invalid version strings by setting @version to **nil** instead of
|
|
6
32
|
storing malformed objects
|
|
7
33
|
- Changes in `bin\efi`
|
data/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
1.
|
|
1
|
+
1.9.0
|
data/hackmac.gemspec
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
|
2
|
-
# stub: hackmac 1.
|
|
2
|
+
# stub: hackmac 1.9.0 ruby lib
|
|
3
3
|
|
|
4
4
|
Gem::Specification.new do |s|
|
|
5
5
|
s.name = "hackmac".freeze
|
|
6
|
-
s.version = "1.
|
|
6
|
+
s.version = "1.9.0".freeze
|
|
7
7
|
|
|
8
8
|
s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
|
|
9
9
|
s.require_paths = ["lib".freeze]
|
|
@@ -12,12 +12,12 @@ Gem::Specification.new do |s|
|
|
|
12
12
|
s.description = "This ruby gem provides some useful tools for working with a Hackintosh.".freeze
|
|
13
13
|
s.email = "flori@ping.de".freeze
|
|
14
14
|
s.executables = ["efi".freeze, "gfxmon".freeze, "usb".freeze]
|
|
15
|
-
s.extra_rdoc_files = ["README.md".freeze, "lib/hackmac.rb".freeze, "lib/hackmac/asset_tools.rb".freeze, "lib/hackmac/config.rb".freeze, "lib/hackmac/disks.rb".freeze, "lib/hackmac/github_source.rb".freeze, "lib/hackmac/graph.rb".freeze, "lib/hackmac/graph/display.rb".freeze, "lib/hackmac/ioreg.rb".freeze, "lib/hackmac/kext.rb".freeze, "lib/hackmac/kext_upgrader.rb".freeze, "lib/hackmac/oc.rb".freeze, "lib/hackmac/oc_upgrader.rb".freeze, "lib/hackmac/oc_validator.rb".freeze, "lib/hackmac/plist.rb".freeze, "lib/hackmac/url_download.rb".freeze, "lib/hackmac/utils.rb".freeze, "lib/hackmac/version.rb".freeze]
|
|
16
|
-
s.files = ["CHANGES.md".freeze, "Gemfile".freeze, "LICENSE".freeze, "README.md".freeze, "Rakefile".freeze, "VERSION".freeze, "bin/efi".freeze, "bin/gfxmon".freeze, "bin/usb".freeze, "hackmac.gemspec".freeze, "img/gfxmon.png".freeze, "lib/hackmac.rb".freeze, "lib/hackmac/asset_tools.rb".freeze, "lib/hackmac/config.rb".freeze, "lib/hackmac/disks.rb".freeze, "lib/hackmac/github_source.rb".freeze, "lib/hackmac/graph.rb".freeze, "lib/hackmac/graph/display.rb".freeze, "lib/hackmac/hackmac.yml".freeze, "lib/hackmac/ioreg.rb".freeze, "lib/hackmac/kext.rb".freeze, "lib/hackmac/kext_upgrader.rb".freeze, "lib/hackmac/oc.rb".freeze, "lib/hackmac/oc_upgrader.rb".freeze, "lib/hackmac/oc_validator.rb".freeze, "lib/hackmac/plist.rb".freeze, "lib/hackmac/url_download.rb".freeze, "lib/hackmac/utils.rb".freeze, "lib/hackmac/version.rb".freeze]
|
|
15
|
+
s.extra_rdoc_files = ["README.md".freeze, "lib/hackmac.rb".freeze, "lib/hackmac/asset_tools.rb".freeze, "lib/hackmac/config.rb".freeze, "lib/hackmac/disks.rb".freeze, "lib/hackmac/github_source.rb".freeze, "lib/hackmac/graph.rb".freeze, "lib/hackmac/graph/display.rb".freeze, "lib/hackmac/graph/display/cell.rb".freeze, "lib/hackmac/graph/formatters.rb".freeze, "lib/hackmac/ioreg.rb".freeze, "lib/hackmac/kext.rb".freeze, "lib/hackmac/kext_upgrader.rb".freeze, "lib/hackmac/oc.rb".freeze, "lib/hackmac/oc_upgrader.rb".freeze, "lib/hackmac/oc_validator.rb".freeze, "lib/hackmac/plist.rb".freeze, "lib/hackmac/url_download.rb".freeze, "lib/hackmac/utils.rb".freeze, "lib/hackmac/version.rb".freeze]
|
|
16
|
+
s.files = ["CHANGES.md".freeze, "Gemfile".freeze, "LICENSE".freeze, "README.md".freeze, "Rakefile".freeze, "VERSION".freeze, "bin/efi".freeze, "bin/gfxmon".freeze, "bin/usb".freeze, "hackmac.gemspec".freeze, "img/gfxmon.png".freeze, "lib/hackmac.rb".freeze, "lib/hackmac/asset_tools.rb".freeze, "lib/hackmac/config.rb".freeze, "lib/hackmac/disks.rb".freeze, "lib/hackmac/github_source.rb".freeze, "lib/hackmac/graph.rb".freeze, "lib/hackmac/graph/display.rb".freeze, "lib/hackmac/graph/display/cell.rb".freeze, "lib/hackmac/graph/formatters.rb".freeze, "lib/hackmac/hackmac.yml".freeze, "lib/hackmac/ioreg.rb".freeze, "lib/hackmac/kext.rb".freeze, "lib/hackmac/kext_upgrader.rb".freeze, "lib/hackmac/oc.rb".freeze, "lib/hackmac/oc_upgrader.rb".freeze, "lib/hackmac/oc_validator.rb".freeze, "lib/hackmac/plist.rb".freeze, "lib/hackmac/url_download.rb".freeze, "lib/hackmac/utils.rb".freeze, "lib/hackmac/version.rb".freeze]
|
|
17
17
|
s.homepage = "http://github.com/flori/hackmac".freeze
|
|
18
18
|
s.licenses = ["MIT".freeze]
|
|
19
19
|
s.rdoc_options = ["--title".freeze, "Hackmac - Some useful tools for working with a Hackintosh".freeze, "--main".freeze, "README.md".freeze]
|
|
20
|
-
s.rubygems_version = "3.
|
|
20
|
+
s.rubygems_version = "3.7.2".freeze
|
|
21
21
|
s.summary = "Some useful tools for working with a Hackintosh".freeze
|
|
22
22
|
|
|
23
23
|
s.specification_version = 4
|
data/lib/hackmac/config.rb
CHANGED
|
@@ -26,6 +26,7 @@ module Hackmac
|
|
|
26
26
|
extend ComplexConfig::Provider::Shortcuts
|
|
27
27
|
extend Term::ANSIColor
|
|
28
28
|
|
|
29
|
+
# The default configuration settings for Hackmac application.
|
|
29
30
|
DEFAULT = File.read(File.join(File.dirname(__FILE__), 'hackmac.yml'))
|
|
30
31
|
|
|
31
32
|
# Loads the Hackmac configuration from the specified path or default
|
|
@@ -16,6 +16,8 @@ module Hackmac
|
|
|
16
16
|
# source = Hackmac::GithubSource.new('owner/repo', auth: ['user', 'token'])
|
|
17
17
|
# # Fetches latest release information and allows asset downloads
|
|
18
18
|
class GithubSource
|
|
19
|
+
|
|
20
|
+
# The GitHub API URL template for fetching releases
|
|
19
21
|
GITHUB_API_URL = 'https://api.github.com/repos/%s/releases'
|
|
20
22
|
|
|
21
23
|
include Tins::StringVersion
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
class Hackmac::Graph::Display
|
|
2
|
+
# A cell representation for terminal display with character, color,
|
|
3
|
+
# background color, and styling attributes
|
|
4
|
+
#
|
|
5
|
+
# The Cell class encapsulates the properties of a single character cell in
|
|
6
|
+
# a terminal display, including its visual characteristics such as the
|
|
7
|
+
# displayed character, text color, background color, and styling
|
|
8
|
+
# attributes. It provides methods to compare cells and convert them to
|
|
9
|
+
# their string representation with ANSI escape codes for terminal
|
|
10
|
+
# rendering.
|
|
11
|
+
class Cell < Struct.new(:char, :color, :on_color, :styles)
|
|
12
|
+
# The == method compares two Cell objects for equality by their internal
|
|
13
|
+
# array representation
|
|
14
|
+
#
|
|
15
|
+
# This method checks if the current Cell instance is equal to another
|
|
16
|
+
# Cell instance by comparing their underlying array representations
|
|
17
|
+
# returned by to_a
|
|
18
|
+
#
|
|
19
|
+
# @param other [ Hackmac::Graph::Display::Cell ] the other Cell object to
|
|
20
|
+
# compare against
|
|
21
|
+
#
|
|
22
|
+
# @return [ Boolean ] true if both cells have identical char, color,
|
|
23
|
+
# on_color, and styles values, false otherwise
|
|
24
|
+
def ==(other)
|
|
25
|
+
to_a == other.to_a
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
# The to_s method converts a Cell object into its string representation
|
|
29
|
+
# with ANSI styling
|
|
30
|
+
#
|
|
31
|
+
# This method constructs a formatted string that includes the cell's
|
|
32
|
+
# character along with its color, background color, and text style
|
|
33
|
+
# attributes using ANSI escape sequences. The resulting string is
|
|
34
|
+
# suitable for display in terminal environments that support ANSI colors.
|
|
35
|
+
#
|
|
36
|
+
# @return [ String ] a formatted string containing the cell's visual
|
|
37
|
+
# representation with appropriate ANSI styling codes for terminal
|
|
38
|
+
# rendering
|
|
39
|
+
def to_s
|
|
40
|
+
result = +''
|
|
41
|
+
result << ANSI.color(color)
|
|
42
|
+
result << ANSI.on_color(on_color)
|
|
43
|
+
styles.each { |s| result << ANSI.send(s) }
|
|
44
|
+
result << char
|
|
45
|
+
result << ANSI.reset
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
end
|
|
@@ -13,54 +13,9 @@ class Hackmac::Graph
|
|
|
13
13
|
# display = Hackmac::Graph::Display.new(24, 80)
|
|
14
14
|
# # Creates a 24x80 character display grid for terminal rendering
|
|
15
15
|
class Display
|
|
16
|
+
# Shortcut for Term::ANSIColor module.
|
|
16
17
|
ANSI = Term::ANSIColor
|
|
17
18
|
|
|
18
|
-
# A cell representation for terminal display with character, color,
|
|
19
|
-
# background color, and styling attributes
|
|
20
|
-
#
|
|
21
|
-
# The Cell class encapsulates the properties of a single character cell in
|
|
22
|
-
# a terminal display, including its visual characteristics such as the
|
|
23
|
-
# displayed character, text color, background color, and styling
|
|
24
|
-
# attributes. It provides methods to compare cells and convert them to
|
|
25
|
-
# their string representation with ANSI escape codes for terminal
|
|
26
|
-
# rendering.
|
|
27
|
-
class Cell < Struct.new(:char, :color, :on_color, :styles)
|
|
28
|
-
# The == method compares two Cell objects for equality by their internal
|
|
29
|
-
# array representation
|
|
30
|
-
#
|
|
31
|
-
# This method checks if the current Cell instance is equal to another
|
|
32
|
-
# Cell instance by comparing their underlying array representations
|
|
33
|
-
# returned by to_a
|
|
34
|
-
#
|
|
35
|
-
# @param other [ Hackmac::Graph::Display::Cell ] the other Cell object to
|
|
36
|
-
# compare against
|
|
37
|
-
#
|
|
38
|
-
# @return [ Boolean ] true if both cells have identical char, color,
|
|
39
|
-
# on_color, and styles values, false otherwise
|
|
40
|
-
def ==(other)
|
|
41
|
-
to_a == other.to_a
|
|
42
|
-
end
|
|
43
|
-
|
|
44
|
-
# The to_s method converts a Cell object into its string representation
|
|
45
|
-
# with ANSI styling
|
|
46
|
-
#
|
|
47
|
-
# This method constructs a formatted string that includes the cell's
|
|
48
|
-
# character along with its color, background color, and text style
|
|
49
|
-
# attributes using ANSI escape sequences. The resulting string is
|
|
50
|
-
# suitable for display in terminal environments that support ANSI colors.
|
|
51
|
-
#
|
|
52
|
-
# @return [ String ] a formatted string containing the cell's visual representation
|
|
53
|
-
# with appropriate ANSI styling codes for terminal rendering
|
|
54
|
-
def to_s
|
|
55
|
-
result = +''
|
|
56
|
-
result << ANSI.color(color)
|
|
57
|
-
result << ANSI.on_color(on_color)
|
|
58
|
-
styles.each { |s| result << ANSI.send(s) }
|
|
59
|
-
result << char
|
|
60
|
-
result << ANSI.reset
|
|
61
|
-
end
|
|
62
|
-
end
|
|
63
|
-
|
|
64
19
|
# The initialize method sets up a Display instance by configuring its grid
|
|
65
20
|
# dimensions and initializing internal state
|
|
66
21
|
#
|
|
@@ -528,3 +483,5 @@ class Hackmac::Graph
|
|
|
528
483
|
end
|
|
529
484
|
end
|
|
530
485
|
end
|
|
486
|
+
|
|
487
|
+
require 'hackmac/graph/display/cell'
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
class Hackmac::Graph
|
|
2
|
+
# A module that provides various formatting methods for converting numeric
|
|
3
|
+
# values into human-readable strings with appropriate units and display
|
|
4
|
+
# formats.
|
|
5
|
+
#
|
|
6
|
+
# The Formatters module contains a collection of utility methods designed to
|
|
7
|
+
# transform raw numeric data into formatted strings that are more suitable
|
|
8
|
+
# for display purposes. These methods handle common formatting tasks such as
|
|
9
|
+
# converting byte measurements, frequency values, temperature readings, and
|
|
10
|
+
# percentages into clean, readable representations.
|
|
11
|
+
#
|
|
12
|
+
# Each formatter method in this module is intended to be used with data
|
|
13
|
+
# visualization or reporting scenarios where presenting numerical information
|
|
14
|
+
# in an easily understandable format is important. The module also includes
|
|
15
|
+
# specialized functionality for deriving consistent color values based on
|
|
16
|
+
# input strings, which can be useful for maintaining visual coherence when
|
|
17
|
+
# displaying multiple data series.
|
|
18
|
+
#
|
|
19
|
+
# @example
|
|
20
|
+
# include Hackmac::Graph::Formatters
|
|
21
|
+
#
|
|
22
|
+
# as_bytes(1024 * 1024) # => "1.000MB"
|
|
23
|
+
# as_hertz(2500000000) # => "2.500GHz"
|
|
24
|
+
# as_celsius(37.5) # => "37.5°"
|
|
25
|
+
# as_percent(95.7) # => "95.7%"
|
|
26
|
+
# as_default(42) # => "42"
|
|
27
|
+
module Formatters
|
|
28
|
+
# The as_bytes method formats a numeric value into a human-readable byte
|
|
29
|
+
# representation
|
|
30
|
+
#
|
|
31
|
+
# This method takes a numeric input and converts it into a formatted string
|
|
32
|
+
# representing the value in bytes with appropriate binary prefixes (KB,
|
|
33
|
+
# MB, GB, etc.)
|
|
34
|
+
#
|
|
35
|
+
# @param value [ Numeric ] the numeric value to be formatted as bytes
|
|
36
|
+
#
|
|
37
|
+
# @return [ String ] the formatted byte representation with unit suffix
|
|
38
|
+
def as_bytes(value)
|
|
39
|
+
Tins::Unit.format(value, prefix: :uc, format: '%.3f%U', unit: 'B')
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
# The as_hertz method formats a numeric value into a human-readable
|
|
43
|
+
# frequency representation
|
|
44
|
+
#
|
|
45
|
+
# This method takes a numeric input and converts it into a formatted string
|
|
46
|
+
# representing the value in hertz with appropriate metric prefixes (kHz,
|
|
47
|
+
# MHz, GHz, etc.)
|
|
48
|
+
#
|
|
49
|
+
# @param value [ Numeric ] the numeric frequency value to be formatted
|
|
50
|
+
#
|
|
51
|
+
# @return [ String ] the formatted frequency representation with unit suffix
|
|
52
|
+
def as_hertz(value)
|
|
53
|
+
Tins::Unit.format(value, prefix: :uc, format: '%.3f%U', unit: 'Hz')
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
# The as_celsius method formats a temperature value with a degree symbol
|
|
57
|
+
#
|
|
58
|
+
# This method takes a numeric temperature value and returns a string
|
|
59
|
+
# representation with the degree Celsius symbol appended to it
|
|
60
|
+
#
|
|
61
|
+
# @param value [ Numeric ] the temperature value to be formatted
|
|
62
|
+
#
|
|
63
|
+
# @return [ String ] the temperature value formatted with a degree Celsius symbol
|
|
64
|
+
def as_celsius(value)
|
|
65
|
+
"#{value}°"
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
# The as_percent method formats a numeric value as a percentage string
|
|
69
|
+
#
|
|
70
|
+
# This method takes a numeric input and returns a string representation
|
|
71
|
+
# with a percent sign appended to it, providing a simple way to format
|
|
72
|
+
# numeric values as percentages for display purposes
|
|
73
|
+
#
|
|
74
|
+
# @param value [ Numeric ] the numeric value to be formatted as a percentage
|
|
75
|
+
#
|
|
76
|
+
# @return [ String ] the numeric value formatted as a percentage string
|
|
77
|
+
def as_percent(value)
|
|
78
|
+
"#{value}%"
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
# The as_default method converts a value to its string representation
|
|
82
|
+
#
|
|
83
|
+
# This method takes any input value and converts it to a string using the to_s method
|
|
84
|
+
# It serves as a fallback formatting option when no specific formatting is required
|
|
85
|
+
#
|
|
86
|
+
# @param value [ Object ] the value to be converted to a string
|
|
87
|
+
#
|
|
88
|
+
# @return [ String ] the string representation of the input value
|
|
89
|
+
def as_default(value)
|
|
90
|
+
value.to_s
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
# The derive_color_from_string method calculates a color value based on the
|
|
94
|
+
# input string by generating an MD5 hash and selecting from a predefined
|
|
95
|
+
# set of dark colors
|
|
96
|
+
#
|
|
97
|
+
# @param string [ String ] the input string used to derive the color value
|
|
98
|
+
#
|
|
99
|
+
# @return [ Integer ] the derived color value from the set of dark ANSI attributes
|
|
100
|
+
def derive_color_from_string(string)
|
|
101
|
+
cs = (21..226).select { |d|
|
|
102
|
+
Term::ANSIColor::Attribute[d].to_rgb_triple.to_hsl_triple.
|
|
103
|
+
lightness < 40
|
|
104
|
+
}
|
|
105
|
+
s = Digest::MD5.digest(string).unpack('Q*')
|
|
106
|
+
cs[ s.first % cs.size ]
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
self
|
|
110
|
+
end
|
|
111
|
+
end
|
data/lib/hackmac/graph.rb
CHANGED
|
@@ -2,6 +2,8 @@ require 'term/ansicolor'
|
|
|
2
2
|
require 'tins'
|
|
3
3
|
require 'digest/md5'
|
|
4
4
|
|
|
5
|
+
require 'hackmac/graph/formatters.rb'
|
|
6
|
+
|
|
5
7
|
# A class that provides graphical display functionality for terminal-based data
|
|
6
8
|
# visualization
|
|
7
9
|
#
|
|
@@ -36,117 +38,7 @@ require 'digest/md5'
|
|
|
36
38
|
# # Starts a memory usage graph with custom data source and formatting
|
|
37
39
|
class Hackmac::Graph
|
|
38
40
|
include Term::ANSIColor
|
|
39
|
-
|
|
40
|
-
# A module that provides various formatting methods for converting numeric
|
|
41
|
-
# values into human-readable strings with appropriate units and display
|
|
42
|
-
# formats.
|
|
43
|
-
#
|
|
44
|
-
# The Formatters module contains a collection of utility methods designed to
|
|
45
|
-
# transform raw numeric data into formatted strings that are more suitable
|
|
46
|
-
# for display purposes. These methods handle common formatting tasks such as
|
|
47
|
-
# converting byte measurements, frequency values, temperature readings, and
|
|
48
|
-
# percentages into clean, readable representations.
|
|
49
|
-
#
|
|
50
|
-
# Each formatter method in this module is intended to be used with data
|
|
51
|
-
# visualization or reporting scenarios where presenting numerical information
|
|
52
|
-
# in an easily understandable format is important. The module also includes
|
|
53
|
-
# specialized functionality for deriving consistent color values based on
|
|
54
|
-
# input strings, which can be useful for maintaining visual coherence when
|
|
55
|
-
# displaying multiple data series.
|
|
56
|
-
#
|
|
57
|
-
# @example
|
|
58
|
-
# include Hackmac::Graph::Formatters
|
|
59
|
-
#
|
|
60
|
-
# as_bytes(1024 * 1024) # => "1.000MB"
|
|
61
|
-
# as_hertz(2500000000) # => "2.500GHz"
|
|
62
|
-
# as_celsius(37.5) # => "37.5°"
|
|
63
|
-
# as_percent(95.7) # => "95.7%"
|
|
64
|
-
# as_default(42) # => "42"
|
|
65
|
-
module Formatters
|
|
66
|
-
# The as_bytes method formats a numeric value into a human-readable byte
|
|
67
|
-
# representation
|
|
68
|
-
#
|
|
69
|
-
# This method takes a numeric input and converts it into a formatted string
|
|
70
|
-
# representing the value in bytes with appropriate binary prefixes (KB,
|
|
71
|
-
# MB, GB, etc.)
|
|
72
|
-
#
|
|
73
|
-
# @param value [ Numeric ] the numeric value to be formatted as bytes
|
|
74
|
-
#
|
|
75
|
-
# @return [ String ] the formatted byte representation with unit suffix
|
|
76
|
-
def as_bytes(value)
|
|
77
|
-
Tins::Unit.format(value, prefix: :uc, format: '%.3f%U', unit: 'B')
|
|
78
|
-
end
|
|
79
|
-
|
|
80
|
-
# The as_hertz method formats a numeric value into a human-readable
|
|
81
|
-
# frequency representation
|
|
82
|
-
#
|
|
83
|
-
# This method takes a numeric input and converts it into a formatted string
|
|
84
|
-
# representing the value in hertz with appropriate metric prefixes (kHz,
|
|
85
|
-
# MHz, GHz, etc.)
|
|
86
|
-
#
|
|
87
|
-
# @param value [ Numeric ] the numeric frequency value to be formatted
|
|
88
|
-
#
|
|
89
|
-
# @return [ String ] the formatted frequency representation with unit suffix
|
|
90
|
-
def as_hertz(value)
|
|
91
|
-
Tins::Unit.format(value, prefix: :uc, format: '%.3f%U', unit: 'Hz')
|
|
92
|
-
end
|
|
93
|
-
|
|
94
|
-
# The as_celsius method formats a temperature value with a degree symbol
|
|
95
|
-
#
|
|
96
|
-
# This method takes a numeric temperature value and returns a string
|
|
97
|
-
# representation with the degree Celsius symbol appended to it
|
|
98
|
-
#
|
|
99
|
-
# @param value [ Numeric ] the temperature value to be formatted
|
|
100
|
-
#
|
|
101
|
-
# @return [ String ] the temperature value formatted with a degree Celsius symbol
|
|
102
|
-
def as_celsius(value)
|
|
103
|
-
"#{value}°"
|
|
104
|
-
end
|
|
105
|
-
|
|
106
|
-
# The as_percent method formats a numeric value as a percentage string
|
|
107
|
-
#
|
|
108
|
-
# This method takes a numeric input and returns a string representation
|
|
109
|
-
# with a percent sign appended to it, providing a simple way to format
|
|
110
|
-
# numeric values as percentages for display purposes
|
|
111
|
-
#
|
|
112
|
-
# @param value [ Numeric ] the numeric value to be formatted as a percentage
|
|
113
|
-
#
|
|
114
|
-
# @return [ String ] the numeric value formatted as a percentage string
|
|
115
|
-
def as_percent(value)
|
|
116
|
-
"#{value}%"
|
|
117
|
-
end
|
|
118
|
-
|
|
119
|
-
# The as_default method converts a value to its string representation
|
|
120
|
-
#
|
|
121
|
-
# This method takes any input value and converts it to a string using the to_s method
|
|
122
|
-
# It serves as a fallback formatting option when no specific formatting is required
|
|
123
|
-
#
|
|
124
|
-
# @param value [ Object ] the value to be converted to a string
|
|
125
|
-
#
|
|
126
|
-
# @return [ String ] the string representation of the input value
|
|
127
|
-
def as_default(value)
|
|
128
|
-
value.to_s
|
|
129
|
-
end
|
|
130
|
-
|
|
131
|
-
# The derive_color_from_string method calculates a color value based on the
|
|
132
|
-
# input string by generating an MD5 hash and selecting from a predefined
|
|
133
|
-
# set of dark colors
|
|
134
|
-
#
|
|
135
|
-
# @param string [ String ] the input string used to derive the color value
|
|
136
|
-
#
|
|
137
|
-
# @return [ Integer ] the derived color value from the set of dark ANSI attributes
|
|
138
|
-
def derive_color_from_string(string)
|
|
139
|
-
cs = (21..226).select { |d|
|
|
140
|
-
Term::ANSIColor::Attribute[d].to_rgb_triple.to_hsl_triple.
|
|
141
|
-
lightness < 40
|
|
142
|
-
}
|
|
143
|
-
s = Digest::MD5.digest(string).unpack('Q*')
|
|
144
|
-
cs[ s.first % cs.size ]
|
|
145
|
-
end
|
|
146
|
-
|
|
147
|
-
self
|
|
148
|
-
end
|
|
149
|
-
include Formatters
|
|
41
|
+
include Hackmac::Graph::Formatters
|
|
150
42
|
|
|
151
43
|
# The initialize method sets up a Graph instance by configuring its display
|
|
152
44
|
# parameters and internal state
|
|
@@ -210,6 +102,44 @@ class Hackmac::Graph
|
|
|
210
102
|
|
|
211
103
|
private
|
|
212
104
|
|
|
105
|
+
# Draws the graphical representation of the data on the display.
|
|
106
|
+
#
|
|
107
|
+
# This method renders the data as a graph using Unicode block characters (▀)
|
|
108
|
+
# to achieve 2px vertical resolution in terminal graphics. Each data point is
|
|
109
|
+
# plotted with appropriate color blending for visual appeal.
|
|
110
|
+
def draw_graph
|
|
111
|
+
y_width = data_range
|
|
112
|
+
color = pick_color
|
|
113
|
+
color_light = color.to_rgb_triple.to_hsl_triple.lighten(15) rescue color
|
|
114
|
+
data.each_with_index do |value, i|
|
|
115
|
+
x = 1 + i + columns - data.size
|
|
116
|
+
y0 = ((value - data.min) * lines / y_width.to_f)
|
|
117
|
+
y = lines - y0.round + 1
|
|
118
|
+
y.upto(lines) do |iy|
|
|
119
|
+
if iy > y
|
|
120
|
+
@display.at(iy, x).on_color(color_light).write(' ')
|
|
121
|
+
else
|
|
122
|
+
fract = 1 - (y0 - y0.floor).abs
|
|
123
|
+
case
|
|
124
|
+
when (0...0.5) === fract
|
|
125
|
+
@display.at(iy, x).color(0).on_color(color).write(?▀)
|
|
126
|
+
else
|
|
127
|
+
@display.at(iy, x).color(color).on_color(color_light).write(?▀)
|
|
128
|
+
end
|
|
129
|
+
end
|
|
130
|
+
end
|
|
131
|
+
end
|
|
132
|
+
end
|
|
133
|
+
|
|
134
|
+
# The data_range method calculates the range of data values by computing the
|
|
135
|
+
# difference between the maximum and minimum values in the data set and
|
|
136
|
+
# converting the result to a float
|
|
137
|
+
#
|
|
138
|
+
# @return [ Float ] the calculated range of the data values as a float
|
|
139
|
+
def data_range
|
|
140
|
+
(data.max - data.min).abs.to_f
|
|
141
|
+
end
|
|
142
|
+
|
|
213
143
|
# The start_loop method executes a continuous loop to update and display
|
|
214
144
|
# graphical data
|
|
215
145
|
#
|
|
@@ -222,8 +152,6 @@ class Hackmac::Graph
|
|
|
222
152
|
# until explicitly stopped.
|
|
223
153
|
def start_loop
|
|
224
154
|
full_reset
|
|
225
|
-
color = pick_color
|
|
226
|
-
color_light = color.to_rgb_triple.to_hsl_triple.lighten(15) rescue color
|
|
227
155
|
@counter = -1
|
|
228
156
|
@continue = true
|
|
229
157
|
while @continue
|
|
@@ -234,8 +162,7 @@ class Hackmac::Graph
|
|
|
234
162
|
@data << @value.(@counter += 1)
|
|
235
163
|
@data = data.last(columns)
|
|
236
164
|
|
|
237
|
-
|
|
238
|
-
if y_width == 0
|
|
165
|
+
if data_range.zero?
|
|
239
166
|
@display.reset.bottom.styled(:bold).
|
|
240
167
|
write_centered("#@title / #{sleep_duration}").
|
|
241
168
|
reset.centered.styled(:italic).write_centered("no data")
|
|
@@ -245,15 +172,7 @@ class Hackmac::Graph
|
|
|
245
172
|
end
|
|
246
173
|
|
|
247
174
|
@display.reset
|
|
248
|
-
|
|
249
|
-
x = x + columns - data.size + 1
|
|
250
|
-
y = lines - (((value - data.min) * lines / y_width)).round + 1
|
|
251
|
-
y.upto(lines) do |iy|
|
|
252
|
-
@display.at(iy, x).on_color(
|
|
253
|
-
y == iy ? color : color_light
|
|
254
|
-
).write(' ')
|
|
255
|
-
end
|
|
256
|
-
end
|
|
175
|
+
draw_graph
|
|
257
176
|
|
|
258
177
|
@display.reset.bottom.styled(:bold).
|
|
259
178
|
write_centered("#@title #{format_value(data.last)} / #{sleep_duration}")
|
|
@@ -357,18 +276,6 @@ class Hackmac::Graph
|
|
|
357
276
|
end
|
|
358
277
|
]
|
|
359
278
|
end
|
|
360
|
-
def pick_color
|
|
361
|
-
Term::ANSIColor::Attribute[
|
|
362
|
-
case @color
|
|
363
|
-
when Proc
|
|
364
|
-
@color.(@title)
|
|
365
|
-
when nil
|
|
366
|
-
derive_color_from_string(@title)
|
|
367
|
-
else
|
|
368
|
-
@color
|
|
369
|
-
end
|
|
370
|
-
]
|
|
371
|
-
end
|
|
372
279
|
|
|
373
280
|
# The sleep_now method calculates and executes a sleep duration based on the
|
|
374
281
|
# configured sleep time and elapsed time since start
|
data/lib/hackmac/version.rb
CHANGED
data/lib/hackmac.rb
CHANGED
|
@@ -1,3 +1,13 @@
|
|
|
1
|
+
# Hackmac is a set of Ruby tools specifically designed for managing and
|
|
2
|
+
# customizing Hackintosh configurations. While primarily intended for users
|
|
3
|
+
# with Hackintosh setups, it may also be useful for ordinary Mac users who want
|
|
4
|
+
# to leverage its features for monitoring system performance using `gfxmon`.
|
|
5
|
+
#
|
|
6
|
+
# The library provides core functionality for:
|
|
7
|
+
# - EFI partition management
|
|
8
|
+
# - GPU performance monitoring
|
|
9
|
+
# - USB bootable drive creation
|
|
10
|
+
# - System configuration and validation
|
|
1
11
|
module Hackmac
|
|
2
12
|
end
|
|
3
13
|
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: hackmac
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.9.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Florian Frank
|
|
@@ -165,6 +165,8 @@ extra_rdoc_files:
|
|
|
165
165
|
- lib/hackmac/github_source.rb
|
|
166
166
|
- lib/hackmac/graph.rb
|
|
167
167
|
- lib/hackmac/graph/display.rb
|
|
168
|
+
- lib/hackmac/graph/display/cell.rb
|
|
169
|
+
- lib/hackmac/graph/formatters.rb
|
|
168
170
|
- lib/hackmac/ioreg.rb
|
|
169
171
|
- lib/hackmac/kext.rb
|
|
170
172
|
- lib/hackmac/kext_upgrader.rb
|
|
@@ -194,6 +196,8 @@ files:
|
|
|
194
196
|
- lib/hackmac/github_source.rb
|
|
195
197
|
- lib/hackmac/graph.rb
|
|
196
198
|
- lib/hackmac/graph/display.rb
|
|
199
|
+
- lib/hackmac/graph/display/cell.rb
|
|
200
|
+
- lib/hackmac/graph/formatters.rb
|
|
197
201
|
- lib/hackmac/hackmac.yml
|
|
198
202
|
- lib/hackmac/ioreg.rb
|
|
199
203
|
- lib/hackmac/kext.rb
|
|
@@ -227,7 +231,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
227
231
|
- !ruby/object:Gem::Version
|
|
228
232
|
version: '0'
|
|
229
233
|
requirements: []
|
|
230
|
-
rubygems_version: 3.
|
|
234
|
+
rubygems_version: 3.7.2
|
|
231
235
|
specification_version: 4
|
|
232
236
|
summary: Some useful tools for working with a Hackintosh
|
|
233
237
|
test_files: []
|