ansi-showcase 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE +22 -0
- data/README.md +38 -0
- data/Rakefile +2 -0
- data/ansi-showcase.gemspec +20 -0
- data/bin/ansi-showcase +9 -0
- data/lib/ansi-showcase.rb +128 -0
- data/lib/ansi-showcase/version.rb +3 -0
- data/references/dark-italic.rb +60 -0
- metadata +103 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2012 TODO: Write your name
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
ANSI Showcase - A showcase for Term::ANSIColor
|
2
|
+
==============================================
|
3
|
+
|
4
|
+
A gem (both in cuteness and size) for easy remembering and test of the [Term::ANSIColor][term-ansicolor] methods used to print ANSI escape sequences to the terminal and get a nicely colored and formatted output.
|
5
|
+
|
6
|
+
[term-ansicolor]: http://github.com/flori/term-ansicolor
|
7
|
+
|
8
|
+
Installation
|
9
|
+
------------
|
10
|
+
|
11
|
+
gem install ansi-showcase
|
12
|
+
|
13
|
+
Usage
|
14
|
+
-----
|
15
|
+
|
16
|
+
Just type:
|
17
|
+
|
18
|
+
ansi-showcase
|
19
|
+
|
20
|
+
and you'll get what you payed for.
|
21
|
+
|
22
|
+
License
|
23
|
+
--------
|
24
|
+
|
25
|
+
Copyright (C) 2012 Xavier Via
|
26
|
+
|
27
|
+
This program is free software: you can redistribute it and/or modify
|
28
|
+
it under the terms of the GNU General Public License as published by
|
29
|
+
the Free Software Foundation, either version 3 of the License, or
|
30
|
+
(at your option) any later version.
|
31
|
+
|
32
|
+
This program is distributed in the hope that it will be useful,
|
33
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
34
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
35
|
+
GNU General Public License for more details.
|
36
|
+
|
37
|
+
You should have received a copy of the GNU General Public License
|
38
|
+
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
data/Rakefile
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('../lib/ansi-showcase/version', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gem.authors = ["Xavier Via"]
|
6
|
+
gem.email = ["xavierviacanel@gmail.com"]
|
7
|
+
gem.description = %q{A little command line utility that showcases Term::ANSIColor}
|
8
|
+
gem.summary = %q{A little command line utility that showcases Term::ANSIColor}
|
9
|
+
gem.homepage = "http://github.com/xaviervia/ansi-showcase"
|
10
|
+
|
11
|
+
gem.add_dependency "term-ansicolor"
|
12
|
+
gem.add_dependency "thor"
|
13
|
+
|
14
|
+
gem.files = `git ls-files`.split($\)
|
15
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
16
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
17
|
+
gem.name = "ansi-showcase"
|
18
|
+
gem.require_paths = ["lib"]
|
19
|
+
gem.version = AnsiShowcase::VERSION
|
20
|
+
end
|
data/bin/ansi-showcase
ADDED
@@ -0,0 +1,128 @@
|
|
1
|
+
require "thor"
|
2
|
+
require "term/ansicolor"
|
3
|
+
require "ansi-showcase/version"
|
4
|
+
|
5
|
+
# Make coloring available for String's
|
6
|
+
class String
|
7
|
+
include Term::ANSIColor
|
8
|
+
end
|
9
|
+
|
10
|
+
module AnsiShowcase
|
11
|
+
class Task < Thor
|
12
|
+
|
13
|
+
SHADES = [
|
14
|
+
[ :black, :dark ],
|
15
|
+
[ :white, :intense_white, :bold ],
|
16
|
+
[ :magenta, :intense_magenta, [ :bold, :magenta] ],
|
17
|
+
[ :blue, :intense_blue, [ :bold, :blue] ],
|
18
|
+
[ :cyan, :intense_cyan, [ :bold, :cyan] ],
|
19
|
+
[ :green, :intense_green, [ :bold, :green] ],
|
20
|
+
[ :yellow, :intense_yellow, [ :bold, :yellow] ],
|
21
|
+
[ :red, :intense_red, [ :bold, :red ] ]
|
22
|
+
]
|
23
|
+
|
24
|
+
EFFECTS = [
|
25
|
+
[ :italic, :underline, :underscore ],
|
26
|
+
[ :blink, :rapid_blink, :concealed ],
|
27
|
+
[ :strikethrough ]
|
28
|
+
]
|
29
|
+
|
30
|
+
BACKGROUNDS = [
|
31
|
+
[ :on_black ],
|
32
|
+
[ :on_white, :on_intense_white, ],
|
33
|
+
[ :on_magenta, :on_intense_magenta, ],
|
34
|
+
[ :on_blue, :on_intense_blue ],
|
35
|
+
[ :on_green, :on_intense_green ],
|
36
|
+
[ :on_yellow, :on_intense_yellow ],
|
37
|
+
[ :on_red, :on_intense_red ]
|
38
|
+
]
|
39
|
+
|
40
|
+
NEGATIVES = [
|
41
|
+
[ :negative, [ :negative, :bold ], [ :negative, :underline ] ],
|
42
|
+
[ [ :negative, :black ], [ :negative, :dark ] ],
|
43
|
+
[ [ :negative, :blue ], [ :negative, :intense_blue ], [ :negative, :blue, :bold ] ],
|
44
|
+
[ [ :negative, :underline ] ],
|
45
|
+
[ [ :negative, :red, :on_blue ], [ :negative, :on_green ] ],
|
46
|
+
[ [ :negative, :on_intense_yellow ] ]
|
47
|
+
]
|
48
|
+
|
49
|
+
desc "shades", "Display shades showcase"
|
50
|
+
def shades
|
51
|
+
puts
|
52
|
+
puts " Shades: "
|
53
|
+
puts
|
54
|
+
say_palette SHADES
|
55
|
+
end
|
56
|
+
|
57
|
+
desc "effects", "Display effects showcase"
|
58
|
+
def effects
|
59
|
+
puts
|
60
|
+
puts " Effects:"
|
61
|
+
puts
|
62
|
+
say_palette EFFECTS
|
63
|
+
end
|
64
|
+
|
65
|
+
desc "backgrounds", "Display backgrounds showcase"
|
66
|
+
def backgrounds
|
67
|
+
puts
|
68
|
+
puts " Backgrounds:"
|
69
|
+
puts
|
70
|
+
say_palette BACKGROUNDS
|
71
|
+
end
|
72
|
+
|
73
|
+
desc "negatives", "Display showcase for negative effects, the ones used in selections"
|
74
|
+
def negatives
|
75
|
+
puts
|
76
|
+
puts " Negatives:"
|
77
|
+
puts " Several combinations of the negative (reverse) effect with other"
|
78
|
+
puts " effects are shown in order to make it easy to grasp what it does,"
|
79
|
+
puts " because is not self-evident."
|
80
|
+
puts
|
81
|
+
say_palette NEGATIVES
|
82
|
+
end
|
83
|
+
|
84
|
+
desc "all", "Displays all showcases"
|
85
|
+
def all
|
86
|
+
puts
|
87
|
+
puts " This is a brief showcase featuring the names of the methods in the "
|
88
|
+
puts " " + "Term::ANSIColor".intense_white + " (term-ansicolor) Ruby Gem for easy coloring using "
|
89
|
+
puts " escape sequences on ANSI terminals."
|
90
|
+
puts
|
91
|
+
puts " For more information about term-ansicolor, visit the documentation on "
|
92
|
+
puts " http://github.com/flori/term-ansicolor"
|
93
|
+
puts
|
94
|
+
puts " Keep in mind that many of the effects might be unsupported.".intense_white
|
95
|
+
puts " Support varies a lot between terminals and platforms."
|
96
|
+
invoke :shades
|
97
|
+
invoke :effects
|
98
|
+
invoke :backgrounds
|
99
|
+
invoke :negatives
|
100
|
+
puts " For a full list of options type: " + "ansi-showcase help".intense_white
|
101
|
+
puts
|
102
|
+
end
|
103
|
+
|
104
|
+
private
|
105
|
+
def say_palette palette
|
106
|
+
palette.each do |colorset|
|
107
|
+
colorset.each do |color|
|
108
|
+
print "\t"
|
109
|
+
if color.is_a? Symbol
|
110
|
+
print color.to_s.send(color) + "\t"
|
111
|
+
else
|
112
|
+
to_print = ""
|
113
|
+
color.each do |c|
|
114
|
+
to_print += "#{c}&"
|
115
|
+
end
|
116
|
+
to_print = to_print[0..-2]
|
117
|
+
color.each do |c|
|
118
|
+
to_print = to_print.send(c)
|
119
|
+
end
|
120
|
+
print to_print + "\t"
|
121
|
+
end
|
122
|
+
end
|
123
|
+
puts
|
124
|
+
end
|
125
|
+
puts
|
126
|
+
end
|
127
|
+
end
|
128
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require "term/ansicolor"
|
3
|
+
extend Term::ANSIColor
|
4
|
+
#puts dark italic "Hola"
|
5
|
+
#puts "Blanco normal"
|
6
|
+
#puts intense_white "Blanco intenso igual"
|
7
|
+
#puts bold "Brillante (por el bold)"
|
8
|
+
#puts blue "Simplemente azul"
|
9
|
+
#puts intense_blue "Intenso azul"
|
10
|
+
#puts bold blue "Azul bold"
|
11
|
+
#puts green "Verde"
|
12
|
+
#puts intense_green "Intenso verde"
|
13
|
+
#puts bold green "Verde bold?"
|
14
|
+
|
15
|
+
shades = [
|
16
|
+
[ :black, :dark ],
|
17
|
+
[ :white, :intense_white, :bold ],
|
18
|
+
[ :magenta, :intense_magenta, [ :bold, :magenta] ],
|
19
|
+
[ :blue, :intense_blue, [ :bold, :blue] ],
|
20
|
+
[ :cyan, :intense_cyan, [ :bold, :cyan] ],
|
21
|
+
[ :green, :intense_green, [ :bold, :green] ],
|
22
|
+
[ :yellow, :intense_yellow, [ :bold, :yellow] ],
|
23
|
+
[ :red, :intense_red, [ :bold, :red] ]
|
24
|
+
]
|
25
|
+
|
26
|
+
effects = [
|
27
|
+
[ :italic, :underline, :underscore ],
|
28
|
+
]
|
29
|
+
|
30
|
+
negatives = [
|
31
|
+
[ :negative, [ :negative, :bold ], [ :negative, :dark ] ],
|
32
|
+
[ [ :negative, :blue ], [ :negative, :intense_blue ] ]
|
33
|
+
]
|
34
|
+
|
35
|
+
# Prints out the given palette construct
|
36
|
+
# @param [Array] palette
|
37
|
+
def puts_palette palette
|
38
|
+
palette.each do |colorset|
|
39
|
+
colorset.each do |color|
|
40
|
+
print "\t"
|
41
|
+
if color.is_a? Symbol
|
42
|
+
print send(color, color.to_s) + "\t"
|
43
|
+
else
|
44
|
+
print send(color.first, send(color.last, "#{color.first}&#{color.last}") ) + "\t"
|
45
|
+
end
|
46
|
+
end
|
47
|
+
puts
|
48
|
+
end
|
49
|
+
puts
|
50
|
+
end
|
51
|
+
|
52
|
+
puts
|
53
|
+
puts intense_white "Keep in mind that many of the effects might be unsupported"
|
54
|
+
puts "Support varies a lot between terminals"
|
55
|
+
puts
|
56
|
+
puts "Shades:"
|
57
|
+
puts_palette shades
|
58
|
+
|
59
|
+
puts "Effects:"
|
60
|
+
puts_palette effects
|
metadata
ADDED
@@ -0,0 +1,103 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ansi-showcase
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 29
|
5
|
+
prerelease:
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 0
|
9
|
+
- 1
|
10
|
+
version: 0.0.1
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Xavier Via
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2012-08-12 00:00:00 Z
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
name: term-ansicolor
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
none: false
|
25
|
+
requirements:
|
26
|
+
- - ">="
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
hash: 3
|
29
|
+
segments:
|
30
|
+
- 0
|
31
|
+
version: "0"
|
32
|
+
type: :runtime
|
33
|
+
version_requirements: *id001
|
34
|
+
- !ruby/object:Gem::Dependency
|
35
|
+
name: thor
|
36
|
+
prerelease: false
|
37
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
38
|
+
none: false
|
39
|
+
requirements:
|
40
|
+
- - ">="
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
hash: 3
|
43
|
+
segments:
|
44
|
+
- 0
|
45
|
+
version: "0"
|
46
|
+
type: :runtime
|
47
|
+
version_requirements: *id002
|
48
|
+
description: A little command line utility that showcases Term::ANSIColor
|
49
|
+
email:
|
50
|
+
- xavierviacanel@gmail.com
|
51
|
+
executables:
|
52
|
+
- ansi-showcase
|
53
|
+
extensions: []
|
54
|
+
|
55
|
+
extra_rdoc_files: []
|
56
|
+
|
57
|
+
files:
|
58
|
+
- .gitignore
|
59
|
+
- Gemfile
|
60
|
+
- LICENSE
|
61
|
+
- README.md
|
62
|
+
- Rakefile
|
63
|
+
- ansi-showcase.gemspec
|
64
|
+
- bin/ansi-showcase
|
65
|
+
- lib/ansi-showcase.rb
|
66
|
+
- lib/ansi-showcase/version.rb
|
67
|
+
- references/dark-italic.rb
|
68
|
+
homepage: http://github.com/xaviervia/ansi-showcase
|
69
|
+
licenses: []
|
70
|
+
|
71
|
+
post_install_message:
|
72
|
+
rdoc_options: []
|
73
|
+
|
74
|
+
require_paths:
|
75
|
+
- lib
|
76
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
77
|
+
none: false
|
78
|
+
requirements:
|
79
|
+
- - ">="
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
hash: 3
|
82
|
+
segments:
|
83
|
+
- 0
|
84
|
+
version: "0"
|
85
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
86
|
+
none: false
|
87
|
+
requirements:
|
88
|
+
- - ">="
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
hash: 3
|
91
|
+
segments:
|
92
|
+
- 0
|
93
|
+
version: "0"
|
94
|
+
requirements: []
|
95
|
+
|
96
|
+
rubyforge_project:
|
97
|
+
rubygems_version: 1.8.21
|
98
|
+
signing_key:
|
99
|
+
specification_version: 3
|
100
|
+
summary: A little command line utility that showcases Term::ANSIColor
|
101
|
+
test_files: []
|
102
|
+
|
103
|
+
has_rdoc:
|