term-ansicolor 1.3.2 → 1.4.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.
- checksums.yaml +4 -4
- data/.travis.yml +6 -4
- data/CHANGES +1 -0
- data/COPYING +20 -20
- data/Gemfile +2 -0
- data/README.rdoc +0 -0
- data/Rakefile +3 -1
- data/VERSION +1 -1
- data/bin/{cdiff → term_cdiff} +0 -0
- data/bin/{colortab → term_colortab} +0 -0
- data/bin/{decolor → term_decolor} +0 -0
- data/examples/example.rb +3 -3
- data/lib/term/ansicolor.rb +6 -132
- data/lib/term/ansicolor/attribute.rb +8 -10
- data/lib/term/ansicolor/attribute/color256.rb +69 -0
- data/lib/term/ansicolor/attribute/color8.rb +25 -0
- data/lib/term/ansicolor/attribute/intense_color8.rb +43 -0
- data/lib/term/ansicolor/attribute/text.rb +21 -0
- data/lib/term/ansicolor/version.rb +1 -1
- data/term-ansicolor.gemspec +11 -10
- data/tests/ansicolor_test.rb +9 -0
- data/tests/test_helper.rb +5 -0
- metadata +21 -13
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5099b1eabbfe82fc6b439af1e0cb88bb4e6d7be8
|
4
|
+
data.tar.gz: 117f27d8658a7b1cc0060c68569b14e596f029f6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4ed73586397d8ebcbb3dbd1fb11a9dcbd4e43884606ef9a246e12e714dd5713fdb3ef702832c8948db95589ccbe816353eb6b4053c88b416c7f2d08ad03bb0a0
|
7
|
+
data.tar.gz: e3d04d1f82719b58f05b798ebedf6f64335f1d5078cdd060f58e7c6aa98091c9ab99e41facfef6a34a40fb6ddd9f4d4d9ed6d33d11d53601832b520280ef1120
|
data/.travis.yml
CHANGED
@@ -2,11 +2,13 @@ rvm:
|
|
2
2
|
- 2.0
|
3
3
|
- 2.1
|
4
4
|
- 2.2
|
5
|
+
- 2.3.1
|
5
6
|
- ruby-head
|
6
|
-
-
|
7
|
-
- jruby-head
|
7
|
+
- jruby
|
8
8
|
matrix:
|
9
9
|
allow_failures:
|
10
10
|
- rvm: ruby-head
|
11
|
-
- rvm: jruby
|
12
|
-
|
11
|
+
- rvm: jruby
|
12
|
+
env:
|
13
|
+
- CODECLIMATE_REPO_TOKEN=ef2c31d6fd3c385eef57dcb62374be51b56af36dd4405763d3e43a1c06330b33
|
14
|
+
sudo: false
|
data/CHANGES
CHANGED
data/COPYING
CHANGED
@@ -1,12 +1,12 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
GNU GENERAL PUBLIC LICENSE
|
2
|
+
Version 2, June 1991
|
3
3
|
|
4
|
-
Copyright (C) 1989, 1991 Free Software Foundation, Inc
|
5
|
-
|
4
|
+
Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
|
5
|
+
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
6
6
|
Everyone is permitted to copy and distribute verbatim copies
|
7
7
|
of this license document, but changing it is not allowed.
|
8
8
|
|
9
|
-
|
9
|
+
Preamble
|
10
10
|
|
11
11
|
The licenses for most software are designed to take away your
|
12
12
|
freedom to share and change it. By contrast, the GNU General Public
|
@@ -15,7 +15,7 @@ software--to make sure the software is free for all its users. This
|
|
15
15
|
General Public License applies to most of the Free Software
|
16
16
|
Foundation's software and to any other program whose authors commit to
|
17
17
|
using it. (Some other Free Software Foundation software is covered by
|
18
|
-
the GNU
|
18
|
+
the GNU Lesser General Public License instead.) You can apply it to
|
19
19
|
your programs, too.
|
20
20
|
|
21
21
|
When we speak of free software, we are referring to freedom, not
|
@@ -55,8 +55,8 @@ patent must be licensed for everyone's free use or not licensed at all.
|
|
55
55
|
|
56
56
|
The precise terms and conditions for copying, distribution and
|
57
57
|
modification follow.
|
58
|
-
|
59
|
-
|
58
|
+
|
59
|
+
GNU GENERAL PUBLIC LICENSE
|
60
60
|
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
61
61
|
|
62
62
|
0. This License applies to any program or other work which contains
|
@@ -110,7 +110,7 @@ above, provided that you also meet all of these conditions:
|
|
110
110
|
License. (Exception: if the Program itself is interactive but
|
111
111
|
does not normally print such an announcement, your work based on
|
112
112
|
the Program is not required to print an announcement.)
|
113
|
-
|
113
|
+
|
114
114
|
These requirements apply to the modified work as a whole. If
|
115
115
|
identifiable sections of that work are not derived from the Program,
|
116
116
|
and can be reasonably considered independent and separate works in
|
@@ -168,7 +168,7 @@ access to copy from a designated place, then offering equivalent
|
|
168
168
|
access to copy the source code from the same place counts as
|
169
169
|
distribution of the source code, even though third parties are not
|
170
170
|
compelled to copy the source along with the object code.
|
171
|
-
|
171
|
+
|
172
172
|
4. You may not copy, modify, sublicense, or distribute the Program
|
173
173
|
except as expressly provided under this License. Any attempt
|
174
174
|
otherwise to copy, modify, sublicense or distribute the Program is
|
@@ -225,7 +225,7 @@ impose that choice.
|
|
225
225
|
|
226
226
|
This section is intended to make thoroughly clear what is believed to
|
227
227
|
be a consequence of the rest of this License.
|
228
|
-
|
228
|
+
|
229
229
|
8. If the distribution and/or use of the Program is restricted in
|
230
230
|
certain countries either by patents or by copyrighted interfaces, the
|
231
231
|
original copyright holder who places the Program under this License
|
@@ -255,7 +255,7 @@ make exceptions for this. Our decision will be guided by the two goals
|
|
255
255
|
of preserving the free status of all derivatives of our free software and
|
256
256
|
of promoting the sharing and reuse of software generally.
|
257
257
|
|
258
|
-
|
258
|
+
NO WARRANTY
|
259
259
|
|
260
260
|
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
|
261
261
|
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
|
@@ -277,9 +277,9 @@ YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
|
|
277
277
|
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
|
278
278
|
POSSIBILITY OF SUCH DAMAGES.
|
279
279
|
|
280
|
-
|
281
|
-
|
282
|
-
|
280
|
+
END OF TERMS AND CONDITIONS
|
281
|
+
|
282
|
+
How to Apply These Terms to Your New Programs
|
283
283
|
|
284
284
|
If you develop a new program, and you want it to be of the greatest
|
285
285
|
possible use to the public, the best way to achieve this is to make it
|
@@ -303,10 +303,9 @@ the "copyright" line and a pointer to where the full notice is found.
|
|
303
303
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
304
304
|
GNU General Public License for more details.
|
305
305
|
|
306
|
-
You should have received a copy of the GNU General Public License
|
307
|
-
|
308
|
-
|
309
|
-
|
306
|
+
You should have received a copy of the GNU General Public License along
|
307
|
+
with this program; if not, write to the Free Software Foundation, Inc.,
|
308
|
+
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
310
309
|
|
311
310
|
Also add information on how to contact you by electronic and paper mail.
|
312
311
|
|
@@ -336,5 +335,6 @@ necessary. Here is a sample; alter the names:
|
|
336
335
|
This General Public License does not permit incorporating your program into
|
337
336
|
proprietary programs. If your program is a subroutine library, you may
|
338
337
|
consider it more useful to permit linking proprietary applications with the
|
339
|
-
library. If this is what you want to do, use the GNU
|
338
|
+
library. If this is what you want to do, use the GNU Lesser General
|
340
339
|
Public License instead of this License.
|
340
|
+
|
data/Gemfile
CHANGED
data/README.rdoc
CHANGED
File without changes
|
data/Rakefile
CHANGED
@@ -15,12 +15,14 @@ GemHadar do
|
|
15
15
|
test_dir 'tests'
|
16
16
|
ignore '.*.sw[pon]', 'pkg', 'Gemfile.lock', '.rvmrc', 'coverage', 'tags', '.bundle'
|
17
17
|
readme 'README.rdoc'
|
18
|
-
executables
|
18
|
+
executables.merge Dir['bin/*'].map { |x| File.basename(x) }
|
19
19
|
|
20
20
|
dependency 'tins', '~>1.0'
|
21
21
|
development_dependency 'simplecov'
|
22
22
|
development_dependency 'minitest_tu_shim'
|
23
23
|
|
24
|
+
required_ruby_version '>= 2.0'
|
25
|
+
|
24
26
|
install_library do
|
25
27
|
destdir = "#{ENV['DESTDIR']}"
|
26
28
|
libdir = CONFIG["sitelibdir"]
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.
|
1
|
+
1.4.0
|
data/bin/{cdiff → term_cdiff}
RENAMED
File without changes
|
File without changes
|
File without changes
|
data/examples/example.rb
CHANGED
@@ -1,11 +1,11 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#
|
1
3
|
require 'term/ansicolor'
|
2
4
|
|
3
5
|
# Use this trick to work around namespace cluttering that
|
4
6
|
# happens if you just include Term::ANSIColor:
|
5
7
|
|
6
|
-
|
7
|
-
extend Term::ANSIColor
|
8
|
-
end
|
8
|
+
Color = Object.new.extend Term::ANSIColor
|
9
9
|
|
10
10
|
print Color.red, Color.bold, "No Namespace cluttering:", Color.clear, "\n"
|
11
11
|
print Color.green + "green" + Color.clear, "\n"
|
data/lib/term/ansicolor.rb
CHANGED
@@ -7,136 +7,10 @@ module Term
|
|
7
7
|
require 'term/ansicolor/attribute'
|
8
8
|
require 'term/ansicolor/rgb_triple'
|
9
9
|
require 'term/ansicolor/ppm_reader'
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
Attribute.set :dark , 2
|
15
|
-
Attribute.set :faint , 2
|
16
|
-
Attribute.set :italic , 3 # not widely implemented
|
17
|
-
Attribute.set :underline , 4
|
18
|
-
Attribute.set :underscore , 4 # synonym for :underline
|
19
|
-
Attribute.set :blink , 5
|
20
|
-
Attribute.set :rapid_blink , 6 # not widely implemented
|
21
|
-
Attribute.set :negative , 7 # no reverse because of String#reverse
|
22
|
-
Attribute.set :concealed , 8
|
23
|
-
Attribute.set :strikethrough , 9 # not widely implemented
|
24
|
-
|
25
|
-
Attribute.set :black , 30
|
26
|
-
Attribute.set :red , 31
|
27
|
-
Attribute.set :green , 32
|
28
|
-
Attribute.set :yellow , 33
|
29
|
-
Attribute.set :blue , 34
|
30
|
-
Attribute.set :magenta , 35
|
31
|
-
Attribute.set :cyan , 36
|
32
|
-
Attribute.set :white , 37
|
33
|
-
|
34
|
-
Attribute.set :on_black , 40
|
35
|
-
Attribute.set :on_red , 41
|
36
|
-
Attribute.set :on_green , 42
|
37
|
-
Attribute.set :on_yellow , 43
|
38
|
-
Attribute.set :on_blue , 44
|
39
|
-
Attribute.set :on_magenta , 45
|
40
|
-
Attribute.set :on_cyan , 46
|
41
|
-
Attribute.set :on_white , 47
|
42
|
-
|
43
|
-
# High intensity, aixterm (works in OS X)
|
44
|
-
Attribute.set :intense_black , 90
|
45
|
-
Attribute.set :bright_black , 90
|
46
|
-
Attribute.set :intense_red , 91
|
47
|
-
Attribute.set :bright_red , 91
|
48
|
-
Attribute.set :intense_green , 92
|
49
|
-
Attribute.set :bright_green , 92
|
50
|
-
Attribute.set :intense_yellow , 93
|
51
|
-
Attribute.set :bright_yellow , 93
|
52
|
-
Attribute.set :intense_blue , 94
|
53
|
-
Attribute.set :bright_blue , 94
|
54
|
-
Attribute.set :intense_magenta , 95
|
55
|
-
Attribute.set :bright_magenta , 95
|
56
|
-
Attribute.set :intense_cyan , 96
|
57
|
-
Attribute.set :bright_cyan , 96
|
58
|
-
Attribute.set :intense_white , 97
|
59
|
-
Attribute.set :bright_white , 97
|
60
|
-
|
61
|
-
# High intensity background, aixterm (works in OS X)
|
62
|
-
Attribute.set :on_intense_black , 100
|
63
|
-
Attribute.set :on_bright_black , 100
|
64
|
-
Attribute.set :on_intense_red , 101
|
65
|
-
Attribute.set :on_bright_red , 101
|
66
|
-
Attribute.set :on_intense_green , 102
|
67
|
-
Attribute.set :on_bright_green , 102
|
68
|
-
Attribute.set :on_intense_yellow , 103
|
69
|
-
Attribute.set :on_bright_yellow , 103
|
70
|
-
Attribute.set :on_intense_blue , 104
|
71
|
-
Attribute.set :on_bright_blue , 104
|
72
|
-
Attribute.set :on_intense_magenta, 105
|
73
|
-
Attribute.set :on_bright_magenta , 105
|
74
|
-
Attribute.set :on_intense_cyan , 106
|
75
|
-
Attribute.set :on_bright_cyan , 106
|
76
|
-
Attribute.set :on_intense_white , 107
|
77
|
-
Attribute.set :on_bright_white , 107
|
78
|
-
|
79
|
-
Attribute.set :color0, 0, :html => '#000000'
|
80
|
-
Attribute.set :color1, 1, :html => '#800000'
|
81
|
-
Attribute.set :color2, 2, :html => '#808000'
|
82
|
-
Attribute.set :color3, 3, :html => '#808000'
|
83
|
-
Attribute.set :color4, 4, :html => '#000080'
|
84
|
-
Attribute.set :color5, 5, :html => '#800080'
|
85
|
-
Attribute.set :color6, 6, :html => '#008080'
|
86
|
-
Attribute.set :color7, 7, :html => '#c0c0c0'
|
87
|
-
|
88
|
-
Attribute.set :color8, 8, :html => '#808080'
|
89
|
-
Attribute.set :color9, 9, :html => '#ff0000'
|
90
|
-
Attribute.set :color10, 10, :html => '#00ff00'
|
91
|
-
Attribute.set :color11, 11, :html => '#ffff00'
|
92
|
-
Attribute.set :color12, 12, :html => '#0000ff'
|
93
|
-
Attribute.set :color13, 13, :html => '#ff00ff'
|
94
|
-
Attribute.set :color14, 14, :html => '#00ffff'
|
95
|
-
Attribute.set :color15, 15, :html => '#ffffff'
|
96
|
-
|
97
|
-
steps = [ 0x00, 0x5f, 0x87, 0xaf, 0xd7, 0xff ]
|
98
|
-
|
99
|
-
for i in 16..231
|
100
|
-
red, green, blue = (i - 16).to_s(6).rjust(3, '0').each_char.map { |c| steps[c.to_i] }
|
101
|
-
Attribute.set "color#{i}", i, :red => red, :green => green, :blue => blue
|
102
|
-
end
|
103
|
-
|
104
|
-
grey = 8
|
105
|
-
for i in 232..255
|
106
|
-
Attribute.set "color#{i}", i, :red => grey, :green => grey, :blue => grey
|
107
|
-
grey += 10
|
108
|
-
end
|
109
|
-
|
110
|
-
Attribute.set :on_color0, 0, :html => '#000000'
|
111
|
-
Attribute.set :on_color1, 1, :html => '#800000'
|
112
|
-
Attribute.set :on_color2, 2, :html => '#808000'
|
113
|
-
Attribute.set :on_color3, 3, :html => '#808000'
|
114
|
-
Attribute.set :on_color4, 4, :html => '#000080'
|
115
|
-
Attribute.set :on_color5, 5, :html => '#800080'
|
116
|
-
Attribute.set :on_color6, 6, :html => '#008080'
|
117
|
-
Attribute.set :on_color7, 7, :html => '#c0c0c0'
|
118
|
-
|
119
|
-
Attribute.set :on_color8, 8, :html => '#808080'
|
120
|
-
Attribute.set :on_color9, 9, :html => '#ff0000'
|
121
|
-
Attribute.set :on_color10, 10, :html => '#00ff00'
|
122
|
-
Attribute.set :on_color11, 11, :html => '#ffff00'
|
123
|
-
Attribute.set :on_color12, 12, :html => '#0000ff'
|
124
|
-
Attribute.set :on_color13, 13, :html => '#ff00ff'
|
125
|
-
Attribute.set :on_color14, 14, :html => '#00ffff'
|
126
|
-
Attribute.set :on_color15, 15, :html => '#ffffff'
|
127
|
-
|
128
|
-
steps = [ 0x00, 0x5f, 0x87, 0xaf, 0xd7, 0xff ]
|
129
|
-
|
130
|
-
for i in 16..231
|
131
|
-
red, green, blue = (i - 16).to_s(6).rjust(3, '0').each_char.map { |c| steps[c.to_i] }
|
132
|
-
Attribute.set "on_color#{i}", i, :red => red, :green => green, :blue => blue
|
133
|
-
end
|
134
|
-
|
135
|
-
grey = 8
|
136
|
-
for i in 232..255
|
137
|
-
Attribute.set "on_color#{i}", i, :red => grey, :green => grey, :blue => grey
|
138
|
-
grey += 10
|
139
|
-
end
|
10
|
+
require 'term/ansicolor/attribute/text'
|
11
|
+
require 'term/ansicolor/attribute/color8'
|
12
|
+
require 'term/ansicolor/attribute/intense_color8'
|
13
|
+
require 'term/ansicolor/attribute/color256'
|
140
14
|
|
141
15
|
# :stopdoc:
|
142
16
|
ATTRIBUTE_NAMES = Attribute.named_attributes.map(&:name)
|
@@ -196,7 +70,7 @@ module Term
|
|
196
70
|
to_str.gsub(COLORED_REGEXP, '')
|
197
71
|
else
|
198
72
|
''
|
199
|
-
end
|
73
|
+
end.extend(Term::ANSIColor)
|
200
74
|
end
|
201
75
|
|
202
76
|
alias uncolored uncolor
|
@@ -218,7 +92,7 @@ module Term
|
|
218
92
|
return result #only switch on
|
219
93
|
end
|
220
94
|
result << "\e[0m" if Term::ANSIColor.coloring?
|
221
|
-
result
|
95
|
+
result.extend(Term::ANSIColor)
|
222
96
|
end
|
223
97
|
|
224
98
|
def on_color(name, string = nil, &block)
|
@@ -45,8 +45,12 @@ module Term
|
|
45
45
|
@__store__[name.to_sym]
|
46
46
|
end
|
47
47
|
|
48
|
-
def self.rgb_colors(&block)
|
49
|
-
@rgb_colors ||= attributes.select(&:rgb_color?)
|
48
|
+
def self.rgb_colors(options = {}, &block)
|
49
|
+
colors = @rgb_colors ||= attributes.select(&:rgb_color?)
|
50
|
+
if options.key?(:gray) && !options[:gray]
|
51
|
+
colors = colors.reject(&:gray?)
|
52
|
+
end
|
53
|
+
colors.each(&block)
|
50
54
|
end
|
51
55
|
|
52
56
|
def self.named_attributes(&block)
|
@@ -55,19 +59,13 @@ module Term
|
|
55
59
|
|
56
60
|
def self.nearest_rgb_color(color, options = {})
|
57
61
|
rgb = RGBTriple[color]
|
58
|
-
colors = rgb_colors
|
59
|
-
if options.key?(:gray) && !options[:gray]
|
60
|
-
colors = colors.reject(&:gray?)
|
61
|
-
end
|
62
|
+
colors = rgb_colors(options)
|
62
63
|
colors.reject(&:background?).min_by { |c| c.distance_to(rgb, options) }
|
63
64
|
end
|
64
65
|
|
65
66
|
def self.nearest_rgb_on_color(color, options = {})
|
66
67
|
rgb = RGBTriple[color]
|
67
|
-
colors = rgb_colors
|
68
|
-
if options.key?(:gray) && !options[:gray]
|
69
|
-
colors = colors.reject(&:gray?)
|
70
|
-
end
|
68
|
+
colors = rgb_colors(options)
|
71
69
|
colors.select(&:background?).min_by { |c| c.distance_to(rgb, options) }
|
72
70
|
end
|
73
71
|
|
@@ -0,0 +1,69 @@
|
|
1
|
+
module Term
|
2
|
+
module ANSIColor
|
3
|
+
class Attribute
|
4
|
+
class Color256
|
5
|
+
Attribute.set :color0, 0, :html => '#000000'
|
6
|
+
Attribute.set :color1, 1, :html => '#800000'
|
7
|
+
Attribute.set :color2, 2, :html => '#808000'
|
8
|
+
Attribute.set :color3, 3, :html => '#808000'
|
9
|
+
Attribute.set :color4, 4, :html => '#000080'
|
10
|
+
Attribute.set :color5, 5, :html => '#800080'
|
11
|
+
Attribute.set :color6, 6, :html => '#008080'
|
12
|
+
Attribute.set :color7, 7, :html => '#c0c0c0'
|
13
|
+
|
14
|
+
Attribute.set :color8, 8, :html => '#808080'
|
15
|
+
Attribute.set :color9, 9, :html => '#ff0000'
|
16
|
+
Attribute.set :color10, 10, :html => '#00ff00'
|
17
|
+
Attribute.set :color11, 11, :html => '#ffff00'
|
18
|
+
Attribute.set :color12, 12, :html => '#0000ff'
|
19
|
+
Attribute.set :color13, 13, :html => '#ff00ff'
|
20
|
+
Attribute.set :color14, 14, :html => '#00ffff'
|
21
|
+
Attribute.set :color15, 15, :html => '#ffffff'
|
22
|
+
|
23
|
+
steps = [ 0x00, 0x5f, 0x87, 0xaf, 0xd7, 0xff ]
|
24
|
+
|
25
|
+
for i in 16..231
|
26
|
+
red, green, blue = (i - 16).to_s(6).rjust(3, '0').each_char.map { |c| steps[c.to_i] }
|
27
|
+
Attribute.set "color#{i}", i, :red => red, :green => green, :blue => blue
|
28
|
+
end
|
29
|
+
|
30
|
+
grey = 8
|
31
|
+
for i in 232..255
|
32
|
+
Attribute.set "color#{i}", i, :red => grey, :green => grey, :blue => grey
|
33
|
+
grey += 10
|
34
|
+
end
|
35
|
+
|
36
|
+
Attribute.set :on_color0, 0, :html => '#000000'
|
37
|
+
Attribute.set :on_color1, 1, :html => '#800000'
|
38
|
+
Attribute.set :on_color2, 2, :html => '#808000'
|
39
|
+
Attribute.set :on_color3, 3, :html => '#808000'
|
40
|
+
Attribute.set :on_color4, 4, :html => '#000080'
|
41
|
+
Attribute.set :on_color5, 5, :html => '#800080'
|
42
|
+
Attribute.set :on_color6, 6, :html => '#008080'
|
43
|
+
Attribute.set :on_color7, 7, :html => '#c0c0c0'
|
44
|
+
|
45
|
+
Attribute.set :on_color8, 8, :html => '#808080'
|
46
|
+
Attribute.set :on_color9, 9, :html => '#ff0000'
|
47
|
+
Attribute.set :on_color10, 10, :html => '#00ff00'
|
48
|
+
Attribute.set :on_color11, 11, :html => '#ffff00'
|
49
|
+
Attribute.set :on_color12, 12, :html => '#0000ff'
|
50
|
+
Attribute.set :on_color13, 13, :html => '#ff00ff'
|
51
|
+
Attribute.set :on_color14, 14, :html => '#00ffff'
|
52
|
+
Attribute.set :on_color15, 15, :html => '#ffffff'
|
53
|
+
|
54
|
+
steps = [ 0x00, 0x5f, 0x87, 0xaf, 0xd7, 0xff ]
|
55
|
+
|
56
|
+
for i in 16..231
|
57
|
+
red, green, blue = (i - 16).to_s(6).rjust(3, '0').each_char.map { |c| steps[c.to_i] }
|
58
|
+
Attribute.set "on_color#{i}", i, :red => red, :green => green, :blue => blue
|
59
|
+
end
|
60
|
+
|
61
|
+
grey = 8
|
62
|
+
for i in 232..255
|
63
|
+
Attribute.set "on_color#{i}", i, :red => grey, :green => grey, :blue => grey
|
64
|
+
grey += 10
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module Term
|
2
|
+
module ANSIColor
|
3
|
+
class Attribute
|
4
|
+
class Color8
|
5
|
+
Attribute.set :black, 30
|
6
|
+
Attribute.set :red, 31
|
7
|
+
Attribute.set :green, 32
|
8
|
+
Attribute.set :yellow, 33
|
9
|
+
Attribute.set :blue, 34
|
10
|
+
Attribute.set :magenta, 35
|
11
|
+
Attribute.set :cyan, 36
|
12
|
+
Attribute.set :white, 37
|
13
|
+
|
14
|
+
Attribute.set :on_black, 40
|
15
|
+
Attribute.set :on_red, 41
|
16
|
+
Attribute.set :on_green, 42
|
17
|
+
Attribute.set :on_yellow, 43
|
18
|
+
Attribute.set :on_blue, 44
|
19
|
+
Attribute.set :on_magenta, 45
|
20
|
+
Attribute.set :on_cyan, 46
|
21
|
+
Attribute.set :on_white, 47
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
module Term
|
2
|
+
module ANSIColor
|
3
|
+
class Attribute
|
4
|
+
class IntenseColor8
|
5
|
+
# High intensity, aixterm (works in OS X)
|
6
|
+
Attribute.set :intense_black, 90
|
7
|
+
Attribute.set :bright_black, 90
|
8
|
+
Attribute.set :intense_red, 91
|
9
|
+
Attribute.set :bright_red, 91
|
10
|
+
Attribute.set :intense_green, 92
|
11
|
+
Attribute.set :bright_green, 92
|
12
|
+
Attribute.set :intense_yellow, 93
|
13
|
+
Attribute.set :bright_yellow, 93
|
14
|
+
Attribute.set :intense_blue, 94
|
15
|
+
Attribute.set :bright_blue, 94
|
16
|
+
Attribute.set :intense_magenta, 95
|
17
|
+
Attribute.set :bright_magenta, 95
|
18
|
+
Attribute.set :intense_cyan, 96
|
19
|
+
Attribute.set :bright_cyan, 96
|
20
|
+
Attribute.set :intense_white, 97
|
21
|
+
Attribute.set :bright_white, 97
|
22
|
+
|
23
|
+
# High intensity background, aixterm (works in OS X)
|
24
|
+
Attribute.set :on_intense_black, 100
|
25
|
+
Attribute.set :on_bright_black, 100
|
26
|
+
Attribute.set :on_intense_red, 101
|
27
|
+
Attribute.set :on_bright_red, 101
|
28
|
+
Attribute.set :on_intense_green, 102
|
29
|
+
Attribute.set :on_bright_green, 102
|
30
|
+
Attribute.set :on_intense_yellow, 103
|
31
|
+
Attribute.set :on_bright_yellow, 103
|
32
|
+
Attribute.set :on_intense_blue, 104
|
33
|
+
Attribute.set :on_bright_blue, 104
|
34
|
+
Attribute.set :on_intense_magenta, 105
|
35
|
+
Attribute.set :on_bright_magenta, 105
|
36
|
+
Attribute.set :on_intense_cyan, 106
|
37
|
+
Attribute.set :on_bright_cyan, 106
|
38
|
+
Attribute.set :on_intense_white, 107
|
39
|
+
Attribute.set :on_bright_white, 107
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Term
|
2
|
+
module ANSIColor
|
3
|
+
class Attribute
|
4
|
+
class Text
|
5
|
+
Attribute.set :clear, 0 # String#clear is already used to empty string in Ruby 1.9
|
6
|
+
Attribute.set :reset, 0 # synonym for :clear
|
7
|
+
Attribute.set :bold, 1
|
8
|
+
Attribute.set :dark, 2
|
9
|
+
Attribute.set :faint, 2
|
10
|
+
Attribute.set :italic, 3 # not widely implemented
|
11
|
+
Attribute.set :underline, 4
|
12
|
+
Attribute.set :underscore, 4 # synonym for :underline
|
13
|
+
Attribute.set :blink, 5
|
14
|
+
Attribute.set :rapid_blink, 6 # not widely implemented
|
15
|
+
Attribute.set :negative, 7 # no reverse because of String#reverse
|
16
|
+
Attribute.set :concealed, 8
|
17
|
+
Attribute.set :strikethrough, 9 # not widely implemented
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
data/term-ansicolor.gemspec
CHANGED
@@ -1,23 +1,24 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
|
-
# stub: term-ansicolor 1.
|
2
|
+
# stub: term-ansicolor 1.4.0 ruby lib
|
3
3
|
|
4
4
|
Gem::Specification.new do |s|
|
5
5
|
s.name = "term-ansicolor"
|
6
|
-
s.version = "1.
|
6
|
+
s.version = "1.4.0"
|
7
7
|
|
8
8
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
9
9
|
s.require_paths = ["lib"]
|
10
10
|
s.authors = ["Florian Frank"]
|
11
|
-
s.date = "
|
11
|
+
s.date = "2016-09-27"
|
12
12
|
s.description = "This library uses ANSI escape sequences to control the attributes of terminal output"
|
13
13
|
s.email = "flori@ping.de"
|
14
|
-
s.executables = ["
|
15
|
-
s.extra_rdoc_files = ["README.rdoc", "lib/term/ansicolor.rb", "lib/term/ansicolor/attribute.rb", "lib/term/ansicolor/ppm_reader.rb", "lib/term/ansicolor/rgb_color_metrics.rb", "lib/term/ansicolor/rgb_triple.rb", "lib/term/ansicolor/version.rb"]
|
16
|
-
s.files = [".gitignore", ".travis.yml", "CHANGES", "COPYING", "Gemfile", "README.rdoc", "Rakefile", "VERSION", "bin/
|
14
|
+
s.executables = ["term_cdiff", "term_colortab", "term_decolor", "term_display", "term_mandel"]
|
15
|
+
s.extra_rdoc_files = ["README.rdoc", "lib/term/ansicolor.rb", "lib/term/ansicolor/attribute.rb", "lib/term/ansicolor/attribute/color256.rb", "lib/term/ansicolor/attribute/color8.rb", "lib/term/ansicolor/attribute/intense_color8.rb", "lib/term/ansicolor/attribute/text.rb", "lib/term/ansicolor/ppm_reader.rb", "lib/term/ansicolor/rgb_color_metrics.rb", "lib/term/ansicolor/rgb_triple.rb", "lib/term/ansicolor/version.rb"]
|
16
|
+
s.files = [".gitignore", ".travis.yml", "CHANGES", "COPYING", "Gemfile", "README.rdoc", "Rakefile", "VERSION", "bin/term_cdiff", "bin/term_colortab", "bin/term_decolor", "bin/term_display", "bin/term_mandel", "examples/ColorTest.gif", "examples/Mona_Lisa.jpg", "examples/Stilleben.jpg", "examples/example.rb", "examples/lambda-red-plain.ppm", "examples/lambda-red.png", "examples/lambda-red.ppm", "examples/pacman.jpg", "examples/smiley.png", "examples/wool.jpg", "lib/term/ansicolor.rb", "lib/term/ansicolor/.keep", "lib/term/ansicolor/attribute.rb", "lib/term/ansicolor/attribute/color256.rb", "lib/term/ansicolor/attribute/color8.rb", "lib/term/ansicolor/attribute/intense_color8.rb", "lib/term/ansicolor/attribute/text.rb", "lib/term/ansicolor/ppm_reader.rb", "lib/term/ansicolor/rgb_color_metrics.rb", "lib/term/ansicolor/rgb_triple.rb", "lib/term/ansicolor/version.rb", "term-ansicolor.gemspec", "tests/ansicolor_test.rb", "tests/attribute_test.rb", "tests/ppm_reader_test.rb", "tests/rgb_color_metrics_test.rb", "tests/rgb_triple_test.rb", "tests/test_helper.rb"]
|
17
17
|
s.homepage = "http://flori.github.com/term-ansicolor"
|
18
18
|
s.licenses = ["GPL-2"]
|
19
19
|
s.rdoc_options = ["--title", "Term-ansicolor - Ruby library that colors strings using ANSI escape sequences", "--main", "README.rdoc"]
|
20
|
-
s.
|
20
|
+
s.required_ruby_version = Gem::Requirement.new(">= 2.0")
|
21
|
+
s.rubygems_version = "2.5.1"
|
21
22
|
s.summary = "Ruby library that colors strings using ANSI escape sequences"
|
22
23
|
s.test_files = ["tests/ansicolor_test.rb", "tests/attribute_test.rb", "tests/ppm_reader_test.rb", "tests/rgb_color_metrics_test.rb", "tests/rgb_triple_test.rb", "tests/test_helper.rb"]
|
23
24
|
|
@@ -25,18 +26,18 @@ Gem::Specification.new do |s|
|
|
25
26
|
s.specification_version = 4
|
26
27
|
|
27
28
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
28
|
-
s.add_development_dependency(%q<gem_hadar>, ["~> 1.
|
29
|
+
s.add_development_dependency(%q<gem_hadar>, ["~> 1.8.0"])
|
29
30
|
s.add_development_dependency(%q<simplecov>, [">= 0"])
|
30
31
|
s.add_development_dependency(%q<minitest_tu_shim>, [">= 0"])
|
31
32
|
s.add_runtime_dependency(%q<tins>, ["~> 1.0"])
|
32
33
|
else
|
33
|
-
s.add_dependency(%q<gem_hadar>, ["~> 1.
|
34
|
+
s.add_dependency(%q<gem_hadar>, ["~> 1.8.0"])
|
34
35
|
s.add_dependency(%q<simplecov>, [">= 0"])
|
35
36
|
s.add_dependency(%q<minitest_tu_shim>, [">= 0"])
|
36
37
|
s.add_dependency(%q<tins>, ["~> 1.0"])
|
37
38
|
end
|
38
39
|
else
|
39
|
-
s.add_dependency(%q<gem_hadar>, ["~> 1.
|
40
|
+
s.add_dependency(%q<gem_hadar>, ["~> 1.8.0"])
|
40
41
|
s.add_dependency(%q<simplecov>, [">= 0"])
|
41
42
|
s.add_dependency(%q<minitest_tu_shim>, [">= 0"])
|
42
43
|
s.add_dependency(%q<tins>, ["~> 1.0"])
|
data/tests/ansicolor_test.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
require 'test_helper'
|
2
2
|
|
3
|
+
OldString = String.dup
|
4
|
+
|
3
5
|
class String
|
4
6
|
include Term::ANSIColor
|
5
7
|
end
|
@@ -130,4 +132,11 @@ class ANSIColorTest < Test::Unit::TestCase
|
|
130
132
|
assert string.frozen?
|
131
133
|
assert_equal red, string.red
|
132
134
|
end
|
135
|
+
|
136
|
+
def test_extending
|
137
|
+
string = OldString.new('new')
|
138
|
+
assert_equal false, Term::ANSIColor === string
|
139
|
+
string = Color.red(string)
|
140
|
+
assert_kind_of Term::ANSIColor, 'new'
|
141
|
+
end
|
133
142
|
end
|
data/tests/test_helper.rb
CHANGED
@@ -4,5 +4,10 @@ if ENV['START_SIMPLECOV'].to_i == 1
|
|
4
4
|
add_filter "#{File.basename(File.dirname(__FILE__))}/"
|
5
5
|
end
|
6
6
|
end
|
7
|
+
if RUBY_VERSION >= '1.9' && ENV['CODECLIMATE_REPO_TOKEN']
|
8
|
+
require "codeclimate-test-reporter"
|
9
|
+
CodeClimate::TestReporter.start
|
10
|
+
end
|
11
|
+
require 'minitest/unit'
|
7
12
|
require 'test/unit'
|
8
13
|
require 'term/ansicolor'
|
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.4.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:
|
11
|
+
date: 2016-09-27 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.8.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.8.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: simplecov
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -70,16 +70,20 @@ description: This library uses ANSI escape sequences to control the attributes o
|
|
70
70
|
terminal output
|
71
71
|
email: flori@ping.de
|
72
72
|
executables:
|
73
|
-
-
|
74
|
-
-
|
75
|
-
-
|
76
|
-
- term_mandel
|
73
|
+
- term_cdiff
|
74
|
+
- term_colortab
|
75
|
+
- term_decolor
|
77
76
|
- term_display
|
77
|
+
- term_mandel
|
78
78
|
extensions: []
|
79
79
|
extra_rdoc_files:
|
80
80
|
- README.rdoc
|
81
81
|
- lib/term/ansicolor.rb
|
82
82
|
- lib/term/ansicolor/attribute.rb
|
83
|
+
- lib/term/ansicolor/attribute/color256.rb
|
84
|
+
- lib/term/ansicolor/attribute/color8.rb
|
85
|
+
- lib/term/ansicolor/attribute/intense_color8.rb
|
86
|
+
- lib/term/ansicolor/attribute/text.rb
|
83
87
|
- lib/term/ansicolor/ppm_reader.rb
|
84
88
|
- lib/term/ansicolor/rgb_color_metrics.rb
|
85
89
|
- lib/term/ansicolor/rgb_triple.rb
|
@@ -93,9 +97,9 @@ files:
|
|
93
97
|
- README.rdoc
|
94
98
|
- Rakefile
|
95
99
|
- VERSION
|
96
|
-
- bin/
|
97
|
-
- bin/
|
98
|
-
- bin/
|
100
|
+
- bin/term_cdiff
|
101
|
+
- bin/term_colortab
|
102
|
+
- bin/term_decolor
|
99
103
|
- bin/term_display
|
100
104
|
- bin/term_mandel
|
101
105
|
- examples/ColorTest.gif
|
@@ -111,6 +115,10 @@ files:
|
|
111
115
|
- lib/term/ansicolor.rb
|
112
116
|
- lib/term/ansicolor/.keep
|
113
117
|
- lib/term/ansicolor/attribute.rb
|
118
|
+
- lib/term/ansicolor/attribute/color256.rb
|
119
|
+
- lib/term/ansicolor/attribute/color8.rb
|
120
|
+
- lib/term/ansicolor/attribute/intense_color8.rb
|
121
|
+
- lib/term/ansicolor/attribute/text.rb
|
114
122
|
- lib/term/ansicolor/ppm_reader.rb
|
115
123
|
- lib/term/ansicolor/rgb_color_metrics.rb
|
116
124
|
- lib/term/ansicolor/rgb_triple.rb
|
@@ -138,7 +146,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
138
146
|
requirements:
|
139
147
|
- - ">="
|
140
148
|
- !ruby/object:Gem::Version
|
141
|
-
version: '0'
|
149
|
+
version: '2.0'
|
142
150
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
143
151
|
requirements:
|
144
152
|
- - ">="
|
@@ -146,7 +154,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
146
154
|
version: '0'
|
147
155
|
requirements: []
|
148
156
|
rubyforge_project:
|
149
|
-
rubygems_version: 2.
|
157
|
+
rubygems_version: 2.5.1
|
150
158
|
signing_key:
|
151
159
|
specification_version: 4
|
152
160
|
summary: Ruby library that colors strings using ANSI escape sequences
|