colorize 0.8.1 → 1.1.0

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.
@@ -1,3 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ require File.expand_path('colorize/errors', File.dirname(__FILE__))
1
4
  require File.expand_path('colorize/class_methods', File.dirname(__FILE__))
2
5
  require File.expand_path('colorize/instance_methods', File.dirname(__FILE__))
3
6
  #
@@ -10,8 +13,11 @@ class ColorizedString < String
10
13
  color_methods
11
14
  modes_methods
12
15
 
16
+ add_color_alias(:grey, :light_black) unless color_exist?(:grey)
17
+ add_color_alias(:gray, :light_black) unless color_exist?(:gray)
18
+
13
19
  #
14
- # Sortcut to create ColorizedString with ColorizedString['test'].
20
+ # Shortcut to create ColorizedString with ColorizedString['test'].
15
21
  #
16
22
  def self.[](string)
17
23
  ColorizedString.new(string)
@@ -1,153 +1,128 @@
1
- require 'codeclimate-test-reporter'
2
- CodeClimate::TestReporter.start
1
+ # frozen_string_literal: true
3
2
 
4
3
  require 'minitest/autorun'
5
- require File.dirname(__FILE__) + '/../lib/colorize'
4
+ require "#{File.dirname(__FILE__)}/../lib/colorize"
6
5
 
7
6
  class TestColorize < Minitest::Test
8
7
  def test_blue_symbol
9
- assert_equal 'This is blue'.colorize(:blue),
10
- "\e[0;34;49mThis is blue\e[0m"
8
+ assert_equal "\033[0;34;49mThis is blue\033[0m", 'This is blue'.colorize(:blue)
11
9
  end
12
10
 
13
11
  def test_incorrect_symbol
14
- assert_equal 'This is incorrect color'.colorize(:bold),
15
- "\e[0;39;49mThis is incorrect color\e[0m"
12
+ assert_equal "\033[0;39;49mThis is incorrect color\033[0m", 'This is incorrect color'.colorize(:bold)
16
13
  end
17
14
 
18
15
  def test_incorrect_hash
19
- assert_equal 'This is incorrect color'.colorize(:color => :bold),
20
- "\e[0;39;49mThis is incorrect color\e[0m"
16
+ assert_equal "\033[0;39;49mThis is incorrect color\033[0m", 'This is incorrect color'.colorize(:color => :bold)
21
17
 
22
- assert_equal 'This is incorrect color'.colorize(:mode => :green),
23
- "\e[0;39;49mThis is incorrect color\e[0m"
18
+ assert_equal "\033[0;39;49mThis is incorrect color\033[0m", 'This is incorrect color'.colorize(:mode => :green)
24
19
 
25
- assert_equal 'This is incorrect color'.colorize(:background => :bold),
26
- "\e[0;39;49mThis is incorrect color\e[0m"
20
+ assert_equal "\033[0;39;49mThis is incorrect color\033[0m", 'This is incorrect color'.colorize(:background => :bold)
27
21
  end
28
22
 
29
23
  def test_blue_hash
30
- assert_equal 'This is also blue'.colorize(:color => :blue),
31
- "\e[0;34;49mThis is also blue\e[0m"
24
+ assert_equal "\033[0;34;49mThis is also blue?\033[0m", 'This is also blue?'.colorize(:color => :blue)
32
25
  end
33
26
 
34
27
  def test_light_blue_symbol
35
- assert_equal 'This is light blue'.colorize(:light_blue),
36
- "\e[0;94;49mThis is light blue\e[0m"
28
+ assert_equal "\033[0;94;49mThis is light blue\033[0m", 'This is light blue'.colorize(:light_blue)
37
29
  end
38
30
 
39
31
  def test_light_blue_with_red_background_hash
40
- assert_equal 'This is light blue with red background'.colorize(:color => :light_blue, :background => :red),
41
- "\e[0;94;41mThis is light blue with red background\e[0m"
32
+ assert_equal "\033[0;94;41mThis is light blue with red background\033[0m", 'This is light blue with red background'.colorize(:color => :light_blue, :background => :red)
42
33
  end
43
34
 
44
35
  def test_light_blue_with_red_background_symbol_and_hash
45
- assert_equal 'This is light blue with red background'.colorize(:light_blue).colorize(:background => :red),
46
- "\e[0;94;41mThis is light blue with red background\e[0m"
36
+ assert_equal "\033[0;94;41mThis is light blue with red background\033[0m", 'This is light blue with red background'.colorize(:light_blue).colorize(:background => :red)
47
37
  end
48
38
 
49
39
  def test_blue_with_red_background_method
50
- assert_equal 'This is blue text on red'.blue.on_red,
51
- "\e[0;34;41mThis is blue text on red\e[0m"
40
+ assert_equal "\033[0;34;41mThis is blue text on red\033[0m", 'This is blue text on red'.blue.on_red
52
41
  end
53
42
 
54
43
  def test_red_with_blue_background_symbol_and_method
55
- assert_equal 'This is red on blue'.colorize(:red).on_blue,
56
- "\e[0;31;44mThis is red on blue\e[0m"
44
+ assert_equal "\033[0;31;44mThis is red on blue\033[0m", 'This is red on blue'.colorize(:red).on_blue
57
45
  end
58
46
 
59
- def test_red_with_blue_background_and_underline_sumbol_and_methods
60
- assert_equal 'This is red on blue and underline'.colorize(:red).on_blue.underline,
61
- "\e[4;31;44mThis is red on blue and underline\e[0m"
47
+ def test_red_with_blue_background_and_underline_symbol_and_methods
48
+ assert_equal "\033[4;31;44mThis is red on blue and underline\033[0m", 'This is red on blue and underline'.colorize(:red).on_blue.underline
62
49
  end
63
50
 
64
51
  def test_blue_with_red_background_and_blink_methods
65
- assert_equal 'This is blue text on red'.blue.on_red.blink,
66
- "\e[5;34;41mThis is blue text on red\e[0m"
52
+ assert_equal "\033[5;34;41mThis is blue text on red\033[0m", 'This is blue text on red'.blue.on_red.blink
67
53
  end
68
54
 
69
55
  def test_uncolorize
70
- assert_equal 'This is uncolorized'.blue.on_red.uncolorize,
71
- 'This is uncolorized'
56
+ assert_equal 'This is uncolorized', 'This is uncolorized'.blue.on_red.uncolorize
72
57
  end
73
58
 
74
59
  def test_colorized?
75
- assert_equal 'Red'.red.colorized?, true
76
- assert_equal 'Blue'.colorized?, false
77
- assert_equal 'Green'.blue.green.uncolorize.colorized?, false
60
+ assert_predicate 'Red'.red, :colorized?
61
+ refute_predicate 'Blue', :colorized?
62
+ refute_predicate 'Green'.blue.green.uncolorize, :colorized?
78
63
  end
79
64
 
80
65
  def test_concatenated__colorize?
81
- assert_equal "none #{'red'.red} none #{'blue'.blue} none".colorized?, true
82
- assert_equal "none #{'red'.red} none #{'blue'.blue} none".uncolorize.colorized?, false
66
+ assert_predicate "none #{'red'.red} none #{'blue'.blue} none", :colorized?
67
+ refute_predicate "none #{'red'.red} none #{'blue'.blue} none".uncolorize, :colorized?
83
68
  end
84
69
 
85
70
  def test_concatenated_strings_on_green
86
- assert_equal "none #{'red'.red} none #{'blue'.blue} none".on_green,
87
- "\e[0;39;42mnone \e[0m\e[0;31;42mred\e[0m\e[0;39;42m none \e[0m\e[0;34;42mblue\e[0m\e[0;39;42m none\e[0m"
71
+ assert_equal "\033[0;39;42mnone \033[0m\033[0;31;42mred\033[0m\033[0;39;42m none \033[0m\033[0;34;42mblue\033[0m\033[0;39;42m none\033[0m", "none #{'red'.red} none #{'blue'.blue} none".on_green
88
72
  end
89
73
 
90
74
  def test_concatenated_strings_uncolorize
91
- assert_equal "none #{'red'.red} none #{'blue'.blue} none".uncolorize,
92
- 'none red none blue none'
93
- end
94
-
95
- def test_frozen_strings
96
- assert_equal 'This is blue text on red'.freeze.blue.on_red.blink,
97
- "\e[5;34;41mThis is blue text on red\e[0m"
75
+ assert_equal 'none red none blue none', "none #{'red'.red} none #{'blue'.blue} none".uncolorize
98
76
  end
99
77
 
100
78
  def test_new_line
101
- assert_equal "This is blue\ntext on red".freeze.blue.on_red.blink,
102
- "\e[5;34;41mThis is blue\ntext on red\e[0m"
79
+ assert_equal "\033[5;34;41mThis is blue\ntext on red\033[0m", "This is blue\ntext on red".blue.on_red.blink
103
80
  end
104
81
 
105
82
  def test_disable_colorization_with_=
106
83
  String.disable_colorization = true
107
- assert_equal String.disable_colorization, true
84
+
85
+ assert String.disable_colorization
86
+
108
87
  String.disable_colorization = false
109
88
  end
110
89
 
111
90
  def test_disable_colorization_with_method
112
91
  String.disable_colorization true
113
- assert_equal String.disable_colorization, true
92
+
93
+ assert String.disable_colorization
94
+
114
95
  String.disable_colorization false
115
96
  end
116
97
 
117
98
  def test_string_disable_colorization_with_=
118
99
  String.disable_colorization = true
119
100
 
120
- assert_equal String.disable_colorization, true
101
+ assert String.disable_colorization
121
102
 
122
- assert_equal 'This is blue after disabling'.blue,
123
- 'This is blue after disabling'
103
+ assert_equal 'This is blue after disabling', 'This is blue after disabling'.blue
124
104
 
125
105
  String.disable_colorization = false
126
106
 
127
- assert_equal 'This is blue after enabling'.colorize(:blue),
128
- "\e[0;34;49mThis is blue after enabling\e[0m"
107
+ assert_equal "\033[0;34;49mThis is blue after enabling\033[0m", 'This is blue after enabling'.colorize(:blue)
129
108
  end
130
109
 
131
110
  def test_string_disable_colorization_with_method
132
- assert_equal 'This is blue before disabling'.colorize(:blue),
133
- "\e[0;34;49mThis is blue before disabling\e[0m"
111
+ assert_equal "\033[0;34;49mThis is blue before disabling\033[0m", 'This is blue before disabling'.colorize(:blue)
134
112
 
135
113
  String.disable_colorization true
136
114
 
137
- assert_equal String.disable_colorization, true
115
+ assert String.disable_colorization
138
116
 
139
- assert_equal 'This is blue after disabling'.blue,
140
- 'This is blue after disabling'
117
+ assert_equal 'This is blue after disabling', 'This is blue after disabling'.blue
141
118
 
142
119
  String.disable_colorization false
143
120
 
144
- assert_equal 'This is blue after enabling'.colorize(:blue),
145
- "\e[0;34;49mThis is blue after enabling\e[0m"
121
+ assert_equal "\033[0;34;49mThis is blue after enabling\033[0m", 'This is blue after enabling'.colorize(:blue)
146
122
  end
147
123
 
148
124
  def test_already_colored_string_with_one_value
149
- assert_equal "\e[31mThis is red\e[0m".red,
150
- 'This is red'.red
125
+ assert_equal 'This is red'.red, "\033[31mThis is red\033[0m".red
151
126
  end
152
127
 
153
128
  def test_color_matrix_method
@@ -161,4 +136,79 @@ class TestColorize < Minitest::Test
161
136
  String.color_samples
162
137
  end
163
138
  end
139
+
140
+ def test_grey_alias
141
+ assert_equal 'This is grey'.grey, 'This is grey'.light_black
142
+ end
143
+
144
+ def test_gray_alias
145
+ assert_equal 'This is gray'.gray, 'This is gray'.light_black
146
+ end
147
+
148
+ def test_add_color_alias
149
+ String.add_color_alias(:extra_blue, :light_blue)
150
+
151
+ assert_equal 'blue'.light_blue, 'blue'.extra_blue
152
+ assert_equal 'blue'.on_light_blue, 'blue'.on_extra_blue
153
+ end
154
+
155
+ def test_add_color_alias_errors
156
+ String.add_color_alias(:extra_red, :light_red)
157
+
158
+ assert_raises ::Colorize::ColorAlreadyExist, 'Colorize: color :extra_red already exist!' do
159
+ String.add_color_alias(:extra_red, :light_blue)
160
+ end
161
+
162
+ assert_raises ::Colorize::ColorDontExist, 'Colorize: color :light_color don\'t exist!' do
163
+ String.add_color_alias(:extra_white, :light_color)
164
+ end
165
+ end
166
+
167
+ def test_add_color_alias_with_single_hash
168
+ String.add_color_alias(extra_green: :light_green)
169
+
170
+ assert_equal 'example string'.light_green, 'example string'.extra_green
171
+ assert_equal 'example string'.on_light_green, 'example string'.on_extra_green
172
+ end
173
+
174
+ def test_add_color_alias_with_single_hash_with_arrow
175
+ String.add_color_alias(:extra_color => :gray)
176
+
177
+ assert_equal 'example string'.gray, 'example string'.extra_color
178
+ assert_equal 'example string'.on_gray, 'example string'.on_extra_color
179
+ end
180
+
181
+ def test_add_color_alias_with_multi_hash
182
+ String.add_color_alias(extra_color_a: :gray, extra_color_b: :blue)
183
+
184
+ assert_equal 'example string'.gray, 'example string'.extra_color_a
185
+ assert_equal 'example string'.blue, 'example string'.extra_color_b
186
+ end
187
+
188
+ def test_add_color_alias_with_multi_hash_with_arrow
189
+ String.add_color_alias(:extra_color_c => :gray, :extra_color_d => :blue)
190
+
191
+ assert_equal 'example string'.gray, 'example string'.extra_color_c
192
+ assert_equal 'example string'.on_blue, 'example string'.on_extra_color_d
193
+ end
194
+
195
+ def test_add_color_alias_with_multi_hash_mixed
196
+ String.add_color_alias(extra_color_e: :gray, :extra_color_f => :blue)
197
+
198
+ assert_equal 'example string'.gray, 'example string'.extra_color_e
199
+ assert_equal 'example string'.on_blue, 'example string'.on_extra_color_f
200
+ end
201
+
202
+ def test_prevent_colors
203
+ String.prevent_colors true
204
+
205
+ assert String.prevent_colors
206
+ assert_equal "#{'blue'.blue}#{'red'.red}#{'green'.green}", "#{'blue'.blue}red#{'green'.green}".red
207
+
208
+ String.prevent_colors false
209
+ end
210
+
211
+ def test_colorized_string_without_readline
212
+ assert_equal "\e[0;31;49mgreen\e[0m".green, 'green'.green
213
+ end
164
214
  end
@@ -0,0 +1,216 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'minitest/autorun'
4
+ require "#{File.dirname(__FILE__)}/../lib/colorized_string"
5
+
6
+ class TestColorizedString < Minitest::Test
7
+ def test_colorize_not_required
8
+ refute_respond_to '', :colorize, 'Colorize should not be required. Only colorized_string'
9
+ end
10
+
11
+ def test_blue_symbol
12
+ assert_equal "\033[0;34;49mThis is blue\033[0m", ColorizedString['This is blue'].colorize(:blue)
13
+ end
14
+
15
+ def test_incorrect_symbol
16
+ assert_equal "\033[0;39;49mThis is incorrect color\033[0m", ColorizedString['This is incorrect color'].colorize(:bold)
17
+ end
18
+
19
+ def test_incorrect_hash
20
+ assert_equal "\033[0;39;49mThis is incorrect color\033[0m", ColorizedString['This is incorrect color'].colorize(:color => :bold)
21
+
22
+ assert_equal "\033[0;39;49mThis is incorrect color\033[0m", ColorizedString['This is incorrect color'].colorize(:mode => :green)
23
+
24
+ assert_equal "\033[0;39;49mThis is incorrect color\033[0m", ColorizedString['This is incorrect color'].colorize(:background => :bold)
25
+ end
26
+
27
+ def test_blue_hash
28
+ assert_equal "\033[0;34;49mThis is also blue\033[0m", ColorizedString['This is also blue'].colorize(:color => :blue)
29
+ end
30
+
31
+ def test_light_blue_symbol
32
+ assert_equal "\033[0;94;49mThis is light blue\033[0m", ColorizedString['This is light blue'].colorize(:light_blue)
33
+ end
34
+
35
+ def test_light_blue_with_red_background_hash
36
+ assert_equal "\033[0;94;41mThis is light blue with red background\033[0m", ColorizedString['This is light blue with red background'].colorize(:color => :light_blue, :background => :red)
37
+ end
38
+
39
+ def test_light_blue_with_red_background_symbol_and_hash
40
+ assert_equal "\033[0;94;41mThis is light blue with red background\033[0m", ColorizedString['This is light blue with red background'].colorize(:light_blue).colorize(:background => :red)
41
+ end
42
+
43
+ def test_blue_with_red_background_method
44
+ assert_equal "\033[0;34;41mThis is blue text on red\033[0m", ColorizedString['This is blue text on red'].blue.on_red
45
+ end
46
+
47
+ def test_red_with_blue_background_symbol_and_method
48
+ assert_equal "\033[0;31;44mThis is red on blue\033[0m", ColorizedString['This is red on blue'].colorize(:red).on_blue
49
+ end
50
+
51
+ def test_red_with_blue_background_and_underline_sumbol_and_methods
52
+ assert_equal "\033[4;31;44mThis is red on blue and underline\033[0m", ColorizedString['This is red on blue and underline'].colorize(:red).on_blue.underline
53
+ end
54
+
55
+ def test_blue_with_red_background_and_blink_methods
56
+ assert_equal "\033[5;34;41mThis is blue text on red\033[0m", ColorizedString['This is blue text on red'].blue.on_red.blink
57
+ end
58
+
59
+ def test_uncolorize
60
+ assert_equal 'This is uncolorized', ColorizedString['This is uncolorized'].blue.on_red.uncolorize
61
+ end
62
+
63
+ def test_colorized?
64
+ assert_predicate ColorizedString['Red'].red, :colorized?
65
+ refute_predicate ColorizedString['Blue'], :colorized?
66
+ refute_predicate ColorizedString['Green'].blue.green.uncolorize, :colorized?
67
+ end
68
+
69
+ def test_concatenated__colorize?
70
+ assert_predicate ColorizedString["none #{ColorizedString['red'].red} none #{ColorizedString['blue'].blue} none"], :colorized?
71
+ refute_predicate ColorizedString["none #{ColorizedString['red'].red} none #{ColorizedString['blue'].blue} none"].uncolorize, :colorized?
72
+ end
73
+
74
+ def test_concatenated_strings_on_green
75
+ assert_equal "\033[0;39;42mnone \033[0m\033[0;31;42mred\033[0m\033[0;39;42m none \033[0m\033[0;34;42mblue\033[0m\033[0;39;42m none\033[0m", ColorizedString["none #{ColorizedString['red'].red} none #{ColorizedString['blue'].blue} none"].on_green
76
+ end
77
+
78
+ def test_concatenated_strings_uncolorize
79
+ assert_equal 'none red none blue none', ColorizedString["none #{ColorizedString['red'].red} none #{ColorizedString['blue'].blue} none"].uncolorize
80
+ end
81
+
82
+ def test_frozen_strings
83
+ assert_equal "\033[5;34;41mThis is blue text on red\033[0m", ColorizedString['This is blue text on red'].freeze.blue.on_red.blink
84
+ end
85
+
86
+ def test_new_line
87
+ assert_equal "\033[5;34;41mThis is blue\ntext on red\033[0m", ColorizedString["This is blue\ntext on red"].freeze.blue.on_red.blink
88
+ end
89
+
90
+ def test_disable_colorization_with_=
91
+ ColorizedString.disable_colorization = true
92
+
93
+ assert ColorizedString.disable_colorization
94
+
95
+ ColorizedString.disable_colorization = false
96
+ end
97
+
98
+ def test_disable_colorization_with_method
99
+ ColorizedString.disable_colorization true
100
+
101
+ assert ColorizedString.disable_colorization
102
+
103
+ ColorizedString.disable_colorization false
104
+ end
105
+
106
+ def test_string_disable_colorization_with_=
107
+ ColorizedString.disable_colorization = true
108
+
109
+ assert ColorizedString.disable_colorization
110
+
111
+ assert_equal 'This is blue after disabling', ColorizedString['This is blue after disabling'].blue
112
+
113
+ ColorizedString.disable_colorization = false
114
+
115
+ assert_equal "\033[0;34;49mThis is blue after enabling\033[0m", ColorizedString['This is blue after enabling'].colorize(:blue)
116
+ end
117
+
118
+ def test_string_disable_colorization_with_method
119
+ assert_equal "\033[0;34;49mThis is blue before disabling\033[0m", ColorizedString['This is blue before disabling'].colorize(:blue)
120
+
121
+ ColorizedString.disable_colorization true
122
+
123
+ assert ColorizedString.disable_colorization
124
+
125
+ assert_equal 'This is blue after disabling', ColorizedString['This is blue after disabling'].blue
126
+
127
+ ColorizedString.disable_colorization false
128
+
129
+ assert_equal "\033[0;34;49mThis is blue after enabling\033[0m", ColorizedString['This is blue after enabling'].colorize(:blue)
130
+ end
131
+
132
+ def test_already_colored_string_with_one_value
133
+ assert_equal ColorizedString['This is red'].red, ColorizedString["\033[31mThis is red\033[0m"].red
134
+ end
135
+
136
+ def test_color_matrix_method
137
+ assert_raises(NoMethodError) { ColorizedString.color_matrix }
138
+ end
139
+
140
+ def test_color_samples_method
141
+ assert_output do
142
+ ColorizedString.color_samples
143
+ end
144
+ end
145
+
146
+ def test_grey_alias
147
+ assert_equal ColorizedString['This is grey'].grey, ColorizedString['This is grey'].light_black
148
+ end
149
+
150
+ def test_gray_alias
151
+ assert_equal ColorizedString['This is gray'].gray, ColorizedString['This is gray'].light_black
152
+ end
153
+
154
+ def test_add_color_alias
155
+ ColorizedString.add_color_alias(:extra_blue, :light_blue)
156
+
157
+ assert_equal ColorizedString['blue'].light_blue, ColorizedString['blue'].extra_blue
158
+ assert_equal ColorizedString['blue'].on_light_blue, ColorizedString['blue'].on_extra_blue
159
+
160
+ assert_raises ::Colorize::ColorAlreadyExist, 'Colorize: color :extra_blue already exist!' do
161
+ ColorizedString.add_color_alias(:extra_blue, :light_color)
162
+ end
163
+
164
+ assert_raises ::Colorize::ColorDontExist, 'Colorize: color :light_color don\'t exist!' do
165
+ ColorizedString.add_color_alias(:extra_white, :light_color)
166
+ end
167
+ end
168
+
169
+ def test_add_color_alias_with_single_hash
170
+ ColorizedString.add_color_alias(extra_green: :light_green)
171
+
172
+ assert_equal ColorizedString['example string'].light_green, ColorizedString['example string'].extra_green
173
+ assert_equal ColorizedString['example string'].on_light_green, ColorizedString['example string'].on_extra_green
174
+ end
175
+
176
+ def test_add_color_alias_with_single_hash_with_arrow
177
+ ColorizedString.add_color_alias(:extra_color => :gray)
178
+
179
+ assert_equal ColorizedString['example string'].gray, ColorizedString['example string'].extra_color
180
+ assert_equal ColorizedString['example string'].on_gray, ColorizedString['example string'].on_extra_color
181
+ end
182
+
183
+ def test_add_color_alias_with_multi_hash
184
+ ColorizedString.add_color_alias(extra_color_a: :gray, extra_color_b: :blue)
185
+
186
+ assert_equal ColorizedString['example string'].gray, ColorizedString['example string'].extra_color_a
187
+ assert_equal ColorizedString['example string'].blue, ColorizedString['example string'].extra_color_b
188
+ end
189
+
190
+ def test_add_color_alias_with_multi_hash_with_arrow
191
+ ColorizedString.add_color_alias(:extra_color_c => :gray, :extra_color_d => :blue)
192
+
193
+ assert_equal ColorizedString['example string'].gray, ColorizedString['example string'].extra_color_c
194
+ assert_equal ColorizedString['example string'].on_blue, ColorizedString['example string'].on_extra_color_d
195
+ end
196
+
197
+ def test_add_color_alias_with_multi_hash_mixed
198
+ ColorizedString.add_color_alias(extra_color_e: :gray, :extra_color_f => :blue)
199
+
200
+ assert_equal ColorizedString['example string'].gray, ColorizedString['example string'].extra_color_e
201
+ assert_equal ColorizedString['example string'].on_blue, ColorizedString['example string'].on_extra_color_f
202
+ end
203
+
204
+ def test_prevent_colors
205
+ ColorizedString.prevent_colors true
206
+
207
+ assert ColorizedString.prevent_colors
208
+ assert_equal "#{ColorizedString['blue'].blue}#{ColorizedString['red'].red}#{ColorizedString['green'].green}", ColorizedString["#{ColorizedString['blue'].blue}red#{ColorizedString['green'].green}"].red
209
+
210
+ ColorizedString.prevent_colors false
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
216
+ end
metadata CHANGED
@@ -1,57 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: colorize
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.1
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michał Kalbarczyk
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-06-29 00:00:00.000000000 Z
12
- dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: rake
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - "~>"
18
- - !ruby/object:Gem::Version
19
- version: '10.0'
20
- type: :development
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - "~>"
25
- - !ruby/object:Gem::Version
26
- version: '10.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: codeclimate-test-reporter
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - "~>"
46
- - !ruby/object:Gem::Version
47
- version: '0.4'
48
- type: :development
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - "~>"
53
- - !ruby/object:Gem::Version
54
- version: '0.4'
11
+ date: 2023-06-23 00:00:00.000000000 Z
12
+ dependencies: []
55
13
  description: Extends String class or add a ColorizedString with methods to set text
56
14
  color, background color and text effects.
57
15
  email: fazibear@gmail.com
@@ -59,21 +17,25 @@ executables: []
59
17
  extensions: []
60
18
  extra_rdoc_files: []
61
19
  files:
62
- - CHANGELOG
20
+ - CHANGELOG.md
63
21
  - LICENSE
64
22
  - README.md
65
23
  - Rakefile
66
24
  - colorize.gemspec
67
25
  - lib/colorize.rb
68
26
  - lib/colorize/class_methods.rb
27
+ - lib/colorize/errors.rb
69
28
  - lib/colorize/instance_methods.rb
29
+ - lib/colorize/version.rb
70
30
  - lib/colorized_string.rb
71
31
  - test/test_colorize.rb
32
+ - test/test_colorized_string.rb
72
33
  homepage: http://github.com/fazibear/colorize
73
34
  licenses:
74
35
  - GPL-2.0
75
- metadata: {}
76
- post_install_message:
36
+ metadata:
37
+ rubygems_mfa_required: 'true'
38
+ post_install_message:
77
39
  rdoc_options: []
78
40
  require_paths:
79
41
  - lib
@@ -81,17 +43,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
81
43
  requirements:
82
44
  - - ">="
83
45
  - !ruby/object:Gem::Version
84
- version: '0'
46
+ version: '2.6'
85
47
  required_rubygems_version: !ruby/object:Gem::Requirement
86
48
  requirements:
87
49
  - - ">="
88
50
  - !ruby/object:Gem::Version
89
51
  version: '0'
90
52
  requirements: []
91
- rubyforge_project:
92
- rubygems_version: 2.5.1
93
- signing_key:
53
+ rubygems_version: 3.4.14
54
+ signing_key:
94
55
  specification_version: 4
95
56
  summary: Ruby gem for colorizing text using ANSI escape sequences.
96
- test_files:
97
- - test/test_colorize.rb
57
+ test_files: []
data/CHANGELOG DELETED
@@ -1,65 +0,0 @@
1
- == 0.8.1 / 2016-06-29
2
- * fix gemspec bug
3
-
4
- == 0.8.0 / 2016-06-27
5
- * add ColorizedString class
6
- * update README file
7
- * add rubocop.yml and follow style
8
- * add italic mode
9
- * remove interpreter warrnings
10
-
11
- == 0.7.7 / 2015-04-19
12
- * update gems
13
-
14
- == 0.7.6 / 2015-04-18
15
- * fix bugs
16
-
17
- == 0.7.5 / 2014-12-11
18
- * big code refactoring
19
- * disable_colorization feature added
20
-
21
- == 0.7.4 / 2014-12-10
22
- * code cleanups
23
-
24
- == 0.7.3 / 2014-05-19
25
- * fix new line maching
26
-
27
- == 0.7.2 / 2014-04-08
28
- * tests cleanups
29
- * gem release date fixed
30
-
31
- == 0.7.1 / 2014-04-02
32
- * handling wrong color values
33
-
34
- == 0.7.0 / 2014-03-12
35
- * refactored to use regexp pattern matching
36
- * works with frozen strings
37
- * works with concatenated string
38
-
39
- == 0.6.0 / 2013-09-25
40
- * code cleanups
41
- * bold mode fixed
42
- * STDOUT.isatty condition removed
43
- * doc updated
44
- * jeweler tasks removed
45
- * Rakefile updated
46
-
47
- == 0.5.8 / 2009-12-02
48
- * code cleanups
49
- * removed 'ruby -w' warnings
50
-
51
- == 0.5.7 / 2009-11-24
52
- * moved to github/gemcutter
53
- * 1.9 compatible
54
-
55
- == 0.5.6 / 2007-08-27
56
- * rdocs Allison template
57
- * cleanups
58
-
59
- == 0.5.5 / 2007-08-11
60
- * added effects methods
61
- * README files
62
- * new rake file
63
-
64
- == 0.5.0 / 2007-04-22
65
- * initial rewritten version