rainbow 2.2.1 → 2.2.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 +4 -0
- data/README.markdown +28 -146
- data/lib/rainbow/color.rb +6 -1
- data/lib/rainbow/ext/string.rb +4 -0
- data/lib/rainbow/null_presenter.rb +3 -0
- data/lib/rainbow/presenter.rb +9 -0
- data/lib/rainbow/version.rb +1 -1
- data/rainbow.gemspec +2 -0
- data/spec/integration/rainbow_spec.rb +12 -1
- data/spec/integration/string_spec.rb +4 -0
- data/spec/unit/null_presenter_spec.rb +18 -0
- data/spec/unit/presenter_spec.rb +22 -0
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ae78749f89ed058bfe6d143f96ab9140e243a0bc
|
4
|
+
data.tar.gz: 0ea8625303c1f3c6668ef9cf05692db0295138a3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6a4d28dea14c12a91fb545046183a8fe02b1da104f4dd52c59245cb045ce1116b5b2777570a211112f973ccf52d18cea9547ae1f9ce0405e72538d2dceb4237a
|
7
|
+
data.tar.gz: 03c7b7197f82cd5974c01458524217cfd000a67cff73962b67440c3c44dfd261c5fa1b160da99110fb618a09b3830d0fac1b9b47e854daa28ee0543ff40856df
|
data/Changelog.md
CHANGED
data/README.markdown
CHANGED
@@ -38,7 +38,8 @@ Rainbow presenter adds the following methods to presented string:
|
|
38
38
|
* `blink`
|
39
39
|
* `inverse`
|
40
40
|
* `hide`
|
41
|
-
* `
|
41
|
+
* `faint` (not well supported by terminal emulators)
|
42
|
+
* `italic` (not well supported by terminal emulators)
|
42
43
|
|
43
44
|
Text color can also be changed by calling a method named by a color:
|
44
45
|
|
@@ -181,154 +182,35 @@ gem install rainbow
|
|
181
182
|
|
182
183
|
### ANSI colors
|
183
184
|
|
184
|
-
|
185
|
-
* `red`
|
186
|
-
* `green`
|
187
|
-
* `yellow`
|
188
|
-
* `blue`
|
189
|
-
* `magenta`
|
190
|
-
* `cyan`
|
191
|
-
* `white`
|
185
|
+
`black`, `red`, `green`, `yellow`, `blue`, `magenta`, `cyan`, `white`
|
192
186
|
|
193
187
|
### X11 colors
|
194
188
|
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
* `brown`
|
221
|
-
* `rosybrown`
|
222
|
-
* `saddlebrown`
|
223
|
-
* `sandybrown`
|
224
|
-
* `burlywood`
|
225
|
-
* `chartreuse`
|
226
|
-
* `chocolate`
|
227
|
-
* `coral`
|
228
|
-
* `lightcoral`
|
229
|
-
* `cornflower`
|
230
|
-
* `cornsilk`
|
231
|
-
* `crimson`
|
232
|
-
* `darkcyan`
|
233
|
-
* `lightcyan`
|
234
|
-
* `firebrick`
|
235
|
-
* `fuchsia`
|
236
|
-
* `gainsboro`
|
237
|
-
* `gold`
|
238
|
-
* `goldenrod`
|
239
|
-
* `darkgoldenrod`
|
240
|
-
* `lightgoldenrod`
|
241
|
-
* `palegoldenrod`
|
242
|
-
* `gray`
|
243
|
-
* `darkgray`
|
244
|
-
* `dimgray`
|
245
|
-
* `lightgray`
|
246
|
-
* `slategray`
|
247
|
-
* `lightslategray`
|
248
|
-
* `webgray`
|
249
|
-
* `darkgreen`
|
250
|
-
* `lightgreen`
|
251
|
-
* `palegreen`
|
252
|
-
* `darkolivegreen`
|
253
|
-
* `yellowgreen`
|
254
|
-
* `forestgreen`
|
255
|
-
* `lawngreen`
|
256
|
-
* `limegreen`
|
257
|
-
* `seagreen`
|
258
|
-
* `darkseagreen`
|
259
|
-
* `lightseagreen`
|
260
|
-
* `mediumseagreen`
|
261
|
-
* `springgreen`
|
262
|
-
* `mediumspringgreen`
|
263
|
-
* `webgreen`
|
264
|
-
* `honeydew`
|
265
|
-
* `indianred`
|
266
|
-
* `indigo`
|
267
|
-
* `ivory`
|
268
|
-
* `khaki`
|
269
|
-
* `darkkhaki`
|
270
|
-
* `lavender`
|
271
|
-
* `lavenderblush`
|
272
|
-
* `lemonchiffon`
|
273
|
-
* `lime`
|
274
|
-
* `linen`
|
275
|
-
* `darkmagenta`
|
276
|
-
* `maroon`
|
277
|
-
* `webmaroon`
|
278
|
-
* `mintcream`
|
279
|
-
* `mistyrose`
|
280
|
-
* `moccasin`
|
281
|
-
* `oldlace`
|
282
|
-
* `olive`
|
283
|
-
* `olivedrab`
|
284
|
-
* `orange`
|
285
|
-
* `darkorange`
|
286
|
-
* `orchid`
|
287
|
-
* `darkorchid`
|
288
|
-
* `mediumorchid`
|
289
|
-
* `papayawhip`
|
290
|
-
* `peachpuff`
|
291
|
-
* `peru`
|
292
|
-
* `pink`
|
293
|
-
* `deeppink`
|
294
|
-
* `lightpink`
|
295
|
-
* `hotpink`
|
296
|
-
* `plum`
|
297
|
-
* `purple`
|
298
|
-
* `mediumpurple`
|
299
|
-
* `rebeccapurple`
|
300
|
-
* `webpurple`
|
301
|
-
* `darkred`
|
302
|
-
* `orangered`
|
303
|
-
* `mediumvioletred`
|
304
|
-
* `palevioletred`
|
305
|
-
* `salmon`
|
306
|
-
* `darksalmon`
|
307
|
-
* `lightsalmon`
|
308
|
-
* `seashell`
|
309
|
-
* `sienna`
|
310
|
-
* `silver`
|
311
|
-
* `darkslategray`
|
312
|
-
* `snow`
|
313
|
-
* `tan`
|
314
|
-
* `teal`
|
315
|
-
* `thistle`
|
316
|
-
* `tomato`
|
317
|
-
* `turquoise`
|
318
|
-
* `darkturquoise`
|
319
|
-
* `mediumturquoise`
|
320
|
-
* `paleturquoise`
|
321
|
-
* `violet`
|
322
|
-
* `darkviolet`
|
323
|
-
* `blueviolet`
|
324
|
-
* `wheat`
|
325
|
-
* `antiquewhite`
|
326
|
-
* `floralwhite`
|
327
|
-
* `ghostwhite`
|
328
|
-
* `navajowhite`
|
329
|
-
* `whitesmoke`
|
330
|
-
* `lightyellow`
|
331
|
-
* `greenyellow`
|
189
|
+
`aliceblue`, `antiquewhite`, `aqua`, `aquamarine`, `azure`, `beige`, `bisque`,
|
190
|
+
`blanchedalmond`, `blueviolet`, `brown`, `burlywood`, `cadetblue`, `chartreuse`,
|
191
|
+
`chocolate`, `coral`, `cornflower`, `cornsilk`, `crimson`, `darkblue`,
|
192
|
+
`darkcyan`, `darkgoldenrod`, `darkgray`, `darkgreen`, `darkkhaki`,
|
193
|
+
`darkmagenta`, `darkolivegreen`, `darkorange`, `darkorchid`, `darkred`,
|
194
|
+
`darksalmon`, `darkseagreen`, `darkslateblue`, `darkslategray`, `darkturquoise`,
|
195
|
+
`darkviolet`, `deeppink`, `deepskyblue`, `dimgray`, `dodgerblue`, `firebrick`,
|
196
|
+
`floralwhite`, `forestgreen`, `fuchsia`, `gainsboro`, `ghostwhite`, `gold`,
|
197
|
+
`goldenrod`, `gray`, `greenyellow`, `honeydew`, `hotpink`, `indianred`,
|
198
|
+
`indigo`, `ivory`, `khaki`, `lavender`, `lavenderblush`, `lawngreen`,
|
199
|
+
`lemonchiffon`, `lightblue`, `lightcoral`, `lightcyan`, `lightgoldenrod`,
|
200
|
+
`lightgray`, `lightgreen`, `lightpink`, `lightsalmon`, `lightseagreen`,
|
201
|
+
`lightskyblue`, `lightslategray`, `lightsteelblue`, `lightyellow`, `lime`,
|
202
|
+
`limegreen`, `linen`, `maroon`, `mediumaquamarine`, `mediumblue`,
|
203
|
+
`mediumorchid`, `mediumpurple`, `mediumseagreen`, `mediumslateblue`,
|
204
|
+
`mediumspringgreen`, `mediumturquoise`, `mediumvioletred`, `midnightblue`,
|
205
|
+
`mintcream`, `mistyrose`, `moccasin`, `navajowhite`, `navyblue`, `oldlace`,
|
206
|
+
`olive`, `olivedrab`, `orange`, `orangered`, `orchid`, `palegoldenrod`,
|
207
|
+
`palegreen`, `paleturquoise`, `palevioletred`, `papayawhip`, `peachpuff`,
|
208
|
+
`peru`, `pink`, `plum`, `powderblue`, `purple`, `rebeccapurple`, `rosybrown`,
|
209
|
+
`royalblue`, `saddlebrown`, `salmon`, `sandybrown`, `seagreen`, `seashell`,
|
210
|
+
`sienna`, `silver`, `skyblue`, `slateblue`, `slategray`, `snow`, `springgreen`,
|
211
|
+
`steelblue`, `tan`, `teal`, `thistle`, `tomato`, `turquoise`, `violet`,
|
212
|
+
`webgray`, `webgreen`, `webmaroon`, `webpurple`, `wheat`, `whitesmoke`,
|
213
|
+
`yellowgreen`
|
332
214
|
|
333
215
|
## Authors
|
334
216
|
|
data/lib/rainbow/color.rb
CHANGED
@@ -12,7 +12,12 @@ module Rainbow
|
|
12
12
|
color = values.size == 1 ? values.first : values
|
13
13
|
|
14
14
|
case color
|
15
|
-
|
15
|
+
# NOTE: Properly handle versions before/after Ruby 2.4.0.
|
16
|
+
# Ruby 2.4+ unifies Fixnum & Bignum into Integer.
|
17
|
+
# However previous versions would still use Fixnum.
|
18
|
+
# To avoid missing `Fixnum` input, call `0.class` which would
|
19
|
+
# return either `Integer` or `Fixnum`.
|
20
|
+
when 0.class
|
16
21
|
Indexed.new(ground, color)
|
17
22
|
when Symbol
|
18
23
|
if Named.color_names.include?(color)
|
data/lib/rainbow/ext/string.rb
CHANGED
@@ -6,6 +6,7 @@ module Rainbow
|
|
6
6
|
def background(*values); self; end
|
7
7
|
def reset; self; end
|
8
8
|
def bright; self; end
|
9
|
+
def faint; self; end
|
9
10
|
def italic; self; end
|
10
11
|
def underline; self; end
|
11
12
|
def blink; self; end
|
@@ -32,6 +33,8 @@ module Rainbow
|
|
32
33
|
alias_method :foreground, :color
|
33
34
|
alias_method :fg, :color
|
34
35
|
alias_method :bg, :background
|
36
|
+
alias_method :bold, :bright
|
37
|
+
alias_method :dark, :faint
|
35
38
|
|
36
39
|
end
|
37
40
|
|
data/lib/rainbow/presenter.rb
CHANGED
@@ -9,6 +9,7 @@ module Rainbow
|
|
9
9
|
TERM_EFFECTS = {
|
10
10
|
reset: 0,
|
11
11
|
bright: 1,
|
12
|
+
faint: 2,
|
12
13
|
italic: 3,
|
13
14
|
underline: 4,
|
14
15
|
blink: 5,
|
@@ -46,6 +47,14 @@ module Rainbow
|
|
46
47
|
|
47
48
|
alias_method :bold, :bright
|
48
49
|
|
50
|
+
# Turns on faint/dark for this text (not well supported by terminal
|
51
|
+
# emulators).
|
52
|
+
def faint
|
53
|
+
wrap_with_sgr(TERM_EFFECTS[:faint])
|
54
|
+
end
|
55
|
+
|
56
|
+
alias_method :dark, :faint
|
57
|
+
|
49
58
|
# Turns on italic style for this text (not well supported by terminal
|
50
59
|
# emulators).
|
51
60
|
def italic
|
data/lib/rainbow/version.rb
CHANGED
data/rainbow.gemspec
CHANGED
@@ -19,6 +19,8 @@ Gem::Specification.new do |spec|
|
|
19
19
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
20
20
|
spec.require_paths = ["lib"]
|
21
21
|
|
22
|
+
spec.add_dependency "rake"
|
23
|
+
|
22
24
|
spec.add_development_dependency "bundler", "~> 1.3"
|
23
25
|
spec.extensions = ["ext/mkrf_conf.rb"]
|
24
26
|
end
|
@@ -77,6 +77,11 @@ describe 'Rainbow() wrapper' do
|
|
77
77
|
expect(result).to eq("\e[1mhello\e[0m")
|
78
78
|
end
|
79
79
|
|
80
|
+
it 'allows making text faint' do
|
81
|
+
result = Rainbow('hello').faint
|
82
|
+
expect(result).to eq("\e[2mhello\e[0m")
|
83
|
+
end
|
84
|
+
|
80
85
|
it 'allows making text italic' do
|
81
86
|
result = Rainbow('hello').italic
|
82
87
|
expect(result).to eq("\e[3mhello\e[0m")
|
@@ -111,6 +116,9 @@ describe 'Rainbow() wrapper' do
|
|
111
116
|
result = Rainbow('hello').
|
112
117
|
foreground(:red).
|
113
118
|
bright.
|
119
|
+
bold.
|
120
|
+
faint.
|
121
|
+
dark.
|
114
122
|
italic.
|
115
123
|
background('#ff8040').
|
116
124
|
underline.
|
@@ -120,7 +128,7 @@ describe 'Rainbow() wrapper' do
|
|
120
128
|
hide
|
121
129
|
|
122
130
|
expect(result).to eq(
|
123
|
-
"\e[31m\e[1m\e[3m\e[48;5;215m\e[4m\e[34m\e[5m\e[7m\e[8mhello\e[0m"
|
131
|
+
"\e[31m\e[1m\e[1m\e[2m\e[2m\e[3m\e[48;5;215m\e[4m\e[34m\e[5m\e[7m\e[8mhello\e[0m"
|
124
132
|
)
|
125
133
|
end
|
126
134
|
|
@@ -134,6 +142,9 @@ describe 'Rainbow() wrapper' do
|
|
134
142
|
result = Rainbow('hello').
|
135
143
|
foreground(:red).
|
136
144
|
bright.
|
145
|
+
bold.
|
146
|
+
faint.
|
147
|
+
dark.
|
137
148
|
italic.
|
138
149
|
background('#ff8040').
|
139
150
|
underline.
|
@@ -31,6 +31,10 @@ describe 'String mixin' do
|
|
31
31
|
expect('hello'.bright).to eq(Rainbow('hello').bright)
|
32
32
|
end
|
33
33
|
|
34
|
+
it 'proxies faint to Rainbow().faint' do
|
35
|
+
expect('hello'.faint).to eq(Rainbow('hello').faint)
|
36
|
+
end
|
37
|
+
|
34
38
|
it 'proxies italic to Rainbow().italic' do
|
35
39
|
expect('hello'.italic).to eq(Rainbow('hello').italic)
|
36
40
|
end
|
@@ -58,6 +58,24 @@ module Rainbow
|
|
58
58
|
it_behaves_like "rainbow null string method"
|
59
59
|
end
|
60
60
|
|
61
|
+
describe '#bold' do
|
62
|
+
subject { presenter.bold }
|
63
|
+
|
64
|
+
it_behaves_like "rainbow null string method"
|
65
|
+
end
|
66
|
+
|
67
|
+
describe '#faint' do
|
68
|
+
subject { presenter.faint }
|
69
|
+
|
70
|
+
it_behaves_like "rainbow null string method"
|
71
|
+
end
|
72
|
+
|
73
|
+
describe '#dark' do
|
74
|
+
subject { presenter.dark }
|
75
|
+
|
76
|
+
it_behaves_like "rainbow null string method"
|
77
|
+
end
|
78
|
+
|
61
79
|
describe '#italic' do
|
62
80
|
subject { presenter.italic }
|
63
81
|
|
data/spec/unit/presenter_spec.rb
CHANGED
@@ -117,6 +117,28 @@ module Rainbow
|
|
117
117
|
end
|
118
118
|
end
|
119
119
|
|
120
|
+
describe '#faint' do
|
121
|
+
subject { presenter.faint }
|
122
|
+
|
123
|
+
it_behaves_like "rainbow string method"
|
124
|
+
|
125
|
+
it 'wraps with 2 code' do
|
126
|
+
subject
|
127
|
+
expect(StringUtils).to have_received(:wrap_with_sgr).with('hello', [2])
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
describe '#dark' do
|
132
|
+
subject { presenter.dark }
|
133
|
+
|
134
|
+
it_behaves_like "rainbow string method"
|
135
|
+
|
136
|
+
it 'wraps with 2 code' do
|
137
|
+
subject
|
138
|
+
expect(StringUtils).to have_received(:wrap_with_sgr).with('hello', [2])
|
139
|
+
end
|
140
|
+
end
|
141
|
+
|
120
142
|
describe '#italic' do
|
121
143
|
subject { presenter.italic }
|
122
144
|
|
metadata
CHANGED
@@ -1,15 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rainbow
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.2.
|
4
|
+
version: 2.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Marcin Kulik
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-04-21 00:00:00.000000000 Z
|
12
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: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
13
27
|
- !ruby/object:Gem::Dependency
|
14
28
|
name: bundler
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|