term-ansicolor 1.0.7 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 7f55c51691dcf6121b58981a3be46ed4ec366de6
4
+ data.tar.gz: 1c3e21a9d0eddf89f87a7c8320ffaa94eda84f21
5
+ SHA512:
6
+ metadata.gz: a41ad2f0632b9c2220ccc60d4a262c8b591dbb84910f28c5db2352b07b38b0944c747b9b803d777bcacde9885dddca32fe679bd3f3cb301641bc885d1264bf36
7
+ data.tar.gz: ec5a09c6b8fdec985a092abe1c3743054f4b00ca7cd0dba4ea7b1f63d69a95b5bfc8a7b98b1fcec83ecd489e5f99ebf4913ddb63778af56b1f000623506abc7f
@@ -2,7 +2,10 @@ rvm:
2
2
  - 1.8.7
3
3
  - 1.9.2
4
4
  - 1.9.3
5
+ - 2.0.0
5
6
  - ruby-head
6
7
  - ree
7
- - rbx
8
- - jruby
8
+ - rbx-18mode
9
+ - rbx-19mode
10
+ - jruby-18mode
11
+ - jruby-19mode
data/CHANGES CHANGED
@@ -1,3 +1,11 @@
1
+ 2013-03-07 - 1.1.0 * Cleanup documentation.
2
+ * Implement color0 - color255 and on_color0 - on_color255
3
+ methods for xterm256 colors.
4
+ 2011-10-13 - 1.0.7 * Merged patch by Mike Bethany <mikbe.tk@gmail.com> that
5
+ adds high intensity colors and backgrounds.
6
+ * Fix problem caused by Ruby 1.9 implementing String#clear
7
+ * now, reported by Joe Fiorini <joe@joefiorini.com>.
8
+ 2011-07-21 - 1.0.6 * Use gem_hadar for building.
1
9
  2010-03-10 - 1.0.5 * Added cdiff example as an executable.
2
10
  * Disabled building of gemspec file.
3
11
  * Made an decolor executable, that removes colors from an io
data/Gemfile CHANGED
@@ -1,5 +1,5 @@
1
1
  # vim: set filetype=ruby et sw=2 ts=2:
2
2
 
3
- source :rubygems
3
+ source 'https://rubygems.org'
4
4
 
5
5
  gemspec
@@ -33,98 +33,7 @@ The homepage of this library is located at
33
33
 
34
34
  Additional to the two executables cdiff and decolor, the file
35
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"
117
-
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"
120
-
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" }
36
+ be used.
128
37
 
129
38
  == Author
130
39
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.7
1
+ 1.1.0
@@ -76,7 +76,7 @@ print "clear".clear, "reset".reset, "bold".bold, "dark".dark,
76
76
 
77
77
  symbols = Term::ANSIColor::attributes
78
78
  print red { bold { "All supported attributes = " } },
79
- blue { symbols.inspect }, "\n\n"
79
+ symbols.map { |s| __send__(s, s.inspect) } * ', ', "\n\n"
80
80
 
81
81
  print "Send symbols to strings:".send(:red).send(:bold), "\n"
82
82
  print symbols[12, 8].map { |c| c.to_s.send(c) } * '', "\n\n"
@@ -9,47 +9,47 @@ module Term
9
9
  ATTRIBUTES = [
10
10
  [ :clear , 0 ], # String#clear is already used to empty string in Ruby 1.9
11
11
  [ :reset , 0 ], # synonym for :clear
12
- [ :bold , 1 ],
13
- [ :dark , 2 ],
12
+ [ :bold , 1 ],
13
+ [ :dark , 2 ],
14
14
  [ :italic , 3 ], # not widely implemented
15
- [ :underline , 4 ],
15
+ [ :underline , 4 ],
16
16
  [ :underscore , 4 ], # synonym for :underline
17
- [ :blink , 5 ],
17
+ [ :blink , 5 ],
18
18
  [ :rapid_blink , 6 ], # not widely implemented
19
19
  [ :negative , 7 ], # no reverse because of String#reverse
20
- [ :concealed , 8 ],
20
+ [ :concealed , 8 ],
21
21
  [ :strikethrough , 9 ], # not widely implemented
22
- [ :black , 30 ],
23
- [ :red , 31 ],
24
- [ :green , 32 ],
25
- [ :yellow , 33 ],
26
- [ :blue , 34 ],
27
- [ :magenta , 35 ],
28
- [ :cyan , 36 ],
29
- [ :white , 37 ],
30
- [ :on_black , 40 ],
31
- [ :on_red , 41 ],
32
- [ :on_green , 42 ],
33
- [ :on_yellow , 43 ],
34
- [ :on_blue , 44 ],
35
- [ :on_magenta , 45 ],
36
- [ :on_cyan , 46 ],
22
+ [ :black , 30 ],
23
+ [ :red , 31 ],
24
+ [ :green , 32 ],
25
+ [ :yellow , 33 ],
26
+ [ :blue , 34 ],
27
+ [ :magenta , 35 ],
28
+ [ :cyan , 36 ],
29
+ [ :white , 37 ],
30
+ [ :on_black , 40 ],
31
+ [ :on_red , 41 ],
32
+ [ :on_green , 42 ],
33
+ [ :on_yellow , 43 ],
34
+ [ :on_blue , 44 ],
35
+ [ :on_magenta , 45 ],
36
+ [ :on_cyan , 46 ],
37
37
  [ :on_white , 47 ],
38
38
  [ :intense_black , 90 ], # High intensity, aixterm (works in OS X)
39
- [ :intense_red , 91 ],
40
- [ :intense_green , 92 ],
41
- [ :intense_yellow , 93 ],
42
- [ :intense_blue , 94 ],
43
- [ :intense_magenta , 95 ],
44
- [ :intense_cyan , 96 ],
45
- [ :intense_white , 97 ],
39
+ [ :intense_red , 91 ],
40
+ [ :intense_green , 92 ],
41
+ [ :intense_yellow , 93 ],
42
+ [ :intense_blue , 94 ],
43
+ [ :intense_magenta , 95 ],
44
+ [ :intense_cyan , 96 ],
45
+ [ :intense_white , 97 ],
46
46
  [ :on_intense_black , 100 ], # High intensity background, aixterm (works in OS X)
47
- [ :on_intense_red , 101 ],
48
- [ :on_intense_green , 102 ],
49
- [ :on_intense_yellow , 103 ],
50
- [ :on_intense_blue , 104 ],
51
- [ :on_intense_magenta , 105 ],
52
- [ :on_intense_cyan , 106 ],
47
+ [ :on_intense_red , 101 ],
48
+ [ :on_intense_green , 102 ],
49
+ [ :on_intense_yellow , 103 ],
50
+ [ :on_intense_blue , 104 ],
51
+ [ :on_intense_magenta , 105 ],
52
+ [ :on_intense_cyan , 106 ],
53
53
  [ :on_intense_white , 107 ]
54
54
  ]
55
55
 
@@ -82,11 +82,11 @@ module Term
82
82
  end
83
83
  self.coloring = true
84
84
 
85
- ATTRIBUTES.each do |c, v|
86
- eval <<-EOT
87
- def #{c}(string = nil)
85
+ def self.create_color_method(color_name, color_value)
86
+ module_eval <<-EOT
87
+ def #{color_name}(string = nil)
88
88
  result = ''
89
- result << "\e[#{v}m" if Term::ANSIColor.coloring?
89
+ result << "\e[#{color_value}m" if Term::ANSIColor.coloring?
90
90
  if block_given?
91
91
  result << yield
92
92
  elsif string.respond_to?(:to_str)
@@ -100,15 +100,42 @@ module Term
100
100
  result
101
101
  end
102
102
  EOT
103
+ self
103
104
  end
104
105
 
106
+ def method_missing(name, *args, &block)
107
+ color_name, color_value = Term::ANSIColor::ATTRIBUTES.assoc(name)
108
+ if color_name
109
+ ::Term::ANSIColor.create_color_method(name, color_value)
110
+ return __send__(color_name, *args, &block)
111
+ end
112
+ color_name = name.to_s
113
+ if color_name =~ /\A(?:(on_)?color)(\d+)\z/
114
+ code = $1 ? 48 : 38
115
+ index = $2.to_i
116
+ if (0..255).include?(index)
117
+ ::Term::ANSIColor.create_color_method($&, "#{code};5;#{index}")
118
+ return __send__(color_name, *args, &block)
119
+ end
120
+ end
121
+ super
122
+ end
123
+
124
+ module RespondTo
125
+ def respond_to?(symbol, include_all = false)
126
+ attributes.include?(symbol) or super
127
+ end
128
+ end
129
+ include RespondTo
130
+ extend RespondTo
131
+
105
132
  # Regular expression that is used to scan for ANSI-sequences while
106
133
  # uncoloring strings.
107
- COLORED_REGEXP = /\e\[(?:(?:[349]|10)[0-7]|[0-9])?m/
134
+ COLORED_REGEXP = /\e\[(?:(?:[349]|10)[0-7]|[0-9]|[34]8;5;\d{1,3})?m/
108
135
 
109
136
  # Returns an uncolored version of the string, that is all
110
137
  # ANSI-sequences are stripped from the string.
111
- def uncolored(string = nil) # :yields:
138
+ def uncolor(string = nil) # :yields:
112
139
  if block_given?
113
140
  yield.to_str.gsub(COLORED_REGEXP, '')
114
141
  elsif string.respond_to?(:to_str)
@@ -120,11 +147,13 @@ module Term
120
147
  end
121
148
  end
122
149
 
123
- module_function
150
+ alias uncolored uncolor
124
151
 
125
152
  # Returns an array of all Term::ANSIColor attributes as symbols.
126
153
  def attributes
127
- ATTRIBUTE_NAMES
154
+ @attributes ||= ATTRIBUTE_NAMES +
155
+ (0..255).map { |index| "color#{index}".to_sym } +
156
+ (0..255).map { |index| "on_color#{index}".to_sym }
128
157
  end
129
158
  extend self
130
159
  end
@@ -1,6 +1,6 @@
1
1
  module Term::ANSIColor
2
2
  # Term::ANSIColor version
3
- VERSION = '1.0.7'
3
+ VERSION = '1.1.0'
4
4
  VERSION_ARRAY = VERSION.split(/\./).map { |x| x.to_i } # :nodoc:
5
5
  VERSION_MAJOR = VERSION_ARRAY[0] # :nodoc:
6
6
  VERSION_MINOR = VERSION_ARRAY[1] # :nodoc:
@@ -2,32 +2,32 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = "term-ansicolor"
5
- s.version = "1.0.7"
5
+ s.version = "1.1.0"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Florian Frank"]
9
- s.date = "2011-10-13"
9
+ s.date = "2013-03-07"
10
10
  s.description = ""
11
11
  s.email = "flori@ping.de"
12
12
  s.executables = ["cdiff", "decolor"]
13
- s.extra_rdoc_files = ["README.rdoc", "lib/term/ansicolor/version.rb", "lib/term/ansicolor.rb"]
14
- s.files = [".gitignore", ".travis.yml", "CHANGES", "COPYING", "Gemfile", "README.rdoc", "Rakefile", "VERSION", "bin/cdiff", "bin/decolor", "doc-main.txt", "examples/example.rb", "install.rb", "lib/term/ansicolor.rb", "lib/term/ansicolor/.keep", "lib/term/ansicolor/version.rb", "term-ansicolor.gemspec", "tests/ansicolor_test.rb"]
13
+ s.extra_rdoc_files = ["README.rdoc", "lib/term/ansicolor.rb", "lib/term/ansicolor/version.rb"]
14
+ s.files = [".gitignore", ".travis.yml", "CHANGES", "COPYING", "Gemfile", "README.rdoc", "Rakefile", "VERSION", "bin/cdiff", "bin/decolor", "examples/example.rb", "lib/term/ansicolor.rb", "lib/term/ansicolor/.keep", "lib/term/ansicolor/version.rb", "term-ansicolor.gemspec", "tests/ansicolor_test.rb"]
15
15
  s.homepage = "http://flori.github.com/term-ansicolor"
16
16
  s.rdoc_options = ["--title", "Term-ansicolor - Ruby library that colors strings using ANSI escape sequences", "--main", "README.rdoc"]
17
17
  s.require_paths = ["lib"]
18
- s.rubygems_version = "1.8.11"
18
+ s.rubygems_version = "2.0.0"
19
19
  s.summary = "Ruby library that colors strings using ANSI escape sequences"
20
20
  s.test_files = ["tests/ansicolor_test.rb"]
21
21
 
22
22
  if s.respond_to? :specification_version then
23
- s.specification_version = 3
23
+ s.specification_version = 4
24
24
 
25
25
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
26
- s.add_development_dependency(%q<gem_hadar>, ["~> 0.1.1"])
26
+ s.add_development_dependency(%q<gem_hadar>, ["~> 0.1.8"])
27
27
  else
28
- s.add_dependency(%q<gem_hadar>, ["~> 0.1.1"])
28
+ s.add_dependency(%q<gem_hadar>, ["~> 0.1.8"])
29
29
  end
30
30
  else
31
- s.add_dependency(%q<gem_hadar>, ["~> 0.1.1"])
31
+ s.add_dependency(%q<gem_hadar>, ["~> 0.1.8"])
32
32
  end
33
33
  end
@@ -52,35 +52,39 @@ class ANSIColorTest < Test::Unit::TestCase
52
52
  end
53
53
 
54
54
 
55
- def test_uncolored
56
- assert_equal string, string_red.uncolored
57
- assert_equal string, Color.uncolored(string_red)
58
- assert_equal string, Color.uncolored(string_like_red)
59
- assert_equal string, Color.uncolored { string_red }
60
- assert_equal string, Color.uncolored { string_like_red }
61
- assert_equal string, Term::ANSIColor.uncolored { string_red }
62
- assert_equal string, Term::ANSIColor.uncolored { string_like_red }
63
- assert_equal string, uncolored { string }
64
- assert_equal string, uncolored { string_like_red }
65
- assert_equal "", uncolored(Object.new)
55
+ def test_uncolor
56
+ assert_equal string, string_red.uncolor
57
+ assert_equal string, Color.uncolor(string_red)
58
+ assert_equal string, Color.uncolor(string_like_red)
59
+ assert_equal string, Color.uncolor { string_red }
60
+ assert_equal string, Color.uncolor { string_like_red }
61
+ assert_equal string, Term::ANSIColor.uncolor { string_red }
62
+ assert_equal string, Term::ANSIColor.uncolor { string_like_red }
63
+ assert_equal string, uncolor { string }
64
+ assert_equal string, uncolor { string_like_red }
65
+ assert_equal "", uncolor(Object.new)
66
+ for index in 0..255
67
+ assert_equal "foo", Color.uncolor(Color.__send__("color#{index}", "foo"))
68
+ assert_equal "foo", Color.uncolor(Color.__send__("on_color#{index}", "foo"))
69
+ end
66
70
  end
67
71
 
68
72
  def test_attributes
69
73
  foo = 'foo'
70
- for (a, _) in Term::ANSIColor.attributes
74
+ for a in Term::ANSIColor.attributes
71
75
  # skip clear for Ruby 1.9 which implements String#clear to empty the string
72
76
  if a != :clear || Term::ANSIColor.support?(:clear)
73
77
  assert_not_equal foo, foo_colored = foo.__send__(a)
74
- assert_equal foo, foo_colored.uncolored
78
+ assert_equal foo, foo_colored.uncolor
75
79
  end
76
80
  assert_not_equal foo, foo_colored = Color.__send__(a, foo)
77
- assert_equal foo, Color.uncolored(foo_colored)
81
+ assert_equal foo, Color.uncolor(foo_colored)
78
82
  assert_not_equal foo, foo_colored = Color.__send__(a) { foo }
79
- assert_equal foo, Color.uncolored { foo_colored }
83
+ assert_equal foo, Color.uncolor { foo_colored }
80
84
  assert_not_equal foo, foo_colored = Term::ANSIColor.__send__(a) { foo }
81
- assert_equal foo, Term::ANSIColor.uncolored { foo_colored }
85
+ assert_equal foo, Term::ANSIColor.uncolor { foo_colored }
82
86
  assert_not_equal foo, foo_colored = __send__(a) { foo }
83
- assert_equal foo, uncolored { foo_colored }
87
+ assert_equal foo, uncolor { foo_colored }
84
88
  end
85
89
  end
86
90
 
metadata CHANGED
@@ -1,27 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: term-ansicolor
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.7
5
- prerelease:
4
+ version: 1.1.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Florian Frank
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2011-10-13 00:00:00.000000000Z
11
+ date: 2013-03-07 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: gem_hadar
16
- requirement: &74228550 !ruby/object:Gem::Requirement
17
- none: false
15
+ requirement: !ruby/object:Gem::Requirement
18
16
  requirements:
19
17
  - - ~>
20
18
  - !ruby/object:Gem::Version
21
- version: 0.1.1
19
+ version: 0.1.8
22
20
  type: :development
23
21
  prerelease: false
24
- version_requirements: *74228550
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: 0.1.8
25
27
  description: ''
26
28
  email: flori@ping.de
27
29
  executables:
@@ -30,8 +32,8 @@ executables:
30
32
  extensions: []
31
33
  extra_rdoc_files:
32
34
  - README.rdoc
33
- - lib/term/ansicolor/version.rb
34
35
  - lib/term/ansicolor.rb
36
+ - lib/term/ansicolor/version.rb
35
37
  files:
36
38
  - .gitignore
37
39
  - .travis.yml
@@ -43,9 +45,7 @@ files:
43
45
  - VERSION
44
46
  - bin/cdiff
45
47
  - bin/decolor
46
- - doc-main.txt
47
48
  - examples/example.rb
48
- - install.rb
49
49
  - lib/term/ansicolor.rb
50
50
  - lib/term/ansicolor/.keep
51
51
  - lib/term/ansicolor/version.rb
@@ -53,6 +53,7 @@ files:
53
53
  - tests/ansicolor_test.rb
54
54
  homepage: http://flori.github.com/term-ansicolor
55
55
  licenses: []
56
+ metadata: {}
56
57
  post_install_message:
57
58
  rdoc_options:
58
59
  - --title
@@ -62,22 +63,20 @@ rdoc_options:
62
63
  require_paths:
63
64
  - lib
64
65
  required_ruby_version: !ruby/object:Gem::Requirement
65
- none: false
66
66
  requirements:
67
- - - ! '>='
67
+ - - '>='
68
68
  - !ruby/object:Gem::Version
69
69
  version: '0'
70
70
  required_rubygems_version: !ruby/object:Gem::Requirement
71
- none: false
72
71
  requirements:
73
- - - ! '>='
72
+ - - '>='
74
73
  - !ruby/object:Gem::Version
75
74
  version: '0'
76
75
  requirements: []
77
76
  rubyforge_project:
78
- rubygems_version: 1.8.11
77
+ rubygems_version: 2.0.0
79
78
  signing_key:
80
- specification_version: 3
79
+ specification_version: 4
81
80
  summary: Ruby library that colors strings using ANSI escape sequences
82
81
  test_files:
83
82
  - tests/ansicolor_test.rb
@@ -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/install.rb DELETED
@@ -1,15 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require 'rbconfig'
4
- include Config
5
- require 'fileutils'
6
- include FileUtils::Verbose
7
-
8
- destdir = "#{ENV['DESTDIR']}"
9
- libdir = CONFIG["sitelibdir"]
10
- dest = destdir + File.join(libdir, 'term')
11
- mkdir_p dest
12
- install 'lib/term/ansicolor.rb', dest
13
- dest = destdir + File.join(libdir, 'term', 'ansicolor')
14
- mkdir_p dest
15
- install 'lib/term/ansicolor/version.rb', dest