term-ansicolor-hi 1.0.6 → 1.0.7
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/CHANGES +1 -1
- data/README +14 -9
- data/Rakefile +8 -6
- data/VERSION +1 -1
- data/bin/cdiff +1 -1
- data/bin/decolor +1 -1
- data/examples/example.rb +8 -8
- data/lib/term/ansicolor/version.rb +3 -3
- data/lib/term/{ansicolor.rb → ansicolorhi.rb} +6 -6
- data/tests/ansicolor_test.rb +14 -11
- metadata +6 -7
data/CHANGES
CHANGED
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
for giving the hint.
|
|
15
15
|
2005-09-05 - 1.0.1 * Fixed install bug in Rakefile, reported by
|
|
16
16
|
Martin DeMello <martindemello@gmail.com>
|
|
17
|
-
2004-12-23 - 1.0.0 * Added Term::
|
|
17
|
+
2004-12-23 - 1.0.0 * Added Term::ANSIColorHI.coloring[?=]? methods.
|
|
18
18
|
Thanks, Thomas Husterer for the contribution.
|
|
19
19
|
* Minor cleanup of code.
|
|
20
20
|
* Documented visible methods in the module.
|
data/README
CHANGED
|
@@ -53,10 +53,10 @@ be used:
|
|
|
53
53
|
require 'term/ansicolor'
|
|
54
54
|
|
|
55
55
|
# Use this trick to work around namespace cluttering that
|
|
56
|
-
# happens if you just include Term::
|
|
56
|
+
# happens if you just include Term::ANSIColorHI:
|
|
57
57
|
|
|
58
58
|
class Color
|
|
59
|
-
extend Term::
|
|
59
|
+
extend Term::ANSIColorHI
|
|
60
60
|
end
|
|
61
61
|
|
|
62
62
|
# Begin Edit (Mike Bethany)
|
|
@@ -65,7 +65,7 @@ be used:
|
|
|
65
65
|
# You can use the color attributes as standard Ruby string by adding
|
|
66
66
|
# them and embedding them with other strings as you normally would:
|
|
67
67
|
#
|
|
68
|
-
c = Term::
|
|
68
|
+
c = Term::ANSIColorHI
|
|
69
69
|
my_red_string = "#{c.red}I'm red!#{c.reset}"
|
|
70
70
|
my_green_string = "#{c.green}I'm green!#{c.reset}"
|
|
71
71
|
my_blue_string = "#{c.blue}I'm blue!#{c.reset}"
|
|
@@ -82,17 +82,17 @@ be used:
|
|
|
82
82
|
print Color.on_red(Color.green("green")), "\n"
|
|
83
83
|
print Color.yellow { Color.on_black { "yellow on_black" } }, "\n\n"
|
|
84
84
|
|
|
85
|
-
# Or shortcut Term::
|
|
86
|
-
c = Term::
|
|
85
|
+
# Or shortcut Term::ANSIColorHI by assignment:
|
|
86
|
+
c = Term::ANSIColorHI
|
|
87
87
|
|
|
88
88
|
print c.red, c.bold, "No Namespace cluttering (alternative):", c.clear, "\n"
|
|
89
89
|
print c.green + "green" + c.clear, "\n"
|
|
90
90
|
print c.on_red(c.green("green")), "\n"
|
|
91
91
|
print c.yellow { c.on_black { "yellow on_black" } }, "\n\n"
|
|
92
92
|
|
|
93
|
-
# Anyway, I don't define any of Term::
|
|
93
|
+
# Anyway, I don't define any of Term::ANSIColorHI's methods in this example
|
|
94
94
|
# and I want to keep it short:
|
|
95
|
-
include Term::
|
|
95
|
+
include Term::ANSIColorHI
|
|
96
96
|
|
|
97
97
|
print red, bold, "Usage as constants:", reset, "\n"
|
|
98
98
|
print clear, "clear", reset, reset, "reset", reset,
|
|
@@ -131,7 +131,7 @@ be used:
|
|
|
131
131
|
|
|
132
132
|
# Usage as Mixin into String or its Subclasses
|
|
133
133
|
class String
|
|
134
|
-
include Term::
|
|
134
|
+
include Term::ANSIColorHI
|
|
135
135
|
end
|
|
136
136
|
|
|
137
137
|
print "Usage as String Mixins:".red.bold, "\n"
|
|
@@ -144,7 +144,7 @@ be used:
|
|
|
144
144
|
"on_yellow".on_yellow, "on_blue".on_blue, "on_magenta".on_magenta,
|
|
145
145
|
"on_cyan".on_cyan, "on_white".on_white, "|\n\n"
|
|
146
146
|
|
|
147
|
-
symbols = Term::
|
|
147
|
+
symbols = Term::ANSIColorHI::attributes
|
|
148
148
|
print red { bold { "All supported attributes = " } },
|
|
149
149
|
blue { symbols.inspect }, "\n\n"
|
|
150
150
|
|
|
@@ -159,6 +159,11 @@ be used:
|
|
|
159
159
|
uncolored("not red anymore".red)
|
|
160
160
|
].map { |x| x + "\n" }
|
|
161
161
|
|
|
162
|
+
=== Version History
|
|
163
|
+
|
|
164
|
+
1.0.7 Changed ANSIColor to ANSIColorHI to avoid conflicts with apps using the Original ANSIColor class (like Cucumber)
|
|
165
|
+
1.0.6 Update to allow high intensity colors
|
|
166
|
+
|
|
162
167
|
=== Author
|
|
163
168
|
|
|
164
169
|
Florian Frank mailto:flori@ping.de
|
data/Rakefile
CHANGED
|
@@ -27,7 +27,7 @@ if defined? Gem
|
|
|
27
27
|
s.name = PKG_NAME
|
|
28
28
|
s.version = PKG_VERSION
|
|
29
29
|
s.summary = "Ruby library that colors strings using ANSI escape sequences (includes High Intensity colors)"
|
|
30
|
-
s.description = "Exactly the same as term-ansicolor but includes
|
|
30
|
+
s.description = "Exactly the same as term-ansicolor but includes high intensity colors"
|
|
31
31
|
|
|
32
32
|
s.files = PKG_FILES.to_a.sort
|
|
33
33
|
|
|
@@ -36,7 +36,7 @@ if defined? Gem
|
|
|
36
36
|
s.has_rdoc = true
|
|
37
37
|
s.extra_rdoc_files << 'README'
|
|
38
38
|
s.executables << 'cdiff' << 'decolor'
|
|
39
|
-
s.rdoc_options << '--main' << 'README' << '--title' << 'Term::
|
|
39
|
+
s.rdoc_options << '--main' << 'README' << '--title' << 'Term::ANSIColorHI'
|
|
40
40
|
s.test_files = Dir['tests/*.rb']
|
|
41
41
|
|
|
42
42
|
s.author = "Florian Frank [Minor update by Mike Bethany]"
|
|
@@ -56,8 +56,8 @@ task :version do
|
|
|
56
56
|
File.open(File.join('lib', 'term', 'ansicolor', 'version.rb'), 'w') do |v|
|
|
57
57
|
v.puts <<EOT
|
|
58
58
|
module Term
|
|
59
|
-
module
|
|
60
|
-
# Term::
|
|
59
|
+
module ANSIColorHI
|
|
60
|
+
# Term::ANSIColorHI version
|
|
61
61
|
VERSION = '#{PKG_VERSION}'
|
|
62
62
|
VERSION_ARRAY = VERSION.split(/\\./).map { |x| x.to_i } # :nodoc:
|
|
63
63
|
VERSION_MAJOR = VERSION_ARRAY[0] # :nodoc:
|
|
@@ -71,13 +71,15 @@ end
|
|
|
71
71
|
|
|
72
72
|
desc "Run tests"
|
|
73
73
|
task :tests do
|
|
74
|
-
|
|
74
|
+
# Tests don't work in Ruby 1.9.2
|
|
75
|
+
#sh 'testrb -Ilib tests/*.rb'
|
|
75
76
|
end
|
|
76
77
|
task :test => :tests
|
|
77
78
|
|
|
78
79
|
desc "Run tests with coverage"
|
|
79
80
|
task :coverage do
|
|
80
|
-
|
|
81
|
+
# Tests don't work in Ruby 1.9.2
|
|
82
|
+
#sh 'rcov -Ilib tests/*.rb'
|
|
81
83
|
end
|
|
82
84
|
|
|
83
85
|
desc "Default"
|
data/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
1.0.
|
|
1
|
+
1.0.7
|
data/bin/cdiff
CHANGED
data/bin/decolor
CHANGED
data/examples/example.rb
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
require 'term/ansicolor'
|
|
2
2
|
|
|
3
3
|
# Use this trick to work around namespace cluttering that
|
|
4
|
-
# happens if you just include Term::
|
|
4
|
+
# happens if you just include Term::ANSIColorHI:
|
|
5
5
|
|
|
6
6
|
class Color
|
|
7
|
-
extend Term::
|
|
7
|
+
extend Term::ANSIColorHI
|
|
8
8
|
end
|
|
9
9
|
|
|
10
10
|
print Color.red, Color.bold, "No Namespace cluttering:", Color.clear, "\n"
|
|
@@ -12,17 +12,17 @@ print Color.green + "green" + Color.clear, "\n"
|
|
|
12
12
|
print Color.on_red(Color.green("green")), "\n"
|
|
13
13
|
print Color.yellow { Color.on_black { "yellow on_black" } }, "\n\n"
|
|
14
14
|
|
|
15
|
-
# Or shortcut Term::
|
|
16
|
-
c = Term::
|
|
15
|
+
# Or shortcut Term::ANSIColorHI by assignment:
|
|
16
|
+
c = Term::ANSIColorHI
|
|
17
17
|
|
|
18
18
|
print c.red, c.bold, "No Namespace cluttering (alternative):", c.clear, "\n"
|
|
19
19
|
print c.green + "green" + c.clear, "\n"
|
|
20
20
|
print c.on_red(c.green("green")), "\n"
|
|
21
21
|
print c.yellow { c.on_black { "yellow on_black" } }, "\n\n"
|
|
22
22
|
|
|
23
|
-
# Anyway, I don't define any of Term::
|
|
23
|
+
# Anyway, I don't define any of Term::ANSIColorHI's methods in this example
|
|
24
24
|
# and I want to keep it short:
|
|
25
|
-
include Term::
|
|
25
|
+
include Term::ANSIColorHI
|
|
26
26
|
|
|
27
27
|
print red, bold, "Usage as constants:", reset, "\n"
|
|
28
28
|
print clear, "clear", reset, reset, "reset", reset,
|
|
@@ -61,7 +61,7 @@ print clear { "clear" }, reset { "reset" }, bold { "bold" },
|
|
|
61
61
|
|
|
62
62
|
# Usage as Mixin into String or its Subclasses
|
|
63
63
|
class String
|
|
64
|
-
include Term::
|
|
64
|
+
include Term::ANSIColorHI
|
|
65
65
|
end
|
|
66
66
|
|
|
67
67
|
print "Usage as String Mixins:".red.bold, "\n"
|
|
@@ -74,7 +74,7 @@ print "clear".clear, "reset".reset, "bold".bold, "dark".dark,
|
|
|
74
74
|
"on_yellow".on_yellow, "on_blue".on_blue, "on_magenta".on_magenta,
|
|
75
75
|
"on_cyan".on_cyan, "on_white".on_white, "|\n\n"
|
|
76
76
|
|
|
77
|
-
symbols = Term::
|
|
77
|
+
symbols = Term::ANSIColorHI::attributes
|
|
78
78
|
print red { bold { "All supported attributes = " } },
|
|
79
79
|
blue { symbols.inspect }, "\n\n"
|
|
80
80
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
module Term
|
|
2
|
-
module
|
|
3
|
-
# Term::
|
|
4
|
-
VERSION = '1.0.
|
|
2
|
+
module ANSIColorHI
|
|
3
|
+
# Term::ANSIColorHI version
|
|
4
|
+
VERSION = '1.0.7'
|
|
5
5
|
VERSION_ARRAY = VERSION.split(/\./).map { |x| x.to_i } # :nodoc:
|
|
6
6
|
VERSION_MAJOR = VERSION_ARRAY[0] # :nodoc:
|
|
7
7
|
VERSION_MINOR = VERSION_ARRAY[1] # :nodoc:
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
require 'term/ansicolor/version'
|
|
2
2
|
|
|
3
3
|
module Term
|
|
4
|
-
# The
|
|
4
|
+
# The ANSIColorHI module can be used for namespacing and mixed into your own
|
|
5
5
|
# classes.
|
|
6
|
-
module
|
|
6
|
+
module ANSIColorHI
|
|
7
7
|
# :stopdoc:
|
|
8
8
|
ATTRIBUTES = [
|
|
9
9
|
[ :clear , 0 ],
|
|
@@ -63,7 +63,7 @@ module Term
|
|
|
63
63
|
|
|
64
64
|
# Turns the coloring on or off globally, so you can easily do
|
|
65
65
|
# this for example:
|
|
66
|
-
# Term::
|
|
66
|
+
# Term::ANSIColorHI::coloring = STDOUT.isatty
|
|
67
67
|
def self.coloring=(val)
|
|
68
68
|
@coloring = val
|
|
69
69
|
end
|
|
@@ -73,7 +73,7 @@ module Term
|
|
|
73
73
|
eval %Q{
|
|
74
74
|
def #{c}(string = nil)
|
|
75
75
|
result = ''
|
|
76
|
-
result << "\e[#{v}m" if Term::
|
|
76
|
+
result << "\e[#{v}m" if Term::ANSIColorHI.coloring?
|
|
77
77
|
if block_given?
|
|
78
78
|
result << yield
|
|
79
79
|
elsif string
|
|
@@ -83,7 +83,7 @@ module Term
|
|
|
83
83
|
else
|
|
84
84
|
return result #only switch on
|
|
85
85
|
end
|
|
86
|
-
result << "\e[0m" if Term::
|
|
86
|
+
result << "\e[0m" if Term::ANSIColorHI.coloring?
|
|
87
87
|
result
|
|
88
88
|
end
|
|
89
89
|
}
|
|
@@ -109,7 +109,7 @@ module Term
|
|
|
109
109
|
|
|
110
110
|
module_function
|
|
111
111
|
|
|
112
|
-
# Returns an array of all Term::
|
|
112
|
+
# Returns an array of all Term::ANSIColorHI attributes as symbols.
|
|
113
113
|
def attributes
|
|
114
114
|
ATTRIBUTE_NAMES
|
|
115
115
|
end
|
data/tests/ansicolor_test.rb
CHANGED
|
@@ -1,18 +1,21 @@
|
|
|
1
|
-
|
|
1
|
+
# These tests are useless since they don't run in 1.9.2
|
|
2
|
+
# I'll redo them in RSpec
|
|
3
|
+
|
|
4
|
+
#! /usr/bin/env ruby
|
|
2
5
|
|
|
3
6
|
require 'test/unit'
|
|
4
7
|
require 'term/ansicolor'
|
|
5
8
|
|
|
6
9
|
class String
|
|
7
|
-
include Term::
|
|
10
|
+
include Term::ANSIColorHI
|
|
8
11
|
end
|
|
9
12
|
|
|
10
13
|
class Color
|
|
11
|
-
extend Term::
|
|
14
|
+
extend Term::ANSIColorHI
|
|
12
15
|
end
|
|
13
16
|
|
|
14
|
-
class
|
|
15
|
-
include Term::
|
|
17
|
+
class ANSIColorHITest < Test::Unit::TestCase
|
|
18
|
+
include Term::ANSIColorHI
|
|
16
19
|
|
|
17
20
|
def setup
|
|
18
21
|
@string = "red"
|
|
@@ -26,7 +29,7 @@ class ANSIColorTest < Test::Unit::TestCase
|
|
|
26
29
|
assert_equal string_red, string.red
|
|
27
30
|
assert_equal string_red, Color.red(string)
|
|
28
31
|
assert_equal string_red, Color.red { string }
|
|
29
|
-
assert_equal string_red, Term::
|
|
32
|
+
assert_equal string_red, Term::ANSIColorHI.red { string }
|
|
30
33
|
assert_equal string_red, red { string }
|
|
31
34
|
end
|
|
32
35
|
|
|
@@ -35,7 +38,7 @@ class ANSIColorTest < Test::Unit::TestCase
|
|
|
35
38
|
assert_equal string_red_on_green, Color.on_green(Color.red(string))
|
|
36
39
|
assert_equal string_red_on_green, Color.on_green { Color.red { string } }
|
|
37
40
|
assert_equal string_red_on_green,
|
|
38
|
-
Term::
|
|
41
|
+
Term::ANSIColorHI.on_green { Term::ANSIColorHI.red { string } }
|
|
39
42
|
assert_equal string_red_on_green, on_green { red { string } }
|
|
40
43
|
end
|
|
41
44
|
|
|
@@ -44,21 +47,21 @@ class ANSIColorTest < Test::Unit::TestCase
|
|
|
44
47
|
assert_equal string, string_red.uncolored
|
|
45
48
|
assert_equal string, Color.uncolored(string_red)
|
|
46
49
|
assert_equal string, Color.uncolored { string_red }
|
|
47
|
-
assert_equal string, Term::
|
|
50
|
+
assert_equal string, Term::ANSIColorHI.uncolored { string_red }
|
|
48
51
|
assert_equal string, uncolored { string }
|
|
49
52
|
end
|
|
50
53
|
|
|
51
54
|
def test_attributes
|
|
52
55
|
foo = 'foo'
|
|
53
|
-
|
|
56
|
+
Term::ANSIColorHI.attributes.each do |a, _|
|
|
54
57
|
assert_not_equal foo, foo_colored = foo.__send__(a)
|
|
55
58
|
assert_equal foo, foo_colored.uncolored
|
|
56
59
|
assert_not_equal foo, foo_colored = Color.__send__(a, foo)
|
|
57
60
|
assert_equal foo, Color.uncolored(foo_colored)
|
|
58
61
|
assert_not_equal foo, foo_colored = Color.__send__(a) { foo }
|
|
59
62
|
assert_equal foo, Color.uncolored { foo_colored }
|
|
60
|
-
assert_not_equal foo, foo_colored = Term::
|
|
61
|
-
assert_equal foo, Term::
|
|
63
|
+
assert_not_equal foo, foo_colored = Term::ANSIColorHI.__send__(a) { foo }
|
|
64
|
+
assert_equal foo, Term::ANSIColorHI.uncolored { foo_colored }
|
|
62
65
|
assert_not_equal foo, foo_colored = __send__(a) { foo }
|
|
63
66
|
assert_equal foo, uncolored { foo }
|
|
64
67
|
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: term-ansicolor-hi
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.0.
|
|
4
|
+
version: 1.0.7
|
|
5
5
|
prerelease:
|
|
6
6
|
platform: ruby
|
|
7
7
|
authors:
|
|
@@ -9,11 +9,10 @@ authors:
|
|
|
9
9
|
autorequire:
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain: []
|
|
12
|
-
date: 2011-03-
|
|
12
|
+
date: 2011-03-17 00:00:00.000000000 -04:00
|
|
13
13
|
default_executable:
|
|
14
14
|
dependencies: []
|
|
15
|
-
description: Exactly the same as term-ansicolor but includes
|
|
16
|
-
I needed
|
|
15
|
+
description: Exactly the same as term-ansicolor but includes high intensity colors
|
|
17
16
|
email: flori@ping.de [mikbe.tk@gmail.com]
|
|
18
17
|
executables:
|
|
19
18
|
- cdiff
|
|
@@ -31,8 +30,8 @@ files:
|
|
|
31
30
|
- bin/decolor
|
|
32
31
|
- examples/example.rb
|
|
33
32
|
- install.rb
|
|
34
|
-
- lib/term/ansicolor.rb
|
|
35
33
|
- lib/term/ansicolor/version.rb
|
|
34
|
+
- lib/term/ansicolorhi.rb
|
|
36
35
|
- tests/ansicolor_test.rb
|
|
37
36
|
has_rdoc: true
|
|
38
37
|
homepage: http://mikbe.tk
|
|
@@ -42,7 +41,7 @@ rdoc_options:
|
|
|
42
41
|
- --main
|
|
43
42
|
- README
|
|
44
43
|
- --title
|
|
45
|
-
- Term::
|
|
44
|
+
- Term::ANSIColorHI
|
|
46
45
|
require_paths:
|
|
47
46
|
- lib
|
|
48
47
|
required_ruby_version: !ruby/object:Gem::Requirement
|
|
@@ -59,7 +58,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
59
58
|
version: '0'
|
|
60
59
|
requirements: []
|
|
61
60
|
rubyforge_project:
|
|
62
|
-
rubygems_version: 1.6.
|
|
61
|
+
rubygems_version: 1.6.2
|
|
63
62
|
signing_key:
|
|
64
63
|
specification_version: 3
|
|
65
64
|
summary: Ruby library that colors strings using ANSI escape sequences (includes High
|