ruby-nuggets 0.1.3.221 → 0.1.4.231
Sign up to get free protection for your applications and to get access to all the features.
- data/README +1 -1
- data/lib/nuggets/util/ansicolor2css.rb +90 -0
- data/lib/nuggets/version.rb +1 -1
- metadata +3 -2
data/README
CHANGED
@@ -0,0 +1,90 @@
|
|
1
|
+
#--
|
2
|
+
###############################################################################
|
3
|
+
# #
|
4
|
+
# A component of ruby-nuggets, some extensions to the Ruby programming #
|
5
|
+
# language. #
|
6
|
+
# #
|
7
|
+
# Copyright (C) 2007-2008 Jens Wille #
|
8
|
+
# #
|
9
|
+
# Authors: #
|
10
|
+
# Jens Wille <jens.wille@uni-koeln.de> #
|
11
|
+
# #
|
12
|
+
# ruby-nuggets is free software; you can redistribute it and/or modify it #
|
13
|
+
# under the terms of the GNU General Public License as published by the Free #
|
14
|
+
# Software Foundation; either version 3 of the License, or (at your option) #
|
15
|
+
# any later version. #
|
16
|
+
# #
|
17
|
+
# ruby-nuggets is distributed in the hope that it will be useful, but WITHOUT #
|
18
|
+
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or #
|
19
|
+
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for #
|
20
|
+
# more details. #
|
21
|
+
# #
|
22
|
+
# You should have received a copy of the GNU General Public License along #
|
23
|
+
# with ruby-nuggets. If not, see <http://www.gnu.org/licenses/>. #
|
24
|
+
# #
|
25
|
+
###############################################################################
|
26
|
+
#++
|
27
|
+
|
28
|
+
module Util
|
29
|
+
|
30
|
+
module ANSIColor2CSS
|
31
|
+
|
32
|
+
extend self
|
33
|
+
|
34
|
+
COLOUR_RE = %r{\e\[((?:[0-9]|[34][0-7])(?:;(?:[0-9]|[34][0-7]))*)m}
|
35
|
+
|
36
|
+
OPEN = '<span style="'.freeze
|
37
|
+
OPENC = '">'.freeze
|
38
|
+
CLOSE = '</span>'.freeze
|
39
|
+
|
40
|
+
ATTRIBUTES = {
|
41
|
+
'0' => CLOSE, # clear
|
42
|
+
'1' => 'font-weight: bold', # bold
|
43
|
+
'2' => '', # dark
|
44
|
+
'3' => 'font-style: italic', # italic -- not widely implemented
|
45
|
+
'4' => 'text-decoration: underline', # underline
|
46
|
+
'5' => 'text-decoration: blink', # blink
|
47
|
+
'6' => 'text-decoration: blink', # rapid blink -- not widely implemented
|
48
|
+
'7' => '', # negative
|
49
|
+
'8' => '', # concealed
|
50
|
+
'9' => 'text-decoration: line-through', # strikethrough -- not widely implemented
|
51
|
+
'30' => 'color: black', # black
|
52
|
+
'31' => 'color: red', # red
|
53
|
+
'32' => 'color: green', # green
|
54
|
+
'33' => 'color: yellow', # yellow
|
55
|
+
'34' => 'color: blue', # blue
|
56
|
+
'35' => 'color: magenta', # magenta
|
57
|
+
'36' => 'color: cyan', # cyan
|
58
|
+
'37' => 'color: white', # white
|
59
|
+
'40' => 'background-color: black', # on black
|
60
|
+
'41' => 'background-color: red', # on red
|
61
|
+
'42' => 'background-color: green', # on green
|
62
|
+
'43' => 'background-color: yellow', # on yellow
|
63
|
+
'44' => 'background-color: blue', # on blue
|
64
|
+
'45' => 'background-color: magenta', # on magenta
|
65
|
+
'46' => 'background-color: cyan', # on cyan
|
66
|
+
'47' => 'background-color: white' # on white
|
67
|
+
}
|
68
|
+
|
69
|
+
def convert(string)
|
70
|
+
string.gsub(COLOUR_RE) {
|
71
|
+
subst, attrs = '', $1.split(';')
|
72
|
+
|
73
|
+
subst << CLOSE if attrs.delete('0')
|
74
|
+
subst << OPEN << attrs.map { |c| ATTRIBUTES[c] }.join('; ') << OPENC unless attrs.empty?
|
75
|
+
|
76
|
+
subst
|
77
|
+
}
|
78
|
+
end
|
79
|
+
|
80
|
+
end
|
81
|
+
|
82
|
+
end
|
83
|
+
|
84
|
+
class String
|
85
|
+
|
86
|
+
def ansicolor2css
|
87
|
+
Util::ANSIColor2CSS.convert(self)
|
88
|
+
end
|
89
|
+
|
90
|
+
end
|
data/lib/nuggets/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby-nuggets
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4.231
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jens Wille
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2008-
|
12
|
+
date: 2008-04-09 00:00:00 +02:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|
@@ -48,6 +48,7 @@ files:
|
|
48
48
|
- lib/nuggets/array/format.rb
|
49
49
|
- lib/nuggets/array/combination.rb
|
50
50
|
- lib/nuggets/numeric/signum.rb
|
51
|
+
- lib/nuggets/util/ansicolor2css.rb
|
51
52
|
- lib/nuggets/util/content_type.rb
|
52
53
|
- lib/nuggets/util/i18n.rb
|
53
54
|
- lib/nuggets/file/which.rb
|