ansi 1.0.1 → 1.1.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.
- data/{LICENSE → COPYING} +1 -1
- data/MANIFEST +9 -7
- data/README +2 -2
- data/lib/ansi/bbcode.rb +339 -0
- data/lib/ansi/code.rb +4 -0
- data/lib/ansi/logger.rb +9 -7
- data/lib/ansi/progressbar.rb +3 -1
- data/lib/ansi/string.rb +6 -3
- data/lib/ansi/terminal.rb +8 -8
- data/meta/authors +1 -2
- data/meta/homepage +1 -1
- data/meta/repository +1 -1
- data/meta/version +1 -1
- data/test/test_bbcode.rb +19 -0
- metadata +25 -13
data/{LICENSE → COPYING}
RENAMED
@@ -164,7 +164,7 @@ apply, that proxy's public statement of acceptance of any version is
|
|
164
164
|
permanent authorization for you to choose that version for the
|
165
165
|
Library.
|
166
166
|
|
167
|
-
|
167
|
+
----
|
168
168
|
|
169
169
|
= GNU GENERAL PUBLIC LICENSE
|
170
170
|
|
data/MANIFEST
CHANGED
@@ -1,23 +1,21 @@
|
|
1
|
-
|
2
|
-
LICENSE
|
3
|
-
MANIFEST
|
4
|
-
README
|
1
|
+
#!mast bin demo lib meta test [A-Z]*
|
5
2
|
demo
|
6
3
|
demo/logger.rd
|
7
4
|
demo/progressbar.rd
|
8
5
|
lib
|
9
6
|
lib/ansi
|
10
|
-
lib/ansi.rb
|
7
|
+
lib/ansi/bbcode.rb
|
11
8
|
lib/ansi/code.rb
|
12
9
|
lib/ansi/logger.rb
|
13
10
|
lib/ansi/progressbar.rb
|
14
11
|
lib/ansi/string.rb
|
15
12
|
lib/ansi/terminal
|
16
|
-
lib/ansi/terminal.rb
|
17
13
|
lib/ansi/terminal/curses.rb
|
18
14
|
lib/ansi/terminal/stty.rb
|
19
15
|
lib/ansi/terminal/termios.rb
|
20
16
|
lib/ansi/terminal/win32.rb
|
17
|
+
lib/ansi/terminal.rb
|
18
|
+
lib/ansi.rb
|
21
19
|
meta
|
22
20
|
meta/abstract
|
23
21
|
meta/authors
|
@@ -34,4 +32,8 @@ meta/title
|
|
34
32
|
meta/version
|
35
33
|
test
|
36
34
|
test/test_ansicode.rb
|
37
|
-
test/
|
35
|
+
test/test_bbcode.rb
|
36
|
+
test/test_progressbar.rb
|
37
|
+
README
|
38
|
+
HISTORY
|
39
|
+
COPYING
|
data/README
CHANGED
data/lib/ansi/bbcode.rb
ADDED
@@ -0,0 +1,339 @@
|
|
1
|
+
# = BBCode
|
2
|
+
#
|
3
|
+
# Copyright (c) 2002 Thomas-Ivo Heinen
|
4
|
+
#
|
5
|
+
# This module is free software. You may use, modify, and/or redistribute this
|
6
|
+
# software under the same terms as Ruby.
|
7
|
+
#
|
8
|
+
# This program is distributed in the hope that it will be useful, but WITHOUT
|
9
|
+
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
10
|
+
# FOR A PARTICULAR PURPOSE.
|
11
|
+
|
12
|
+
module ANSI
|
13
|
+
|
14
|
+
# = BBCode
|
15
|
+
#
|
16
|
+
# The BBCode module helps ease the separation of core and frontend with the
|
17
|
+
# core (or submodules) being still able to say, what colors shall be used
|
18
|
+
# in it's responses. This is achieved by encoding formatting information
|
19
|
+
# using the BBCode tokens. This enables you to "pipe" layout information
|
20
|
+
# such as colors, style, fonttype, size and alignment through the core to
|
21
|
+
# the frontend.
|
22
|
+
#
|
23
|
+
# Additionally it converts markups/codes between ANSI, HTML and BBCode
|
24
|
+
# almost freely ;)
|
25
|
+
#
|
26
|
+
# == Usage
|
27
|
+
#
|
28
|
+
# # Converting a bbcode string to ANSI and XHTML
|
29
|
+
#
|
30
|
+
# str = "this is [COLOR=red]red[/COLOR], this is [B]bold[/B]"
|
31
|
+
# print( BBCode.bbcode_to_ansi(str) )
|
32
|
+
# print( BBCode.bbcode_to_html(str) )
|
33
|
+
#
|
34
|
+
module BBCode
|
35
|
+
|
36
|
+
## ANSIname => ANSIcode LUT
|
37
|
+
ANSINAME2CODE= { "reset" => "\e[0m", "bold" => "\e[1m",
|
38
|
+
"underline" => "\e[4m", "blink" => "\e[5m",
|
39
|
+
"reverse" => "\e[7m", "invisible" => "\e[8m",
|
40
|
+
"black" => "\e[0;30m", "darkgrey" => "\e[1;30m",
|
41
|
+
"red" => "\e[0;31m", "lightred" => "\e[1;31m",
|
42
|
+
"green" => "\e[0;32m", "lightgreen" => "\e[1;32m",
|
43
|
+
"brown" => "\e[0;33m", "yellow" => "\e[1;33m",
|
44
|
+
"blue" => "\e[0;34m", "lightblue" => "\e[1;34m",
|
45
|
+
"purple" => "\e[0;35m", "magenta" => "\e[1;35m",
|
46
|
+
"cyan" => "\e[1;36m", "lightcyan" => "\e[1;36m",
|
47
|
+
"grey" => "\e[0;37m", "white" => "\e[1;37m",
|
48
|
+
"bgblack" => "\e[40m", "bgred" => "\e[41m",
|
49
|
+
"bggreen" => "\e[42m", "bgyellow" => "\e[43m",
|
50
|
+
"bgblue" => "\e[44m", "bgmagenta" => "\e[45m",
|
51
|
+
"bgcyan" => "\e[46m", "bgwhite" => "\e[47m"
|
52
|
+
}
|
53
|
+
|
54
|
+
## BBColor => ANSIname LUT
|
55
|
+
BBCOLOR2ANSI = { "skyblue" => "blue", "royalblue" => "blue",
|
56
|
+
"blue" => "blue", "darkblue" => "blue",
|
57
|
+
"orange" => "red", "orangered" => "red",
|
58
|
+
"crimson" => "red", "red" => "lightred",
|
59
|
+
"firebrick" => "red", "darkred" => "red",
|
60
|
+
"green" => "green", "limegreen" => "green",
|
61
|
+
"seagreen" => "green", "darkgreen" => "green",
|
62
|
+
"deeppink" => "magenta", "tomato" => "red",
|
63
|
+
"coral" => "cyan", "purple" => "purple",
|
64
|
+
"indigo" => "blue", "burlywood" => "red",
|
65
|
+
"sandybrown"=> "red", "sierra" => "sierra",
|
66
|
+
"chocolate" => "brown", "teal" => "teal",
|
67
|
+
"silver" => "white",
|
68
|
+
"black" => "black", "yellow" => "yellow",
|
69
|
+
"magenta" => "magenta", "cyan" => "cyan",
|
70
|
+
"white" => "white"
|
71
|
+
}
|
72
|
+
|
73
|
+
## ANSInames => BBCode LUT
|
74
|
+
ANSINAME2BBCODE = { "bold" => "B", "underline" => "U", "reverse" => "I",
|
75
|
+
|
76
|
+
"red" => "COLOR=red", "blue" => "COLOR=blue",
|
77
|
+
"green" => "COLOR=green", "cyan" => "COLOR=cyan",
|
78
|
+
"magenta"=> "COLOR=deeppink", "purple" => "COLOR=purple",
|
79
|
+
"black" => "COLOR=black", "white" => "COLOR=white",
|
80
|
+
"yellow" => "COLOR=yellow", "brown" => "COLOR=chocolate"
|
81
|
+
}
|
82
|
+
|
83
|
+
## Needed for alignments
|
84
|
+
@@width = 80
|
85
|
+
|
86
|
+
|
87
|
+
# ---------------------------
|
88
|
+
|
89
|
+
# Returns the ANSI sequence for given color, if existant
|
90
|
+
def BBCode.ansi(colorname)
|
91
|
+
colorname.strip!
|
92
|
+
return ANSINAME2CODE[ colorname.downcase ]
|
93
|
+
end
|
94
|
+
|
95
|
+
# --- strip_bbcode( string )
|
96
|
+
# Will strip any BBCode tags from the given string.
|
97
|
+
def BBCode.strip_bbcode(string)
|
98
|
+
string.strip!
|
99
|
+
return string.gsub(/\[[A-Za-z0-9\/=]+\]/, "")
|
100
|
+
end
|
101
|
+
|
102
|
+
# Returns the string with all ansi escape sequences converted to BBCodes
|
103
|
+
def BBCode.ansi_to_bbcode(string)
|
104
|
+
return "" if string.nil? || string.to_s.strip.empty?
|
105
|
+
result = ""
|
106
|
+
tagstack = []
|
107
|
+
|
108
|
+
## Iterate over input lines
|
109
|
+
string.split("\n").each do |line|
|
110
|
+
ansi = line.scan(/\e\[[0-9;]+m/)
|
111
|
+
continue if ansi.nil? || ansi.empty?
|
112
|
+
|
113
|
+
## Iterate over found ansi sequences
|
114
|
+
ansi.each do |seq|
|
115
|
+
ansiname = ANSINAME2CODE.invert["#{seq}"]
|
116
|
+
|
117
|
+
## Pop last tag and form closing tag
|
118
|
+
if ansiname == "reset"
|
119
|
+
lasttag = tagstack.pop
|
120
|
+
bbname = "/" + String.new( lasttag.split("=")[0] )
|
121
|
+
|
122
|
+
## Get corresponding BBCode tag + Push to stack
|
123
|
+
else
|
124
|
+
bbname = ANSINAME2BBCODE[ansiname]
|
125
|
+
tagstack.push(bbname)
|
126
|
+
end
|
127
|
+
|
128
|
+
## Replace ansi sequence by BBCode tag
|
129
|
+
replace = sprintf("[%s]", bbname)
|
130
|
+
line.sub!("#{Regexp.quote(seq)}", replace)
|
131
|
+
end
|
132
|
+
|
133
|
+
## Append converted line
|
134
|
+
result << sprintf("%s\n", line)
|
135
|
+
end
|
136
|
+
|
137
|
+
|
138
|
+
## Some tags are unclosed
|
139
|
+
while !tagstack.empty?
|
140
|
+
result << sprintf("[/%s]", String.new(tagstack.pop.split("=")[0]) )
|
141
|
+
end
|
142
|
+
|
143
|
+
return result
|
144
|
+
end
|
145
|
+
|
146
|
+
# Converts a BBCode string to one with ANSI sequences.
|
147
|
+
# Returns the string with all formatting instructions in BBCodes converted
|
148
|
+
# to ANSI code sequences / aligned with spaces to specified width.
|
149
|
+
def BBCode.bbcode_to_ansi(string, usecolors = true)
|
150
|
+
return "" if string.nil? || string.to_s.strip.empty?
|
151
|
+
result = ""
|
152
|
+
|
153
|
+
return BBCode.strip_bbcode(string) if !usecolors
|
154
|
+
|
155
|
+
## Iterate over lines
|
156
|
+
string.split("\n").each do |line|
|
157
|
+
|
158
|
+
## TODO: stacking? other styles!
|
159
|
+
ANSINAME2BBCODE.each do |key,val|
|
160
|
+
line.gsub!(/\[#{val}\]/, ANSINAME2CODE[key])
|
161
|
+
line.gsub!(/\[\/#{val}\]/, ANSINAME2CODE["reset"])
|
162
|
+
end
|
163
|
+
|
164
|
+
## Fonttypes and sizes not available
|
165
|
+
line.gsub!(/\[SIZE=\d\]/, "")
|
166
|
+
line.gsub!(/\[\/SIZE\]/, "")
|
167
|
+
line.gsub!(/\[FONT=[^\]]*\]/, "")
|
168
|
+
line.gsub!(/\[\/FONT\]/, "")
|
169
|
+
|
170
|
+
## Color-mapping
|
171
|
+
colors = line.scan(/\[COLOR=(.*?)\]/i)
|
172
|
+
colors = colors.collect{|s| s[0].to_s} if !colors.nil?
|
173
|
+
colors.each do |col|
|
174
|
+
name = BBCOLOR2ANSI[col.downcase]
|
175
|
+
name = BBCOLOR2ANSI["white"] if name.nil?
|
176
|
+
code = ANSINAME2CODE[name]
|
177
|
+
|
178
|
+
line.gsub!(/\[COLOR=#{col}\]/i, code)
|
179
|
+
end
|
180
|
+
line.gsub!(/\[\/COLOR\]/, ANSINAME2CODE["reset"])
|
181
|
+
|
182
|
+
## TODO: Alignment
|
183
|
+
## TODO: IMGs
|
184
|
+
## TODO: EMAILs
|
185
|
+
## TODO: URLs
|
186
|
+
## TODO: QUOTEs
|
187
|
+
## TODO: LISTs
|
188
|
+
|
189
|
+
result << sprintf("%s\n", line)
|
190
|
+
end
|
191
|
+
|
192
|
+
return result
|
193
|
+
end
|
194
|
+
|
195
|
+
# Converts a HTML string into one with BBCode markup (TODO)
|
196
|
+
# Returns the (X)HTML markup string as BBCode
|
197
|
+
def BBCode.html_to_bbcode(string)
|
198
|
+
return "" if string.nil? || string.to_s.strip.empty?
|
199
|
+
result = ""
|
200
|
+
|
201
|
+
## Iterate over lines
|
202
|
+
string.split(/<br *\/?>/i).each do |line|
|
203
|
+
styles = { "strong" => "b", "b" => "b",
|
204
|
+
"em" => "i", "i" => "i",
|
205
|
+
"u" => "u" }
|
206
|
+
|
207
|
+
## preserve B, I, U
|
208
|
+
styles.each do |html,code|
|
209
|
+
line.gsub!(/<#{html}>/i, "[#{code.upcase}]")
|
210
|
+
line.gsub!(/<\/#{html}>/i, "[/#{code.upcase}]")
|
211
|
+
end
|
212
|
+
|
213
|
+
## TODO: COLORs
|
214
|
+
## TODO: SIZEs
|
215
|
+
## TODO: FONTs
|
216
|
+
|
217
|
+
## EMAIL
|
218
|
+
line.gsub!(/<a +href *= *\"mailto:(.*?)\".*?>.*?<\/a>/i, "[EMAIL]\\1[/EMAIL]")
|
219
|
+
|
220
|
+
## URL
|
221
|
+
line.gsub!(/<a +href *= *\"((?:https?|ftp):\/\/.*?)\".*?>(.*?)<\/a>/i, "[URL=\\1]\\2[/URL]")
|
222
|
+
|
223
|
+
## Other refs + closing tags => throw away
|
224
|
+
line.gsub!(/<a +href *= *\".*?\".*?>/i, "")
|
225
|
+
line.gsub!(/<\/a>/i, "")
|
226
|
+
|
227
|
+
## IMG
|
228
|
+
#line.gsub!(/<img +src *= *\"(.*?)\".*?\/?>/i, "[IMG=\\1]")
|
229
|
+
line.gsub!(/<img +src *= *\"(.*?)\".*?\/?>/i, "[IMG]\\1[/IMG]")
|
230
|
+
|
231
|
+
## CENTER (right/left??)
|
232
|
+
line.gsub!(/<center>/i, "[ALIGN=center]")
|
233
|
+
line.gsub!(/<\/center>/i, "[/ALIGN]")
|
234
|
+
|
235
|
+
## QUOTE
|
236
|
+
line.gsub!(/<(?:xmp|pre)>/i, "[QUOTE]")
|
237
|
+
line.gsub!(/<\/(?:xmp|pre)>/i, "[/QUOTE]")
|
238
|
+
|
239
|
+
## LIST
|
240
|
+
line.gsub!(/<ul>/i, "\n[LIST]\n")
|
241
|
+
line.gsub!(/<\/ul>/i, "\n[/LIST]\n")
|
242
|
+
line.gsub!(/<li *\/?> */i, "\n[*] ")
|
243
|
+
|
244
|
+
## Unkown tags => throw away
|
245
|
+
line.gsub!(/<.*? *\/?>/, "")
|
246
|
+
|
247
|
+
result << sprintf("%s<br />\n", line)
|
248
|
+
end
|
249
|
+
|
250
|
+
return result.gsub!(/<br *\/?>/i, "\n")
|
251
|
+
end
|
252
|
+
|
253
|
+
# Converts a BBCode string to one with HTML markup.
|
254
|
+
# Returns the string with all formatting instructions in
|
255
|
+
# BBCodes converted to XHTML markups.
|
256
|
+
def BBCode.bbcode_to_html(string)
|
257
|
+
return "" if string.nil? || string.to_s.strip.empty?
|
258
|
+
result = ""
|
259
|
+
quote = 0
|
260
|
+
|
261
|
+
## Iterate over lines
|
262
|
+
string.split("\n").each do |line|
|
263
|
+
styles = { "b" => "strong", "i" => "em", "u" => "u" }
|
264
|
+
|
265
|
+
## preserve B, I, U
|
266
|
+
styles.each do |code,html|
|
267
|
+
line.gsub!(/\[#{code}\]/i, "<#{html}>")
|
268
|
+
line.gsub!(/\[\/#{code}\]/i, "</#{html}>")
|
269
|
+
end
|
270
|
+
|
271
|
+
## COLOR => font color=... (TODO: should be numeric!)
|
272
|
+
line.gsub!(/\[COLOR=(.*?)\]/i, "<font color=\"\\1\">")
|
273
|
+
line.gsub!(/\[\/COLOR\]/i, "</font>")
|
274
|
+
|
275
|
+
## SIZE => font size=...
|
276
|
+
line.gsub!(/\[SIZE=(.*?)\]/i, "<font size=\"\\1\">")
|
277
|
+
line.gsub!(/\[\/SIZE\]/i, "</font>")
|
278
|
+
|
279
|
+
## URL
|
280
|
+
line.gsub!(/\[URL\]([^\[]+?)\[\/URL\]/i, "<a href=\"\\1\">\\1</a>")
|
281
|
+
line.gsub!(/\[URL=(.*?)\](.+?)\[\/URL\]/i, "<a href=\"\\1\">\\2</a>")
|
282
|
+
|
283
|
+
## IMG
|
284
|
+
line.gsub!(/\[IMG=(.*?)\]/i, "<img src=\"\\1\" />")
|
285
|
+
|
286
|
+
## ALIGN=center (TODO: right, left)
|
287
|
+
line.gsub!(/\[ALIGN=center\]/i, "<center>")
|
288
|
+
line.gsub!(/\[ALIGN=right\]/i, "<center>")
|
289
|
+
line.gsub!(/\[ALIGN=left\]/i, "<center>")
|
290
|
+
line.gsub!(/\[\/ALIGN\]/i, "</center>")
|
291
|
+
|
292
|
+
## QUOTE
|
293
|
+
quote+=1 if line =~ /\[QUOTE\]/i
|
294
|
+
quote-=1 if (line =~ /\[\/QUOTE\]/i) && (quote > -1)
|
295
|
+
line.gsub!(/\[QUOTE\]/i, "<pre>\n")
|
296
|
+
line.gsub!(/\[\/QUOTE\]/i, "</pre>\n")
|
297
|
+
line.gsub!(/^/, ">"*quote) if quote > 0
|
298
|
+
|
299
|
+
## EMAIL
|
300
|
+
line.gsub!(/\[EMAIL\](.*?)\[\/EMAIL\]/i, "<a href=\"mailto:\\1\">\\1</a>")
|
301
|
+
|
302
|
+
## LIST (TODO: LIST=1, LIST=A)
|
303
|
+
line.gsub!(/\[LIST(?:=(.*?))?\]/i, "\n<ul>\n")
|
304
|
+
line.gsub!(/\[\/LIST\]/i, "\n</ul>\n")
|
305
|
+
line.gsub!(/\[\*\]/i, "\n<li />")
|
306
|
+
|
307
|
+
## FONT => font ??????
|
308
|
+
## ?BLUR?, FADE?
|
309
|
+
|
310
|
+
result << sprintf("%s<br />\n", line)
|
311
|
+
end
|
312
|
+
|
313
|
+
return result
|
314
|
+
end
|
315
|
+
|
316
|
+
|
317
|
+
# -- Transitive methods ---------------
|
318
|
+
|
319
|
+
# Converts a ANSI string to one with HTML markup.
|
320
|
+
# Returns the string with ANSI code sequences converted to XHTML markup.
|
321
|
+
def BBCode.ansi_to_html(string)
|
322
|
+
bbcoded = BBCode.ansi_to_bbcode(string )
|
323
|
+
htmled = BBCode.bbcode_to_html(bbcoded)
|
324
|
+
|
325
|
+
return htmled
|
326
|
+
end
|
327
|
+
|
328
|
+
# Returns the (X)HTML markup code as ANSI sequences
|
329
|
+
def BBCode.html_to_ansi(string)
|
330
|
+
bbcoded = BBCode.html_to_bbcode(string )
|
331
|
+
ansied = BBCode.bbcode_to_ansi(bbcoded)
|
332
|
+
|
333
|
+
return ansied
|
334
|
+
end
|
335
|
+
|
336
|
+
end #module BBCode
|
337
|
+
|
338
|
+
end
|
339
|
+
|
data/lib/ansi/code.rb
CHANGED
@@ -8,11 +8,14 @@
|
|
8
8
|
# TODO: Re-evaluate how color/yielding methods are defined.
|
9
9
|
# TODO: Maybe up, down, right, left should have yielding methods too?
|
10
10
|
|
11
|
+
#
|
11
12
|
module ANSI
|
12
13
|
|
13
14
|
# Currently Windows is not supported.
|
14
15
|
SUPPORTED = !(RUBY_PLATFORM =~ /win/)
|
15
16
|
|
17
|
+
# = ANSI Codes
|
18
|
+
#
|
16
19
|
# Ansi::Code module makes it very easy to use ANSI codes.
|
17
20
|
# These are esspecially nice for beautifying shell output.
|
18
21
|
#
|
@@ -227,3 +230,4 @@ module ANSI
|
|
227
230
|
end
|
228
231
|
|
229
232
|
end
|
233
|
+
|
data/lib/ansi/logger.rb
CHANGED
@@ -8,8 +8,8 @@ require "ansi/code"
|
|
8
8
|
|
9
9
|
# = ANSI::Logger
|
10
10
|
#
|
11
|
-
# Extended variation of Ruby's standard Logger library
|
12
|
-
#
|
11
|
+
# Extended variation of Ruby's standard Logger library that supports
|
12
|
+
# color output.
|
13
13
|
#
|
14
14
|
# log = ANSI::Logger.new
|
15
15
|
#
|
@@ -30,12 +30,14 @@ class ANSI::Logger < Logger
|
|
30
30
|
SIMPLE_FORMAT = "%5s: %s\n"
|
31
31
|
DETAILED_FORMAT = "%s %5s: %s\n"
|
32
32
|
|
33
|
-
#
|
34
|
-
class ::Logger
|
35
|
-
|
33
|
+
# TODO: Not sure I like this approach.
|
34
|
+
class ::Logger #:nodoc:
|
35
|
+
class LogDevice #:nodoc:
|
36
|
+
attr_writer :ansicolor
|
36
37
|
|
37
|
-
|
38
|
-
|
38
|
+
def ansicolor?
|
39
|
+
@ansicolor.nil? ? true : @ansicolor
|
40
|
+
end
|
39
41
|
end
|
40
42
|
end
|
41
43
|
|
data/lib/ansi/progressbar.rb
CHANGED
data/lib/ansi/string.rb
CHANGED
@@ -7,8 +7,10 @@ def ANSI.string(str)
|
|
7
7
|
ANSI::String.new(str)
|
8
8
|
end
|
9
9
|
|
10
|
-
#
|
11
|
-
#
|
10
|
+
# = String
|
11
|
+
#
|
12
|
+
# ANSI Strings store a regular string (@text) and
|
13
|
+
# a Hash mapping character index to ANSI codes (@marks).
|
12
14
|
# For example is we have the string:
|
13
15
|
#
|
14
16
|
# "Big Apple"
|
@@ -18,7 +20,8 @@ end
|
|
18
20
|
# { 0=>[:red] , 9=>[:clear] }
|
19
21
|
#
|
20
22
|
# TODO: In the future we may be able to subclass String,
|
21
|
-
# instead of delegating via @text, but not until it is more
|
23
|
+
# instead of delegating via @text, but not until it is more
|
24
|
+
# compatible.
|
22
25
|
#
|
23
26
|
class ANSI::String
|
24
27
|
|
data/lib/ansi/terminal.rb
CHANGED
@@ -1,13 +1,13 @@
|
|
1
|
-
#
|
2
|
-
# This library is based of HighLine's SystemExtensions
|
3
|
-
# by James Edward Gray II.
|
4
|
-
#
|
5
|
-
# Copyright 2006 Gray Productions. All rights reserved.
|
6
|
-
#
|
7
|
-
# This is Free Software. See LICENSE and COPYING for details.
|
8
|
-
|
9
1
|
module ANSI
|
10
2
|
|
3
|
+
# = Terminal
|
4
|
+
#
|
5
|
+
# This library is based of HighLine's SystemExtensions
|
6
|
+
# by James Edward Gray II.
|
7
|
+
#
|
8
|
+
# Copyright 2006 Gray Productions.
|
9
|
+
#
|
10
|
+
# This is Free Software. See LICENSE and COPYING for details.
|
11
11
|
#
|
12
12
|
module Terminal
|
13
13
|
|
data/meta/authors
CHANGED
data/meta/homepage
CHANGED
@@ -1 +1 @@
|
|
1
|
-
http://death.rubyforge.org/
|
1
|
+
http://death.rubyforge.org/ansi
|
data/meta/repository
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
git://github.com/rubyworks/ansi.git
|
data/meta/version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.0
|
1
|
+
1.1.0
|
data/test/test_bbcode.rb
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'ansi/bbcode'
|
2
|
+
require 'test/unit'
|
3
|
+
|
4
|
+
class TC_BBCode < Test::Unit::TestCase
|
5
|
+
|
6
|
+
def test_to_ansi
|
7
|
+
str = "this is [COLOR=red]red[/COLOR], this is [B]bold[/B]"
|
8
|
+
out = "this is \e[0;31mred\e[0m, this is \e[1mbold\e[0m\n"
|
9
|
+
assert_equal( out, BBCode.bbcode_to_ansi(str) )
|
10
|
+
end
|
11
|
+
|
12
|
+
def test_to_html
|
13
|
+
str = "this is [COLOR=red]red[/COLOR], this is [B]bold[/B]"
|
14
|
+
out = "this is <font color=\"red\">red</font>, this is <strong>bold</strong><br />\n"
|
15
|
+
assert_equal( out, BBCode.bbcode_to_html(str) )
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
|
metadata
CHANGED
@@ -1,21 +1,30 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ansi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
+
- Thomas Sawyer
|
7
8
|
- Florian Frank
|
8
|
-
- Trans <transfire@gmail.com>
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2009-
|
13
|
+
date: 2009-10-03 00:00:00 -04:00
|
14
14
|
default_executable:
|
15
15
|
dependencies: []
|
16
16
|
|
17
|
-
description:
|
18
|
-
|
17
|
+
description: |-
|
18
|
+
The ANSI project is a collection of ANSI code related libraries
|
19
|
+
enabling ANSI code based colorization and stylization of output.
|
20
|
+
It is very nice for beautifying shell output.
|
21
|
+
|
22
|
+
This collection is based on a set of scripts spun-off from
|
23
|
+
Ruby Facets. Include are Code (used to be ANSICode), Logger,
|
24
|
+
Progressbar and String. In addition the library include
|
25
|
+
Terminal which provides information about the current output
|
26
|
+
device.
|
27
|
+
email: Thomas Sawyer
|
19
28
|
executables: []
|
20
29
|
|
21
30
|
extensions: []
|
@@ -23,25 +32,22 @@ extensions: []
|
|
23
32
|
extra_rdoc_files:
|
24
33
|
- README
|
25
34
|
- MANIFEST
|
26
|
-
- LICENSE
|
27
35
|
- HISTORY
|
36
|
+
- COPYING
|
28
37
|
files:
|
29
|
-
- HISTORY
|
30
|
-
- LICENSE
|
31
|
-
- MANIFEST
|
32
|
-
- README
|
33
38
|
- demo/logger.rd
|
34
39
|
- demo/progressbar.rd
|
35
|
-
- lib/ansi.rb
|
40
|
+
- lib/ansi/bbcode.rb
|
36
41
|
- lib/ansi/code.rb
|
37
42
|
- lib/ansi/logger.rb
|
38
43
|
- lib/ansi/progressbar.rb
|
39
44
|
- lib/ansi/string.rb
|
40
|
-
- lib/ansi/terminal.rb
|
41
45
|
- lib/ansi/terminal/curses.rb
|
42
46
|
- lib/ansi/terminal/stty.rb
|
43
47
|
- lib/ansi/terminal/termios.rb
|
44
48
|
- lib/ansi/terminal/win32.rb
|
49
|
+
- lib/ansi/terminal.rb
|
50
|
+
- lib/ansi.rb
|
45
51
|
- meta/abstract
|
46
52
|
- meta/authors
|
47
53
|
- meta/created
|
@@ -56,9 +62,14 @@ files:
|
|
56
62
|
- meta/title
|
57
63
|
- meta/version
|
58
64
|
- test/test_ansicode.rb
|
65
|
+
- test/test_bbcode.rb
|
59
66
|
- test/test_progressbar.rb
|
67
|
+
- README
|
68
|
+
- HISTORY
|
69
|
+
- COPYING
|
70
|
+
- MANIFEST
|
60
71
|
has_rdoc: true
|
61
|
-
homepage: http://death.rubyforge.org/
|
72
|
+
homepage: http://death.rubyforge.org/ansi
|
62
73
|
licenses: []
|
63
74
|
|
64
75
|
post_install_message:
|
@@ -91,4 +102,5 @@ specification_version: 3
|
|
91
102
|
summary: ANSI codes at your fingertips!
|
92
103
|
test_files:
|
93
104
|
- test/test_ansicode.rb
|
105
|
+
- test/test_bbcode.rb
|
94
106
|
- test/test_progressbar.rb
|