term-ansicolor 1.7.1 → 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 +17 -0
- data/.tool-versions +1 -0
- data/Rakefile +2 -3
- 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 +15 -29
- data/tests/hyperlink_test.rb +54 -0
- metadata +34 -15
- data/.travis.yml +0 -15
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
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
dockerfile: |-
|
2
|
+
RUN apk add --no-cache build-base git
|
3
|
+
RUN gem update --system
|
4
|
+
RUN gem install gem_hadar bundler
|
5
|
+
|
6
|
+
script: &script |-
|
7
|
+
echo -e "\e[1m"
|
8
|
+
ruby -v
|
9
|
+
echo -e "\e[0m"
|
10
|
+
bundle
|
11
|
+
rake test
|
12
|
+
|
13
|
+
images:
|
14
|
+
ruby:3.3-alpine: *script
|
15
|
+
ruby:3.2-alpine: *script
|
16
|
+
ruby:3.1-alpine: *script
|
17
|
+
ruby:3.0-alpine: *script
|
data/.tool-versions
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
ruby 3.3.0
|
data/Rakefile
CHANGED
@@ -8,7 +8,7 @@ GemHadar do
|
|
8
8
|
path_module 'Term::ANSIColor'
|
9
9
|
author 'Florian Frank'
|
10
10
|
email 'flori@ping.de'
|
11
|
-
homepage "
|
11
|
+
homepage "https://github.com/flori/#{name}"
|
12
12
|
summary 'Ruby library that colors strings using ANSI escape sequences'
|
13
13
|
description 'This library uses ANSI escape sequences to control the attributes of terminal output'
|
14
14
|
licenses << 'Apache-2.0'
|
@@ -23,6 +23,5 @@ GemHadar do
|
|
23
23
|
dependency 'tins', '~>1.0'
|
24
24
|
development_dependency 'simplecov'
|
25
25
|
development_dependency 'test-unit'
|
26
|
-
|
27
|
-
required_ruby_version '>= 2.0'
|
26
|
+
development_dependency 'utils'
|
28
27
|
end
|
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,45 +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 = "
|
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
|
-
s.executables = ["
|
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 = [".
|
17
|
-
s.homepage = "
|
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/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
|
+
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.
|
21
|
-
s.rubygems_version = "3.0.1".freeze
|
20
|
+
s.rubygems_version = "3.5.3".freeze
|
22
21
|
s.summary = "Ruby library that colors strings using ANSI escape sequences".freeze
|
23
|
-
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]
|
24
23
|
|
25
|
-
|
26
|
-
s.specification_version = 4
|
24
|
+
s.specification_version = 4
|
27
25
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
else
|
34
|
-
s.add_dependency(%q<gem_hadar>.freeze, ["~> 1.9.1"])
|
35
|
-
s.add_dependency(%q<simplecov>.freeze, [">= 0"])
|
36
|
-
s.add_dependency(%q<test-unit>.freeze, [">= 0"])
|
37
|
-
s.add_dependency(%q<tins>.freeze, ["~> 1.0"])
|
38
|
-
end
|
39
|
-
else
|
40
|
-
s.add_dependency(%q<gem_hadar>.freeze, ["~> 1.9.1"])
|
41
|
-
s.add_dependency(%q<simplecov>.freeze, [">= 0"])
|
42
|
-
s.add_dependency(%q<test-unit>.freeze, [">= 0"])
|
43
|
-
s.add_dependency(%q<tins>.freeze, ["~> 1.0"])
|
44
|
-
end
|
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])
|
45
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
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
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
|
@@ -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
|
@@ -70,12 +84,12 @@ description: This library uses ANSI escape sequences to control the attributes o
|
|
70
84
|
terminal output
|
71
85
|
email: flori@ping.de
|
72
86
|
executables:
|
73
|
-
- term_snow
|
74
|
-
- term_display
|
75
|
-
- term_decolor
|
76
87
|
- term_cdiff
|
77
|
-
- term_mandel
|
78
88
|
- term_colortab
|
89
|
+
- term_decolor
|
90
|
+
- term_display
|
91
|
+
- term_mandel
|
92
|
+
- term_snow
|
79
93
|
extensions: []
|
80
94
|
extra_rdoc_files:
|
81
95
|
- README.md
|
@@ -86,14 +100,16 @@ extra_rdoc_files:
|
|
86
100
|
- lib/term/ansicolor/attribute/intense_color8.rb
|
87
101
|
- lib/term/ansicolor/attribute/text.rb
|
88
102
|
- lib/term/ansicolor/hsl_triple.rb
|
103
|
+
- lib/term/ansicolor/hyperlink.rb
|
89
104
|
- lib/term/ansicolor/movement.rb
|
90
105
|
- lib/term/ansicolor/ppm_reader.rb
|
91
106
|
- lib/term/ansicolor/rgb_color_metrics.rb
|
92
107
|
- lib/term/ansicolor/rgb_triple.rb
|
93
108
|
- lib/term/ansicolor/version.rb
|
94
109
|
files:
|
110
|
+
- ".all_images.yml"
|
95
111
|
- ".gitignore"
|
96
|
-
- ".
|
112
|
+
- ".tool-versions"
|
97
113
|
- CHANGES
|
98
114
|
- COPYING
|
99
115
|
- Gemfile
|
@@ -118,6 +134,7 @@ files:
|
|
118
134
|
- lib/term/ansicolor/attribute/intense_color8.rb
|
119
135
|
- lib/term/ansicolor/attribute/text.rb
|
120
136
|
- lib/term/ansicolor/hsl_triple.rb
|
137
|
+
- lib/term/ansicolor/hyperlink.rb
|
121
138
|
- lib/term/ansicolor/movement.rb
|
122
139
|
- lib/term/ansicolor/ppm_reader.rb
|
123
140
|
- lib/term/ansicolor/rgb_color_metrics.rb
|
@@ -127,15 +144,16 @@ files:
|
|
127
144
|
- tests/ansicolor_test.rb
|
128
145
|
- tests/attribute_test.rb
|
129
146
|
- tests/hsl_triple_test.rb
|
147
|
+
- tests/hyperlink_test.rb
|
130
148
|
- tests/ppm_reader_test.rb
|
131
149
|
- tests/rgb_color_metrics_test.rb
|
132
150
|
- tests/rgb_triple_test.rb
|
133
151
|
- tests/test_helper.rb
|
134
|
-
homepage:
|
152
|
+
homepage: https://github.com/flori/term-ansicolor
|
135
153
|
licenses:
|
136
154
|
- Apache-2.0
|
137
155
|
metadata: {}
|
138
|
-
post_install_message:
|
156
|
+
post_install_message:
|
139
157
|
rdoc_options:
|
140
158
|
- "--title"
|
141
159
|
- Term-ansicolor - Ruby library that colors strings using ANSI escape sequences
|
@@ -147,21 +165,22 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
147
165
|
requirements:
|
148
166
|
- - ">="
|
149
167
|
- !ruby/object:Gem::Version
|
150
|
-
version: '
|
168
|
+
version: '0'
|
151
169
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
152
170
|
requirements:
|
153
171
|
- - ">="
|
154
172
|
- !ruby/object:Gem::Version
|
155
173
|
version: '0'
|
156
174
|
requirements: []
|
157
|
-
rubygems_version: 3.
|
158
|
-
signing_key:
|
175
|
+
rubygems_version: 3.5.3
|
176
|
+
signing_key:
|
159
177
|
specification_version: 4
|
160
178
|
summary: Ruby library that colors strings using ANSI escape sequences
|
161
179
|
test_files:
|
162
180
|
- tests/ansicolor_test.rb
|
163
181
|
- tests/attribute_test.rb
|
164
182
|
- tests/hsl_triple_test.rb
|
183
|
+
- tests/hyperlink_test.rb
|
165
184
|
- tests/ppm_reader_test.rb
|
166
185
|
- tests/rgb_color_metrics_test.rb
|
167
186
|
- tests/rgb_triple_test.rb
|