| 1 | |
| 2 | <h1 id="label-ANSI">ANSI</h1> |
| 3 | |
| 4 | <p><a href="http://rubyworks.github.com/ansi">Home</a> / <a |
| 5 | href="http://rubydoc.info/gems/ansi/frames">API</a> / <a |
| 6 | href="http://github.com/rubyworks/ansi">Code</a> / <a |
| 7 | href="http://googlegroups.com/group/rubyworks-mailinglist">Mail</a></p> |
| 8 | |
| 9 | <p><a href="http://travis-ci.org/rubyworks/ansi"><img |
| 10 | src="http://travis-ci.org/rubyworks/ansi.png" /></a></p> |
| 11 | |
| 12 | <h2 id="label-DESCRIPTION">DESCRIPTION</h2> |
| 13 | |
| 14 | <p>The ANSI project is a collection of ANSI escape code related libraries |
| 15 | enabling ANSI code based colorization and stylization of output. It is very |
| 16 | nice for beautifying shell output.</p> |
| 17 | |
| 18 | <p>This collection is based on a set of scripts spun-off from Ruby Facets. |
| 19 | Included are Code (used to be ANSICode), Logger, ProgressBar and String. In |
| 20 | addition the library includes Terminal which provides information about the |
| 21 | current output device.</p> |
| 22 | |
| 23 | <h2 id="label-FEATURES">FEATURES</h2> |
| 24 | <ul><li> |
| 25 | <p>ANSI::Code provides ANSI codes as module functions.</p> |
| 26 | </li><li> |
| 27 | <p>String#ansi makes common usage very easy and elegant.</p> |
| 28 | </li><li> |
| 29 | <p>ANSI::Mixin provides an alternative mixin (like <code>colored</code> gem).</p> |
| 30 | </li><li> |
| 31 | <p>Very Good coverage of standard ANSI codes.</p> |
| 32 | </li><li> |
| 33 | <p>Additional clases for colorized columns, tables, loggers and more.</p> |
| 34 | </li></ul> |
| 35 | |
| 36 | <h2 id="label-RELEASE+NOTES">RELEASE NOTES</h2> |
| 37 | |
| 38 | <p>Please see HISTORY file.</p> |
| 39 | |
| 40 | <h2 id="label-SYNOPSIS">SYNOPSIS</h2> |
| 41 | |
| 42 | <p>There are a number of modules and classes provided by the ANSI package. To |
| 43 | get a good understanding of them it is best to pursue the QED <a |
| 44 | href="http://github.com/rubyworks/ansi/tree/master/demo/">documents</a> or |
| 45 | the API <a |
| 46 | href="http://rubydoc.info/gems/ansi/frames">documentation</a>.</p> |
| 47 | |
| 48 | <p>At the heart of all the provided libraries lies the ANSI::Code module which |
| 49 | defines ANSI codes as constants and methods. For example:</p> |
| 50 | |
| 51 | <pre class="ruby"><span class="ruby-identifier">require</span> <span class="ruby-string">'ansi/code'</span> |
| 52 | |
| 53 | <span class="ruby-constant">ANSI</span>.<span class="ruby-identifier">red</span> <span class="ruby-operator">+</span> <span class="ruby-string">"Hello"</span> <span class="ruby-operator">+</span> <span class="ruby-constant">ANSI</span>.<span class="ruby-identifier">blue</span> <span class="ruby-operator">+</span> <span class="ruby-string">"World"</span> |
| 54 | =<span class="ruby-operator">></span> <span class="ruby-string">"\e[31mHello\e[34mWorld"</span> |
| 55 | </pre> |
| 56 | |
| 57 | <p>Or in block form.</p> |
| 58 | |
| 59 | <pre class="ruby"><span class="ruby-constant">ANSI</span>.<span class="ruby-identifier">red</span>{ <span class="ruby-string">"Hello"</span> } <span class="ruby-operator">+</span> <span class="ruby-constant">ANSI</span>.<span class="ruby-identifier">blue</span>{ <span class="ruby-string">"World"</span> } |
| 60 | =<span class="ruby-operator">></span> <span class="ruby-string">"\e[31mHello\e[0m\e[34mWorld\e[0m"</span> |
| 61 | </pre> |
| 62 | |
| 63 | <p>The methods defined by this module are used throughout the rest of the |
| 64 | system.</p> |
| 65 | |
| 66 | <h2 id="label-INSTALLATION">INSTALLATION</h2> |
| 67 | |
| 68 | <p>To install with RubyGems simply open a console and type:</p> |
| 69 | |
| 70 | <pre>$ sudo gem install ansi</pre> |
| 71 | |
| 72 | <p>Local installation requires Setup.rb (gem install setup), then <a |
| 73 | href="http://github.com/rubyworks/ansi/download">download</a> the tarball |
| 74 | package and type:</p> |
| 75 | |
| 76 | <pre>$ tar -xvzf ansi-1.0.0.tgz |
| 77 | $ cd ansi-1.0.0 |
| 78 | $ sudo setup.rb all</pre> |
| 79 | |
| 80 | <p>Windows users use ‘ruby setup.rb all’.</p> |
| 81 | |
| 82 | <h2 id="label-LICENSE+%26+COPYRIGHTS">LICENSE & COPYRIGHTS</h2> |
| 83 | |
| 84 | <p>Copyright © 2009 Rubyworks</p> |
| 85 | |
| 86 | <p>This program is redistributable under the terms of the |
| 87 | <strong>FreeBSD</strong> license.</p> |
| 88 | |
| 89 | <p>Some pieces of the code are copyrighted by others.</p> |
| 90 | |
| 91 | <p>See COPYING.rdoc file for details.</p> |