term-ansicolor 1.7.1 → 1.10.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.all_images.yml +27 -0
- data/.gitignore +1 -0
- data/.utilsrc +26 -0
- data/README.md +5 -3
- data/Rakefile +4 -4
- data/VERSION +1 -1
- data/bin/term_colortab +27 -1
- data/bin/term_display +5 -3
- data/bin/term_mandel +30 -24
- data/bin/term_snow +13 -13
- data/examples/example.rb +31 -1
- data/lib/term/ansicolor/attribute/color256.rb +38 -36
- data/lib/term/ansicolor/attribute/color8.rb +16 -16
- data/lib/term/ansicolor/attribute/intense_color8.rb +32 -34
- data/lib/term/ansicolor/attribute/text.rb +18 -15
- data/lib/term/ansicolor/attribute/underline.rb +34 -0
- data/lib/term/ansicolor/attribute.rb +86 -45
- data/lib/term/ansicolor/hsl_triple.rb +2 -2
- data/lib/term/ansicolor/hyperlink.rb +34 -0
- data/lib/term/ansicolor/ppm_reader.rb +9 -4
- data/lib/term/ansicolor/rgb_triple.rb +1 -3
- data/lib/term/ansicolor/version.rb +1 -1
- data/lib/term/ansicolor.rb +46 -42
- data/term-ansicolor.gemspec +16 -29
- data/tests/ansicolor_test.rb +69 -2
- data/tests/attribute_test.rb +45 -6
- data/tests/hsl_triple_test.rb +2 -2
- data/tests/hyperlink_test.rb +58 -0
- data/tests/ppm_reader_test.rb +8 -0
- data/tests/rgb_triple_test.rb +1 -1
- metadata +50 -15
- data/.travis.yml +0 -15
data/tests/attribute_test.rb
CHANGED
@@ -32,7 +32,7 @@ class AttributeTest < Test::Unit::TestCase
|
|
32
32
|
assert_in_delta 250.954, Attribute.get(:color0).distance_to(color), 1e-3
|
33
33
|
color = Attribute.nearest_rgb_color('#0f0')
|
34
34
|
assert_in_delta 255, Attribute.get(:color0).distance_to(color,
|
35
|
-
:
|
35
|
+
metric: RGBColorMetrics::Euclidean), 1e-3
|
36
36
|
assert_equal 1 / 0.0, Attribute.get(:color0).distance_to(nil)
|
37
37
|
end
|
38
38
|
|
@@ -40,14 +40,14 @@ class AttributeTest < Test::Unit::TestCase
|
|
40
40
|
assert_equal Attribute.get(:color0).rgb, Attribute.nearest_rgb_color('#000').rgb
|
41
41
|
assert_equal Attribute.get(:color15).rgb, Attribute.nearest_rgb_color('#ffffff').rgb
|
42
42
|
assert_equal :color248, Attribute.nearest_rgb_color('#aaa').name
|
43
|
-
assert_equal :color109, Attribute.nearest_rgb_color('#aaa', :
|
43
|
+
assert_equal :color109, Attribute.nearest_rgb_color('#aaa', gray: false).name
|
44
44
|
end
|
45
45
|
|
46
46
|
def test_nearest_rgb_on_color
|
47
47
|
assert_equal Attribute.get(:on_color0).rgb, Attribute.nearest_rgb_on_color('#000').rgb
|
48
48
|
assert_equal Attribute.get(:on_color15).rgb, Attribute.nearest_rgb_on_color('#ffffff').rgb
|
49
49
|
assert_equal :on_color248, Attribute.nearest_rgb_on_color('#aaa').name
|
50
|
-
assert_equal :on_color109, Attribute.nearest_rgb_on_color('#aaa', :
|
50
|
+
assert_equal :on_color109, Attribute.nearest_rgb_on_color('#aaa', gray: false).name
|
51
51
|
end
|
52
52
|
|
53
53
|
def test_apply
|
@@ -59,15 +59,54 @@ class AttributeTest < Test::Unit::TestCase
|
|
59
59
|
def test_gradient
|
60
60
|
g0 = Attribute[:blink].gradient_to Attribute['#30ffaa']
|
61
61
|
assert_equal [], g0
|
62
|
-
g1 = Attribute['#30ffaa'].gradient_to(Attribute['#ff507f'], :
|
62
|
+
g1 = Attribute['#30ffaa'].gradient_to(Attribute['#ff507f'], steps: 9)
|
63
63
|
assert_equal [ :color49, :color49, :color43, :color79, :color108,
|
64
64
|
:color247, :color138, :color168, :color204 ], g1.map(&:name)
|
65
65
|
g2 = Attribute['#30ffaa'].gradient_to(
|
66
66
|
Attribute['#ff507f'],
|
67
|
-
:
|
68
|
-
:
|
67
|
+
steps: 9,
|
68
|
+
metric: RGBColorMetrics::Euclidean
|
69
69
|
)
|
70
70
|
assert_equal [ :color49, :color43, :color79, :color73, :color108,
|
71
71
|
:color247, :color138, :color168, :color204 ], g2.map(&:name)
|
72
72
|
end
|
73
|
+
|
74
|
+
def test_true_color
|
75
|
+
pinkish = Attribute['#f050a0', true_coloring: true]
|
76
|
+
assert_equal [ 240, 80, 160 ], pinkish.to_rgb_triple.to_a
|
77
|
+
on_pinkish = Attribute['on_#f050a0', true_coloring: true]
|
78
|
+
assert_equal [ 240, 80, 160 ], on_pinkish.to_rgb_triple.to_a
|
79
|
+
red = Attribute['9', true_coloring: true]
|
80
|
+
assert_equal [ 255, 0, 0 ], red.to_rgb_triple.to_a
|
81
|
+
red = Attribute['red', true_coloring: true]
|
82
|
+
assert_equal :red, red.name
|
83
|
+
pinkish_pinkish = Attribute[pinkish, true_coloring: true]
|
84
|
+
assert_equal pinkish, pinkish_pinkish
|
85
|
+
pinkish_pinkish = Attribute[pinkish.to_rgb_triple, true_coloring: true]
|
86
|
+
assert_equal pinkish.to_rgb_triple, pinkish_pinkish.to_rgb_triple
|
87
|
+
pinkish_pinkish = Attribute[pinkish.to_rgb_triple.to_a, true_coloring: true]
|
88
|
+
assert_equal pinkish.to_rgb_triple, pinkish_pinkish.to_rgb_triple
|
89
|
+
end
|
90
|
+
|
91
|
+
def test_true_color_gradient
|
92
|
+
g0 = Attribute[:blink].gradient_to Attribute['#30ffaa']
|
93
|
+
assert_equal [], g0
|
94
|
+
g1 = Attribute['#30ffaa'].gradient_to(
|
95
|
+
Attribute['#ff507f'],
|
96
|
+
steps: 9,
|
97
|
+
true_coloring: true
|
98
|
+
)
|
99
|
+
assert_equal %w[
|
100
|
+
#00ffaf #1febaa #3ed7a5 #5dc3a0 #7caf9b #9b9b96 #ba8791 #d9738c #ff5f87
|
101
|
+
], g1.map { |c| c.rgb.html }
|
102
|
+
g2 = Attribute['#30ffaa'].gradient_to(
|
103
|
+
Attribute['#ff507f'],
|
104
|
+
steps: 9,
|
105
|
+
true_coloring: true,
|
106
|
+
metric: RGBColorMetrics::Euclidean
|
107
|
+
)
|
108
|
+
assert_equal %w[
|
109
|
+
#00ffaf #1febaa #3ed7a5 #5dc3a0 #7caf9b #9b9b96 #ba8791 #d9738c #ff5f87
|
110
|
+
], g2.map { |c| c.rgb.html }
|
111
|
+
end
|
73
112
|
end
|
data/tests/hsl_triple_test.rb
CHANGED
@@ -13,7 +13,7 @@ class HSLTripleTest < Test::Unit::TestCase
|
|
13
13
|
|
14
14
|
def test_hsl_cast
|
15
15
|
assert_equal '#85e085', HSLTriple[ @pastel_green_hsl ].html
|
16
|
-
assert_equal '#85e085', HSLTriple[ :
|
16
|
+
assert_equal '#85e085', HSLTriple[ hue: 120, saturation: 59.4, lightness: 70 ].html
|
17
17
|
assert_equal '#11ddff', HSLTriple[ '#1df' ].html
|
18
18
|
assert_equal '#8000ff', HSLTriple[ 'rgb(128,0,255)' ].html
|
19
19
|
assert_equal '#85e085', HSLTriple[ 'hsl(120.0,59.4%,70.0%)' ].html
|
@@ -80,6 +80,6 @@ class HSLTripleTest < Test::Unit::TestCase
|
|
80
80
|
end
|
81
81
|
|
82
82
|
def test_method_missing
|
83
|
-
|
83
|
+
assert_raises(NoMethodError) { @pastel_green_hsl.foo }
|
84
84
|
end
|
85
85
|
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class HyperlinkTest < Test::Unit::TestCase
|
4
|
+
include Term::ANSIColor
|
5
|
+
|
6
|
+
def setup
|
7
|
+
@link = 'https://foo.example.com'
|
8
|
+
end
|
9
|
+
|
10
|
+
def test_hyperlink_switch_on
|
11
|
+
assert_equal(
|
12
|
+
"\e]8;;#@link\e\\",
|
13
|
+
hyperlink(@link)
|
14
|
+
)
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_hyperlink_switch_off
|
18
|
+
assert_equal(
|
19
|
+
"\e]8;;\e\\",
|
20
|
+
hyperlink(nil)
|
21
|
+
)
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_hyperlink_as_link
|
25
|
+
assert_equal(
|
26
|
+
hyperlink(@link, as_link: true),
|
27
|
+
"\e]8;;#@link\e\\#@link\e]8;;\e\\",
|
28
|
+
)
|
29
|
+
end
|
30
|
+
|
31
|
+
def test_hyperlink_two_args
|
32
|
+
assert_equal(
|
33
|
+
"\e]8;;#@link\e\\foo\e]8;;\e\\",
|
34
|
+
hyperlink(@link, 'foo')
|
35
|
+
)
|
36
|
+
end
|
37
|
+
|
38
|
+
def test_hyperlink_two_args_with_id
|
39
|
+
assert_equal(
|
40
|
+
"\e]8;id=666;#@link\e\\foo\e]8;;\e\\",
|
41
|
+
hyperlink(@link, 'foo', id: 666)
|
42
|
+
)
|
43
|
+
end
|
44
|
+
|
45
|
+
def test_hyperlink_block_arg
|
46
|
+
assert_raises(ArgumentError) { hyperlink(@link, 'bar') { 'baz' } }
|
47
|
+
assert_equal(
|
48
|
+
"\e]8;;#@link\e\\foo\e]8;;\e\\",
|
49
|
+
hyperlink(@link) { 'foo' }
|
50
|
+
)
|
51
|
+
end
|
52
|
+
|
53
|
+
def test_with_stringy_self
|
54
|
+
string = 'foo'
|
55
|
+
string.extend Term::ANSIColor
|
56
|
+
assert_equal "\e]8;;#@link\e\\foo\e]8;;\e\\", string.hyperlink(@link)
|
57
|
+
end
|
58
|
+
end
|
data/tests/ppm_reader_test.rb
CHANGED
@@ -28,6 +28,14 @@ class PPMReaderTest < Test::Unit::TestCase
|
|
28
28
|
end
|
29
29
|
end
|
30
30
|
|
31
|
+
def test_rendering_ppm_with_true_colors
|
32
|
+
File.open(example_path('lambda-red.ppm')) do |ppm6|
|
33
|
+
ppm_reader = PPMReader.new(ppm6, :true_coloring => true)
|
34
|
+
assert_equal '5faa2b046cc3e030f86588e472683834',
|
35
|
+
Digest::MD5.hexdigest(ppm_reader.to_s)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
31
39
|
def test_to_a
|
32
40
|
File.open(example_path('lambda-red.ppm')) do |ppm6|
|
33
41
|
ppm_reader = PPMReader.new(ppm6, :gray => false)
|
data/tests/rgb_triple_test.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: term-ansicolor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.10.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Florian Frank
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-07-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: gem_hadar
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 1.
|
19
|
+
version: 1.16.0
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 1.
|
26
|
+
version: 1.16.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: simplecov
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -52,6 +52,20 @@ dependencies:
|
|
52
52
|
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: utils
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
55
69
|
- !ruby/object:Gem::Dependency
|
56
70
|
name: tins
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -66,16 +80,30 @@ dependencies:
|
|
66
80
|
- - "~>"
|
67
81
|
- !ruby/object:Gem::Version
|
68
82
|
version: '1.0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: mize
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0.5'
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0.5'
|
69
97
|
description: This library uses ANSI escape sequences to control the attributes of
|
70
98
|
terminal output
|
71
99
|
email: flori@ping.de
|
72
100
|
executables:
|
73
|
-
- term_snow
|
74
|
-
- term_display
|
75
|
-
- term_decolor
|
76
101
|
- term_cdiff
|
77
|
-
- term_mandel
|
78
102
|
- term_colortab
|
103
|
+
- term_decolor
|
104
|
+
- term_display
|
105
|
+
- term_mandel
|
106
|
+
- term_snow
|
79
107
|
extensions: []
|
80
108
|
extra_rdoc_files:
|
81
109
|
- README.md
|
@@ -85,15 +113,18 @@ extra_rdoc_files:
|
|
85
113
|
- lib/term/ansicolor/attribute/color8.rb
|
86
114
|
- lib/term/ansicolor/attribute/intense_color8.rb
|
87
115
|
- lib/term/ansicolor/attribute/text.rb
|
116
|
+
- lib/term/ansicolor/attribute/underline.rb
|
88
117
|
- lib/term/ansicolor/hsl_triple.rb
|
118
|
+
- lib/term/ansicolor/hyperlink.rb
|
89
119
|
- lib/term/ansicolor/movement.rb
|
90
120
|
- lib/term/ansicolor/ppm_reader.rb
|
91
121
|
- lib/term/ansicolor/rgb_color_metrics.rb
|
92
122
|
- lib/term/ansicolor/rgb_triple.rb
|
93
123
|
- lib/term/ansicolor/version.rb
|
94
124
|
files:
|
125
|
+
- ".all_images.yml"
|
95
126
|
- ".gitignore"
|
96
|
-
- ".
|
127
|
+
- ".utilsrc"
|
97
128
|
- CHANGES
|
98
129
|
- COPYING
|
99
130
|
- Gemfile
|
@@ -117,7 +148,9 @@ files:
|
|
117
148
|
- lib/term/ansicolor/attribute/color8.rb
|
118
149
|
- lib/term/ansicolor/attribute/intense_color8.rb
|
119
150
|
- lib/term/ansicolor/attribute/text.rb
|
151
|
+
- lib/term/ansicolor/attribute/underline.rb
|
120
152
|
- lib/term/ansicolor/hsl_triple.rb
|
153
|
+
- lib/term/ansicolor/hyperlink.rb
|
121
154
|
- lib/term/ansicolor/movement.rb
|
122
155
|
- lib/term/ansicolor/ppm_reader.rb
|
123
156
|
- lib/term/ansicolor/rgb_color_metrics.rb
|
@@ -127,15 +160,16 @@ files:
|
|
127
160
|
- tests/ansicolor_test.rb
|
128
161
|
- tests/attribute_test.rb
|
129
162
|
- tests/hsl_triple_test.rb
|
163
|
+
- tests/hyperlink_test.rb
|
130
164
|
- tests/ppm_reader_test.rb
|
131
165
|
- tests/rgb_color_metrics_test.rb
|
132
166
|
- tests/rgb_triple_test.rb
|
133
167
|
- tests/test_helper.rb
|
134
|
-
homepage:
|
168
|
+
homepage: https://github.com/flori/term-ansicolor
|
135
169
|
licenses:
|
136
170
|
- Apache-2.0
|
137
171
|
metadata: {}
|
138
|
-
post_install_message:
|
172
|
+
post_install_message:
|
139
173
|
rdoc_options:
|
140
174
|
- "--title"
|
141
175
|
- Term-ansicolor - Ruby library that colors strings using ANSI escape sequences
|
@@ -147,21 +181,22 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
147
181
|
requirements:
|
148
182
|
- - ">="
|
149
183
|
- !ruby/object:Gem::Version
|
150
|
-
version: '
|
184
|
+
version: '0'
|
151
185
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
152
186
|
requirements:
|
153
187
|
- - ">="
|
154
188
|
- !ruby/object:Gem::Version
|
155
189
|
version: '0'
|
156
190
|
requirements: []
|
157
|
-
rubygems_version: 3.
|
158
|
-
signing_key:
|
191
|
+
rubygems_version: 3.5.11
|
192
|
+
signing_key:
|
159
193
|
specification_version: 4
|
160
194
|
summary: Ruby library that colors strings using ANSI escape sequences
|
161
195
|
test_files:
|
162
196
|
- tests/ansicolor_test.rb
|
163
197
|
- tests/attribute_test.rb
|
164
198
|
- tests/hsl_triple_test.rb
|
199
|
+
- tests/hyperlink_test.rb
|
165
200
|
- tests/ppm_reader_test.rb
|
166
201
|
- tests/rgb_color_metrics_test.rb
|
167
202
|
- tests/rgb_triple_test.rb
|