graphina 0.1.1 → 0.2.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/README.md +43 -75
- data/VERSION +1 -1
- data/bin/graphina +7 -1
- data/graphina.gemspec +4 -4
- data/lib/graphina/panel/defaults/x86_64-darwin.yml +35 -0
- data/lib/graphina/panel/defaults/x86_64-linux.yml +35 -0
- data/lib/graphina/setup.rb +112 -0
- data/lib/graphina/version.rb +1 -1
- data/lib/graphina.rb +1 -0
- metadata +5 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: cca65e421a6d4a67744edd6f1acc65219c29f16b5d1decf0e886c9208e9d9906
|
|
4
|
+
data.tar.gz: ff1f2e42524b8eae0c6df646b010740bc312f8348d03727639a85b097835de4d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 4fd6afb55759a51ff4b5d6d52723af3e7a29e888273784aa8b637be5591486093bc65fd9315c0a8c02eb83a4e7b53b604b19a1c809f0dc27cdcfd900f49370d0
|
|
7
|
+
data.tar.gz: f1ec824b10b71a579d9c10e9ffb5642943313952c46b85d199d2d903e60cc2d87b0911fbf9f32a8e54883b72e29b1306e3b64e0b5b141635df0834b0ed41c668
|
data/README.md
CHANGED
|
@@ -54,12 +54,47 @@ Or install the gem directly:
|
|
|
54
54
|
gem install graphina
|
|
55
55
|
```
|
|
56
56
|
|
|
57
|
+
## Panel Configuration Setup
|
|
58
|
+
|
|
59
|
+
Graphina now supports predefined panel configurations. You can create a
|
|
60
|
+
`panels.yml` file in your configuration directory
|
|
61
|
+
(`"$XDG_CONFIG_HOME/graphina"`, usually `~/.config/graphina/panels.yml`) to
|
|
62
|
+
define reusable panel setups.
|
|
63
|
+
|
|
64
|
+
To install one of the included defaults you can try
|
|
65
|
+
```bash
|
|
66
|
+
graphina -S default
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
which attempts to infer a default config for your platform.
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
Currently these platforms are included:
|
|
73
|
+
|
|
74
|
+
- MacOS x86 64 see [x86_64-darwin](lib/graphina/panel/defaults/x86_64-darwin.yml).
|
|
75
|
+
- Linux x86 64 see [x86_64-linux](lib/graphina/panel/defaults/x86_64-linux.yml).
|
|
76
|
+
|
|
77
|
+
These can be installed eplicitly via:
|
|
78
|
+
```bash
|
|
79
|
+
graphina -S x86_64-darwin
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
Then to use a specific panel:
|
|
83
|
+
```bash
|
|
84
|
+
graphina -P cpu_usage_percentage
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
To see all available panels:
|
|
88
|
+
```bash
|
|
89
|
+
graphina
|
|
90
|
+
```
|
|
91
|
+
|
|
57
92
|
## Usage
|
|
58
93
|
|
|
59
94
|
### 1. Basic Usage with Random Data
|
|
60
95
|
|
|
61
96
|
```bash
|
|
62
|
-
# Simple usage with random data
|
|
97
|
+
# Simple usage with random data or interactive panel selection
|
|
63
98
|
graphina
|
|
64
99
|
```
|
|
65
100
|
|
|
@@ -74,19 +109,22 @@ graphina -t "CPU Usage (faked)" -f blue -b black
|
|
|
74
109
|
|
|
75
110
|
```bash
|
|
76
111
|
# Monitor CPU usage in real-time
|
|
77
|
-
graphina -t 'CPU Usage' -n 1 -F as_percent -e "top -l 1 -n 0 | grep 'CPU usage' | awk '{print \$3+\$5}'
|
|
112
|
+
graphina -t 'CPU Usage' -n 1 -F as_percent -e "top -l 1 -n 0 | grep 'CPU usage' | awk '{print \$3+\$5}'"
|
|
78
113
|
```
|
|
79
114
|
|
|
80
115
|
### 4. Using Predefined Panels
|
|
81
116
|
|
|
82
117
|
```bash
|
|
83
118
|
# Use a predefined panel configuration
|
|
84
|
-
graphina -P
|
|
119
|
+
graphina -P cpu_usage_percentage
|
|
85
120
|
|
|
86
121
|
# Interactive panel selection
|
|
87
122
|
graphina
|
|
88
123
|
```
|
|
89
124
|
|
|
125
|
+
See below under **Panel Configuration** how to setup these panel configurations
|
|
126
|
+
on your system.
|
|
127
|
+
|
|
90
128
|
### 5. Custom Data Source
|
|
91
129
|
|
|
92
130
|
```ruby
|
|
@@ -116,77 +154,6 @@ graph = Graphina::Graph.new(
|
|
|
116
154
|
graph.start
|
|
117
155
|
```
|
|
118
156
|
|
|
119
|
-
## Panel Configuration
|
|
120
|
-
|
|
121
|
-
Graphina now supports predefined panel configurations. Create a `panels.yml`
|
|
122
|
-
file in your configuration directory (`"$XDG_CONFIG_HOME/graphina"`, usually
|
|
123
|
-
`~/.config/graphina/panels.yml`) to define reusable panel setups.
|
|
124
|
-
|
|
125
|
-
Example for MacOS:
|
|
126
|
-
|
|
127
|
-
```yaml
|
|
128
|
-
cpu_usage_percentage:
|
|
129
|
-
title: "CPU Usage (%)"
|
|
130
|
-
interval: 1
|
|
131
|
-
command: "top -l 1 -n 0 | awk '/^CPU usage:/ { printf \"%.1f\", $3 + $5 }'"
|
|
132
|
-
format_value: as_percent
|
|
133
|
-
color: '#ff5f00'
|
|
134
|
-
memory_usage:
|
|
135
|
-
title: "Memory Usage"
|
|
136
|
-
interval: 1
|
|
137
|
-
command: "free -b | awk '/^Mem:/ { print $4 }'"
|
|
138
|
-
format_value: as_bytes
|
|
139
|
-
color: '#00d787'
|
|
140
|
-
color_secondary: '#00ffd7'
|
|
141
|
-
memory_usage_percentage:
|
|
142
|
-
title: "Memory Usage (%)"
|
|
143
|
-
interval: 1
|
|
144
|
-
command: "free -b | awk '/^Mem:/ { printf \"%.1f\", 100 * $4 / $2 }'"
|
|
145
|
-
format_value: as_percent
|
|
146
|
-
color: '#87d700'
|
|
147
|
-
color_secondary: '#d7ff00'
|
|
148
|
-
cpu_temperature:
|
|
149
|
-
title: "CPU Temperature ℃ "
|
|
150
|
-
interval: 1
|
|
151
|
-
command: "osx-cpu-temp -C | tr -dc '0-9.'"
|
|
152
|
-
format_value: as_celsius
|
|
153
|
-
color: '#aa0000'
|
|
154
|
-
```
|
|
155
|
-
|
|
156
|
-
Example for Linux:
|
|
157
|
-
|
|
158
|
-
```yaml
|
|
159
|
-
cpu:
|
|
160
|
-
title: "CPU Usage (%)"
|
|
161
|
-
interval: 1
|
|
162
|
-
command: "top -b -n 1 | awk '/^%Cpu\\(s\\)/ { print $2 + $4 + $6 }'"
|
|
163
|
-
format_value: as_percent
|
|
164
|
-
color: '#ff5f00'
|
|
165
|
-
memory:
|
|
166
|
-
title: "Memory Usage"
|
|
167
|
-
interval: 1
|
|
168
|
-
command: "free -b | awk '/^Mem:/ { print $3 }'"
|
|
169
|
-
format_value: as_bytes
|
|
170
|
-
color: '#87d700'
|
|
171
|
-
color_secondary: '#d7ff00'
|
|
172
|
-
temperature:
|
|
173
|
-
title: "CPU Temperature ℃ "
|
|
174
|
-
interval: 1
|
|
175
|
-
command: "sensors | awk '/^Tctl:/ { print $2 }' | tr -dc '0-9.'"
|
|
176
|
-
format_value: as_celsius
|
|
177
|
-
color: '#ff0000'
|
|
178
|
-
```
|
|
179
|
-
|
|
180
|
-
To use a specific panel:
|
|
181
|
-
```bash
|
|
182
|
-
graphina -P cpu
|
|
183
|
-
```
|
|
184
|
-
|
|
185
|
-
To see all available panels:
|
|
186
|
-
```bash
|
|
187
|
-
graphina
|
|
188
|
-
```
|
|
189
|
-
|
|
190
157
|
## Command Line Options
|
|
191
158
|
|
|
192
159
|
```
|
|
@@ -202,8 +169,9 @@ Usage: graphina [OPTIONS]
|
|
|
202
169
|
-c COLOR Primary color (default: derived from title)
|
|
203
170
|
-C COLOR Secondary color (default: derived from primary)
|
|
204
171
|
-F FORMAT Format function (:as_bytes, :as_hertz, :as_celsius, :as_percent, :as_default, default: :as_default)
|
|
172
|
+
-P PANEL Use predefined panel configuration (default: interactive selection)
|
|
173
|
+
-S CONFIG Setup panel config (default infers from OS)
|
|
205
174
|
-e COMMAND External command to execute for data values (default: random data)
|
|
206
|
-
-P PANEL Panel name to use from configuration (default: interactive selection)
|
|
207
175
|
-h this help
|
|
208
176
|
```
|
|
209
177
|
|
data/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
0.
|
|
1
|
+
0.2.0
|
data/bin/graphina
CHANGED
|
@@ -20,6 +20,7 @@ def usage
|
|
|
20
20
|
-C COLOR Secondary color (default: derived from primary)
|
|
21
21
|
-F FORMAT Format function (:as_bytes, :as_hertz, :as_celsius, :as_percent, :as_default, default: :as_default)
|
|
22
22
|
-P PANEL Use predefined panel configuration (default: interactive selection)
|
|
23
|
+
-S CONFIG Setup panel config (default infers from OS)
|
|
23
24
|
-e COMMAND External command to execute for data values (default: random data)
|
|
24
25
|
-h this help
|
|
25
26
|
|
|
@@ -37,9 +38,14 @@ def usage
|
|
|
37
38
|
0
|
|
38
39
|
end
|
|
39
40
|
|
|
40
|
-
$opts = go 't:n:r:f:b:c:C:F:e:P:h'
|
|
41
|
+
$opts = go 't:n:r:f:b:c:C:F:e:P:S:h'
|
|
41
42
|
|
|
42
43
|
$opts[?h] and exit usage
|
|
44
|
+
if $opts[?S]
|
|
45
|
+
setup = Graphina::Setup.new(default_panels_name: $opts[?S])
|
|
46
|
+
setup.install_default_panels
|
|
47
|
+
exit
|
|
48
|
+
end
|
|
43
49
|
|
|
44
50
|
panel = Graphina::Panel.new
|
|
45
51
|
case
|
data/graphina.gemspec
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
|
2
|
-
# stub: graphina 0.
|
|
2
|
+
# stub: graphina 0.2.0 ruby lib
|
|
3
3
|
|
|
4
4
|
Gem::Specification.new do |s|
|
|
5
5
|
s.name = "graphina".freeze
|
|
6
|
-
s.version = "0.
|
|
6
|
+
s.version = "0.2.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,8 +12,8 @@ Gem::Specification.new do |s|
|
|
|
12
12
|
s.description = "Gem that provides terminal-based data visualization capabilities, enabling\ndevelopers to create dynamic, real-time graphical displays of numerical data\ndirectly within terminal environments using Unicode characters and ANSI\nstyling.\n".freeze
|
|
13
13
|
s.email = "flori@ping.de".freeze
|
|
14
14
|
s.executables = ["graphina".freeze]
|
|
15
|
-
s.extra_rdoc_files = ["README.md".freeze, "lib/graphina.rb".freeze, "lib/graphina/graph.rb".freeze, "lib/graphina/graph/display.rb".freeze, "lib/graphina/graph/display/cell.rb".freeze, "lib/graphina/graph/formatters.rb".freeze, "lib/graphina/graphina_config.rb".freeze, "lib/graphina/panel.rb".freeze, "lib/graphina/panel/chooser.rb".freeze, "lib/graphina/version.rb".freeze]
|
|
16
|
-
s.files = [".utilsrc".freeze, "Gemfile".freeze, "LICENSE".freeze, "README.md".freeze, "Rakefile".freeze, "VERSION".freeze, "bin/graphina".freeze, "graphina.gemspec".freeze, "img/graphina.png".freeze, "lib/graphina.rb".freeze, "lib/graphina/graph.rb".freeze, "lib/graphina/graph/display.rb".freeze, "lib/graphina/graph/display/cell.rb".freeze, "lib/graphina/graph/formatters.rb".freeze, "lib/graphina/graphina_config.rb".freeze, "lib/graphina/panel.rb".freeze, "lib/graphina/panel/chooser.rb".freeze, "lib/graphina/version.rb".freeze]
|
|
15
|
+
s.extra_rdoc_files = ["README.md".freeze, "lib/graphina.rb".freeze, "lib/graphina/graph.rb".freeze, "lib/graphina/graph/display.rb".freeze, "lib/graphina/graph/display/cell.rb".freeze, "lib/graphina/graph/formatters.rb".freeze, "lib/graphina/graphina_config.rb".freeze, "lib/graphina/panel.rb".freeze, "lib/graphina/panel/chooser.rb".freeze, "lib/graphina/setup.rb".freeze, "lib/graphina/version.rb".freeze]
|
|
16
|
+
s.files = [".utilsrc".freeze, "Gemfile".freeze, "LICENSE".freeze, "README.md".freeze, "Rakefile".freeze, "VERSION".freeze, "bin/graphina".freeze, "graphina.gemspec".freeze, "img/graphina.png".freeze, "lib/graphina.rb".freeze, "lib/graphina/graph.rb".freeze, "lib/graphina/graph/display.rb".freeze, "lib/graphina/graph/display/cell.rb".freeze, "lib/graphina/graph/formatters.rb".freeze, "lib/graphina/graphina_config.rb".freeze, "lib/graphina/panel.rb".freeze, "lib/graphina/panel/chooser.rb".freeze, "lib/graphina/panel/defaults/x86_64-darwin.yml".freeze, "lib/graphina/panel/defaults/x86_64-linux.yml".freeze, "lib/graphina/setup.rb".freeze, "lib/graphina/version.rb".freeze]
|
|
17
17
|
s.homepage = "https://github.com/flori/graphina".freeze
|
|
18
18
|
s.licenses = ["MIT".freeze]
|
|
19
19
|
s.rdoc_options = ["--title".freeze, "Graphina - Gem for creating terminal-based data visualizations with real-time\ngraphical displays using Unicode characters and ANSI styling.\n".freeze, "--main".freeze, "README.md".freeze]
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
cpu_usage_percentage:
|
|
2
|
+
title: "CPU Usage (%)"
|
|
3
|
+
interval: 1
|
|
4
|
+
command: |
|
|
5
|
+
top -l 1 -n 0 | awk '/^CPU usage:/ { printf "%.1f", $3 + $5 }'
|
|
6
|
+
format_value: as_percent
|
|
7
|
+
color: '#fe8019'
|
|
8
|
+
cpu_temperature:
|
|
9
|
+
title: "CPU Temperature (℃) "
|
|
10
|
+
interval: 1
|
|
11
|
+
command: |
|
|
12
|
+
osx-cpu-temp -C | tr -dc '0-9.'
|
|
13
|
+
format_value: as_celsius
|
|
14
|
+
color: '#fb4934'
|
|
15
|
+
cpu_clock_average:
|
|
16
|
+
title: "CPU Clock Speed (MHz)"
|
|
17
|
+
interval: 1
|
|
18
|
+
command: |
|
|
19
|
+
sudo bash -c 'powermetrics --show-usage-summary -s cpu_power & pid=$!; sleep 1; kill $pid'| awk '/CPU Average/ { count++; gsub(/.*\(/, ""); gsub(/\ .*/, ""); sum += $0 } END { if (count > 0) { print 1000000*sum/count } else { print 0 } }'
|
|
20
|
+
format_value: as_hertz
|
|
21
|
+
color: '#b8bb26'
|
|
22
|
+
memory_usage:
|
|
23
|
+
title: "Memory Usage"
|
|
24
|
+
interval: 1
|
|
25
|
+
command: |
|
|
26
|
+
free -b | awk '/^Mem:/ { print $4 }'
|
|
27
|
+
format_value: as_bytes
|
|
28
|
+
color: '#689d6a'
|
|
29
|
+
memory_usage_percentage:
|
|
30
|
+
title: "Memory Usage (%)"
|
|
31
|
+
interval: 1
|
|
32
|
+
command: |
|
|
33
|
+
free -b | awk '/^Mem:/ { printf "%.1f", 100 * $4 / $2 }'
|
|
34
|
+
format_value: as_percent
|
|
35
|
+
color: '#689d6a'
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
cpu_usage_percentage:
|
|
2
|
+
title: "CPU Usage (%)"
|
|
3
|
+
interval: 1
|
|
4
|
+
command: |
|
|
5
|
+
top -b -n 1 | awk '/^%Cpu\(s\)/ { print $2 + $4 + $6 }'
|
|
6
|
+
format_value: as_percent
|
|
7
|
+
color: '#fe8019'
|
|
8
|
+
cpu_temperature:
|
|
9
|
+
title: "CPU Temperature (℃) "
|
|
10
|
+
interval: 1
|
|
11
|
+
command: |
|
|
12
|
+
sensors | awk '/^Tctl:/ { print $2 }' | tr -dc '0-9.'
|
|
13
|
+
format_value: as_celsius
|
|
14
|
+
color: '#fb4934'
|
|
15
|
+
cpu_clock_average:
|
|
16
|
+
title: "CPU Clock Speed (MHz)"
|
|
17
|
+
interval: 1
|
|
18
|
+
command: |
|
|
19
|
+
awk '/cpu MHz/ {sum += $4; count++} END {if (count > 0) print 1000000 * sum/count}' /proc/cpuinfo
|
|
20
|
+
format_value: as_hertz
|
|
21
|
+
color: '#b8bb26'
|
|
22
|
+
memory_usage:
|
|
23
|
+
title: "Memory Usage"
|
|
24
|
+
interval: 1
|
|
25
|
+
command: |
|
|
26
|
+
free -b | awk '/^Mem:/ { print $3 }'
|
|
27
|
+
format_value: as_bytes
|
|
28
|
+
color: '#689d6a'
|
|
29
|
+
memory_usage_percentage:
|
|
30
|
+
title: "Memory Usage (%)"
|
|
31
|
+
interval: 1
|
|
32
|
+
command: |
|
|
33
|
+
free -b | awk '/^Mem:/ { printf \"%.1f\", 100 * $3 / $2 }'
|
|
34
|
+
format_value: as_percent
|
|
35
|
+
color: '#689d6a'
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
require 'fileutils'
|
|
2
|
+
|
|
3
|
+
# A class that handles the setup and configuration of Graphina
|
|
4
|
+
#
|
|
5
|
+
# The Setup class provides functionality for installing default panel
|
|
6
|
+
# configurations into the user's configuration directory. It manages the
|
|
7
|
+
# detection of platform-specific default configurations and facilitates the
|
|
8
|
+
# copying of these configurations to the appropriate location for use with the
|
|
9
|
+
# Graphina application
|
|
10
|
+
#
|
|
11
|
+
# @example
|
|
12
|
+
# setup = Graphina::Setup.new(default_panels_name: 'c64-linux')
|
|
13
|
+
# setup.install_default_panels
|
|
14
|
+
class Graphina::Setup
|
|
15
|
+
include FileUtils::Verbose
|
|
16
|
+
|
|
17
|
+
# The initialize method sets up a Setup instance with the specified default
|
|
18
|
+
# panel name
|
|
19
|
+
#
|
|
20
|
+
# This method configures a new setup object with a default panel name,
|
|
21
|
+
# handling the special case where the name is 'default' by setting it to nil
|
|
22
|
+
# instead
|
|
23
|
+
#
|
|
24
|
+
# @param default_panels_name [ String ] the name of the default panels to use
|
|
25
|
+
#
|
|
26
|
+
# @return [ Graphina::Setup ] returns the initialized Setup instance
|
|
27
|
+
def initialize(default_panels_name:)
|
|
28
|
+
default_panels_name == 'default' and default_panels_name = nil
|
|
29
|
+
@default_panels_name = default_panels_name
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
# The infer_default_panels_path_from_platform method attempts to determine
|
|
33
|
+
# the appropriate default panel configuration file path based on the current
|
|
34
|
+
# platform
|
|
35
|
+
#
|
|
36
|
+
# This method checks the RUBY_PLATFORM environment variable to identify
|
|
37
|
+
# whether the system is running on an x86_64 Darwin (macOS) or x86_64 Linux
|
|
38
|
+
# platform
|
|
39
|
+
#
|
|
40
|
+
# @return [ Pathname, nil ] returns a Pathname object pointing to the
|
|
41
|
+
# detected default panels configuration file if the platform is supported and
|
|
42
|
+
# the file exists, or nil if the platform is not supported or the file does
|
|
43
|
+
# not exist
|
|
44
|
+
def infer_default_panels_path_from_platform
|
|
45
|
+
case RUBY_PLATFORM
|
|
46
|
+
when /\Ax86_64-darwin/, /\Ax86_64-linux/
|
|
47
|
+
path = default_panels_path($&)
|
|
48
|
+
if path.exist?
|
|
49
|
+
path
|
|
50
|
+
end
|
|
51
|
+
else
|
|
52
|
+
STDERR.puts "Default panel configuration cannot be inferred for platform!"
|
|
53
|
+
nil
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
# The default_panels_path method constructs and returns a Pathname object
|
|
58
|
+
# for a default panels configuration file
|
|
59
|
+
#
|
|
60
|
+
# This method takes a panel name parameter and uses it to build a file path
|
|
61
|
+
# pointing to a default panels configuration file
|
|
62
|
+
# located in the panel defaults directory. It checks if the constructed path
|
|
63
|
+
# exists and returns it if so, or nil if the file doesn't exist
|
|
64
|
+
#
|
|
65
|
+
# @param panels_name [ String ] the name of the panels configuration to look up
|
|
66
|
+
#
|
|
67
|
+
# @return [ Pathname, nil ] a Pathname object pointing to the default panels
|
|
68
|
+
# configuration file if it exists, or nil if it doesn't exist
|
|
69
|
+
def default_panels_path(panels_name)
|
|
70
|
+
path = Pathname.new(__FILE__).dirname + 'panel' + 'defaults' + (panels_name + '.yml')
|
|
71
|
+
if path.exist?
|
|
72
|
+
path
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
# The panels_path_exist? method checks whether the panel configuration file
|
|
77
|
+
# path exists in the user's configuration directory
|
|
78
|
+
#
|
|
79
|
+
# This method verifies the existence of the panels configuration file by
|
|
80
|
+
# querying the predefined path in the Graphina configuration module
|
|
81
|
+
#
|
|
82
|
+
# @return [ Boolean ] true if the panels configuration file exists at the
|
|
83
|
+
# expected location, false otherwise
|
|
84
|
+
def panels_path_exist?
|
|
85
|
+
Graphina::GraphinaConfig::PANELS_PATH.exist?
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
# The install_default_panels method installs default panel configurations
|
|
89
|
+
# into the user's configuration directory
|
|
90
|
+
#
|
|
91
|
+
# This method checks if a panel configuration file already exists in the
|
|
92
|
+
# user's configuration directory and, if not, attempts to determine the
|
|
93
|
+
# appropriate default panel configuration based on the platform or the
|
|
94
|
+
# specified default panel name, then copies the default configuration file to
|
|
95
|
+
# the user's configuration directory
|
|
96
|
+
def install_default_panels
|
|
97
|
+
if panels_path_exist?
|
|
98
|
+
STDOUT.print "#{Graphina::GraphinaConfig::PANELS_PATH.to_s.inspect} exists. Overwrite (y/n)? "
|
|
99
|
+
STDIN.gets !~ /\Ay/i and return
|
|
100
|
+
end
|
|
101
|
+
default_path = @default_panels_name ?
|
|
102
|
+
default_panels_path(@default_panels_name) :
|
|
103
|
+
infer_default_panels_path_from_platform
|
|
104
|
+
if default_path
|
|
105
|
+
mkdir_p Graphina::GraphinaConfig::CONFIG_DIR
|
|
106
|
+
cp default_path, Graphina::GraphinaConfig::PANELS_PATH
|
|
107
|
+
STDOUT.puts "Default panels from #{default_path.to_s.inspect} have been installed."
|
|
108
|
+
else
|
|
109
|
+
STDERR.puts "Default panels for #{@default_panels_name.inspect} could not be installed."
|
|
110
|
+
end
|
|
111
|
+
end
|
|
112
|
+
end
|
data/lib/graphina/version.rb
CHANGED
data/lib/graphina.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: graphina
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.2.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Florian Frank
|
|
@@ -132,6 +132,7 @@ extra_rdoc_files:
|
|
|
132
132
|
- lib/graphina/graphina_config.rb
|
|
133
133
|
- lib/graphina/panel.rb
|
|
134
134
|
- lib/graphina/panel/chooser.rb
|
|
135
|
+
- lib/graphina/setup.rb
|
|
135
136
|
- lib/graphina/version.rb
|
|
136
137
|
files:
|
|
137
138
|
- ".utilsrc"
|
|
@@ -151,6 +152,9 @@ files:
|
|
|
151
152
|
- lib/graphina/graphina_config.rb
|
|
152
153
|
- lib/graphina/panel.rb
|
|
153
154
|
- lib/graphina/panel/chooser.rb
|
|
155
|
+
- lib/graphina/panel/defaults/x86_64-darwin.yml
|
|
156
|
+
- lib/graphina/panel/defaults/x86_64-linux.yml
|
|
157
|
+
- lib/graphina/setup.rb
|
|
154
158
|
- lib/graphina/version.rb
|
|
155
159
|
homepage: https://github.com/flori/graphina
|
|
156
160
|
licenses:
|