customization 1.0.4 → 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.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/lib/customization.rb +78 -9
  3. data/lib/errors.rb +3 -0
  4. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3bc4e9ff270ea764dc80f0e1aee1d6728b041d20c759e08017ed68a1f0783d7f
4
- data.tar.gz: 02ab73dc46fdb3a0962d69af665810f1389feb0d1ff28aa818fe1068d0ff3753
3
+ metadata.gz: d381ced52ea64590919c92843fc63cca1e92642cfedfa73a7daa636678f89cff
4
+ data.tar.gz: 50356248da8fb1be0b01919b7c832b5063ed448e65bc1560c7cd83597785c9a9
5
5
  SHA512:
6
- metadata.gz: 4343a4cc9a30d1175b250c2ec981a6d6a7a42a24913af8c15941d27545a8024dba19a0428fdc5ab971b7ce837d18e434513c489688d7a348dcd9dc7426698bcd
7
- data.tar.gz: 437ace4e60afc241bc748dd4553a199a81bfba47c6ee72ac39a26d32021866020787ce84788c866d35196e851e74e6161c4b04f387396cf206123087f04692eb
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,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
- print "\n"
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
- print "\n"
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
- def self.set_text_border(text, border)
313
- unless BORDERS.key?(border)
314
- raise InvalidBorderError.new(border)
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
@@ -53,3 +53,6 @@ module Customization
53
53
  def initialize(opacity)
54
54
  super("Invalid text opacity value: #{opacity}")
55
55
  end
56
+ end
57
+ end
58
+
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
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 00:00:00.000000000 Z
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