customization 1.0.4 → 1.0.5.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/customization.rb +78 -9
- data/lib/errors.rb +3 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6203c142d1b9336bb8f4371a27af573ae7e9fbe320493e2fac4a87782048d4c5
|
4
|
+
data.tar.gz: 0434405ba7ce39c6911ecf7afe57185bd56d849b69595fbd33e95b391e266c78
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4359f089a693d6add215244a5de33820c23ed53e94266bcbb06ee2d0274e3f0b811c8db999e5ea82aaef8aa88f92ab3f2c478a7397ec8e83875543ec5aba58ed
|
7
|
+
data.tar.gz: 9ea8a3dc0f90d2fe24ce742a1d9da67b35979f7356ba07788d36a7abf8a74ca60826123a8c7abfe023c10606d64e1f1abdcb3750f9c9eb60f9339b9e832090a1
|
data/lib/customization.rb
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
module Customization
|
4
4
|
COLORS = {
|
5
|
+
# Basic colors
|
5
6
|
black: "\e[30m",
|
6
7
|
red: "\e[31m",
|
7
8
|
green: "\e[32m",
|
@@ -10,6 +11,7 @@ module Customization
|
|
10
11
|
magenta: "\e[35m",
|
11
12
|
cyan: "\e[36m",
|
12
13
|
white: "\e[37m",
|
14
|
+
# Bright colors
|
13
15
|
bright_black: "\e[90m",
|
14
16
|
bright_red: "\e[91m",
|
15
17
|
bright_green: "\e[92m",
|
@@ -19,6 +21,7 @@ module Customization
|
|
19
21
|
bright_cyan: "\e[96m",
|
20
22
|
bright_white: "\e[97m",
|
21
23
|
gray: "\e[38;5;236m",
|
24
|
+
# Light colors
|
22
25
|
light_red: "\e[38;5;196m",
|
23
26
|
light_green: "\e[38;5;118m",
|
24
27
|
light_yellow: "\e[38;5;226m",
|
@@ -27,6 +30,7 @@ module Customization
|
|
27
30
|
light_cyan: "\e[38;5;87m",
|
28
31
|
light_gray: "\e[38;5;248m",
|
29
32
|
dark_gray: "\e[38;5;235m",
|
33
|
+
# Other colors
|
30
34
|
purple: "\e[38;5;141m",
|
31
35
|
orange: "\e[38;5;208m",
|
32
36
|
pink: "\e[38;5;200m",
|
@@ -176,6 +180,12 @@ module Customization
|
|
176
180
|
stars: "\u272D" * 30, # Stars border
|
177
181
|
arrows: "\u2192" * 30, # Arrows border
|
178
182
|
double_line: "\u2551" * 30, # Double vertical line
|
183
|
+
wavy_line: "\u2233" * 30, # Wavy horizontal line
|
184
|
+
thin_dotted: "\u2024" * 30, # Thin dotted border
|
185
|
+
fancy: "\u2730" * 30, # A fancy star border
|
186
|
+
dotted_circle: "\u25E6" * 30, # Dotted circle border
|
187
|
+
squiggly: "\u2E15" * 30, # Squiggly line border
|
188
|
+
checkered: "\u25A2" * 30, # Checkered border
|
179
189
|
}.freeze
|
180
190
|
|
181
191
|
TEXT_EFFECTS = {
|
@@ -184,6 +194,22 @@ module Customization
|
|
184
194
|
opacity: "\e[30;40m", # Adjust text opacity (foreground and background colors)
|
185
195
|
}.freeze
|
186
196
|
|
197
|
+
## FLAGS
|
198
|
+
|
199
|
+
@space = 1
|
200
|
+
|
201
|
+
class << self
|
202
|
+
attr_accessor :space
|
203
|
+
end
|
204
|
+
|
205
|
+
@stop_animations = false
|
206
|
+
|
207
|
+
class << self
|
208
|
+
attr_accessor :stop_animations
|
209
|
+
end
|
210
|
+
|
211
|
+
## END FLAGS
|
212
|
+
|
187
213
|
def self.color_text(text, color)
|
188
214
|
unless COLORS.key?(color)
|
189
215
|
raise InvalidColorError.new(color)
|
@@ -204,6 +230,14 @@ module Customization
|
|
204
230
|
text.gsub(/\e\[\d+(;\d+)*m/, '').length
|
205
231
|
end
|
206
232
|
|
233
|
+
def self.upcase(text)
|
234
|
+
text.upcase
|
235
|
+
end
|
236
|
+
|
237
|
+
def self.downcase(text)
|
238
|
+
text.downcase
|
239
|
+
end
|
240
|
+
|
207
241
|
def self.center_text(text, width)
|
208
242
|
padding = [(width - visible_length(text)) / 2, 0].max
|
209
243
|
' ' * padding + text + ' ' * padding
|
@@ -250,6 +284,14 @@ module Customization
|
|
250
284
|
"#{TEXT_EFFECTS[:shadow]}#{text}#{FORMATS[:reset]}"
|
251
285
|
end
|
252
286
|
|
287
|
+
def self.space
|
288
|
+
"\n" * (@space || 1) # Use a newline character, defaults to 1 if not set
|
289
|
+
end
|
290
|
+
|
291
|
+
def self.end
|
292
|
+
FORMATS[:reset] # Reset text formatting to default
|
293
|
+
end
|
294
|
+
|
253
295
|
def self.apply_blinking_effect(text)
|
254
296
|
"#{TEXT_EFFECTS[:blink]}#{text}#{FORMATS[:reset]}"
|
255
297
|
end
|
@@ -264,8 +306,8 @@ module Customization
|
|
264
306
|
print "\r#{text_with_padding[index, text_length]}"
|
265
307
|
sleep(delay)
|
266
308
|
end
|
267
|
-
|
268
|
-
end
|
309
|
+
puts "\n"
|
310
|
+
end
|
269
311
|
|
270
312
|
def self.typewriter_text(text, speed = 0.1)
|
271
313
|
# Simulate a typewriter effect with the specified speed
|
@@ -273,9 +315,30 @@ module Customization
|
|
273
315
|
print char
|
274
316
|
sleep(speed)
|
275
317
|
end
|
276
|
-
|
318
|
+
puts "\n"
|
277
319
|
end
|
278
320
|
|
321
|
+
def self.animate_text(text, speed: 1.0, delay: 0.0)
|
322
|
+
text_length = visible_length(text)
|
323
|
+
text_with_padding = " " * text_length + text + " " * text_length
|
324
|
+
delay_time = 1.0 / speed
|
325
|
+
|
326
|
+
text_with_padding.chars.each_with_index do |char, index|
|
327
|
+
break if @stop_animations
|
328
|
+
print "\r#{text_with_padding[index, text_length]}"
|
329
|
+
sleep(delay_time)
|
330
|
+
sleep(delay) if delay > 0.0
|
331
|
+
end
|
332
|
+
print "\n"
|
333
|
+
end
|
334
|
+
|
335
|
+
def self.animation_end
|
336
|
+
@stop_animations = false
|
337
|
+
end
|
338
|
+
|
339
|
+
def self.stop_animations
|
340
|
+
@stop_animations = true
|
341
|
+
end
|
279
342
|
|
280
343
|
def self.color_text(text, color, custom_code = nil)
|
281
344
|
if COLORS.key?(color)
|
@@ -309,14 +372,20 @@ module Customization
|
|
309
372
|
gradient + FORMATS[:reset]
|
310
373
|
end
|
311
374
|
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
end
|
316
|
-
|
317
|
-
"#{BORDERS[border]}#{text}#{BORDERS[border]}"
|
375
|
+
def self.set_text_border(text, border, color: :black, thickness: 1)
|
376
|
+
unless BORDERS.key?(border)
|
377
|
+
raise InvalidBorderError.new(border)
|
318
378
|
end
|
319
379
|
|
380
|
+
# Customize the border with the specified color, thickness, and style
|
381
|
+
border_code = BORDERS[border]
|
382
|
+
border_code = "#{COLORS[color]}#{border_code}" if COLORS.key?(color)
|
383
|
+
border_code = "#{border_code}\e[38;5;#{thickness}m" if thickness > 1
|
384
|
+
|
385
|
+
"#{border_code}#{text}#{BORDERS[border]}"
|
386
|
+
end
|
387
|
+
|
388
|
+
|
320
389
|
def self.text_with_shadow(text, shadow_color, blur_radius, x_offset, y_offset)
|
321
390
|
shadow = "\e[38;2;#{shadow_color[:r]};#{shadow_color[:g]};#{shadow_color[:b]};48;2;#{shadow_color[:r]};#{shadow_color[:g]};#{shadow_color[:b]}m"
|
322
391
|
"#{shadow}#{text}#{FORMATS[:reset]}"
|
data/lib/errors.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: customization
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.5.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ThatAlecs
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-10-
|
11
|
+
date: 2023-10-15 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: The Customization module is a versatile Ruby library designed to enhance
|
14
14
|
your text formatting capabilities in the terminal. This module empowers you to add
|
@@ -27,6 +27,7 @@ licenses:
|
|
27
27
|
- MIT
|
28
28
|
metadata:
|
29
29
|
documentation_uri: https://github.com/thatalecs/customization/wiki
|
30
|
+
changelog_uri: https://github.com/ThatAlecs/customization/blob/main/changelog.md
|
30
31
|
source_code_uri: https://github.com/thatalecs/customization
|
31
32
|
post_install_message:
|
32
33
|
rdoc_options: []
|