terminal-display-colors 0.0.3 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 303bb16c4601b301865c5b5e924f21a1aab1ef9c
4
- data.tar.gz: fad2a86be92fc96693b0eda85366dc257a40c2fe
3
+ metadata.gz: 19722517cefa04ca37330309cda134ade663d2aa
4
+ data.tar.gz: b96e12b54f236d0e9f1541f574b89f651792099e
5
5
  SHA512:
6
- metadata.gz: 8dca3661dc6ba2394d8af8b96ee628a5aaba305efd922167a6e5e862da430c25b70fb5b70eb4bc8feb23eaebd3dccca09d6e57a332366df5897973764ae12830
7
- data.tar.gz: 762da61430137a6be6ceddf23f0c7d50bdc29a65e39227aabd3b76c1f218cee9ba553749608c5501cdb142829c354e97fe7b0ffb77652abbd5a253e58f7ad5b9
6
+ metadata.gz: 40422e046b74a26f0d3bf58f7e8b4800c77c2694d888c7740574d620d1efa74a57ed1e7367a29aa9eea0734af3437f0c71dace2223ef21447ed51827e801d727
7
+ data.tar.gz: 1efbf921eee0c2ee73188a0e00925985c887c51410cc0822511377cf3e19a085e7d6fa5794648d30cecb13a7f10c2e1374ada0f8355fbfa9ce3c2447655c897d
@@ -9,7 +9,6 @@ Adds color methods to String for easily adding color to terminal output.
9
9
  == FEATURES/PROBLEMS:
10
10
 
11
11
  * Displays strings as colored output.
12
- * Displays strings as bold.
13
12
 
14
13
  == SYNOPSIS:
15
14
 
@@ -20,8 +19,6 @@ Adds color methods to String for easily adding color to terminal output.
20
19
  puts 'green'.green
21
20
  puts 'blue'.blue
22
21
 
23
- puts 'bold yellow'.yellow.bold
24
-
25
22
  == REQUIREMENTS:
26
23
 
27
24
  Ruby.
data/Rakefile CHANGED
@@ -1,19 +1,6 @@
1
- require 'rubygems'
2
- gem 'hoe', '>= 2.1.0'
3
- require 'hoe'
4
- require 'fileutils'
5
- require './lib/terminal-display-colors'
6
-
7
- Hoe.plugin :newgem
8
-
9
- # Generate the Rake tasks
10
- $hoe = Hoe.spec 'terminal-display-colors' do
11
- self.developer 'David Cole', 'davidcole@davidcole.net'
12
- self.post_install_message = 'PostInstall.txt'
13
- #self.rubyforge_name = 'display-colors'
14
- self.readme_file = 'README.rdoc'
15
-
1
+ task :test do
2
+ $:.unshift './test'
3
+ Dir.glob('test/test_*.rb').each { |t| require File.basename(t) }
16
4
  end
17
5
 
18
- require 'newgem/tasks'
19
- Dir['tasks/**/*.rake'].each { |t| load t }
6
+ task :default => :test
data/demo.rb CHANGED
@@ -1,15 +1,276 @@
1
1
  require( 'rubygems' )
2
2
  require( 'terminal-display-colors' )
3
3
 
4
- puts 'gray'.gray
5
- puts 'red'.red
6
- puts 'green'.green
7
- puts 'yellow'.yellow
8
- puts 'blue'.blue
9
- puts 'purple'.purple
10
- puts 'cyan'.cyan
11
- puts 'white'.white
4
+ puts "black".black
5
+ puts "red".red
6
+ puts "green".green
7
+ puts "yellow".yellow
8
+ puts "blue".blue
9
+ puts "magenta".magenta
10
+ puts "cyan".cyan
11
+ puts "gray".gray
12
+ puts "dark gray".dark_gray
13
+ puts "bright red".bright_red
14
+ puts "bright green".bright_green
15
+ puts "bright yellow".bright_yellow
16
+ puts "bright blue".bright_blue
17
+ puts "bright magenta".bright_magenta
18
+ puts "bright cyan".bright_cyan
19
+ puts "white".white
12
20
 
13
- puts 'bold'.bold
14
- puts 'bold red'.bold.red
15
- puts 'red bold'.red.bold
21
+ puts "black background".black_background
22
+ puts "red background".red_background
23
+ puts "green background".green_background
24
+ puts "yellow background".yellow_background
25
+ puts "blue background".blue_background
26
+ puts "magenta background".magenta_background
27
+ puts "cyan background".cyan_background
28
+ puts "white background".white_background
29
+ puts "dark gray background".dark_gray_background
30
+ puts "bright red background".bright_red_background
31
+ puts "bright green background".bright_green_background
32
+ puts "bright yellow background".bright_yellow_background
33
+ puts "bright blue background".bright_blue_background
34
+ puts "bright magenta background".bright_magenta_background
35
+ puts "bright cyan background".bright_cyan_background
36
+
37
+ puts "black with black background".black_background.black
38
+ puts "black with red background".red_background.black
39
+ puts "black with green background".green_background.black
40
+ puts "black with yellow background".yellow_background.black
41
+ puts "black with blue background".blue_background.black
42
+ puts "black with magenta background".magenta_background.black
43
+ puts "black with cyan background".cyan_background.black
44
+ puts "black with white background".white_background.black
45
+ puts "black with dark gray background".dark_gray_background.black
46
+ puts "black with bright red background".bright_red_background.black
47
+ puts "black with bright green background".bright_green_background.black
48
+ puts "black with bright yellow background".bright_yellow_background.black
49
+ puts "black with bright blue background".bright_blue_background.black
50
+ puts "black with bright magenta background".bright_magenta_background.black
51
+ puts "black with bright cyan background".bright_cyan_background.black
52
+ puts "red with black background".black_background.red
53
+ puts "red with red background".red_background.red
54
+ puts "red with green background".green_background.red
55
+ puts "red with yellow background".yellow_background.red
56
+ puts "red with blue background".blue_background.red
57
+ puts "red with magenta background".magenta_background.red
58
+ puts "red with cyan background".cyan_background.red
59
+ puts "red with white background".white_background.red
60
+ puts "red with dark gray background".dark_gray_background.red
61
+ puts "red with bright red background".bright_red_background.red
62
+ puts "red with bright green background".bright_green_background.red
63
+ puts "red with bright yellow background".bright_yellow_background.red
64
+ puts "red with bright blue background".bright_blue_background.red
65
+ puts "red with bright magenta background".bright_magenta_background.red
66
+ puts "red with bright cyan background".bright_cyan_background.red
67
+ puts "green with black background".black_background.green
68
+ puts "green with red background".red_background.green
69
+ puts "green with green background".green_background.green
70
+ puts "green with yellow background".yellow_background.green
71
+ puts "green with blue background".blue_background.green
72
+ puts "green with magenta background".magenta_background.green
73
+ puts "green with cyan background".cyan_background.green
74
+ puts "green with white background".white_background.green
75
+ puts "green with dark gray background".dark_gray_background.green
76
+ puts "green with bright red background".bright_red_background.green
77
+ puts "green with bright green background".bright_green_background.green
78
+ puts "green with bright yellow background".bright_yellow_background.green
79
+ puts "green with bright blue background".bright_blue_background.green
80
+ puts "green with bright magenta background".bright_magenta_background.green
81
+ puts "green with bright cyan background".bright_cyan_background.green
82
+ puts "yellow with black background".black_background.yellow
83
+ puts "yellow with red background".red_background.yellow
84
+ puts "yellow with green background".green_background.yellow
85
+ puts "yellow with yellow background".yellow_background.yellow
86
+ puts "yellow with blue background".blue_background.yellow
87
+ puts "yellow with magenta background".magenta_background.yellow
88
+ puts "yellow with cyan background".cyan_background.yellow
89
+ puts "yellow with white background".white_background.yellow
90
+ puts "yellow with dark gray background".dark_gray_background.yellow
91
+ puts "yellow with bright red background".bright_red_background.yellow
92
+ puts "yellow with bright green background".bright_green_background.yellow
93
+ puts "yellow with bright yellow background".bright_yellow_background.yellow
94
+ puts "yellow with bright blue background".bright_blue_background.yellow
95
+ puts "yellow with bright magenta background".bright_magenta_background.yellow
96
+ puts "yellow with bright cyan background".bright_cyan_background.yellow
97
+ puts "blue with black background".black_background.blue
98
+ puts "blue with red background".red_background.blue
99
+ puts "blue with green background".green_background.blue
100
+ puts "blue with yellow background".yellow_background.blue
101
+ puts "blue with blue background".blue_background.blue
102
+ puts "blue with magenta background".magenta_background.blue
103
+ puts "blue with cyan background".cyan_background.blue
104
+ puts "blue with white background".white_background.blue
105
+ puts "blue with dark gray background".dark_gray_background.blue
106
+ puts "blue with bright red background".bright_red_background.blue
107
+ puts "blue with bright green background".bright_green_background.blue
108
+ puts "blue with bright yellow background".bright_yellow_background.blue
109
+ puts "blue with bright blue background".bright_blue_background.blue
110
+ puts "blue with bright magenta background".bright_magenta_background.blue
111
+ puts "blue with bright cyan background".bright_cyan_background.blue
112
+ puts "magenta with black background".black_background.magenta
113
+ puts "magenta with red background".red_background.magenta
114
+ puts "magenta with green background".green_background.magenta
115
+ puts "magenta with yellow background".yellow_background.magenta
116
+ puts "magenta with blue background".blue_background.magenta
117
+ puts "magenta with magenta background".magenta_background.magenta
118
+ puts "magenta with cyan background".cyan_background.magenta
119
+ puts "magenta with white background".white_background.magenta
120
+ puts "magenta with dark gray background".dark_gray_background.magenta
121
+ puts "magenta with bright red background".bright_red_background.magenta
122
+ puts "magenta with bright green background".bright_green_background.magenta
123
+ puts "magenta with bright yellow background".bright_yellow_background.magenta
124
+ puts "magenta with bright blue background".bright_blue_background.magenta
125
+ puts "magenta with bright magenta background".bright_magenta_background.magenta
126
+ puts "magenta with bright cyan background".bright_cyan_background.magenta
127
+ puts "cyan with black background".black_background.cyan
128
+ puts "cyan with red background".red_background.cyan
129
+ puts "cyan with green background".green_background.cyan
130
+ puts "cyan with yellow background".yellow_background.cyan
131
+ puts "cyan with blue background".blue_background.cyan
132
+ puts "cyan with magenta background".magenta_background.cyan
133
+ puts "cyan with cyan background".cyan_background.cyan
134
+ puts "cyan with white background".white_background.cyan
135
+ puts "cyan with dark gray background".dark_gray_background.cyan
136
+ puts "cyan with bright red background".bright_red_background.cyan
137
+ puts "cyan with bright green background".bright_green_background.cyan
138
+ puts "cyan with bright yellow background".bright_yellow_background.cyan
139
+ puts "cyan with bright blue background".bright_blue_background.cyan
140
+ puts "cyan with bright magenta background".bright_magenta_background.cyan
141
+ puts "cyan with bright cyan background".bright_cyan_background.cyan
142
+ puts "gray with black background".black_background.gray
143
+ puts "gray with red background".red_background.gray
144
+ puts "gray with green background".green_background.gray
145
+ puts "gray with yellow background".yellow_background.gray
146
+ puts "gray with blue background".blue_background.gray
147
+ puts "gray with magenta background".magenta_background.gray
148
+ puts "gray with cyan background".cyan_background.gray
149
+ puts "gray with white background".white_background.gray
150
+ puts "gray with dark gray background".dark_gray_background.gray
151
+ puts "gray with bright red background".bright_red_background.gray
152
+ puts "gray with bright green background".bright_green_background.gray
153
+ puts "gray with bright yellow background".bright_yellow_background.gray
154
+ puts "gray with bright blue background".bright_blue_background.gray
155
+ puts "gray with bright magenta background".bright_magenta_background.gray
156
+ puts "gray with bright cyan background".bright_cyan_background.gray
157
+ puts "dark gray with black background".black_background.dark_gray
158
+ puts "dark gray with red background".red_background.dark_gray
159
+ puts "dark gray with green background".green_background.dark_gray
160
+ puts "dark gray with yellow background".yellow_background.dark_gray
161
+ puts "dark gray with blue background".blue_background.dark_gray
162
+ puts "dark gray with magenta background".magenta_background.dark_gray
163
+ puts "dark gray with cyan background".cyan_background.dark_gray
164
+ puts "dark gray with white background".white_background.dark_gray
165
+ puts "dark gray with dark gray background".dark_gray_background.dark_gray
166
+ puts "dark gray with bright red background".bright_red_background.dark_gray
167
+ puts "dark gray with bright green background".bright_green_background.dark_gray
168
+ puts "dark gray with bright yellow background".bright_yellow_background.dark_gray
169
+ puts "dark gray with bright blue background".bright_blue_background.dark_gray
170
+ puts "dark gray with bright magenta background".bright_magenta_background.dark_gray
171
+ puts "dark gray with bright cyan background".bright_cyan_background.dark_gray
172
+ puts "bright red with black background".black_background.bright_red
173
+ puts "bright red with red background".red_background.bright_red
174
+ puts "bright red with green background".green_background.bright_red
175
+ puts "bright red with yellow background".yellow_background.bright_red
176
+ puts "bright red with blue background".blue_background.bright_red
177
+ puts "bright red with magenta background".magenta_background.bright_red
178
+ puts "bright red with cyan background".cyan_background.bright_red
179
+ puts "bright red with white background".white_background.bright_red
180
+ puts "bright red with dark gray background".dark_gray_background.bright_red
181
+ puts "bright red with bright red background".bright_red_background.bright_red
182
+ puts "bright red with bright green background".bright_green_background.bright_red
183
+ puts "bright red with bright yellow background".bright_yellow_background.bright_red
184
+ puts "bright red with bright blue background".bright_blue_background.bright_red
185
+ puts "bright red with bright magenta background".bright_magenta_background.bright_red
186
+ puts "bright red with bright cyan background".bright_cyan_background.bright_red
187
+ puts "bright green with black background".black_background.bright_green
188
+ puts "bright green with red background".red_background.bright_green
189
+ puts "bright green with green background".green_background.bright_green
190
+ puts "bright green with yellow background".yellow_background.bright_green
191
+ puts "bright green with blue background".blue_background.bright_green
192
+ puts "bright green with magenta background".magenta_background.bright_green
193
+ puts "bright green with cyan background".cyan_background.bright_green
194
+ puts "bright green with white background".white_background.bright_green
195
+ puts "bright green with dark gray background".dark_gray_background.bright_green
196
+ puts "bright green with bright red background".bright_red_background.bright_green
197
+ puts "bright green with bright green background".bright_green_background.bright_green
198
+ puts "bright green with bright yellow background".bright_yellow_background.bright_green
199
+ puts "bright green with bright blue background".bright_blue_background.bright_green
200
+ puts "bright green with bright magenta background".bright_magenta_background.bright_green
201
+ puts "bright green with bright cyan background".bright_cyan_background.bright_green
202
+ puts "bright yellow with black background".black_background.bright_yellow
203
+ puts "bright yellow with red background".red_background.bright_yellow
204
+ puts "bright yellow with green background".green_background.bright_yellow
205
+ puts "bright yellow with yellow background".yellow_background.bright_yellow
206
+ puts "bright yellow with blue background".blue_background.bright_yellow
207
+ puts "bright yellow with magenta background".magenta_background.bright_yellow
208
+ puts "bright yellow with cyan background".cyan_background.bright_yellow
209
+ puts "bright yellow with white background".white_background.bright_yellow
210
+ puts "bright yellow with dark gray background".dark_gray_background.bright_yellow
211
+ puts "bright yellow with bright red background".bright_red_background.bright_yellow
212
+ puts "bright yellow with bright green background".bright_green_background.bright_yellow
213
+ puts "bright yellow with bright yellow background".bright_yellow_background.bright_yellow
214
+ puts "bright yellow with bright blue background".bright_blue_background.bright_yellow
215
+ puts "bright yellow with bright magenta background".bright_magenta_background.bright_yellow
216
+ puts "bright yellow with bright cyan background".bright_cyan_background.bright_yellow
217
+ puts "bright blue with black background".black_background.bright_blue
218
+ puts "bright blue with red background".red_background.bright_blue
219
+ puts "bright blue with green background".green_background.bright_blue
220
+ puts "bright blue with yellow background".yellow_background.bright_blue
221
+ puts "bright blue with blue background".blue_background.bright_blue
222
+ puts "bright blue with magenta background".magenta_background.bright_blue
223
+ puts "bright blue with cyan background".cyan_background.bright_blue
224
+ puts "bright blue with white background".white_background.bright_blue
225
+ puts "bright blue with dark gray background".dark_gray_background.bright_blue
226
+ puts "bright blue with bright red background".bright_red_background.bright_blue
227
+ puts "bright blue with bright green background".bright_green_background.bright_blue
228
+ puts "bright blue with bright yellow background".bright_yellow_background.bright_blue
229
+ puts "bright blue with bright blue background".bright_blue_background.bright_blue
230
+ puts "bright blue with bright magenta background".bright_magenta_background.bright_blue
231
+ puts "bright blue with bright cyan background".bright_cyan_background.bright_blue
232
+ puts "bright magenta with black background".black_background.bright_magenta
233
+ puts "bright magenta with red background".red_background.bright_magenta
234
+ puts "bright magenta with green background".green_background.bright_magenta
235
+ puts "bright magenta with yellow background".yellow_background.bright_magenta
236
+ puts "bright magenta with blue background".blue_background.bright_magenta
237
+ puts "bright magenta with magenta background".magenta_background.bright_magenta
238
+ puts "bright magenta with cyan background".cyan_background.bright_magenta
239
+ puts "bright magenta with white background".white_background.bright_magenta
240
+ puts "bright magenta with dark gray background".dark_gray_background.bright_magenta
241
+ puts "bright magenta with bright red background".bright_red_background.bright_magenta
242
+ puts "bright magenta with bright green background".bright_green_background.bright_magenta
243
+ puts "bright magenta with bright yellow background".bright_yellow_background.bright_magenta
244
+ puts "bright magenta with bright blue background".bright_blue_background.bright_magenta
245
+ puts "bright magenta with bright magenta background".bright_magenta_background.bright_magenta
246
+ puts "bright magenta with bright cyan background".bright_cyan_background.bright_magenta
247
+ puts "bright cyan with black background".black_background.bright_cyan
248
+ puts "bright cyan with red background".red_background.bright_cyan
249
+ puts "bright cyan with green background".green_background.bright_cyan
250
+ puts "bright cyan with yellow background".yellow_background.bright_cyan
251
+ puts "bright cyan with blue background".blue_background.bright_cyan
252
+ puts "bright cyan with magenta background".magenta_background.bright_cyan
253
+ puts "bright cyan with cyan background".cyan_background.bright_cyan
254
+ puts "bright cyan with white background".white_background.bright_cyan
255
+ puts "bright cyan with dark gray background".dark_gray_background.bright_cyan
256
+ puts "bright cyan with bright red background".bright_red_background.bright_cyan
257
+ puts "bright cyan with bright green background".bright_green_background.bright_cyan
258
+ puts "bright cyan with bright yellow background".bright_yellow_background.bright_cyan
259
+ puts "bright cyan with bright blue background".bright_blue_background.bright_cyan
260
+ puts "bright cyan with bright magenta background".bright_magenta_background.bright_cyan
261
+ puts "bright cyan with bright cyan background".bright_cyan_background.bright_cyan
262
+ puts "white with black background".black_background.white
263
+ puts "white with red background".red_background.white
264
+ puts "white with green background".green_background.white
265
+ puts "white with yellow background".yellow_background.white
266
+ puts "white with blue background".blue_background.white
267
+ puts "white with magenta background".magenta_background.white
268
+ puts "white with cyan background".cyan_background.white
269
+ puts "white with white background".white_background.white
270
+ puts "white with dark gray background".dark_gray_background.white
271
+ puts "white with bright red background".bright_red_background.white
272
+ puts "white with bright green background".bright_green_background.white
273
+ puts "white with bright yellow background".bright_yellow_background.white
274
+ puts "white with bright blue background".bright_blue_background.white
275
+ puts "white with bright magenta background".bright_magenta_background.white
276
+ puts "white with bright cyan background".bright_cyan_background.white
@@ -2,25 +2,304 @@ $:.unshift(File.dirname(__FILE__)) unless
2
2
  $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
3
3
 
4
4
  module TerminalDispayColors
5
- VERSION = '0.0.3'
5
+ VERSION = '0.1.0'
6
6
 
7
7
  colors = {
8
- 'gray' => "\033[30m",
9
- 'red' => "\033[31m",
10
- 'green' => "\033[32m",
11
- 'yellow' => "\033[33m",
12
- 'blue' => "\033[34m",
13
- 'purple' => "\033[35m",
14
- 'cyan' => "\033[36m",
15
- 'white' => "\033[37m",
16
- 'bold' => "\033[01m"
8
+ 'black' => "\033[30m",
9
+ 'red' => "\033[31m",
10
+ 'green' => "\033[32m",
11
+ 'yellow' => "\033[33m",
12
+ 'blue' => "\033[34m",
13
+ 'magenta' => "\033[35m",
14
+ 'cyan' => "\033[36m",
15
+ 'gray' => "\033[37m",
16
+
17
+ 'dark_gray' => "\033[90m",
18
+ 'bright_red' => "\033[91m",
19
+ 'bright_green' => "\033[92m",
20
+ 'bright_yellow' => "\033[93m",
21
+ 'bright_blue' => "\033[94m",
22
+ 'bright_magenta' => "\033[95m",
23
+ 'bright_cyan' => "\033[96m",
24
+ 'white' => "\033[97m",
25
+
26
+ 'black_background' => "\033[40m",
27
+ 'red_background' => "\033[41m",
28
+ 'green_background' => "\033[42m",
29
+ 'yellow_background' => "\033[43m",
30
+ 'blue_background' => "\033[44m",
31
+ 'magenta_background' => "\033[45m",
32
+ 'cyan_background' => "\033[46m",
33
+ 'gray_background' => "\033[47m",
34
+
35
+ 'dark_gray_background' => "\033[100m",
36
+ 'bright_red_background' => "\033[101m",
37
+ 'bright_green_background' => "\033[102m",
38
+ 'bright_yellow_background' => "\033[103m",
39
+ 'bright_blue_background' => "\033[104m",
40
+ 'bright_magenta_background' => "\033[105m",
41
+ 'bright_cyan_background' => "\033[106m",
42
+ 'white_background' => "\033[107m"
17
43
  }
18
44
  ending = "\033[00m"
19
45
 
20
46
  colors.keys.each do | color |
21
- color_block = lambda { | *args |
47
+ color_block = lambda {
22
48
  colors[ color ] + self + ending
23
49
  }
24
50
  String.send( :define_method, color.to_sym, color_block )
25
51
  end
52
+
53
+ rgb_colors = {
54
+ '#000000' => 16, # Grey0
55
+ '#00005f' => 17, # NavyBlue
56
+ '#000087' => 18, # DarkBlue
57
+ '#0000af' => 19, # Blue3
58
+ '#0000d7' => 20, # Blue3
59
+ '#0000ff' => 21, # Blue1
60
+ '#005f00' => 22, # DarkGreen
61
+ '#005f5f' => 23, # DeepSkyBlue4
62
+ '#005f87' => 24, # DeepSkyBlue4
63
+ '#005faf' => 25, # DeepSkyBlue4
64
+ '#005fd7' => 26, # DodgerBlue3
65
+ '#005fff' => 27, # DodgerBlue2
66
+ '#008700' => 28, # Green4
67
+ '#00875f' => 29, # SpringGreen4
68
+ '#008787' => 30, # Turquoise4
69
+ '#0087af' => 31, # DeepSkyBlue3
70
+ '#0087d7' => 32, # DeepSkyBlue3
71
+ '#0087ff' => 33, # DodgerBlue1
72
+ '#00af00' => 34, # Green3
73
+ '#00af5f' => 35, # SpringGreen3
74
+ '#00af87' => 36, # DarkCyan
75
+ '#00afaf' => 37, # LightSeaGreen
76
+ '#00afd7' => 38, # DeepSkyBlue2
77
+ '#00afff' => 39, # DeepSkyBlue1
78
+ '#00d700' => 40, # Green3
79
+ '#00d75f' => 41, # SpringGreen3
80
+ '#00d787' => 42, # SpringGreen2
81
+ '#00d7af' => 43, # Cyan3
82
+ '#00d7d7' => 44, # DarkTurquoise
83
+ '#00d7ff' => 45, # Turquoise2
84
+ '#00ff00' => 46, # Green1
85
+ '#00ff5f' => 47, # SpringGreen2
86
+ '#00ff87' => 48, # SpringGreen1
87
+ '#00ffaf' => 49, # MediumSpringGreen
88
+ '#00ffd7' => 50, # Cyan2
89
+ '#00ffff' => 51, # Cyan1
90
+ '#5f0000' => 52, # DarkRed
91
+ '#5f005f' => 53, # DeepPink4
92
+ '#5f0087' => 54, # Purple4
93
+ '#5f00af' => 55, # Purple4
94
+ '#5f00d7' => 56, # Purple3
95
+ '#5f00ff' => 57, # BlueViolet
96
+ '#5f5f00' => 58, # Orange4
97
+ '#5f5f5f' => 59, # Grey37
98
+ '#5f5f87' => 60, # MediumPurple4
99
+ '#5f5faf' => 61, # SlateBlue3
100
+ '#5f5fd7' => 62, # SlateBlue3
101
+ '#5f5fff' => 63, # RoyalBlue1
102
+ '#5f8700' => 64, # Chartreuse4
103
+ '#5f875f' => 65, # DarkSeaGreen4
104
+ '#5f8787' => 66, # PaleTurquoise4
105
+ '#5f87af' => 67, # SteelBlue
106
+ '#5f87d7' => 68, # SteelBlue3
107
+ '#5f87ff' => 69, # CornflowerBlue
108
+ '#5faf00' => 70, # Chartreuse3
109
+ '#5faf5f' => 71, # DarkSeaGreen4
110
+ '#5faf87' => 72, # CadetBlue
111
+ '#5fafaf' => 73, # CadetBlue
112
+ '#5fafd7' => 74, # SkyBlue3
113
+ '#5fafff' => 75, # SteelBlue1
114
+ '#5fd700' => 76, # Chartreuse3
115
+ '#5fd75f' => 77, # PaleGreen3
116
+ '#5fd787' => 78, # SeaGreen3
117
+ '#5fd7af' => 79, # Aquamarine3
118
+ '#5fd7d7' => 80, # MediumTurquoise
119
+ '#5fd7ff' => 81, # SteelBlue1
120
+ '#5fff00' => 82, # Chartreuse2
121
+ '#5fff5f' => 83, # SeaGreen2
122
+ '#5fff87' => 84, # SeaGreen1
123
+ '#5fffaf' => 85, # SeaGreen1
124
+ '#5fffd7' => 86, # Aquamarine1
125
+ '#5fffff' => 87, # DarkSlateGray2
126
+ '#870000' => 88, # DarkRed
127
+ '#87005f' => 89, # DeepPink4
128
+ '#870087' => 90, # DarkMagenta
129
+ '#8700af' => 91, # DarkMagenta
130
+ '#8700d7' => 92, # DarkViolet
131
+ '#8700ff' => 93, # Purple
132
+ '#875f00' => 94, # Orange4
133
+ '#875f5f' => 95, # LightPink4
134
+ '#875f87' => 96, # Plum4
135
+ '#875faf' => 97, # MediumPurple3
136
+ '#875fd7' => 98, # MediumPurple3
137
+ '#875fff' => 99, # SlateBlue1
138
+ '#878700' => 100, # Yellow4
139
+ '#87875f' => 101, # Wheat4
140
+ '#878787' => 102, # Grey53
141
+ '#8787af' => 103, # LightSlateGrey
142
+ '#8787d7' => 104, # MediumPurple
143
+ '#8787ff' => 105, # LightSlateBlue
144
+ '#87af00' => 106, # Yellow4
145
+ '#87af5f' => 107, # DarkOliveGreen3
146
+ '#87af87' => 108, # DarkSeaGreen
147
+ '#87afaf' => 109, # LightSkyBlue3
148
+ '#87afd7' => 110, # LightSkyBlue3
149
+ '#87afff' => 111, # SkyBlue2
150
+ '#87d700' => 112, # Chartreuse2
151
+ '#87d75f' => 113, # DarkOliveGreen3
152
+ '#87d787' => 114, # PaleGreen3
153
+ '#87d7af' => 115, # DarkSeaGreen3
154
+ '#87d7d7' => 116, # DarkSlateGray3
155
+ '#87d7ff' => 117, # SkyBlue1
156
+ '#87ff00' => 118, # Chartreuse1
157
+ '#87ff5f' => 119, # LightGreen
158
+ '#87ff87' => 120, # LightGreen
159
+ '#87ffaf' => 121, # PaleGreen1
160
+ '#87ffd7' => 122, # Aquamarine1
161
+ '#87ffff' => 123, # DarkSlateGray1
162
+ '#af0000' => 124, # Red3
163
+ '#af005f' => 125, # DeepPink4
164
+ '#af0087' => 126, # MediumVioletRed
165
+ '#af00af' => 127, # Magenta3
166
+ '#af00d7' => 128, # DarkViolet
167
+ '#af00ff' => 129, # Purple
168
+ '#af5f00' => 130, # DarkOrange3
169
+ '#af5f5f' => 131, # IndianRed
170
+ '#af5f87' => 132, # HotPink3
171
+ '#af5faf' => 133, # MediumOrchid3
172
+ '#af5fd7' => 134, # MediumOrchid
173
+ '#af5fff' => 135, # MediumPurple2
174
+ '#af8700' => 136, # DarkGoldenrod
175
+ '#af875f' => 137, # LightSalmon3
176
+ '#af8787' => 138, # RosyBrown
177
+ '#af87af' => 139, # Grey63
178
+ '#af87d7' => 140, # MediumPurple2
179
+ '#af87ff' => 141, # MediumPurple1
180
+ '#afaf00' => 142, # Gold3
181
+ '#afaf5f' => 143, # DarkKhaki
182
+ '#afaf87' => 144, # NavajoWhite3
183
+ '#afafaf' => 145, # Grey69
184
+ '#afafd7' => 146, # LightSteelBlue3
185
+ '#afafff' => 147, # LightSteelBlue
186
+ '#afd700' => 148, # Yellow3
187
+ '#afd75f' => 149, # DarkOliveGreen3
188
+ '#afd787' => 150, # DarkSeaGreen3
189
+ '#afd7af' => 151, # DarkSeaGreen2
190
+ '#afd7d7' => 152, # LightCyan3
191
+ '#afd7ff' => 153, # LightSkyBlue1
192
+ '#afff00' => 154, # GreenYellow
193
+ '#afff5f' => 155, # DarkOliveGreen2
194
+ '#afff87' => 156, # PaleGreen1
195
+ '#afffaf' => 157, # DarkSeaGreen2
196
+ '#afffd7' => 158, # DarkSeaGreen1
197
+ '#afffff' => 159, # PaleTurquoise1
198
+ '#d70000' => 160, # Red3
199
+ '#d7005f' => 161, # DeepPink3
200
+ '#d70087' => 162, # DeepPink3
201
+ '#d700af' => 163, # Magenta3
202
+ '#d700d7' => 164, # Magenta3
203
+ '#d700ff' => 165, # Magenta2
204
+ '#d75f00' => 166, # DarkOrange3
205
+ '#d75f5f' => 167, # IndianRed
206
+ '#d75f87' => 168, # HotPink3
207
+ '#d75faf' => 169, # HotPink2
208
+ '#d75fd7' => 170, # Orchid
209
+ '#d75fff' => 171, # MediumOrchid1
210
+ '#d78700' => 172, # Orange3
211
+ '#d7875f' => 173, # LightSalmon3
212
+ '#d78787' => 174, # LightPink3
213
+ '#d787af' => 175, # Pink3
214
+ '#d787d7' => 176, # Plum3
215
+ '#d787ff' => 177, # Violet
216
+ '#d7af00' => 178, # Gold3
217
+ '#d7af5f' => 179, # LightGoldenrod3
218
+ '#d7af87' => 180, # Tan
219
+ '#d7afaf' => 181, # MistyRose3
220
+ '#d7afd7' => 182, # Thistle3
221
+ '#d7afff' => 183, # Plum2
222
+ '#d7d700' => 184, # Yellow3
223
+ '#d7d75f' => 185, # Khaki3
224
+ '#d7d787' => 186, # LightGoldenrod2
225
+ '#d7d7af' => 187, # LightYellow3
226
+ '#d7d7d7' => 188, # Grey84
227
+ '#d7d7ff' => 189, # LightSteelBlue1
228
+ '#d7ff00' => 190, # Yellow2
229
+ '#d7ff5f' => 191, # DarkOliveGreen1
230
+ '#d7ff87' => 192, # DarkOliveGreen1
231
+ '#d7ffaf' => 193, # DarkSeaGreen1
232
+ '#d7ffd7' => 194, # Honeydew2
233
+ '#d7ffff' => 195, # LightCyan1
234
+ '#ff0000' => 196, # Red1
235
+ '#ff005f' => 197, # DeepPink2
236
+ '#ff0087' => 198, # DeepPink1
237
+ '#ff00af' => 199, # DeepPink1
238
+ '#ff00d7' => 200, # Magenta2
239
+ '#ff00ff' => 201, # Magenta1
240
+ '#ff5f00' => 202, # OrangeRed1
241
+ '#ff5f5f' => 203, # IndianRed1
242
+ '#ff5f87' => 204, # IndianRed1
243
+ '#ff5faf' => 205, # HotPink
244
+ '#ff5fd7' => 206, # HotPink
245
+ '#ff5fff' => 207, # MediumOrchid1
246
+ '#ff8700' => 208, # DarkOrange
247
+ '#ff875f' => 209, # Salmon1
248
+ '#ff8787' => 210, # LightCoral
249
+ '#ff87af' => 211, # PaleVioletRed1
250
+ '#ff87d7' => 212, # Orchid2
251
+ '#ff87ff' => 213, # Orchid1
252
+ '#ffaf00' => 214, # Orange1
253
+ '#ffaf5f' => 215, # SandyBrown
254
+ '#ffaf87' => 216, # LightSalmon1
255
+ '#ffafaf' => 217, # LightPink1
256
+ '#ffafd7' => 218, # Pink1
257
+ '#ffafff' => 219, # Plum1
258
+ '#ffd700' => 220, # Gold1
259
+ '#ffd75f' => 221, # LightGoldenrod2
260
+ '#ffd787' => 222, # LightGoldenrod2
261
+ '#ffd7af' => 223, # NavajoWhite1
262
+ '#ffd7d7' => 224, # MistyRose1
263
+ '#ffd7ff' => 225, # Thistle1
264
+ '#ffff00' => 226, # Yellow1
265
+ '#ffff5f' => 227, # LightGoldenrod1
266
+ '#ffff87' => 228, # Khaki1
267
+ '#ffffaf' => 229, # Wheat1
268
+ '#ffffd7' => 230, # Cornsilk1
269
+ '#ffffff' => 231, # Grey100
270
+ '#080808' => 232, # Grey3
271
+ '#121212' => 233, # Grey7
272
+ '#1c1c1c' => 234, # Grey11
273
+ '#262626' => 235, # Grey15
274
+ '#303030' => 236, # Grey19
275
+ '#3a3a3a' => 237, # Grey23
276
+ '#444444' => 238, # Grey27
277
+ '#4e4e4e' => 239, # Grey30
278
+ '#585858' => 240, # Grey35
279
+ '#626262' => 241, # Grey39
280
+ '#6c6c6c' => 242, # Grey42
281
+ '#767676' => 243, # Grey46
282
+ '#808080' => 244, # Grey50
283
+ '#8a8a8a' => 245, # Grey54
284
+ '#949494' => 246, # Grey58
285
+ '#9e9e9e' => 247, # Grey62
286
+ '#a8a8a8' => 248, # Grey66
287
+ '#b2b2b2' => 249, # Grey70
288
+ '#bcbcbc' => 250, # Grey74
289
+ '#c6c6c6' => 251, # Grey78
290
+ '#d0d0d0' => 252, # Grey82
291
+ '#dadada' => 253, # Grey85
292
+ '#e4e4e4' => 254, # Grey89
293
+ '#eeeeee' => 255 # Grey93
294
+ }
295
+
296
+ color_block = lambda { | rgb_hex |
297
+ "\033[38;5;#{ rgb_colors[ rgb_hex.downcase ] }m" + self + ending
298
+ }
299
+ String.send( :define_method, :color, color_block )
300
+
301
+ color_block = lambda { | rgb_hex |
302
+ "\033[48;5;#{ rgb_colors[ rgb_hex.downcase ] }m" + self + ending
303
+ }
304
+ String.send( :define_method, :background, color_block )
26
305
  end
@@ -0,0 +1,267 @@
1
+ #!/usr/bin/env ruby -w
2
+
3
+ $:.unshift File.join( File.dirname( __FILE__ ), '..', 'lib' )
4
+
5
+ require 'test/unit'
6
+ require 'terminal-display-colors'
7
+
8
+ class TestHexColors < Test::Unit::TestCase
9
+
10
+ def setup
11
+ @rgb_colors = {
12
+ '#000000' => 16, # Grey0
13
+ '#00005f' => 17, # NavyBlue
14
+ '#000087' => 18, # DarkBlue
15
+ '#0000af' => 19, # Blue3
16
+ '#0000d7' => 20, # Blue3
17
+ '#0000ff' => 21, # Blue1
18
+ '#005f00' => 22, # DarkGreen
19
+ '#005f5f' => 23, # DeepSkyBlue4
20
+ '#005f87' => 24, # DeepSkyBlue4
21
+ '#005faf' => 25, # DeepSkyBlue4
22
+ '#005fd7' => 26, # DodgerBlue3
23
+ '#005fff' => 27, # DodgerBlue2
24
+ '#008700' => 28, # Green4
25
+ '#00875f' => 29, # SpringGreen4
26
+ '#008787' => 30, # Turquoise4
27
+ '#0087af' => 31, # DeepSkyBlue3
28
+ '#0087d7' => 32, # DeepSkyBlue3
29
+ '#0087ff' => 33, # DodgerBlue1
30
+ '#00af00' => 34, # Green3
31
+ '#00af5f' => 35, # SpringGreen3
32
+ '#00af87' => 36, # DarkCyan
33
+ '#00afaf' => 37, # LightSeaGreen
34
+ '#00afd7' => 38, # DeepSkyBlue2
35
+ '#00afff' => 39, # DeepSkyBlue1
36
+ '#00d700' => 40, # Green3
37
+ '#00d75f' => 41, # SpringGreen3
38
+ '#00d787' => 42, # SpringGreen2
39
+ '#00d7af' => 43, # Cyan3
40
+ '#00d7d7' => 44, # DarkTurquoise
41
+ '#00d7ff' => 45, # Turquoise2
42
+ '#00ff00' => 46, # Green1
43
+ '#00ff5f' => 47, # SpringGreen2
44
+ '#00ff87' => 48, # SpringGreen1
45
+ '#00ffaf' => 49, # MediumSpringGreen
46
+ '#00ffd7' => 50, # Cyan2
47
+ '#00ffff' => 51, # Cyan1
48
+ '#5f0000' => 52, # DarkRed
49
+ '#5f005f' => 53, # DeepPink4
50
+ '#5f0087' => 54, # Purple4
51
+ '#5f00af' => 55, # Purple4
52
+ '#5f00d7' => 56, # Purple3
53
+ '#5f00ff' => 57, # BlueViolet
54
+ '#5f5f00' => 58, # Orange4
55
+ '#5f5f5f' => 59, # Grey37
56
+ '#5f5f87' => 60, # MediumPurple4
57
+ '#5f5faf' => 61, # SlateBlue3
58
+ '#5f5fd7' => 62, # SlateBlue3
59
+ '#5f5fff' => 63, # RoyalBlue1
60
+ '#5f8700' => 64, # Chartreuse4
61
+ '#5f875f' => 65, # DarkSeaGreen4
62
+ '#5f8787' => 66, # PaleTurquoise4
63
+ '#5f87af' => 67, # SteelBlue
64
+ '#5f87d7' => 68, # SteelBlue3
65
+ '#5f87ff' => 69, # CornflowerBlue
66
+ '#5faf00' => 70, # Chartreuse3
67
+ '#5faf5f' => 71, # DarkSeaGreen4
68
+ '#5faf87' => 72, # CadetBlue
69
+ '#5fafaf' => 73, # CadetBlue
70
+ '#5fafd7' => 74, # SkyBlue3
71
+ '#5fafff' => 75, # SteelBlue1
72
+ '#5fd700' => 76, # Chartreuse3
73
+ '#5fd75f' => 77, # PaleGreen3
74
+ '#5fd787' => 78, # SeaGreen3
75
+ '#5fd7af' => 79, # Aquamarine3
76
+ '#5fd7d7' => 80, # MediumTurquoise
77
+ '#5fd7ff' => 81, # SteelBlue1
78
+ '#5fff00' => 82, # Chartreuse2
79
+ '#5fff5f' => 83, # SeaGreen2
80
+ '#5fff87' => 84, # SeaGreen1
81
+ '#5fffaf' => 85, # SeaGreen1
82
+ '#5fffd7' => 86, # Aquamarine1
83
+ '#5fffff' => 87, # DarkSlateGray2
84
+ '#870000' => 88, # DarkRed
85
+ '#87005f' => 89, # DeepPink4
86
+ '#870087' => 90, # DarkMagenta
87
+ '#8700af' => 91, # DarkMagenta
88
+ '#8700d7' => 92, # DarkViolet
89
+ '#8700ff' => 93, # Purple
90
+ '#875f00' => 94, # Orange4
91
+ '#875f5f' => 95, # LightPink4
92
+ '#875f87' => 96, # Plum4
93
+ '#875faf' => 97, # MediumPurple3
94
+ '#875fd7' => 98, # MediumPurple3
95
+ '#875fff' => 99, # SlateBlue1
96
+ '#878700' => 100, # Yellow4
97
+ '#87875f' => 101, # Wheat4
98
+ '#878787' => 102, # Grey53
99
+ '#8787af' => 103, # LightSlateGrey
100
+ '#8787d7' => 104, # MediumPurple
101
+ '#8787ff' => 105, # LightSlateBlue
102
+ '#87af00' => 106, # Yellow4
103
+ '#87af5f' => 107, # DarkOliveGreen3
104
+ '#87af87' => 108, # DarkSeaGreen
105
+ '#87afaf' => 109, # LightSkyBlue3
106
+ '#87afd7' => 110, # LightSkyBlue3
107
+ '#87afff' => 111, # SkyBlue2
108
+ '#87d700' => 112, # Chartreuse2
109
+ '#87d75f' => 113, # DarkOliveGreen3
110
+ '#87d787' => 114, # PaleGreen3
111
+ '#87d7af' => 115, # DarkSeaGreen3
112
+ '#87d7d7' => 116, # DarkSlateGray3
113
+ '#87d7ff' => 117, # SkyBlue1
114
+ '#87ff00' => 118, # Chartreuse1
115
+ '#87ff5f' => 119, # LightGreen
116
+ '#87ff87' => 120, # LightGreen
117
+ '#87ffaf' => 121, # PaleGreen1
118
+ '#87ffd7' => 122, # Aquamarine1
119
+ '#87ffff' => 123, # DarkSlateGray1
120
+ '#af0000' => 124, # Red3
121
+ '#af005f' => 125, # DeepPink4
122
+ '#af0087' => 126, # MediumVioletRed
123
+ '#af00af' => 127, # Magenta3
124
+ '#af00d7' => 128, # DarkViolet
125
+ '#af00ff' => 129, # Purple
126
+ '#af5f00' => 130, # DarkOrange3
127
+ '#af5f5f' => 131, # IndianRed
128
+ '#af5f87' => 132, # HotPink3
129
+ '#af5faf' => 133, # MediumOrchid3
130
+ '#af5fd7' => 134, # MediumOrchid
131
+ '#af5fff' => 135, # MediumPurple2
132
+ '#af8700' => 136, # DarkGoldenrod
133
+ '#af875f' => 137, # LightSalmon3
134
+ '#af8787' => 138, # RosyBrown
135
+ '#af87af' => 139, # Grey63
136
+ '#af87d7' => 140, # MediumPurple2
137
+ '#af87ff' => 141, # MediumPurple1
138
+ '#afaf00' => 142, # Gold3
139
+ '#afaf5f' => 143, # DarkKhaki
140
+ '#afaf87' => 144, # NavajoWhite3
141
+ '#afafaf' => 145, # Grey69
142
+ '#afafd7' => 146, # LightSteelBlue3
143
+ '#afafff' => 147, # LightSteelBlue
144
+ '#afd700' => 148, # Yellow3
145
+ '#afd75f' => 149, # DarkOliveGreen3
146
+ '#afd787' => 150, # DarkSeaGreen3
147
+ '#afd7af' => 151, # DarkSeaGreen2
148
+ '#afd7d7' => 152, # LightCyan3
149
+ '#afd7ff' => 153, # LightSkyBlue1
150
+ '#afff00' => 154, # GreenYellow
151
+ '#afff5f' => 155, # DarkOliveGreen2
152
+ '#afff87' => 156, # PaleGreen1
153
+ '#afffaf' => 157, # DarkSeaGreen2
154
+ '#afffd7' => 158, # DarkSeaGreen1
155
+ '#afffff' => 159, # PaleTurquoise1
156
+ '#d70000' => 160, # Red3
157
+ '#d7005f' => 161, # DeepPink3
158
+ '#d70087' => 162, # DeepPink3
159
+ '#d700af' => 163, # Magenta3
160
+ '#d700d7' => 164, # Magenta3
161
+ '#d700ff' => 165, # Magenta2
162
+ '#d75f00' => 166, # DarkOrange3
163
+ '#d75f5f' => 167, # IndianRed
164
+ '#d75f87' => 168, # HotPink3
165
+ '#d75faf' => 169, # HotPink2
166
+ '#d75fd7' => 170, # Orchid
167
+ '#d75fff' => 171, # MediumOrchid1
168
+ '#d78700' => 172, # Orange3
169
+ '#d7875f' => 173, # LightSalmon3
170
+ '#d78787' => 174, # LightPink3
171
+ '#d787af' => 175, # Pink3
172
+ '#d787d7' => 176, # Plum3
173
+ '#d787ff' => 177, # Violet
174
+ '#d7af00' => 178, # Gold3
175
+ '#d7af5f' => 179, # LightGoldenrod3
176
+ '#d7af87' => 180, # Tan
177
+ '#d7afaf' => 181, # MistyRose3
178
+ '#d7afd7' => 182, # Thistle3
179
+ '#d7afff' => 183, # Plum2
180
+ '#d7d700' => 184, # Yellow3
181
+ '#d7d75f' => 185, # Khaki3
182
+ '#d7d787' => 186, # LightGoldenrod2
183
+ '#d7d7af' => 187, # LightYellow3
184
+ '#d7d7d7' => 188, # Grey84
185
+ '#d7d7ff' => 189, # LightSteelBlue1
186
+ '#d7ff00' => 190, # Yellow2
187
+ '#d7ff5f' => 191, # DarkOliveGreen1
188
+ '#d7ff87' => 192, # DarkOliveGreen1
189
+ '#d7ffaf' => 193, # DarkSeaGreen1
190
+ '#d7ffd7' => 194, # Honeydew2
191
+ '#d7ffff' => 195, # LightCyan1
192
+ '#ff0000' => 196, # Red1
193
+ '#ff005f' => 197, # DeepPink2
194
+ '#ff0087' => 198, # DeepPink1
195
+ '#ff00af' => 199, # DeepPink1
196
+ '#ff00d7' => 200, # Magenta2
197
+ '#ff00ff' => 201, # Magenta1
198
+ '#ff5f00' => 202, # OrangeRed1
199
+ '#ff5f5f' => 203, # IndianRed1
200
+ '#ff5f87' => 204, # IndianRed1
201
+ '#ff5faf' => 205, # HotPink
202
+ '#ff5fd7' => 206, # HotPink
203
+ '#ff5fff' => 207, # MediumOrchid1
204
+ '#ff8700' => 208, # DarkOrange
205
+ '#ff875f' => 209, # Salmon1
206
+ '#ff8787' => 210, # LightCoral
207
+ '#ff87af' => 211, # PaleVioletRed1
208
+ '#ff87d7' => 212, # Orchid2
209
+ '#ff87ff' => 213, # Orchid1
210
+ '#ffaf00' => 214, # Orange1
211
+ '#ffaf5f' => 215, # SandyBrown
212
+ '#ffaf87' => 216, # LightSalmon1
213
+ '#ffafaf' => 217, # LightPink1
214
+ '#ffafd7' => 218, # Pink1
215
+ '#ffafff' => 219, # Plum1
216
+ '#ffd700' => 220, # Gold1
217
+ '#ffd75f' => 221, # LightGoldenrod2
218
+ '#ffd787' => 222, # LightGoldenrod2
219
+ '#ffd7af' => 223, # NavajoWhite1
220
+ '#ffd7d7' => 224, # MistyRose1
221
+ '#ffd7ff' => 225, # Thistle1
222
+ '#ffff00' => 226, # Yellow1
223
+ '#ffff5f' => 227, # LightGoldenrod1
224
+ '#ffff87' => 228, # Khaki1
225
+ '#ffffaf' => 229, # Wheat1
226
+ '#ffffd7' => 230, # Cornsilk1
227
+ '#ffffff' => 231, # Grey100
228
+ '#080808' => 232, # Grey3
229
+ '#121212' => 233, # Grey7
230
+ '#1c1c1c' => 234, # Grey11
231
+ '#262626' => 235, # Grey15
232
+ '#303030' => 236, # Grey19
233
+ '#3a3a3a' => 237, # Grey23
234
+ '#444444' => 238, # Grey27
235
+ '#4e4e4e' => 239, # Grey30
236
+ '#585858' => 240, # Grey35
237
+ '#626262' => 241, # Grey39
238
+ '#6c6c6c' => 242, # Grey42
239
+ '#767676' => 243, # Grey46
240
+ '#808080' => 244, # Grey50
241
+ '#8a8a8a' => 245, # Grey54
242
+ '#949494' => 246, # Grey58
243
+ '#9e9e9e' => 247, # Grey62
244
+ '#a8a8a8' => 248, # Grey66
245
+ '#b2b2b2' => 249, # Grey70
246
+ '#bcbcbc' => 250, # Grey74
247
+ '#c6c6c6' => 251, # Grey78
248
+ '#d0d0d0' => 252, # Grey82
249
+ '#dadada' => 253, # Grey85
250
+ '#e4e4e4' => 254, # Grey89
251
+ '#eeeeee' => 255 # Grey93
252
+ }
253
+ @ending = "\e[00m"
254
+ end
255
+
256
+ def test_hex_colors
257
+ @rgb_colors.each do |hex, code|
258
+ assert_equal( "\033[38;5;#{ code }mTesting #{ hex } text.#{ @ending }", "Testing #{ hex } text.".send( :color, hex ) )
259
+ end
260
+ end
261
+
262
+ def test_hex_backgrounds
263
+ @rgb_colors.each do |hex, code|
264
+ assert_equal( "\033[48;5;#{ code }mTesting #{ hex } background.#{ @ending }", "Testing #{ hex } background.".send( :background, hex ) )
265
+ end
266
+ end
267
+ end
@@ -0,0 +1,72 @@
1
+ #!/usr/bin/env ruby -w
2
+
3
+ $:.unshift File.join( File.dirname( __FILE__ ), '..', 'lib' )
4
+
5
+ require 'test/unit'
6
+ require 'terminal-display-colors'
7
+
8
+ class TestNamedColors < Test::Unit::TestCase
9
+
10
+ def setup
11
+ @colors = {
12
+ 'black' => "\e[30m",
13
+ 'red' => "\e[31m",
14
+ 'green' => "\e[32m",
15
+ 'yellow' => "\e[33m",
16
+ 'blue' => "\e[34m",
17
+ 'magenta' => "\e[35m",
18
+ 'cyan' => "\e[36m",
19
+ 'gray' => "\e[37m",
20
+
21
+ 'dark_gray' => "\e[90m",
22
+ 'bright_red' => "\e[91m",
23
+ 'bright_green' => "\e[92m",
24
+ 'bright_yellow' => "\e[93m",
25
+ 'bright_blue' => "\e[94m",
26
+ 'bright_magenta' => "\e[95m",
27
+ 'bright_cyan' => "\e[96m",
28
+ 'white' => "\e[97m",
29
+ }
30
+ @backgrounds = {
31
+ 'black_background' => "\e[40m",
32
+ 'red_background' => "\e[41m",
33
+ 'green_background' => "\e[42m",
34
+ 'yellow_background' => "\e[43m",
35
+ 'blue_background' => "\e[44m",
36
+ 'magenta_background' => "\e[45m",
37
+ 'cyan_background' => "\e[46m",
38
+ 'gray_background' => "\e[47m",
39
+
40
+ 'dark_gray_background' => "\e[100m",
41
+ 'bright_red_background' => "\e[101m",
42
+ 'bright_green_background' => "\e[102m",
43
+ 'bright_yellow_background' => "\e[103m",
44
+ 'bright_blue_background' => "\e[104m",
45
+ 'bright_magenta_background' => "\e[105m",
46
+ 'bright_cyan_background' => "\e[106m",
47
+ 'white_background' => "\e[107m"
48
+ }
49
+ @ending = "\e[00m"
50
+ end
51
+
52
+ def test_named_colors
53
+ @colors.each do |color, code|
54
+ assert_equal( "#{ code }Testing #{ color } text.#{ @ending }", "Testing #{ color } text.".send( color ) )
55
+ end
56
+ end
57
+
58
+ def test_named_backgrounds
59
+ @backgrounds.each do |background, code|
60
+ assert_equal( "#{ code }Testing #{ background } background.#{ @ending }", "Testing #{ background } background.".send( background ) )
61
+ end
62
+ end
63
+
64
+ def test_named_colors_and_backgrounds
65
+ @colors.each do |color, color_code|
66
+ @backgrounds.each do |background, background_code|
67
+ assert_equal( "#{ color_code }#{ background_code }Testing #{ color } text with #{ background } background.#{ @ending }#{ @ending }", "Testing #{ color } text with #{ background } background.".send( background ).send( color ) )
68
+ assert_equal( "#{ background_code }#{ color_code }Testing #{ background } background with #{ color } text.#{ @ending }#{ @ending }", "Testing #{ background } background with #{ color } text.".send( color ).send( background ) )
69
+ end
70
+ end
71
+ end
72
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: terminal-display-colors
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Cole
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-04-17 00:00:00.000000000 Z
11
+ date: 2014-04-21 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: The terminal-display-colors gem adds color methods to String for easily
14
14
  adding color to terminal output.
@@ -19,12 +19,11 @@ extensions: []
19
19
  extra_rdoc_files: []
20
20
  files:
21
21
  - demo.rb
22
- - History.txt
23
- - Manifest.txt
24
22
  - README.rdoc
25
23
  - Rakefile
26
24
  - lib/terminal-display-colors.rb
27
- - test/test_terminal-display-colors.rb
25
+ - test/test_named_colors.rb
26
+ - test/test_hex_colors.rb
28
27
  homepage: http://github.com/davidcole/terminal-display-colors
29
28
  licenses:
30
29
  - MIT
@@ -50,4 +49,5 @@ signing_key:
50
49
  specification_version: 4
51
50
  summary: Adds color methods to String for easily adding color to terminal output.
52
51
  test_files:
53
- - test/test_terminal-display-colors.rb
52
+ - test/test_named_colors.rb
53
+ - test/test_hex_colors.rb
@@ -1,4 +0,0 @@
1
- === 0.0.1 2010-05-25
2
-
3
- * 1 major enhancement:
4
- * Initial release
@@ -1,9 +0,0 @@
1
- demo.rb
2
- History.txt
3
- Manifest.txt
4
- PostInstall.txt
5
- README.rdoc
6
- Rakefile
7
- lib/terminal-display-colors.rb
8
- test/test_helper.rb
9
- test/test_terminal-display-colors.rb
@@ -1,45 +0,0 @@
1
- #!/usr/bin/env ruby -w
2
-
3
- $:.unshift File.join( File.dirname( __FILE__ ), '..', 'lib' )
4
-
5
- require 'test/unit'
6
- require 'terminal-display-colors'
7
-
8
- class TestTerminalDispayColors < Test::Unit::TestCase
9
-
10
- include TerminalDispayColors
11
-
12
- def setup
13
- end
14
-
15
- def test_normal
16
- assert_equal( "\e[30mtesting some gray text\e[00m", 'testing some gray text'.gray )
17
- assert_equal( "\e[31mtesting some red text\e[00m", 'testing some red text'.red )
18
- assert_equal( "\e[32mtesting some green text\e[00m", 'testing some green text'.green )
19
- assert_equal( "\e[33mtesting some yellow text\e[00m", 'testing some yellow text'.yellow )
20
- assert_equal( "\e[34mtesting some blue text\e[00m", 'testing some blue text'.blue )
21
- assert_equal( "\e[35mtesting some purple text\e[00m", 'testing some purple text'.purple )
22
- assert_equal( "\e[36mtesting some cyan text\e[00m", 'testing some cyan text'.cyan )
23
- assert_equal( "\e[37mtesting some white text\e[00m", 'testing some white text'.white )
24
- end
25
-
26
- def test_bold
27
- assert_equal( "\e[01m\e[30mtesting some gray text\e[00m\e[00m", 'testing some gray text'.gray.bold )
28
- assert_equal( "\e[01m\e[31mtesting some red text\e[00m\e[00m", 'testing some red text'.red.bold )
29
- assert_equal( "\e[01m\e[32mtesting some green text\e[00m\e[00m", 'testing some green text'.green.bold )
30
- assert_equal( "\e[01m\e[33mtesting some yellow text\e[00m\e[00m", 'testing some yellow text'.yellow.bold )
31
- assert_equal( "\e[01m\e[34mtesting some blue text\e[00m\e[00m", 'testing some blue text'.blue.bold )
32
- assert_equal( "\e[01m\e[35mtesting some purple text\e[00m\e[00m", 'testing some purple text'.purple.bold )
33
- assert_equal( "\e[01m\e[36mtesting some cyan text\e[00m\e[00m", 'testing some cyan text'.cyan.bold )
34
- assert_equal( "\e[01m\e[37mtesting some white text\e[00m\e[00m", 'testing some white text'.white.bold )
35
-
36
- assert_equal( "\e[30m\e[01mtesting some gray text\e[00m\e[00m", 'testing some gray text'.bold.gray )
37
- assert_equal( "\e[31m\e[01mtesting some red text\e[00m\e[00m", 'testing some red text'.bold.red )
38
- assert_equal( "\e[32m\e[01mtesting some green text\e[00m\e[00m", 'testing some green text'.bold.green )
39
- assert_equal( "\e[33m\e[01mtesting some yellow text\e[00m\e[00m", 'testing some yellow text'.bold.yellow )
40
- assert_equal( "\e[34m\e[01mtesting some blue text\e[00m\e[00m", 'testing some blue text'.bold.blue )
41
- assert_equal( "\e[35m\e[01mtesting some purple text\e[00m\e[00m", 'testing some purple text'.bold.purple )
42
- assert_equal( "\e[36m\e[01mtesting some cyan text\e[00m\e[00m", 'testing some cyan text'.bold.cyan )
43
- assert_equal( "\e[37m\e[01mtesting some white text\e[00m\e[00m", 'testing some white text'.bold.white )
44
- end
45
- end