just-ansi 0.1.1

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: f93be0e88f2c592c08f145ee09ac614745333ecd14b9a9bb024c50adf3b2d549
4
+ data.tar.gz: daa92f7cb65f9ba56c5991ad2876f7aa4cc2738532dce52cf69ef25432a81275
5
+ SHA512:
6
+ metadata.gz: 11c986e236eff5ef0ce7d815c39341dddb6050f8deec3e50df7a48fb45595d7ab722daa44c5b03d907e31332611fbe3099b05fd3c338c485bd54c00eb9713b31
7
+ data.tar.gz: d910ca7ac0374a2ab2237aa139e1e3cd5e1f29bfbf429ea6e65c7684d5d8932405f86ad5d8096961d59d7aa2bfccff8ac3215912681229b29507dfc502127e54
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Mike Blumtritt
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 ADDED
@@ -0,0 +1,29 @@
1
+ # JustAnsi
2
+
3
+ ![version](https://img.shields.io/gem/v/just-ansi?label=)
4
+
5
+ Simple and fast ANSI control code processing.
6
+
7
+ - Gem: [rubygems.org](https://rubygems.org/gems/just-ansi)
8
+ - Source: [github.com](https://github.com/mblumtritt/just-ansi)
9
+ - Help: [rubydoc.info](https://rubydoc.info/gems/just-ansi/JustAnsi)
10
+
11
+ ## Installation
12
+
13
+ You can install the gem in your system with
14
+
15
+ ```shell
16
+ gem install just-ansi
17
+ ```
18
+
19
+ or you can use [Bundler](http://gembundler.com/) to add JustAnsi to your own project:
20
+
21
+ ```shell
22
+ bundle add just-ansi
23
+ ```
24
+
25
+ After that you only need one line of code to have everything together
26
+
27
+ ```ruby
28
+ require 'just-ansi'
29
+ ```
@@ -0,0 +1,206 @@
1
+ # frozen_string_literal: true
2
+ # shareable_constant_value: literal
3
+
4
+ module JustAnsi
5
+ ATTRIBUTES = {
6
+ '/b' => '22',
7
+ '/blink' => '25',
8
+ '/bold' => '22',
9
+ '/conceal' => '28',
10
+ '/cu' => '4:0',
11
+ '/curly_underline' => '4:0',
12
+ '/dashed_underline' => '4:0',
13
+ '/dau' => '4:0',
14
+ '/dim' => '22',
15
+ '/dotted_underline' => '4:0',
16
+ '/dou' => '4:0',
17
+ '/double_underline' => '24',
18
+ '/encircled' => '54',
19
+ '/faint' => '22',
20
+ '/fraktur' => '23',
21
+ '/framed' => '54',
22
+ '/h' => '28',
23
+ '/hide' => '28',
24
+ '/i' => '23',
25
+ '/inv' => '27',
26
+ '/invert' => '27',
27
+ '/italic' => '23',
28
+ '/overlined' => '55',
29
+ '/ovr' => '55',
30
+ '/proportional' => '50',
31
+ '/slow_blink' => '25',
32
+ '/spacing' => '50',
33
+ '/strike' => '29',
34
+ '/sub' => '75',
35
+ '/subscript' => '75',
36
+ '/sup' => '75',
37
+ '/superscript' => '75',
38
+ '/u' => '24',
39
+ '/underline' => '24',
40
+ '/uu' => '24',
41
+ 'b' => '1',
42
+ 'blink' => '5',
43
+ 'blink_off' => '25',
44
+ 'bold' => '1',
45
+ 'bold_off' => '22',
46
+ 'conceal' => '8',
47
+ 'cu' => '4:3',
48
+ 'curly_underline' => '4:3',
49
+ 'curly_underline_off' => '4:0',
50
+ 'dashed_underline' => '4:5',
51
+ 'dashed_underline_off' => '4:0',
52
+ 'dau' => '4:5',
53
+ 'default_font' => '10',
54
+ 'dim' => '2',
55
+ 'dotted_underline' => '4:4',
56
+ 'dotted_underline_off' => '4:0',
57
+ 'dou' => '4:4',
58
+ 'double_underline' => '21',
59
+ 'double_underline_off' => '24',
60
+ 'encircled' => '52',
61
+ 'encircled_off' => '54',
62
+ 'faint' => '2',
63
+ 'faint_off' => '22',
64
+ 'font1' => '11',
65
+ 'font2' => '12',
66
+ 'font3' => '13',
67
+ 'font4' => '14',
68
+ 'font5' => '15',
69
+ 'font6' => '16',
70
+ 'font7' => '17',
71
+ 'font8' => '18',
72
+ 'font9' => '19',
73
+ 'fraktur' => '20',
74
+ 'fraktur_off' => '23',
75
+ 'framed' => '51',
76
+ 'framed_off' => '54',
77
+ 'h' => '8',
78
+ 'hide' => '8',
79
+ 'hide_off' => '28',
80
+ 'i' => '3',
81
+ 'inv' => '7',
82
+ 'invert' => '7',
83
+ 'invert_off' => '27',
84
+ 'italic' => '3',
85
+ 'italic_off' => '23',
86
+ 'overlined' => '53',
87
+ 'overlined_off' => '55',
88
+ 'ovr' => '53',
89
+ 'primary_font' => '10',
90
+ 'proportional' => '26',
91
+ 'proportional_off' => '50',
92
+ 'rapid_blink' => '6',
93
+ 'reset' => '',
94
+ 'reveal' => '28',
95
+ 'slow_blink' => '5',
96
+ 'spacing' => '26',
97
+ 'strike' => '9',
98
+ 'strike_off' => '29',
99
+ 'sub' => '74',
100
+ 'subscript' => '74',
101
+ 'subscript_off' => '75',
102
+ 'sup' => '73',
103
+ 'superscript' => '73',
104
+ 'superscript_off' => '75',
105
+ 'u' => '4',
106
+ 'underline' => '4',
107
+ 'underline_off' => '24',
108
+ 'uu' => '21'
109
+ }.freeze
110
+
111
+ COLORS = {
112
+ '/bg' => '49',
113
+ '/fg' => '39',
114
+ '/ul' => '59',
115
+ 'bg_black' => '40',
116
+ 'bg_blue' => '44',
117
+ 'bg_bright_black' => '100',
118
+ 'bg_bright_blue' => '104',
119
+ 'bg_bright_cyan' => '106',
120
+ 'bg_bright_green' => '102',
121
+ 'bg_bright_magenta' => '105',
122
+ 'bg_bright_red' => '101',
123
+ 'bg_bright_white' => '107',
124
+ 'bg_bright_yellow' => '103',
125
+ 'bg_cyan' => '46',
126
+ 'bg_default' => '49',
127
+ 'bg_green' => '42',
128
+ 'bg_magenta' => '45',
129
+ 'bg_red' => '41',
130
+ 'bg_white' => '47',
131
+ 'bg_yellow' => '43',
132
+ 'black' => '30',
133
+ 'blue' => '34',
134
+ 'bright_black' => '90',
135
+ 'bright_blue' => '94',
136
+ 'bright_cyan' => '96',
137
+ 'bright_green' => '92',
138
+ 'bright_magenta' => '95',
139
+ 'bright_red' => '91',
140
+ 'bright_white' => '97',
141
+ 'bright_yellow' => '93',
142
+ 'cyan' => '36',
143
+ 'default' => '39',
144
+ 'fg_black' => '30',
145
+ 'fg_blue' => '34',
146
+ 'fg_bright_black' => '90',
147
+ 'fg_bright_blue' => '94',
148
+ 'fg_bright_cyan' => '96',
149
+ 'fg_bright_green' => '92',
150
+ 'fg_bright_magenta' => '95',
151
+ 'fg_bright_red' => '91',
152
+ 'fg_bright_white' => '97',
153
+ 'fg_bright_yellow' => '93',
154
+ 'fg_cyan' => '36',
155
+ 'fg_default' => '39',
156
+ 'fg_green' => '32',
157
+ 'fg_magenta' => '35',
158
+ 'fg_red' => '31',
159
+ 'fg_white' => '37',
160
+ 'fg_yellow' => '33',
161
+ 'green' => '32',
162
+ 'magenta' => '35',
163
+ 'on_black' => '40',
164
+ 'on_blue' => '44',
165
+ 'on_bright_black' => '100',
166
+ 'on_bright_blue' => '104',
167
+ 'on_bright_cyan' => '106',
168
+ 'on_bright_green' => '102',
169
+ 'on_bright_magenta' => '105',
170
+ 'on_bright_red' => '101',
171
+ 'on_bright_white' => '107',
172
+ 'on_bright_yellow' => '103',
173
+ 'on_cyan' => '46',
174
+ 'on_default' => '49',
175
+ 'on_green' => '42',
176
+ 'on_magenta' => '45',
177
+ 'on_red' => '41',
178
+ 'on_white' => '47',
179
+ 'on_yellow' => '43',
180
+ 'red' => '31',
181
+ 'ul_black' => '58;2;0;0;0',
182
+ 'ul_blue' => '58;2;0;0;128',
183
+ 'ul_bright_black' => '58;2;64;64;64',
184
+ 'ul_bright_blue' => '58;2;0;0;255',
185
+ 'ul_bright_cyan' => '58;2;0;255;255',
186
+ 'ul_bright_green' => '58;2;0;255;0',
187
+ 'ul_bright_magenta' => '58;2;255;0;255',
188
+ 'ul_bright_red' => '58;2;255;0;0',
189
+ 'ul_bright_white' => '58;2;255;255;255',
190
+ 'ul_bright_yellow' => '58;2;255;255;0',
191
+ 'ul_cyan' => '58;2;0;128;128',
192
+ 'ul_default' => '59',
193
+ 'ul_green' => '58;2;0;128;0',
194
+ 'ul_magenta' => '58;2;128;0;128',
195
+ 'ul_red' => '58;2;128;0;0',
196
+ 'ul_white' => '58;2;128;128;128',
197
+ 'ul_yellow' => '58;2;128;128;0',
198
+ 'white' => '37',
199
+ 'yellow' => '33'
200
+ }.freeze
201
+
202
+ ATTRIBUTES_S = ATTRIBUTES.transform_keys(&:to_sym).compare_by_identity.freeze
203
+ COLORS_S = COLORS.transform_keys(&:to_sym).compare_by_identity.freeze
204
+
205
+ private_constant :ATTRIBUTES, :COLORS, :ATTRIBUTES_S, :COLORS_S
206
+ end