markdown_exec 1.3.7 → 1.3.9
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/CHANGELOG.md +53 -2
- data/Gemfile +1 -0
- data/Gemfile.lock +5 -1
- data/Rakefile +11 -6
- data/bin/colorize_env_vars.sh +7 -0
- data/bin/tab_completion.sh +19 -19
- data/examples/duplicate_block.md +10 -0
- data/examples/import0.md +8 -0
- data/examples/import1.md +10 -0
- data/examples/include.md +12 -0
- data/examples/infile_config.md +10 -0
- data/examples/linked1.md +28 -0
- data/examples/linked2.md +28 -0
- data/examples/opts.md +13 -0
- data/examples/pass-through.md +14 -0
- data/examples/plant.md +23 -0
- data/examples/port.md +23 -0
- data/examples/vars.md +20 -0
- data/examples/wrap.md +33 -0
- data/lib/block_types.rb +5 -0
- data/lib/cached_nested_file_reader.rb +0 -1
- data/lib/colorize.rb +37 -23
- data/lib/fcb.rb +12 -30
- data/lib/filter.rb +147 -71
- data/lib/markdown_exec/version.rb +1 -1
- data/lib/markdown_exec.rb +523 -235
- data/lib/mdoc.rb +190 -58
- data/lib/menu.src.yml +323 -257
- data/lib/menu.yml +324 -258
- metadata +17 -6
- data/lib/env_opts.rb +0 -242
- data/lib/markdown_block_manager.rb +0 -195
- data/lib/menu_options.rb +0 -0
- data/lib/menu_options.yml +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8fb58efae22bb345c1c1a863aa9dbf62bd6682cda0154d15d8e114cdf1b8ae64
|
4
|
+
data.tar.gz: eb0f7696597c1c53fc529e0a538e0ca9b2b684418242605574d01c449a47bf67
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0520a2e9c8c224e511821e362c189aa648f1f76a2e72876d1d87132d7f76f3ecbf2e84adbb6c4852d07b44aa52ddb08b40cd5f913dbd6540cf459794762b682f
|
7
|
+
data.tar.gz: 8acbbc2f5bde35a2e41b9852951349ff5ee5bd561c42a283675d25d6edc8d915540ea33de8cc48f72e92692ce31edff8b33a1583e3d8a983f8c28b01e82799f9
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,56 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## [1.3.9] - 2023-10-29
|
4
|
+
|
5
|
+
Add block types for linking and variable control
|
6
|
+
|
7
|
+
Rename options to match use.
|
8
|
+
|
9
|
+
### Added
|
10
|
+
|
11
|
+
- Pass-through arguments after "--" to the executed script.
|
12
|
+
See document `examples/pass-through.md`.
|
13
|
+
|
14
|
+
- Add RGB color specification to basic ANSI color names.
|
15
|
+
Foreground R, G, and B values are encoded in the name "fg_rgb_R_G_B" with their decimal values.
|
16
|
+
e.g. red = "fg_rgb_255_0_0"
|
17
|
+
e.g. green = "fg_rgb_0_255_0"
|
18
|
+
e.g. blue = "fg_rgb_0_0_255"
|
19
|
+
|
20
|
+
- Add a "link" fenced code block type as a menu choice to load a different document.
|
21
|
+
The `link` block can specify:
|
22
|
+
- environment variables and values to set prior to loading the document,
|
23
|
+
- a block name to execute in the loaded document.
|
24
|
+
In the resulting menu, an automatic option (Back) allows the user to return to the original document.
|
25
|
+
See documents `examples/linked1.md`, `examples/linked2.md`.
|
26
|
+
|
27
|
+
- Add an "opts" fenced code block type as a menu choice to set current MDE options.
|
28
|
+
See document `examples/opts.md`.
|
29
|
+
|
30
|
+
- Add a "vars" fenced code block type as a menu choice to set current environment variables.
|
31
|
+
See document `examples/vars.md`.
|
32
|
+
These blocks can be hidden blocks and required in a script.
|
33
|
+
|
34
|
+
- Add a "wrap" fenced code block type to facilitate script generation.
|
35
|
+
See document `examples/wrap.md`.
|
36
|
+
These blocks are hidden and can be required by one or more blocks.
|
37
|
+
|
38
|
+
### Changed
|
39
|
+
|
40
|
+
- Rename RegExp options to match use.
|
41
|
+
|
42
|
+
## [1.3.8] - 2023-10-20
|
43
|
+
|
44
|
+
### Added
|
45
|
+
|
46
|
+
- Options for hidden, included, and wrapped blocks
|
47
|
+
|
48
|
+
## [1.3.7] - 2023-10-16
|
49
|
+
|
50
|
+
### Changed
|
51
|
+
|
52
|
+
- Fix invocation of SavedAsset class
|
53
|
+
|
3
54
|
## [1.3.6] - 2023-10-15
|
4
55
|
|
5
56
|
### Added
|
@@ -218,8 +269,8 @@ e.g. `MDE_OUTPUT_VIEWER_OPTIONS="-a '/Applications/Sublime Text.app'" mde --sele
|
|
218
269
|
| block_name_hidden_match | MDE_BLOCK_NAME_HIDDEN_MATCH | `^\(.+\)$` |
|
219
270
|
| block_name_match | MDE_BLOCK_NAME_MATCH | `:(?<title>\S+)( \|$)` |
|
220
271
|
| block_required_scan | MDE_BLOCK_REQUIRED_SCAN | `\+\S+` |
|
221
|
-
|
|
222
|
-
|
|
272
|
+
| fenced_start_and_end_regex | MDE_FENCED_START_AND_END_REGEX | ``^`{3,}`` |
|
273
|
+
| fenced_start_extended_regex | MDE_FENCED_START_EXTENDED_REGEX | ``^`{3,}(?<shell>[^`\s]*) *(?<name>.*)$`` |
|
223
274
|
| heading1_match | MDE_HEADING1_MATCH | `^# *(?<name>[^#]*?) *$` |
|
224
275
|
| heading2_match | MDE_HEADING2_MATCH | `^## *(?<name>[^#]*?) *$` |
|
225
276
|
| heading3_match | MDE_HEADING3_MATCH | `^### *(?<name>.+?) *$` |
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
markdown_exec (1.3.
|
4
|
+
markdown_exec (1.3.9)
|
5
5
|
clipboard (~> 1.3.6)
|
6
6
|
open3 (~> 0.1.1)
|
7
7
|
optparse (~> 0.1.1)
|
@@ -54,6 +54,8 @@ GEM
|
|
54
54
|
nokogiri (>= 1.12.0)
|
55
55
|
method_source (1.0.0)
|
56
56
|
minitest (5.20.0)
|
57
|
+
mocha (2.1.0)
|
58
|
+
ruby2_keywords (>= 0.0.5)
|
57
59
|
nokogiri (1.15.4-arm64-darwin)
|
58
60
|
racc (~> 1.4)
|
59
61
|
open3 (0.1.2)
|
@@ -138,6 +140,7 @@ GEM
|
|
138
140
|
rubocop-capybara (~> 2.17)
|
139
141
|
rubocop-factory_bot (~> 2.22)
|
140
142
|
ruby-progressbar (1.13.0)
|
143
|
+
ruby2_keywords (0.0.5)
|
141
144
|
shellwords (0.1.0)
|
142
145
|
thor (1.2.2)
|
143
146
|
tty-color (0.6.0)
|
@@ -166,6 +169,7 @@ DEPENDENCIES
|
|
166
169
|
erb
|
167
170
|
markdown_exec!
|
168
171
|
minitest
|
172
|
+
mocha
|
169
173
|
pry-nav
|
170
174
|
pry-stack_explorer
|
171
175
|
railties
|
data/Rakefile
CHANGED
@@ -81,6 +81,7 @@ task :minitest do
|
|
81
81
|
'./lib/cached_nested_file_reader.rb',
|
82
82
|
'./lib/fcb.rb',
|
83
83
|
'./lib/filter.rb',
|
84
|
+
'./lib/markdown_exec.rb',
|
84
85
|
'./lib/mdoc.rb',
|
85
86
|
'./lib/object_present.rb',
|
86
87
|
'./lib/option_value.rb',
|
@@ -90,12 +91,10 @@ task :minitest do
|
|
90
91
|
]
|
91
92
|
|
92
93
|
commands.each do |command|
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
exit 1
|
98
|
-
end
|
94
|
+
raise "Failed: #{command}" unless system("bundle exec ruby #{command}")
|
95
|
+
rescue StandardError => err
|
96
|
+
puts "Error: #{err.message}"
|
97
|
+
exit 1
|
99
98
|
end
|
100
99
|
end
|
101
100
|
|
@@ -104,6 +103,12 @@ task :reek do
|
|
104
103
|
`reek --config .reek .`
|
105
104
|
end
|
106
105
|
|
106
|
+
desc 'test'
|
107
|
+
task :test do
|
108
|
+
Rake::Task['minitest'].execute
|
109
|
+
system 'bundle exec rspec'
|
110
|
+
end
|
111
|
+
|
107
112
|
private
|
108
113
|
|
109
114
|
# write menu.yml
|
data/bin/tab_completion.sh
CHANGED
@@ -13,7 +13,7 @@ __filedirs_all()
|
|
13
13
|
}
|
14
14
|
|
15
15
|
_mde_echo_version() {
|
16
|
-
echo "1.3.
|
16
|
+
echo "1.3.9"
|
17
17
|
}
|
18
18
|
|
19
19
|
_mde() {
|
@@ -40,14 +40,6 @@ _mde() {
|
|
40
40
|
|
41
41
|
-f) COMPREPLY="."; return 0 ;;
|
42
42
|
|
43
|
-
--path) COMPREPLY="."; return 0 ;;
|
44
|
-
|
45
|
-
-p) COMPREPLY="."; return 0 ;;
|
46
|
-
|
47
|
-
--user-must-approve) COMPREPLY="1"; return 0 ;;
|
48
|
-
|
49
|
-
-q) COMPREPLY="1"; return 0 ;;
|
50
|
-
|
51
43
|
--list-count) COMPREPLY="32"; return 0 ;;
|
52
44
|
|
53
45
|
--output-execution-summary) COMPREPLY="0"; return 0 ;;
|
@@ -56,6 +48,10 @@ _mde() {
|
|
56
48
|
|
57
49
|
--output-stdout) COMPREPLY="1"; return 0 ;;
|
58
50
|
|
51
|
+
--path) COMPREPLY="."; return 0 ;;
|
52
|
+
|
53
|
+
-p) COMPREPLY="."; return 0 ;;
|
54
|
+
|
59
55
|
--save-executed-script) COMPREPLY="0"; return 0 ;;
|
60
56
|
|
61
57
|
--save-execution-output) COMPREPLY="0"; return 0 ;;
|
@@ -64,6 +60,10 @@ _mde() {
|
|
64
60
|
|
65
61
|
--saved-stdout-folder) COMPREPLY="logs"; return 0 ;;
|
66
62
|
|
63
|
+
--user-must-approve) COMPREPLY="1"; return 0 ;;
|
64
|
+
|
65
|
+
-q) COMPREPLY="1"; return 0 ;;
|
66
|
+
|
67
67
|
--display-level) COMPREPLY="1"; return 0 ;;
|
68
68
|
|
69
69
|
esac
|
@@ -74,7 +74,7 @@ _mde() {
|
|
74
74
|
# present matching option names
|
75
75
|
#
|
76
76
|
if [[ ${cur} == -* ]] ; then
|
77
|
-
opts=("--block-name" "--config" "--debug" "--
|
77
|
+
opts=("--block-name" "--config" "--debug" "--exit" "--filename" "--help" "--list-blocks" "--list-count" "--list-default-env" "--list-default-yaml" "--list-docs" "--list-recent-output" "--list-recent-scripts" "--output-execution-summary" "--output-script" "--output-stdout" "--path" "--pwd" "--run-last-script" "--save-executed-script" "--save-execution-output" "--saved-script-folder" "--saved-stdout-folder" "--select-recent-output" "--select-recent-script" "--tab-completions" "--user-must-approve" "--version" "--display-level")
|
78
78
|
COMPREPLY=( $(compgen -W "$(printf "'%s' " "${opts[@]}")" -- "${cur}") )
|
79
79
|
|
80
80
|
return 0
|
@@ -101,14 +101,6 @@ _mde() {
|
|
101
101
|
|
102
102
|
-f) COMPREPLY=".RELATIVE_PATH."; return 0 ;;
|
103
103
|
|
104
|
-
--path) COMPREPLY=".RELATIVE_PATH."; return 0 ;;
|
105
|
-
|
106
|
-
-p) COMPREPLY=".RELATIVE_PATH."; return 0 ;;
|
107
|
-
|
108
|
-
--user-must-approve) COMPREPLY=".BOOL."; return 0 ;;
|
109
|
-
|
110
|
-
-q) COMPREPLY=".BOOL."; return 0 ;;
|
111
|
-
|
112
104
|
--list-count) COMPREPLY=".INT.1-."; return 0 ;;
|
113
105
|
|
114
106
|
--output-execution-summary) COMPREPLY=".BOOL."; return 0 ;;
|
@@ -117,6 +109,10 @@ _mde() {
|
|
117
109
|
|
118
110
|
--output-stdout) COMPREPLY=".BOOL."; return 0 ;;
|
119
111
|
|
112
|
+
--path) COMPREPLY=".RELATIVE_PATH."; return 0 ;;
|
113
|
+
|
114
|
+
-p) COMPREPLY=".RELATIVE_PATH."; return 0 ;;
|
115
|
+
|
120
116
|
--save-executed-script) COMPREPLY=".BOOL."; return 0 ;;
|
121
117
|
|
122
118
|
--save-execution-output) COMPREPLY=".BOOL."; return 0 ;;
|
@@ -125,6 +121,10 @@ _mde() {
|
|
125
121
|
|
126
122
|
--saved-stdout-folder) COMPREPLY=".RELATIVE_PATH."; return 0 ;;
|
127
123
|
|
124
|
+
--user-must-approve) COMPREPLY=".BOOL."; return 0 ;;
|
125
|
+
|
126
|
+
-q) COMPREPLY=".BOOL."; return 0 ;;
|
127
|
+
|
128
128
|
--display-level) COMPREPLY=".INT.0-3."; return 0 ;;
|
129
129
|
|
130
130
|
esac
|
@@ -138,4 +138,4 @@ _mde() {
|
|
138
138
|
|
139
139
|
complete -o filenames -o nospace -F _mde mde
|
140
140
|
# _mde_echo_version
|
141
|
-
# echo "Updated: 2023-10-
|
141
|
+
# echo "Updated: 2023-10-29 19:38:35 UTC"
|
data/examples/import0.md
ADDED
data/examples/import1.md
ADDED
data/examples/include.md
ADDED
data/examples/linked1.md
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
# Demo document linking
|
2
|
+
|
3
|
+
::: * This is document 1 *
|
4
|
+
::: This document links to a matching document to demonstrate navigation between documents.
|
5
|
+
|
6
|
+
::: This Bash block displays the value of variables "linked1var" and "linked2var"
|
7
|
+
|
8
|
+
```bash :page1_show_vars
|
9
|
+
source bin/colorize_env_vars.sh
|
10
|
+
colorize_env_vars 'on page1' linked1var linked2var
|
11
|
+
```
|
12
|
+
|
13
|
+
::: This Link block sets variable "linked2var" and navigates to document 2.
|
14
|
+
|
15
|
+
```link :linked2
|
16
|
+
file: examples/linked2.md
|
17
|
+
vars:
|
18
|
+
linked2var: from_linked1
|
19
|
+
```
|
20
|
+
|
21
|
+
::: This Link block sets variable "linked2var", navigates to document 2, and executes block "page2_show_vars".
|
22
|
+
|
23
|
+
```link :linked2_show_vars
|
24
|
+
file: examples/linked2.md
|
25
|
+
block: page2_show_vars
|
26
|
+
vars:
|
27
|
+
linked2var: from_linked1
|
28
|
+
```
|
data/examples/linked2.md
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
# Demo document linking
|
2
|
+
|
3
|
+
::: * This is document 2 *
|
4
|
+
::: This document links to a matching document to demonstrate navigation between documents.
|
5
|
+
|
6
|
+
::: This Bash block displays the value of variables "linked1var" and "linked2var"
|
7
|
+
|
8
|
+
```bash :page2_show_vars
|
9
|
+
source bin/colorize_env_vars.sh
|
10
|
+
colorize_env_vars 'on page2' linked1var linked2var
|
11
|
+
```
|
12
|
+
|
13
|
+
::: This Link block sets variable "linked1var" and navigates to document 1.
|
14
|
+
|
15
|
+
```link :linked1
|
16
|
+
file: examples/linked1.md
|
17
|
+
vars:
|
18
|
+
linked1var: from_linked2
|
19
|
+
```
|
20
|
+
|
21
|
+
::: This Link block sets variable "linked1var", navigates to document 1, and executes block "page1_show_vars".
|
22
|
+
|
23
|
+
```link :linked1_show_vars
|
24
|
+
file: examples/linked1.md
|
25
|
+
block: page1_show_vars
|
26
|
+
vars:
|
27
|
+
linked1var: from_linked2
|
28
|
+
```
|
data/examples/opts.md
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
# Demo configuring options
|
2
|
+
|
3
|
+
::: These Opts blocks set the color of a couple of menu options to demonstrate the live update of options.
|
4
|
+
|
5
|
+
```opts :opts1
|
6
|
+
menu_divider_color: yellow
|
7
|
+
menu_task_color: fg_rgb_255_63_255
|
8
|
+
```
|
9
|
+
|
10
|
+
```opts :opts2
|
11
|
+
menu_divider_color: fg_rgb_255_0_255
|
12
|
+
menu_task_color: fg_rgb_127_127_255
|
13
|
+
```
|
@@ -0,0 +1,14 @@
|
|
1
|
+
Pass-through arguments after "--" to the executed script.
|
2
|
+
|
3
|
+
A block can expect arguments to receive all arguments to MDE after "--".
|
4
|
+
|
5
|
+
For `mde examples/pass-through.md output_arguments -- 123`,
|
6
|
+
this block outputs:
|
7
|
+
|
8
|
+
ARGS: 123
|
9
|
+
|
10
|
+
::: This block will output any arguments after "--" in the command line.
|
11
|
+
|
12
|
+
```bash :output_arguments
|
13
|
+
echo "ARGS: $*"
|
14
|
+
```
|
data/examples/plant.md
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
::: Nourish
|
2
|
+
|
3
|
+
[ ] Observe soil moisture level
|
4
|
+
|
5
|
+
```bash :Watering_the_plant
|
6
|
+
echo glug glug glug
|
7
|
+
```
|
8
|
+
|
9
|
+
::: Maintain
|
10
|
+
|
11
|
+
[ ] Observe leaf color and health
|
12
|
+
|
13
|
+
```bash :Trimming_dead_or_yellowing_leaves
|
14
|
+
echo snip snip
|
15
|
+
```
|
16
|
+
|
17
|
+
::: Release
|
18
|
+
|
19
|
+
[ ] Observe flowering and fruiting patterns
|
20
|
+
|
21
|
+
```bash :Repotting_when_necessary
|
22
|
+
echo farewell
|
23
|
+
```
|
data/examples/port.md
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# Demo variable porting
|
2
|
+
|
3
|
+
::: This block requires the Port block and displays the value.
|
4
|
+
::: The Port block contributes the variable VAULT to the generated script.
|
5
|
+
|
6
|
+
```bash :show +(vault)
|
7
|
+
: ${VAULT:=This variable has not been set.}
|
8
|
+
source bin/colorize_env_vars.sh
|
9
|
+
colorize_env_vars '' VAULT
|
10
|
+
```
|
11
|
+
|
12
|
+
::: Set the VAULT value in memory.
|
13
|
+
::: Call this block prior to `show` to demonstrate in-memory value being written to script.
|
14
|
+
|
15
|
+
```vars :set
|
16
|
+
VAULT: This variable was set by the "set" block.
|
17
|
+
```
|
18
|
+
|
19
|
+
::: There is an invisible Port block that saves current/live environment variable values into the generated script.
|
20
|
+
|
21
|
+
```port :(vault)
|
22
|
+
VAULT
|
23
|
+
```
|
data/examples/vars.md
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
```bash :(defaults)
|
2
|
+
: ${VAULT:=default}
|
3
|
+
```
|
4
|
+
```bash :show_vars +(defaults)
|
5
|
+
source bin/colorize_env_vars.sh
|
6
|
+
colorize_env_vars '' VAULT
|
7
|
+
```
|
8
|
+
```vars :set
|
9
|
+
VAULT: 11
|
10
|
+
```
|
11
|
+
```vars :set_with_show +show_vars
|
12
|
+
VAULT: 22
|
13
|
+
```
|
14
|
+
```bash :(hidden)
|
15
|
+
colorize_env_vars '' NOTHING
|
16
|
+
```
|
17
|
+
```bash :show_with_set +set
|
18
|
+
source bin/colorize_env_vars.sh
|
19
|
+
colorize_env_vars '' VAULT
|
20
|
+
```
|
data/examples/wrap.md
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
# Demo block wrapping
|
2
|
+
|
3
|
+
::: This block is wrapped by the `{outer*}` pair of blocks.
|
4
|
+
|
5
|
+
```bash :single +{outer}
|
6
|
+
echo single body - wrapped by outer
|
7
|
+
```
|
8
|
+
|
9
|
+
::: This block is wrapped first by the `{outer*}` pair of blocks
|
10
|
+
::: and nested inside, the `{inner*}` pair of blocks.
|
11
|
+
|
12
|
+
```bash :nested +{outer} +{inner}
|
13
|
+
echo nested body - wrapped by outer and then inner
|
14
|
+
```
|
15
|
+
|
16
|
+
::: This pair of hidden blocks are the `{inner*}` set.
|
17
|
+
```bash :{inner}
|
18
|
+
echo inner-before
|
19
|
+
```
|
20
|
+
|
21
|
+
```bash :{inner-after}
|
22
|
+
echo inner-after
|
23
|
+
```
|
24
|
+
|
25
|
+
::: This pair of hidden blocks are the `{outer*}` set.
|
26
|
+
|
27
|
+
```bash :{outer}
|
28
|
+
echo outer-before
|
29
|
+
```
|
30
|
+
|
31
|
+
```bash :{outer-after}
|
32
|
+
echo outer-after
|
33
|
+
```
|
data/lib/block_types.rb
ADDED
data/lib/colorize.rb
CHANGED
@@ -2,67 +2,81 @@
|
|
2
2
|
|
3
3
|
# encoding=utf-8
|
4
4
|
|
5
|
-
# │0 │ to restore default │
|
6
|
-
# │ │ color │
|
7
|
-
# ├───┼───────────────────────┤
|
8
|
-
# │ │ │
|
9
|
-
# │1 │ for brighter colors │
|
10
|
-
# ├───┼───────────────────────┤
|
11
|
-
# │ │ │
|
12
|
-
# │4 │ for underlined text │
|
13
|
-
# ├───┼───────────────────────┤
|
14
|
-
# │ │ │
|
15
|
-
# │5 │ for flashing text
|
16
5
|
class String
|
6
|
+
alias_method :original_method_missing, :method_missing
|
7
|
+
|
8
|
+
def method_missing(method_name, *args, &block)
|
9
|
+
if /^fg_rgb_/ =~ method_name.to_s
|
10
|
+
fg_rgb_color($'.gsub('_', ';'))
|
11
|
+
else
|
12
|
+
original_method_missing(method_name, *args, &block)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
# control sequence with reset
|
17
|
+
#
|
18
|
+
def ansi_control_sequence
|
19
|
+
"\033[#{self}\033[0m"
|
20
|
+
end
|
21
|
+
|
22
|
+
# use 24-bit RGB foreground color spec
|
23
|
+
# ex: 1;2;3
|
24
|
+
#
|
25
|
+
def fg_rgb_color(rgb)
|
26
|
+
"38;2;#{rgb}m#{self}".ansi_control_sequence
|
27
|
+
end
|
28
|
+
|
17
29
|
def plain
|
18
30
|
self
|
19
31
|
end
|
20
32
|
|
33
|
+
# named colors
|
34
|
+
#
|
21
35
|
def black
|
22
|
-
"
|
36
|
+
"30m#{self}".ansi_control_sequence
|
23
37
|
end
|
24
38
|
|
25
39
|
def red
|
26
|
-
"
|
40
|
+
"31m#{self}".ansi_control_sequence
|
27
41
|
end
|
28
42
|
|
29
43
|
def bred
|
30
|
-
"
|
44
|
+
"1;31m#{self}".ansi_control_sequence
|
31
45
|
end
|
32
46
|
|
33
47
|
def green
|
34
|
-
"
|
48
|
+
"32m#{self}".ansi_control_sequence
|
35
49
|
end
|
36
50
|
|
37
51
|
def bgreen
|
38
|
-
"
|
52
|
+
"1;32m#{self}".ansi_control_sequence
|
39
53
|
end
|
40
54
|
|
41
55
|
def yellow
|
42
|
-
"
|
56
|
+
"33m#{self}".ansi_control_sequence
|
43
57
|
end
|
44
58
|
|
45
59
|
def byellow
|
46
|
-
"
|
60
|
+
"1;33m#{self}".ansi_control_sequence
|
47
61
|
end
|
48
62
|
|
49
63
|
def blue
|
50
|
-
"
|
64
|
+
"34m#{self}".ansi_control_sequence
|
51
65
|
end
|
52
66
|
|
53
67
|
def magenta
|
54
|
-
"
|
68
|
+
"35m#{self}".ansi_control_sequence
|
55
69
|
end
|
56
70
|
|
57
71
|
def cyan
|
58
|
-
"
|
72
|
+
"36m#{self}".ansi_control_sequence
|
59
73
|
end
|
60
74
|
|
61
75
|
def white
|
62
|
-
"
|
76
|
+
"37m#{self}".ansi_control_sequence
|
63
77
|
end
|
64
78
|
|
65
79
|
def bwhite
|
66
|
-
"
|
80
|
+
"1;37m#{self}".ansi_control_sequence
|
67
81
|
end
|
68
82
|
end
|