colorize 1.0.0 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +10 -4
- data/colorize.gemspec +0 -9
- data/lib/colorize/class_methods.rb +6 -2
- data/lib/colorize/instance_methods.rb +1 -1
- data/lib/colorize/version.rb +1 -1
- data/lib/colorize.rb +2 -2
- data/lib/colorized_string.rb +2 -2
- data/test/test_colorize.rb +4 -0
- data/test/test_colorized_string.rb +5 -3
- metadata +3 -115
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5fd14fe9398abe190f9220d78856881233442eebb449e17ef360d37071b27d02
|
4
|
+
data.tar.gz: c347bd5839c004ca73e57cc1af16bf9b54923d0f4676a06e89cf56d149fa3bbd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2cd8c7d986dd434080bdf1c9ab14249f8f96f85a4a66ed1f84b241232cf2e4373576b04de434b3ae500d37a110be42320c8f4b1dc74bb273c851d816cb73cb52
|
7
|
+
data.tar.gz: d35c48011f472e3f214019024c95b9173db56a8928fa182de24167c138000ae08364fdcdf284ccc5dc80e2f450b5d3cf782c24ccc10d6b3ac33b01631776c8a2
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,12 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
-
## 1.0.
|
3
|
+
## 1.0.2 / 2023-06-21
|
4
|
+
- check if color exists when extending class
|
5
|
+
|
6
|
+
## 1.0.1 / 2023-06-19
|
7
|
+
- fix maching of colorized strings without readline characters
|
8
|
+
|
9
|
+
## 1.0.0 / 2023-06-19
|
4
10
|
- add more modes
|
5
11
|
- add aliases
|
6
12
|
- grey and gray default aliases
|
@@ -13,9 +19,9 @@
|
|
13
19
|
- fix gemspec bug
|
14
20
|
|
15
21
|
## 0.8.0 / 2016-06-27
|
16
|
-
|
17
|
-
|
18
|
-
|
22
|
+
- add ColorizedString class
|
23
|
+
- update README file
|
24
|
+
- add rubocop.yml and follow style
|
19
25
|
- add italic mode
|
20
26
|
- remove interpreter warrnings
|
21
27
|
|
data/colorize.gemspec
CHANGED
@@ -17,15 +17,6 @@ Gem::Specification.new do |s|
|
|
17
17
|
|
18
18
|
s.require_paths = ['lib']
|
19
19
|
|
20
|
-
s.add_development_dependency 'json', '~> 2.0'
|
21
|
-
s.add_development_dependency 'minitest', '~> 5.0'
|
22
|
-
s.add_development_dependency 'rake', '~> 13.0'
|
23
|
-
s.add_development_dependency 'rubocop', '~> 1.0'
|
24
|
-
s.add_development_dependency 'rubocop-github', '~> 0.20'
|
25
|
-
s.add_development_dependency 'rubocop-minitest', '~> 0.29.0'
|
26
|
-
s.add_development_dependency 'rubocop-performance', '~> 1.16'
|
27
|
-
s.add_development_dependency 'rubocop-rake', '~> 0.6'
|
28
|
-
|
29
20
|
s.files = [
|
30
21
|
'LICENSE',
|
31
22
|
'CHANGELOG.md',
|
@@ -190,14 +190,18 @@ module Colorize
|
|
190
190
|
# Check if color exists
|
191
191
|
#
|
192
192
|
def check_if_color_available!(color)
|
193
|
-
|
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
|
-
|
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
|
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
|
data/lib/colorize/version.rb
CHANGED
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
|
data/lib/colorized_string.rb
CHANGED
@@ -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'].
|
data/test/test_colorize.rb
CHANGED
@@ -134,9 +134,7 @@ class TestColorizedString < Minitest::Test
|
|
134
134
|
end
|
135
135
|
|
136
136
|
def test_color_matrix_method
|
137
|
-
assert_raises
|
138
|
-
ColorizedString.color_matrix
|
139
|
-
end
|
137
|
+
assert_raises(NoMethodError) { ColorizedString.color_matrix }
|
140
138
|
end
|
141
139
|
|
142
140
|
def test_color_samples_method
|
@@ -211,4 +209,8 @@ class TestColorizedString < Minitest::Test
|
|
211
209
|
|
212
210
|
ColorizedString.prevent_colors false
|
213
211
|
end
|
212
|
+
|
213
|
+
def test_colorized_string_without_readline
|
214
|
+
assert_equal ColorizedString["\e[0;31;49mgreen\e[0m"].green, ColorizedString['green'].green
|
215
|
+
end
|
214
216
|
end
|
metadata
CHANGED
@@ -1,127 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: colorize
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.2
|
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-
|
12
|
-
dependencies:
|
13
|
-
- !ruby/object:Gem::Dependency
|
14
|
-
name: json
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - "~>"
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '2.0'
|
20
|
-
type: :development
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - "~>"
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: '2.0'
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: minitest
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - "~>"
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '5.0'
|
34
|
-
type: :development
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - "~>"
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: '5.0'
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: rake
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - "~>"
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: '13.0'
|
48
|
-
type: :development
|
49
|
-
prerelease: false
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - "~>"
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: '13.0'
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: rubocop
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - "~>"
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '1.0'
|
62
|
-
type: :development
|
63
|
-
prerelease: false
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - "~>"
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: '1.0'
|
69
|
-
- !ruby/object:Gem::Dependency
|
70
|
-
name: rubocop-github
|
71
|
-
requirement: !ruby/object:Gem::Requirement
|
72
|
-
requirements:
|
73
|
-
- - "~>"
|
74
|
-
- !ruby/object:Gem::Version
|
75
|
-
version: '0.20'
|
76
|
-
type: :development
|
77
|
-
prerelease: false
|
78
|
-
version_requirements: !ruby/object:Gem::Requirement
|
79
|
-
requirements:
|
80
|
-
- - "~>"
|
81
|
-
- !ruby/object:Gem::Version
|
82
|
-
version: '0.20'
|
83
|
-
- !ruby/object:Gem::Dependency
|
84
|
-
name: rubocop-minitest
|
85
|
-
requirement: !ruby/object:Gem::Requirement
|
86
|
-
requirements:
|
87
|
-
- - "~>"
|
88
|
-
- !ruby/object:Gem::Version
|
89
|
-
version: 0.29.0
|
90
|
-
type: :development
|
91
|
-
prerelease: false
|
92
|
-
version_requirements: !ruby/object:Gem::Requirement
|
93
|
-
requirements:
|
94
|
-
- - "~>"
|
95
|
-
- !ruby/object:Gem::Version
|
96
|
-
version: 0.29.0
|
97
|
-
- !ruby/object:Gem::Dependency
|
98
|
-
name: rubocop-performance
|
99
|
-
requirement: !ruby/object:Gem::Requirement
|
100
|
-
requirements:
|
101
|
-
- - "~>"
|
102
|
-
- !ruby/object:Gem::Version
|
103
|
-
version: '1.16'
|
104
|
-
type: :development
|
105
|
-
prerelease: false
|
106
|
-
version_requirements: !ruby/object:Gem::Requirement
|
107
|
-
requirements:
|
108
|
-
- - "~>"
|
109
|
-
- !ruby/object:Gem::Version
|
110
|
-
version: '1.16'
|
111
|
-
- !ruby/object:Gem::Dependency
|
112
|
-
name: rubocop-rake
|
113
|
-
requirement: !ruby/object:Gem::Requirement
|
114
|
-
requirements:
|
115
|
-
- - "~>"
|
116
|
-
- !ruby/object:Gem::Version
|
117
|
-
version: '0.6'
|
118
|
-
type: :development
|
119
|
-
prerelease: false
|
120
|
-
version_requirements: !ruby/object:Gem::Requirement
|
121
|
-
requirements:
|
122
|
-
- - "~>"
|
123
|
-
- !ruby/object:Gem::Version
|
124
|
-
version: '0.6'
|
11
|
+
date: 2023-06-21 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
125
13
|
description: Extends String class or add a ColorizedString with methods to set text
|
126
14
|
color, background color and text effects.
|
127
15
|
email: fazibear@gmail.com
|