term-ansicolor 1.0.4 → 1.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +6 -0
- data/README +117 -11
- data/Rakefile +29 -27
- data/VERSION +1 -1
- data/{examples/cdiff.rb → bin/cdiff} +2 -2
- data/bin/decolor +12 -0
- data/examples/example.rb +7 -6
- data/lib/term/ansicolor.rb +3 -3
- data/lib/term/ansicolor/version.rb +1 -1
- data/tests/ansicolor_test.rb +66 -0
- metadata +16 -13
- data/doc-main.txt +0 -119
- data/term-ansicolor.gemspec +0 -20
data/CHANGES
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
2010-03-10 - 1.0.5 * Added cdiff example as an executable.
|
2
|
+
* Disabled building of gemspec file.
|
3
|
+
* Made an decolor executable, that removes colors from an io
|
4
|
+
stream.
|
5
|
+
* Match an additional way to clear the color in the
|
6
|
+
COLORED_REGEXP for the uncolored method.
|
1
7
|
2009-07-23 - 1.0.4 * Some cleanup.
|
2
8
|
* Build a gemspec file.
|
3
9
|
2007-10-05 - 1.0.3 * Better documentation + some code clean up.
|
data/README
CHANGED
@@ -1,5 +1,10 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
== ANSI escape sequences in Ruby
|
2
|
+
|
3
|
+
=== Description
|
4
|
+
|
5
|
+
This library can be used to color/decolor strings using ANSI escape sequences.
|
6
|
+
|
7
|
+
=== Installation
|
3
8
|
|
4
9
|
Just type into the command line as root:
|
5
10
|
|
@@ -14,18 +19,119 @@ installs it for you:
|
|
14
19
|
|
15
20
|
# gem install term-ansicolor
|
16
21
|
|
17
|
-
|
18
|
-
|
22
|
+
=== Download
|
23
|
+
|
24
|
+
The latest version of this library can be downloaded at
|
25
|
+
|
26
|
+
* http://www.ping.de/~flori
|
27
|
+
|
28
|
+
The homepage of this library is located at
|
29
|
+
|
30
|
+
* http://flori.github.com/term-ansicolor
|
31
|
+
|
32
|
+
=== Examples
|
33
|
+
|
34
|
+
Additional to the two executables cdiff and decolor, the file
|
35
|
+
examples/example.rb in the source/gem-distribution shows how this library can
|
36
|
+
be used:
|
37
|
+
|
38
|
+
require 'term/ansicolor'
|
39
|
+
|
40
|
+
# Use this trick to work around namespace cluttering that
|
41
|
+
# happens if you just include Term::ANSIColor:
|
42
|
+
|
43
|
+
class Color
|
44
|
+
extend Term::ANSIColor
|
45
|
+
end
|
46
|
+
|
47
|
+
print Color.red, Color.bold, "No Namespace cluttering:", Color.clear, "\n"
|
48
|
+
print Color.green + "green" + Color.clear, "\n"
|
49
|
+
print Color.on_red(Color.green("green")), "\n"
|
50
|
+
print Color.yellow { Color.on_black { "yellow on_black" } }, "\n\n"
|
51
|
+
|
52
|
+
# Or shortcut Term::ANSIColor by assignment:
|
53
|
+
c = Term::ANSIColor
|
54
|
+
|
55
|
+
print c.red, c.bold, "No Namespace cluttering (alternative):", c.clear, "\n"
|
56
|
+
print c.green + "green" + c.clear, "\n"
|
57
|
+
print c.on_red(c.green("green")), "\n"
|
58
|
+
print c.yellow { c.on_black { "yellow on_black" } }, "\n\n"
|
59
|
+
|
60
|
+
# Anyway, I don't define any of Term::ANSIColor's methods in this example
|
61
|
+
# and I want to keep it short:
|
62
|
+
include Term::ANSIColor
|
63
|
+
|
64
|
+
print red, bold, "Usage as constants:", reset, "\n"
|
65
|
+
print clear, "clear", reset, reset, "reset", reset,
|
66
|
+
bold, "bold", reset, dark, "dark", reset,
|
67
|
+
underscore, "underscore", reset, blink, "blink", reset,
|
68
|
+
negative, "negative", reset, concealed, "concealed", reset, "|\n",
|
69
|
+
black, "black", reset, red, "red", reset, green, "green", reset,
|
70
|
+
yellow, "yellow", reset, blue, "blue", reset, magenta, "magenta", reset,
|
71
|
+
cyan, "cyan", reset, white, "white", reset, "|\n",
|
72
|
+
on_black, "on_black", reset, on_red, "on_red", reset,
|
73
|
+
on_green, "on_green", reset, on_yellow, "on_yellow", reset,
|
74
|
+
on_blue, "on_blue", reset, on_magenta, "on_magenta", reset,
|
75
|
+
on_cyan, "on_cyan", reset, on_white, "on_white", reset, "|\n\n"
|
76
|
+
|
77
|
+
print red, bold, "Usage as unary argument methods:", reset, "\n"
|
78
|
+
print clear("clear"), reset("reset"), bold("bold"), dark("dark"),
|
79
|
+
underscore("underscore"), blink("blink"), negative("negative"),
|
80
|
+
concealed("concealed"), "|\n",
|
81
|
+
black("black"), red("red"), green("green"), yellow("yellow"),
|
82
|
+
blue("blue"), magenta("magenta"), cyan("cyan"), white("white"), "|\n",
|
83
|
+
on_black("on_black"), on_red("on_red"), on_green("on_green"),#
|
84
|
+
on_yellow("on_yellow"), on_blue("on_blue"), on_magenta("on_magenta"),
|
85
|
+
on_cyan("on_cyan"), on_white("on_white"), "|\n\n"
|
86
|
+
|
87
|
+
print red { bold { "Usage as block forms:" } }, "\n"
|
88
|
+
print clear { "clear" }, reset { "reset" }, bold { "bold" },
|
89
|
+
dark { "dark" }, underscore { "underscore" }, blink { "blink" },
|
90
|
+
negative { "negative" }, concealed { "concealed" }, "|\n",
|
91
|
+
black { "black" }, red { "red" }, green { "green" },
|
92
|
+
yellow { "yellow" }, blue { "blue" }, magenta { "magenta" },
|
93
|
+
cyan { "cyan" }, white { "white" }, "|\n",
|
94
|
+
on_black { "on_black" }, on_red { "on_red" }, on_green { "on_green" },
|
95
|
+
on_yellow { "on_yellow" }, on_blue { "on_blue" },
|
96
|
+
on_magenta { "on_magenta" }, on_cyan { "on_cyan" },
|
97
|
+
on_white { "on_white" }, "|\n\n"
|
98
|
+
|
99
|
+
# Usage as Mixin into String or its Subclasses
|
100
|
+
class String
|
101
|
+
include Term::ANSIColor
|
102
|
+
end
|
103
|
+
|
104
|
+
print "Usage as String Mixins:".red.bold, "\n"
|
105
|
+
print "clear".clear, "reset".reset, "bold".bold, "dark".dark,
|
106
|
+
"underscore".underscore, "blink".blink, "negative".negative,
|
107
|
+
"concealed".concealed, "|\n",
|
108
|
+
"black".black, "red".red, "green".green, "yellow".yellow,
|
109
|
+
"blue".blue, "magenta".magenta, "cyan".cyan, "white".white, "|\n",
|
110
|
+
"on_black".on_black, "on_red".on_red, "on_green".on_green,
|
111
|
+
"on_yellow".on_yellow, "on_blue".on_blue, "on_magenta".on_magenta,
|
112
|
+
"on_cyan".on_cyan, "on_white".on_white, "|\n\n"
|
113
|
+
|
114
|
+
symbols = Term::ANSIColor::attributes
|
115
|
+
print red { bold { "All supported attributes = " } },
|
116
|
+
blue { symbols.inspect }, "\n\n"
|
19
117
|
|
20
|
-
|
118
|
+
print "Send symbols to strings:".send(:red).send(:bold), "\n"
|
119
|
+
print symbols[12, 8].map { |c| c.to_s.send(c) }, "\n\n"
|
21
120
|
|
22
|
-
|
23
|
-
|
121
|
+
print red { bold { "Make strings monochromatic again:" } }, "\n"
|
122
|
+
print [
|
123
|
+
"red".red,
|
124
|
+
"not red anymore".red.uncolored,
|
125
|
+
uncolored { "not red anymore".red },
|
126
|
+
uncolored("not red anymore".red)
|
127
|
+
].map { |x| x + "\n" }
|
24
128
|
|
25
|
-
|
129
|
+
=== Author
|
26
130
|
|
27
|
-
|
28
|
-
=======
|
131
|
+
Florian Frank mailto:flori@ping.de
|
29
132
|
|
30
|
-
|
133
|
+
=== License
|
31
134
|
|
135
|
+
This is free software; you can redistribute it and/or modify it under the
|
136
|
+
terms of the GNU General Public License Version 2 as published by the Free
|
137
|
+
Software Foundation: www.gnu.org/copyleft/gpl.html
|
data/Rakefile
CHANGED
@@ -23,37 +23,28 @@ end
|
|
23
23
|
|
24
24
|
|
25
25
|
if defined? Gem
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
s.summary = "Ruby library that colors strings using ANSI escape sequences"
|
32
|
-
s.description = ""
|
26
|
+
spec = Gem::Specification.new do |s|
|
27
|
+
s.name = PKG_NAME
|
28
|
+
s.version = PKG_VERSION
|
29
|
+
s.summary = "Ruby library that colors strings using ANSI escape sequences"
|
30
|
+
s.description = ""
|
33
31
|
|
34
|
-
|
32
|
+
s.files = PKG_FILES.to_a.sort
|
35
33
|
|
36
|
-
|
34
|
+
s.require_path = 'lib'
|
37
35
|
|
38
|
-
|
39
|
-
|
40
|
-
|
36
|
+
s.has_rdoc = true
|
37
|
+
s.extra_rdoc_files << 'README'
|
38
|
+
s.executables << 'cdiff' << 'decolor'
|
39
|
+
s.rdoc_options << '--main' << 'README' << '--title' << 'Term::ANSIColor'
|
40
|
+
s.test_files = Dir['tests/*.rb']
|
41
41
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
end
|
47
|
-
GEM
|
48
|
-
|
49
|
-
desc 'Create a gemspec file'
|
50
|
-
task :gemspec do
|
51
|
-
File.open("#{PKG_NAME}.gemspec", 'w') do |f|
|
52
|
-
f.puts spec_src
|
53
|
-
end
|
42
|
+
s.author = "Florian Frank"
|
43
|
+
s.email = "flori@ping.de"
|
44
|
+
s.homepage = "http://flori.github.com/#{PKG_NAME}"
|
45
|
+
s.rubyforge_project = PKG_NAME
|
54
46
|
end
|
55
47
|
|
56
|
-
spec = eval(spec_src)
|
57
48
|
Rake::GemPackageTask.new(spec) do |pkg|
|
58
49
|
pkg.need_tar = true
|
59
50
|
pkg.package_files += PKG_FILES
|
@@ -79,8 +70,19 @@ EOT
|
|
79
70
|
end
|
80
71
|
end
|
81
72
|
|
73
|
+
desc "Run tests"
|
74
|
+
task :tests do
|
75
|
+
sh 'testrb -Ilib tests/*.rb'
|
76
|
+
end
|
77
|
+
task :test => :tests
|
78
|
+
|
79
|
+
desc "Run tests with coverage"
|
80
|
+
task :coverage do
|
81
|
+
sh 'rcov -Ilib tests/*.rb'
|
82
|
+
end
|
83
|
+
|
82
84
|
desc "Default"
|
83
|
-
task :default => [ :version
|
85
|
+
task :default => [ :version ]
|
84
86
|
|
85
87
|
desc "Prepare a release"
|
86
|
-
task :release => [ :clean, :version, :
|
88
|
+
task :release => [ :clean, :version, :package ]
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.0.
|
1
|
+
1.0.5
|
@@ -1,6 +1,6 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
#
|
3
|
-
## Little unix filter that colorizes diff output
|
3
|
+
## Little unix filter that colorizes diff output.
|
4
4
|
#
|
5
5
|
|
6
6
|
require 'term/ansicolor'
|
@@ -8,7 +8,7 @@ require 'term/ansicolor'
|
|
8
8
|
include Term::ANSIColor
|
9
9
|
|
10
10
|
ARGF.each do |line|
|
11
|
-
print(
|
11
|
+
STDOUT.print(
|
12
12
|
case line
|
13
13
|
when /^\+/ then green { line }
|
14
14
|
when /^-/ then red { line }
|
data/bin/decolor
ADDED
data/examples/example.rb
CHANGED
@@ -4,9 +4,7 @@ require 'term/ansicolor'
|
|
4
4
|
# happens if you just include Term::ANSIColor:
|
5
5
|
|
6
6
|
class Color
|
7
|
-
|
8
|
-
include Term::ANSIColor
|
9
|
-
end
|
7
|
+
extend Term::ANSIColor
|
10
8
|
end
|
11
9
|
|
12
10
|
print Color.red, Color.bold, "No Namespace cluttering:", Color.clear, "\n"
|
@@ -84,6 +82,9 @@ print "Send symbols to strings:".send(:red).send(:bold), "\n"
|
|
84
82
|
print symbols[12, 8].map { |c| c.to_s.send(c) }, "\n\n"
|
85
83
|
|
86
84
|
print red { bold { "Make strings monochromatic again:" } }, "\n"
|
87
|
-
print [
|
88
|
-
|
89
|
-
|
85
|
+
print [
|
86
|
+
"red".red,
|
87
|
+
"not red anymore".red.uncolored,
|
88
|
+
uncolored { "not red anymore".red },
|
89
|
+
uncolored("not red anymore".red)
|
90
|
+
].map { |x| x + "\n" }
|
data/lib/term/ansicolor.rb
CHANGED
@@ -63,7 +63,7 @@ module Term
|
|
63
63
|
elsif string
|
64
64
|
result << string
|
65
65
|
elsif respond_to?(:to_str)
|
66
|
-
result <<
|
66
|
+
result << to_str
|
67
67
|
else
|
68
68
|
return result #only switch on
|
69
69
|
end
|
@@ -75,7 +75,7 @@ module Term
|
|
75
75
|
|
76
76
|
# Regular expression that is used to scan for ANSI-sequences while
|
77
77
|
# uncoloring strings.
|
78
|
-
COLORED_REGEXP = /\e\[([34][0-7]|[0-9])m/
|
78
|
+
COLORED_REGEXP = /\e\[(?:[34][0-7]|[0-9])?m/
|
79
79
|
|
80
80
|
# Returns an uncolored version of the string, that is all
|
81
81
|
# ANSI-sequences are stripped from the string.
|
@@ -85,7 +85,7 @@ module Term
|
|
85
85
|
elsif string
|
86
86
|
string.gsub(COLORED_REGEXP, '')
|
87
87
|
elsif respond_to?(:to_str)
|
88
|
-
gsub(COLORED_REGEXP, '')
|
88
|
+
to_str.gsub(COLORED_REGEXP, '')
|
89
89
|
else
|
90
90
|
''
|
91
91
|
end
|
@@ -0,0 +1,66 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'test/unit'
|
4
|
+
require 'term/ansicolor'
|
5
|
+
|
6
|
+
class String
|
7
|
+
include Term::ANSIColor
|
8
|
+
end
|
9
|
+
|
10
|
+
class Color
|
11
|
+
extend Term::ANSIColor
|
12
|
+
end
|
13
|
+
|
14
|
+
class ANSIColorTest < Test::Unit::TestCase
|
15
|
+
include Term::ANSIColor
|
16
|
+
|
17
|
+
def setup
|
18
|
+
@string = "red"
|
19
|
+
@string_red = "\e[31mred\e[0m"
|
20
|
+
@string_red_on_green = "\e[42m\e[31mred\e[0m\e[0m"
|
21
|
+
end
|
22
|
+
|
23
|
+
attr_reader :string, :string_red, :string_red_on_green
|
24
|
+
|
25
|
+
def test_red
|
26
|
+
assert_equal string_red, string.red
|
27
|
+
assert_equal string_red, Color.red(string)
|
28
|
+
assert_equal string_red, Color.red { string }
|
29
|
+
assert_equal string_red, Term::ANSIColor.red { string }
|
30
|
+
assert_equal string_red, red { string }
|
31
|
+
end
|
32
|
+
|
33
|
+
def test_red_on_green
|
34
|
+
assert_equal string_red_on_green, string.red.on_green
|
35
|
+
assert_equal string_red_on_green, Color.on_green(Color.red(string))
|
36
|
+
assert_equal string_red_on_green, Color.on_green { Color.red { string } }
|
37
|
+
assert_equal string_red_on_green,
|
38
|
+
Term::ANSIColor.on_green { Term::ANSIColor.red { string } }
|
39
|
+
assert_equal string_red_on_green, on_green { red { string } }
|
40
|
+
end
|
41
|
+
|
42
|
+
|
43
|
+
def test_uncolored
|
44
|
+
assert_equal string, string_red.uncolored
|
45
|
+
assert_equal string, Color.uncolored(string_red)
|
46
|
+
assert_equal string, Color.uncolored { string_red }
|
47
|
+
assert_equal string, Term::ANSIColor.uncolored { string_red }
|
48
|
+
assert_equal string, uncolored { string }
|
49
|
+
end
|
50
|
+
|
51
|
+
def test_attributes
|
52
|
+
foo = 'foo'
|
53
|
+
for (a, _) in Term::ANSIColor.attributes
|
54
|
+
assert_not_equal foo, foo_colored = foo.__send__(a)
|
55
|
+
assert_equal foo, foo_colored.uncolored
|
56
|
+
assert_not_equal foo, foo_colored = Color.__send__(a, foo)
|
57
|
+
assert_equal foo, Color.uncolored(foo_colored)
|
58
|
+
assert_not_equal foo, foo_colored = Color.__send__(a) { foo }
|
59
|
+
assert_equal foo, Color.uncolored { foo_colored }
|
60
|
+
assert_not_equal foo, foo_colored = Term::ANSIColor.__send__(a) { foo }
|
61
|
+
assert_equal foo, Term::ANSIColor.uncolored { foo_colored }
|
62
|
+
assert_not_equal foo, foo_colored = __send__(a) { foo }
|
63
|
+
assert_equal foo, uncolored { foo }
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: term-ansicolor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Florian Frank
|
@@ -9,39 +9,42 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date:
|
12
|
+
date: 2010-03-12 00:00:00 +01:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|
16
16
|
description: ""
|
17
17
|
email: flori@ping.de
|
18
|
-
executables:
|
19
|
-
|
18
|
+
executables:
|
19
|
+
- cdiff
|
20
|
+
- decolor
|
20
21
|
extensions: []
|
21
22
|
|
22
23
|
extra_rdoc_files:
|
23
|
-
-
|
24
|
+
- README
|
24
25
|
files:
|
25
26
|
- CHANGES
|
26
27
|
- COPYING
|
27
28
|
- README
|
28
29
|
- Rakefile
|
29
30
|
- VERSION
|
30
|
-
-
|
31
|
+
- bin/cdiff
|
32
|
+
- bin/decolor
|
31
33
|
- examples/example.rb
|
32
34
|
- install.rb
|
33
35
|
- lib/term/ansicolor.rb
|
34
36
|
- lib/term/ansicolor/version.rb
|
35
|
-
-
|
36
|
-
- doc-main.txt
|
37
|
+
- tests/ansicolor_test.rb
|
37
38
|
has_rdoc: true
|
38
|
-
homepage: http://term-ansicolor
|
39
|
+
homepage: http://flori.github.com/term-ansicolor
|
39
40
|
licenses: []
|
40
41
|
|
41
42
|
post_install_message:
|
42
43
|
rdoc_options:
|
43
44
|
- --main
|
44
|
-
-
|
45
|
+
- README
|
46
|
+
- --title
|
47
|
+
- Term::ANSIColor
|
45
48
|
require_paths:
|
46
49
|
- lib
|
47
50
|
required_ruby_version: !ruby/object:Gem::Requirement
|
@@ -59,9 +62,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
59
62
|
requirements: []
|
60
63
|
|
61
64
|
rubyforge_project: term-ansicolor
|
62
|
-
rubygems_version: 1.3.
|
65
|
+
rubygems_version: 1.3.5
|
63
66
|
signing_key:
|
64
67
|
specification_version: 3
|
65
68
|
summary: Ruby library that colors strings using ANSI escape sequences
|
66
|
-
test_files:
|
67
|
-
|
69
|
+
test_files:
|
70
|
+
- tests/ansicolor_test.rb
|
data/doc-main.txt
DELETED
@@ -1,119 +0,0 @@
|
|
1
|
-
== Term::ANSIColor - ANSI escape sequences in Ruby
|
2
|
-
|
3
|
-
=== Description
|
4
|
-
|
5
|
-
This library can be used to color/uncolor strings using ANSI escape sequences.
|
6
|
-
|
7
|
-
=== Author
|
8
|
-
|
9
|
-
Florian Frank mailto:flori@ping.de
|
10
|
-
|
11
|
-
=== License
|
12
|
-
|
13
|
-
This is free software; you can redistribute it and/or modify it under the
|
14
|
-
terms of the GNU General Public License Version 2 as published by the Free
|
15
|
-
Software Foundation: www.gnu.org/copyleft/gpl.html
|
16
|
-
|
17
|
-
=== Download
|
18
|
-
|
19
|
-
The latest version of this library can be downloaded at
|
20
|
-
|
21
|
-
* http://rubyforge.org/frs?group_id=391
|
22
|
-
|
23
|
-
The homepage of this library is located at
|
24
|
-
|
25
|
-
* http://term-ansicolor.rubyforge.org
|
26
|
-
|
27
|
-
=== Examples
|
28
|
-
|
29
|
-
The file examples/example.rb in the source/gem-distribution shows how
|
30
|
-
this library can be used:
|
31
|
-
require 'term/ansicolor'
|
32
|
-
|
33
|
-
# Use this trick to work around namespace cluttering that
|
34
|
-
# happens if you just include Term::ANSIColor:
|
35
|
-
|
36
|
-
class Color
|
37
|
-
class << self
|
38
|
-
include Term::ANSIColor
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
print Color.red, Color.bold, "No Namespace cluttering:", Color.clear, "\n"
|
43
|
-
print Color.green + "green" + Color.clear, "\n"
|
44
|
-
print Color.on_red(Color.green("green")), "\n"
|
45
|
-
print Color.yellow { Color.on_black { "yellow on_black" } }, "\n\n"
|
46
|
-
|
47
|
-
# Or shortcut Term::ANSIColor by assignment:
|
48
|
-
c = Term::ANSIColor
|
49
|
-
|
50
|
-
print c.red, c.bold, "No Namespace cluttering (alternative):", c.clear, "\n"
|
51
|
-
print c.green + "green" + c.clear, "\n"
|
52
|
-
print c.on_red(c.green("green")), "\n"
|
53
|
-
print c.yellow { c.on_black { "yellow on_black" } }, "\n\n"
|
54
|
-
|
55
|
-
# Anyway, I don't define any of Term::ANSIColor's methods in this example
|
56
|
-
# and I want to keep it short:
|
57
|
-
include Term::ANSIColor
|
58
|
-
|
59
|
-
print red, bold, "Usage as constants:", reset, "\n"
|
60
|
-
print clear, "clear", reset, reset, "reset", reset,
|
61
|
-
bold, "bold", reset, dark, "dark", reset,
|
62
|
-
underscore, "underscore", reset, blink, "blink", reset,
|
63
|
-
negative, "negative", reset, concealed, "concealed", reset, "|\n",
|
64
|
-
black, "black", reset, red, "red", reset, green, "green", reset,
|
65
|
-
yellow, "yellow", reset, blue, "blue", reset, magenta, "magenta", reset,
|
66
|
-
cyan, "cyan", reset, white, "white", reset, "|\n",
|
67
|
-
on_black, "on_black", reset, on_red, "on_red", reset,
|
68
|
-
on_green, "on_green", reset, on_yellow, "on_yellow", reset,
|
69
|
-
on_blue, "on_blue", reset, on_magenta, "on_magenta", reset,
|
70
|
-
on_cyan, "on_cyan", reset, on_white, "on_white", reset, "|\n\n"
|
71
|
-
|
72
|
-
print red, bold, "Usage as unary argument methods:", reset, "\n"
|
73
|
-
print clear("clear"), reset("reset"), bold("bold"), dark("dark"),
|
74
|
-
underscore("underscore"), blink("blink"), negative("negative"),
|
75
|
-
concealed("concealed"), "|\n",
|
76
|
-
black("black"), red("red"), green("green"), yellow("yellow"),
|
77
|
-
blue("blue"), magenta("magenta"), cyan("cyan"), white("white"), "|\n",
|
78
|
-
on_black("on_black"), on_red("on_red"), on_green("on_green"),#
|
79
|
-
on_yellow("on_yellow"), on_blue("on_blue"), on_magenta("on_magenta"),
|
80
|
-
on_cyan("on_cyan"), on_white("on_white"), "|\n\n"
|
81
|
-
|
82
|
-
print red { bold { "Usage as block forms:" } }, "\n"
|
83
|
-
print clear { "clear" }, reset { "reset" }, bold { "bold" },
|
84
|
-
dark { "dark" }, underscore { "underscore" }, blink { "blink" },
|
85
|
-
negative { "negative" }, concealed { "concealed" }, "|\n",
|
86
|
-
black { "black" }, red { "red" }, green { "green" },
|
87
|
-
yellow { "yellow" }, blue { "blue" }, magenta { "magenta" },
|
88
|
-
cyan { "cyan" }, white { "white" }, "|\n",
|
89
|
-
on_black { "on_black" }, on_red { "on_red" }, on_green { "on_green" },
|
90
|
-
on_yellow { "on_yellow" }, on_blue { "on_blue" },
|
91
|
-
on_magenta { "on_magenta" }, on_cyan { "on_cyan" },
|
92
|
-
on_white { "on_white" }, "|\n\n"
|
93
|
-
|
94
|
-
# Usage as Mixin into String or its Subclasses
|
95
|
-
class String
|
96
|
-
include Term::ANSIColor
|
97
|
-
end
|
98
|
-
|
99
|
-
print "Usage as String Mixins:".red.bold, "\n"
|
100
|
-
print "clear".clear, "reset".reset, "bold".bold, "dark".dark,
|
101
|
-
"underscore".underscore, "blink".blink, "negative".negative,
|
102
|
-
"concealed".concealed, "|\n",
|
103
|
-
"black".black, "red".red, "green".green, "yellow".yellow,
|
104
|
-
"blue".blue, "magenta".magenta, "cyan".cyan, "white".white, "|\n",
|
105
|
-
"on_black".on_black, "on_red".on_red, "on_green".on_green,
|
106
|
-
"on_yellow".on_yellow, "on_blue".on_blue, "on_magenta".on_magenta,
|
107
|
-
"on_cyan".on_cyan, "on_white".on_white, "|\n\n"
|
108
|
-
|
109
|
-
symbols = Term::ANSIColor::attributes
|
110
|
-
print red { bold { "All supported attributes = " } },
|
111
|
-
blue { symbols.inspect }, "\n\n"
|
112
|
-
|
113
|
-
print "Send symbols to strings:".send(:red).send(:bold), "\n"
|
114
|
-
print symbols[12, 8].map { |c| c.to_s.send(c) }, "\n\n"
|
115
|
-
|
116
|
-
print red { bold { "Make strings monochromatic again:" } }, "\n"
|
117
|
-
print [ "red".red, "not red anymore".red.uncolored,
|
118
|
-
uncolored { "not red anymore".red }, uncolored("not red anymore".red)
|
119
|
-
].map { |x| x + "\n" }
|
data/term-ansicolor.gemspec
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
2
|
-
Gem::Specification.new do |s|
|
3
|
-
s.name = 'term-ansicolor'
|
4
|
-
s.version = '1.0.4'
|
5
|
-
s.summary = "Ruby library that colors strings using ANSI escape sequences"
|
6
|
-
s.description = ""
|
7
|
-
|
8
|
-
s.files = ["CHANGES", "COPYING", "README", "Rakefile", "VERSION", "examples", "examples/cdiff.rb", "examples/example.rb", "install.rb", "lib", "lib/term", "lib/term/ansicolor", "lib/term/ansicolor.rb", "lib/term/ansicolor/version.rb", "term-ansicolor.gemspec"]
|
9
|
-
|
10
|
-
s.require_path = 'lib'
|
11
|
-
|
12
|
-
s.has_rdoc = true
|
13
|
-
s.extra_rdoc_files << 'doc-main.txt'
|
14
|
-
s.rdoc_options << '--main' << 'doc-main.txt'
|
15
|
-
|
16
|
-
s.author = "Florian Frank"
|
17
|
-
s.email = "flori@ping.de"
|
18
|
-
s.homepage = "http://term-ansicolor.rubyforge.org"
|
19
|
-
s.rubyforge_project = 'term-ansicolor'
|
20
|
-
end
|