customization 1.0.3 → 1.0.5
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/lib/customization.rb +98 -6
- data/lib/errors.rb +3 -0
- metadata +7 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d381ced52ea64590919c92843fc63cca1e92642cfedfa73a7daa636678f89cff
|
4
|
+
data.tar.gz: 50356248da8fb1be0b01919b7c832b5063ed448e65bc1560c7cd83597785c9a9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8b3e869eda33eaf383dc9491815804b2144f2e81793e7d4ddb3f563585d2463c1803abe4d474a01625ad97eb9f18ee54a830efeec04e86bd3d19e71c77ca27ce
|
7
|
+
data.tar.gz: 60ffcfc9e666eafb67e374c95ff4f7b00cf0ffd7618be8145a187a42dcf799714b374309c1c12831eb91b4199edc505bb76ecd4c9d858caa3c0e53c5003def31
|
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,10 +284,62 @@ 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
|
256
298
|
|
299
|
+
def self.scroll_text(text, speed = 1)
|
300
|
+
# Simulate scrolling text with the specified speed
|
301
|
+
text_length = visible_length(text)
|
302
|
+
text_with_padding = " " * text_length + text + " " * text_length
|
303
|
+
delay = 1.0 / speed
|
304
|
+
|
305
|
+
text_with_padding.chars.each_with_index do |char, index|
|
306
|
+
print "\r#{text_with_padding[index, text_length]}"
|
307
|
+
sleep(delay)
|
308
|
+
end
|
309
|
+
puts "\n"
|
310
|
+
end
|
311
|
+
|
312
|
+
def self.typewriter_text(text, speed = 0.1)
|
313
|
+
# Simulate a typewriter effect with the specified speed
|
314
|
+
text.each_char do |char|
|
315
|
+
print char
|
316
|
+
sleep(speed)
|
317
|
+
end
|
318
|
+
puts "\n"
|
319
|
+
end
|
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
|
342
|
+
|
257
343
|
def self.color_text(text, color, custom_code = nil)
|
258
344
|
if COLORS.key?(color)
|
259
345
|
"#{COLORS[color]}#{text}#{FORMATS[:reset]}"
|
@@ -286,14 +372,20 @@ module Customization
|
|
286
372
|
gradient + FORMATS[:reset]
|
287
373
|
end
|
288
374
|
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
end
|
293
|
-
|
294
|
-
"#{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)
|
295
378
|
end
|
296
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
|
+
|
297
389
|
def self.text_with_shadow(text, shadow_color, blur_radius, x_offset, y_offset)
|
298
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"
|
299
391
|
"#{shadow}#{text}#{FORMATS[:reset]}"
|
data/lib/errors.rb
CHANGED
metadata
CHANGED
@@ -1,17 +1,20 @@
|
|
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
|
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
|
-
description: Customization is a
|
14
|
-
|
13
|
+
description: The Customization module is a versatile Ruby library designed to enhance
|
14
|
+
your text formatting capabilities in the terminal. This module empowers you to add
|
15
|
+
style, color, and effects to text, making it an excellent tool for creating visually
|
16
|
+
appealing command-line applications, generating stylish reports, or simply adding
|
17
|
+
a touch of flair to your terminal outputs.
|
15
18
|
email:
|
16
19
|
executables: []
|
17
20
|
extensions: []
|