colorize 1.0.1 → 1.0.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2440a0c4dffad361b76dc139b086a986c0cb4eb04c510e37f39cb33f86aa6448
4
- data.tar.gz: c5c8b4df8f4a4fe62b6205205dad479e40e61d6134d38ff156dcd48cdadf7402
3
+ metadata.gz: 71f8aba9c90cbf391acaabc470d94e628d66be6df312605d382cb52b09a939af
4
+ data.tar.gz: 8efeb99bf7ae768b0d6bc528048238cf0c62f4280e7237ef78163eb1fb026282
5
5
  SHA512:
6
- metadata.gz: 498e222fe9f170791b493d6367c613f7c7eeff98b14ca5726e7741fe783af2433683d79115bf6b74ff0ec956fbb2cf4ca900976dd406f451da795ebc0f778340
7
- data.tar.gz: d6b023053c3130ecab27e494c54fbd2da2b8f0756c26931a03b4c74d6f68285bbd61281e38c95c72467126835f4a0382e689705e1dcca94615f7d8450c1e6b07
6
+ metadata.gz: 2543e6215f9a15e7f8507e4c9c061aec22f3a2d3f4b4d84949c4805b912728fb9a018a6b3f65fa2aefbdbb878bc1ddc99c6a5e29f83cd8229a5df31edea68c1e
7
+ data.tar.gz: 98c4349e508062160e5a80221eb686dc6fe32ef8f2b90e438cd741c4bd5ddb8dd9c288fb8e0d556aec7a2d25e0ffc47eeee4731439430fc907e0e1d099f40430
data/CHANGELOG.md CHANGED
@@ -1,6 +1,15 @@
1
1
  # Changelog
2
2
 
3
- ## 1.0.0 / 2023-03-23
3
+ ## 1.0.3 / 2023-06-21
4
+ - fix ? ommit
5
+
6
+ ## 1.0.2 / 2023-06-21
7
+ - check if color exists when extending class
8
+
9
+ ## 1.0.1 / 2023-06-19
10
+ - fix maching of colorized strings without readline characters
11
+
12
+ ## 1.0.0 / 2023-06-19
4
13
  - add more modes
5
14
  - add aliases
6
15
  - grey and gray default aliases
@@ -13,9 +22,9 @@
13
22
  - fix gemspec bug
14
23
 
15
24
  ## 0.8.0 / 2016-06-27
16
- - add ColorizedString class
17
- - update README file
18
- - add rubocop.yml and follow style
25
+ - add ColorizedString class
26
+ - update README file
27
+ - add rubocop.yml and follow style
19
28
  - add italic mode
20
29
  - remove interpreter warrnings
21
30
 
@@ -190,14 +190,18 @@ module Colorize
190
190
  # Check if color exists
191
191
  #
192
192
  def check_if_color_available!(color)
193
- color_codes[color] && fail(::Colorize::ColorAlreadyExist, "Colorize: color named :#{color} already exist!")
193
+ color_exist?(color) && fail(::Colorize::ColorAlreadyExist, "Colorize: color named :#{color} already exist!")
194
194
  end
195
195
 
196
196
  #
197
197
  # Check if color is missing
198
198
  #
199
199
  def check_if_color_exist!(color)
200
- color_codes[color] || fail(::Colorize::ColorDontExist, "Colorize: color :#{color} don't exist!")
200
+ color_exist?(color) || fail(::Colorize::ColorDontExist, "Colorize: color :#{color} don't exist!")
201
+ end
202
+
203
+ def color_exist?(color)
204
+ !color_codes[color].nil?
201
205
  end
202
206
  end
203
207
  end
@@ -118,7 +118,7 @@ module Colorize
118
118
  # Scan for colorized string
119
119
  #
120
120
  def scan_for_colors
121
- scan(/\001?\033\[([0-9;]+)m\002?(.+?)\001?\033\[0m\002?|([^\001?\033]+)/m).map do |match|
121
+ scan(/\001?\033\[([0-9;]+)m\002?(.+?)\001?\033\[0m\002?|([^\001\033]+)/m).map do |match|
122
122
  split_colors(match)
123
123
  end
124
124
  end
@@ -4,5 +4,5 @@
4
4
  # Gem version
5
5
  #
6
6
  module Colorize
7
- VERSION = '1.0.1'
7
+ VERSION = '1.0.3'
8
8
  end
data/lib/colorize.rb CHANGED
@@ -15,6 +15,6 @@ class String
15
15
  color_methods
16
16
  modes_methods
17
17
 
18
- add_color_alias(:grey, :light_black)
19
- add_color_alias(:gray, :light_black)
18
+ add_color_alias(:grey, :light_black) unless color_exist?(:grey)
19
+ add_color_alias(:gray, :light_black) unless color_exist?(:gray)
20
20
  end
@@ -13,8 +13,8 @@ class ColorizedString < String
13
13
  color_methods
14
14
  modes_methods
15
15
 
16
- add_color_alias(:grey, :light_black)
17
- add_color_alias(:gray, :light_black)
16
+ add_color_alias(:grey, :light_black) unless color_exist?(:grey)
17
+ add_color_alias(:gray, :light_black) unless color_exist?(:gray)
18
18
 
19
19
  #
20
20
  # Shortcut to create ColorizedString with ColorizedString['test'].
@@ -21,7 +21,7 @@ class TestColorize < Minitest::Test
21
21
  end
22
22
 
23
23
  def test_blue_hash
24
- assert_equal "\001\033[0;34;49m\002This is also blue\001\033[0m\002", 'This is also blue'.colorize(:color => :blue)
24
+ assert_equal "\001\033[0;34;49m\002This is also blue?\001\033[0m\002", 'This is also blue?'.colorize(:color => :blue)
25
25
  end
26
26
 
27
27
  def test_light_blue_symbol
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: colorize
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michał Kalbarczyk
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-06-19 00:00:00.000000000 Z
11
+ date: 2023-06-21 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Extends String class or add a ColorizedString with methods to set text
14
14
  color, background color and text effects.