term-ansicolor 1.7.2 → 1.8.0
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 +1 -0
- data/.tool-versions +1 -1
- data/VERSION +1 -1
- data/examples/example.rb +2 -0
- data/lib/term/ansicolor/hyperlink.rb +34 -0
- data/lib/term/ansicolor/version.rb +1 -1
- data/lib/term/ansicolor.rb +3 -2
- data/term-ansicolor.gemspec +12 -12
- data/tests/hyperlink_test.rb +54 -0
- metadata +9 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9718f060556740778ada5aec7993d0ed9e4b61548b037f437255c2b01697dafa
|
4
|
+
data.tar.gz: 2f8eebac308b3c1d46436916c4dd7e37d71bfce3bb4376ed0b88027da1a1af9e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3a59e5c5c1ba7d9ece81227fc207be44959ac5c6f9d2b6c89c35a16563217f0f36c70c1ea33fa8a7ed89fc9e47e0a3ebf9827401e08b89b770b2f9a1c28c9701
|
7
|
+
data.tar.gz: a842928574662464fd5ad2bbd18bb9bcf0a45b1bd354e674462004ca07f60d3f36ef8b18bccb60faeba08f416f19652be501e51f17b216fce96f8068d7efdec5
|
data/.all_images.yml
CHANGED
data/.tool-versions
CHANGED
@@ -1 +1 @@
|
|
1
|
-
ruby 3.
|
1
|
+
ruby 3.3.0
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.
|
1
|
+
1.8.0
|
data/examples/example.rb
CHANGED
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'tins/terminal'
|
2
|
+
|
3
|
+
module Term
|
4
|
+
module ANSIColor
|
5
|
+
module Hyperlink
|
6
|
+
def hyperlink(link, string = nil, id: nil, as_link: false)
|
7
|
+
block_given? && string != nil && !respond_to?(:to_str) and
|
8
|
+
raise ArgumentError,
|
9
|
+
"Require either the string argument or a block argument"
|
10
|
+
if link.nil?
|
11
|
+
link = ''
|
12
|
+
end
|
13
|
+
if as_link && !link.empty?
|
14
|
+
string ||= link
|
15
|
+
end
|
16
|
+
result = ''
|
17
|
+
if Term::ANSIColor.coloring?
|
18
|
+
result = "\e]8;#{"id=#{id}" unless id.nil?};" << link.to_str << "\e\\"
|
19
|
+
end
|
20
|
+
if block_given?
|
21
|
+
result << yield.to_s
|
22
|
+
elsif string.respond_to?(:to_str)
|
23
|
+
result << string.to_str
|
24
|
+
elsif respond_to?(:to_str)
|
25
|
+
result << to_str
|
26
|
+
else
|
27
|
+
return result # only switch on
|
28
|
+
end
|
29
|
+
result << "\e]8;;\e\\" if Term::ANSIColor.coloring?
|
30
|
+
result
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
data/lib/term/ansicolor.rb
CHANGED
@@ -15,8 +15,9 @@ module Term
|
|
15
15
|
require 'term/ansicolor/attribute/intense_color8'
|
16
16
|
require 'term/ansicolor/attribute/color256'
|
17
17
|
require 'term/ansicolor/movement'
|
18
|
-
|
19
18
|
include Term::ANSIColor::Movement
|
19
|
+
require 'term/ansicolor/hyperlink'
|
20
|
+
include Term::ANSIColor::Hyperlink
|
20
21
|
|
21
22
|
# :stopdoc:
|
22
23
|
ATTRIBUTE_NAMES = Attribute.named_attributes.map(&:name)
|
@@ -95,7 +96,7 @@ module Term
|
|
95
96
|
elsif respond_to?(:to_str)
|
96
97
|
result << to_str
|
97
98
|
else
|
98
|
-
return result #only switch on
|
99
|
+
return result # only switch on
|
99
100
|
end
|
100
101
|
result << "\e[0m" if Term::ANSIColor.coloring?
|
101
102
|
result.extend(Term::ANSIColor)
|
data/term-ansicolor.gemspec
CHANGED
@@ -1,31 +1,31 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
|
-
# stub: term-ansicolor 1.
|
2
|
+
# stub: term-ansicolor 1.8.0 ruby lib
|
3
3
|
|
4
4
|
Gem::Specification.new do |s|
|
5
5
|
s.name = "term-ansicolor".freeze
|
6
|
-
s.version = "1.
|
6
|
+
s.version = "1.8.0".freeze
|
7
7
|
|
8
8
|
s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
|
9
9
|
s.require_paths = ["lib".freeze]
|
10
10
|
s.authors = ["Florian Frank".freeze]
|
11
|
-
s.date = "2024-
|
11
|
+
s.date = "2024-04-13"
|
12
12
|
s.description = "This library uses ANSI escape sequences to control the attributes of terminal output".freeze
|
13
13
|
s.email = "flori@ping.de".freeze
|
14
14
|
s.executables = ["term_cdiff".freeze, "term_colortab".freeze, "term_decolor".freeze, "term_display".freeze, "term_mandel".freeze, "term_snow".freeze]
|
15
|
-
s.extra_rdoc_files = ["README.md".freeze, "lib/term/ansicolor.rb".freeze, "lib/term/ansicolor/attribute.rb".freeze, "lib/term/ansicolor/attribute/color256.rb".freeze, "lib/term/ansicolor/attribute/color8.rb".freeze, "lib/term/ansicolor/attribute/intense_color8.rb".freeze, "lib/term/ansicolor/attribute/text.rb".freeze, "lib/term/ansicolor/hsl_triple.rb".freeze, "lib/term/ansicolor/movement.rb".freeze, "lib/term/ansicolor/ppm_reader.rb".freeze, "lib/term/ansicolor/rgb_color_metrics.rb".freeze, "lib/term/ansicolor/rgb_triple.rb".freeze, "lib/term/ansicolor/version.rb".freeze]
|
16
|
-
s.files = [".all_images.yml".freeze, ".gitignore".freeze, ".tool-versions".freeze, "CHANGES".freeze, "COPYING".freeze, "Gemfile".freeze, "README.md".freeze, "Rakefile".freeze, "VERSION".freeze, "bin/term_cdiff".freeze, "bin/term_colortab".freeze, "bin/term_decolor".freeze, "bin/term_display".freeze, "bin/term_mandel".freeze, "bin/term_snow".freeze, "examples/example.rb".freeze, "examples/lambda-red-plain.ppm".freeze, "examples/lambda-red.png".freeze, "examples/lambda-red.ppm".freeze, "lib/term/ansicolor.rb".freeze, "lib/term/ansicolor/.keep".freeze, "lib/term/ansicolor/attribute.rb".freeze, "lib/term/ansicolor/attribute/color256.rb".freeze, "lib/term/ansicolor/attribute/color8.rb".freeze, "lib/term/ansicolor/attribute/intense_color8.rb".freeze, "lib/term/ansicolor/attribute/text.rb".freeze, "lib/term/ansicolor/hsl_triple.rb".freeze, "lib/term/ansicolor/movement.rb".freeze, "lib/term/ansicolor/ppm_reader.rb".freeze, "lib/term/ansicolor/rgb_color_metrics.rb".freeze, "lib/term/ansicolor/rgb_triple.rb".freeze, "lib/term/ansicolor/version.rb".freeze, "term-ansicolor.gemspec".freeze, "tests/ansicolor_test.rb".freeze, "tests/attribute_test.rb".freeze, "tests/hsl_triple_test.rb".freeze, "tests/ppm_reader_test.rb".freeze, "tests/rgb_color_metrics_test.rb".freeze, "tests/rgb_triple_test.rb".freeze, "tests/test_helper.rb".freeze]
|
15
|
+
s.extra_rdoc_files = ["README.md".freeze, "lib/term/ansicolor.rb".freeze, "lib/term/ansicolor/attribute.rb".freeze, "lib/term/ansicolor/attribute/color256.rb".freeze, "lib/term/ansicolor/attribute/color8.rb".freeze, "lib/term/ansicolor/attribute/intense_color8.rb".freeze, "lib/term/ansicolor/attribute/text.rb".freeze, "lib/term/ansicolor/hsl_triple.rb".freeze, "lib/term/ansicolor/hyperlink.rb".freeze, "lib/term/ansicolor/movement.rb".freeze, "lib/term/ansicolor/ppm_reader.rb".freeze, "lib/term/ansicolor/rgb_color_metrics.rb".freeze, "lib/term/ansicolor/rgb_triple.rb".freeze, "lib/term/ansicolor/version.rb".freeze]
|
16
|
+
s.files = [".all_images.yml".freeze, ".gitignore".freeze, ".tool-versions".freeze, "CHANGES".freeze, "COPYING".freeze, "Gemfile".freeze, "README.md".freeze, "Rakefile".freeze, "VERSION".freeze, "bin/term_cdiff".freeze, "bin/term_colortab".freeze, "bin/term_decolor".freeze, "bin/term_display".freeze, "bin/term_mandel".freeze, "bin/term_snow".freeze, "examples/example.rb".freeze, "examples/lambda-red-plain.ppm".freeze, "examples/lambda-red.png".freeze, "examples/lambda-red.ppm".freeze, "lib/term/ansicolor.rb".freeze, "lib/term/ansicolor/.keep".freeze, "lib/term/ansicolor/attribute.rb".freeze, "lib/term/ansicolor/attribute/color256.rb".freeze, "lib/term/ansicolor/attribute/color8.rb".freeze, "lib/term/ansicolor/attribute/intense_color8.rb".freeze, "lib/term/ansicolor/attribute/text.rb".freeze, "lib/term/ansicolor/hsl_triple.rb".freeze, "lib/term/ansicolor/hyperlink.rb".freeze, "lib/term/ansicolor/movement.rb".freeze, "lib/term/ansicolor/ppm_reader.rb".freeze, "lib/term/ansicolor/rgb_color_metrics.rb".freeze, "lib/term/ansicolor/rgb_triple.rb".freeze, "lib/term/ansicolor/version.rb".freeze, "term-ansicolor.gemspec".freeze, "tests/ansicolor_test.rb".freeze, "tests/attribute_test.rb".freeze, "tests/hsl_triple_test.rb".freeze, "tests/hyperlink_test.rb".freeze, "tests/ppm_reader_test.rb".freeze, "tests/rgb_color_metrics_test.rb".freeze, "tests/rgb_triple_test.rb".freeze, "tests/test_helper.rb".freeze]
|
17
17
|
s.homepage = "https://github.com/flori/term-ansicolor".freeze
|
18
18
|
s.licenses = ["Apache-2.0".freeze]
|
19
19
|
s.rdoc_options = ["--title".freeze, "Term-ansicolor - Ruby library that colors strings using ANSI escape sequences".freeze, "--main".freeze, "README.md".freeze]
|
20
|
-
s.rubygems_version = "3.
|
20
|
+
s.rubygems_version = "3.5.3".freeze
|
21
21
|
s.summary = "Ruby library that colors strings using ANSI escape sequences".freeze
|
22
|
-
s.test_files = ["tests/ansicolor_test.rb".freeze, "tests/attribute_test.rb".freeze, "tests/hsl_triple_test.rb".freeze, "tests/ppm_reader_test.rb".freeze, "tests/rgb_color_metrics_test.rb".freeze, "tests/rgb_triple_test.rb".freeze, "tests/test_helper.rb".freeze]
|
22
|
+
s.test_files = ["tests/ansicolor_test.rb".freeze, "tests/attribute_test.rb".freeze, "tests/hsl_triple_test.rb".freeze, "tests/hyperlink_test.rb".freeze, "tests/ppm_reader_test.rb".freeze, "tests/rgb_color_metrics_test.rb".freeze, "tests/rgb_triple_test.rb".freeze, "tests/test_helper.rb".freeze]
|
23
23
|
|
24
24
|
s.specification_version = 4
|
25
25
|
|
26
|
-
s.add_development_dependency(%q<gem_hadar>.freeze, ["~> 1.
|
27
|
-
s.add_development_dependency(%q<simplecov>.freeze, [">= 0"])
|
28
|
-
s.add_development_dependency(%q<test-unit>.freeze, [">= 0"])
|
29
|
-
s.add_development_dependency(%q<utils>.freeze, [">= 0"])
|
30
|
-
s.add_runtime_dependency(%q<tins>.freeze, ["~> 1.0"])
|
26
|
+
s.add_development_dependency(%q<gem_hadar>.freeze, ["~> 1.15.0".freeze])
|
27
|
+
s.add_development_dependency(%q<simplecov>.freeze, [">= 0".freeze])
|
28
|
+
s.add_development_dependency(%q<test-unit>.freeze, [">= 0".freeze])
|
29
|
+
s.add_development_dependency(%q<utils>.freeze, [">= 0".freeze])
|
30
|
+
s.add_runtime_dependency(%q<tins>.freeze, ["~> 1.0".freeze])
|
31
31
|
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
class HyperlinkTest < Test::Unit::TestCase
|
2
|
+
include Term::ANSIColor
|
3
|
+
|
4
|
+
def setup
|
5
|
+
@link = 'https://foo.example.com'
|
6
|
+
end
|
7
|
+
|
8
|
+
def test_hyperlink_switch_on
|
9
|
+
assert_equal(
|
10
|
+
"\e]8;;#@link\e\\",
|
11
|
+
hyperlink(@link)
|
12
|
+
)
|
13
|
+
end
|
14
|
+
|
15
|
+
def test_hyperlink_switch_off
|
16
|
+
assert_equal(
|
17
|
+
"\e]8;;\e\\",
|
18
|
+
hyperlink(nil)
|
19
|
+
)
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_hyperlink_as_link
|
23
|
+
assert_equal(
|
24
|
+
hyperlink(@link, as_link: true),
|
25
|
+
"\e]8;;#@link\e\\#@link\e]8;;\e\\",
|
26
|
+
)
|
27
|
+
end
|
28
|
+
|
29
|
+
def test_hyperlink_two_args
|
30
|
+
assert_equal(
|
31
|
+
"\e]8;;#@link\e\\foo\e]8;;\e\\",
|
32
|
+
hyperlink(@link, 'foo')
|
33
|
+
)
|
34
|
+
end
|
35
|
+
|
36
|
+
def test_hyperlink_two_args_with_id
|
37
|
+
assert_equal(
|
38
|
+
"\e]8;id=666;#@link\e\\foo\e]8;;\e\\",
|
39
|
+
hyperlink(@link, 'foo', id: 666)
|
40
|
+
)
|
41
|
+
end
|
42
|
+
|
43
|
+
def test_hyperlink_block_arg
|
44
|
+
assert_raise(ArgumentError) { hyperlink(@link, 'bar') { 'baz' } }
|
45
|
+
assert_equal(
|
46
|
+
"\e]8;;#@link\e\\foo\e]8;;\e\\",
|
47
|
+
hyperlink(@link) { 'foo' }
|
48
|
+
)
|
49
|
+
end
|
50
|
+
|
51
|
+
def test_with_stringy_self
|
52
|
+
assert_equal "\e]8;;#@link\e\\foo\e]8;;\e\\", "foo".hyperlink(@link)
|
53
|
+
end
|
54
|
+
end
|
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.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Florian Frank
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-04-13 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.15.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.15.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: simplecov
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -100,6 +100,7 @@ extra_rdoc_files:
|
|
100
100
|
- lib/term/ansicolor/attribute/intense_color8.rb
|
101
101
|
- lib/term/ansicolor/attribute/text.rb
|
102
102
|
- lib/term/ansicolor/hsl_triple.rb
|
103
|
+
- lib/term/ansicolor/hyperlink.rb
|
103
104
|
- lib/term/ansicolor/movement.rb
|
104
105
|
- lib/term/ansicolor/ppm_reader.rb
|
105
106
|
- lib/term/ansicolor/rgb_color_metrics.rb
|
@@ -133,6 +134,7 @@ files:
|
|
133
134
|
- lib/term/ansicolor/attribute/intense_color8.rb
|
134
135
|
- lib/term/ansicolor/attribute/text.rb
|
135
136
|
- lib/term/ansicolor/hsl_triple.rb
|
137
|
+
- lib/term/ansicolor/hyperlink.rb
|
136
138
|
- lib/term/ansicolor/movement.rb
|
137
139
|
- lib/term/ansicolor/ppm_reader.rb
|
138
140
|
- lib/term/ansicolor/rgb_color_metrics.rb
|
@@ -142,6 +144,7 @@ files:
|
|
142
144
|
- tests/ansicolor_test.rb
|
143
145
|
- tests/attribute_test.rb
|
144
146
|
- tests/hsl_triple_test.rb
|
147
|
+
- tests/hyperlink_test.rb
|
145
148
|
- tests/ppm_reader_test.rb
|
146
149
|
- tests/rgb_color_metrics_test.rb
|
147
150
|
- tests/rgb_triple_test.rb
|
@@ -169,7 +172,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
169
172
|
- !ruby/object:Gem::Version
|
170
173
|
version: '0'
|
171
174
|
requirements: []
|
172
|
-
rubygems_version: 3.
|
175
|
+
rubygems_version: 3.5.3
|
173
176
|
signing_key:
|
174
177
|
specification_version: 4
|
175
178
|
summary: Ruby library that colors strings using ANSI escape sequences
|
@@ -177,6 +180,7 @@ test_files:
|
|
177
180
|
- tests/ansicolor_test.rb
|
178
181
|
- tests/attribute_test.rb
|
179
182
|
- tests/hsl_triple_test.rb
|
183
|
+
- tests/hyperlink_test.rb
|
180
184
|
- tests/ppm_reader_test.rb
|
181
185
|
- tests/rgb_color_metrics_test.rb
|
182
186
|
- tests/rgb_triple_test.rb
|