text_layout¶ ↑
DESCRIPTION:¶ ↑
Text layout engine for CUI apps with a pretty table.
FEATURES/PROBLEMS:¶ ↑
-
Full-width character support.
-
Line wrapping.
-
Table layout with colspan and rowspan.
-
Table with border.
SYNOPSIS:¶ ↑
# (from http://en.wikipedia.org/wiki/MacBook_Air) table = [ [{:colspan => 6, :value => "Table of models"}], ["Model", "Early 2008", "Late 2008", "Mid 2009", "Late 2010", "Mid 2011"], ["Model Identifier", "MacBookAir1,1", {:colspan=>2, :value => "MacBookAir2,1"}, "MacBookAir3,1(11\")\nMacBookAir3,2(13\")", "MacBookAir4,1(11\")\nMacBookAir4,2(13\")"], ["Model number", "MB003LL/A", "MB543LL/A\nMB940LL/A", "MC233LL/A\nMC234LL/A", "MC505LL/A\nMC503LL/A", "MC968ZP/A\nMC969ZP/A\nMC965ZP/A\nMC966ZP/A"], [{:rowspan => 2, :value => "Battery"}, {:colspan => 3, :value => "N/A"}, {:colspan => 2, :value => "35Wh(11\")"}], [{:colspan => 2, :value => "37Wh(13\")"}, "40Wh(13\")", {:colspan => 2, :value => "50Wh(13\")"}] ] puts TextLayout::Table.new(table, :border => true).layout --- +----------------------------------------------------------------------------------------------------+ | Table of models | +------------------+---------------+-----------+-----------+--------------------+--------------------+ | Model | Early 2008 | Late 2008 | Mid 2009 | Late 2010 | Mid 2011 | +------------------+---------------+-----------+-----------+--------------------+--------------------+ | Model Identifier | MacBookAir1,1 | MacBookAir2,1 | MacBookAir3,1(11") | MacBookAir4,1(11") | | | | | MacBookAir3,2(13") | MacBookAir4,2(13") | +------------------+---------------+-----------+-----------+--------------------+--------------------+ | Model number | MB003LL/A | MB543LL/A | MC233LL/A | MC505LL/A | MC968ZP/A | | | | MB940LL/A | MC234LL/A | MC503LL/A | MC969ZP/A | | | | | | | MC965ZP/A | | | | | | | MC966ZP/A | +------------------+---------------+-----------+-----------+--------------------+--------------------+ | Battery | N/A | 35Wh(11") | | +---------------------------+-----------+-----------------------------------------+ | | 37Wh(13") | 40Wh(13") | 50Wh(13") | +------------------+---------------------------+-----------+-----------------------------------------+
REQUIREMENTS:¶ ↑
-
unicode-display_width
INSTALL:¶ ↑
-
$ gem install text_layout
OTHER CHOICES¶ ↑
DEVELOPERS:¶ ↑
After checking out the source, run:
$ rake newb
This task will install any missing dependencies, run the tests/specs, and generate the RDoc.
LICENSE:¶ ↑
(The MIT License)
Copyright © 2011 NANKI Haruo
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the ‘Software’), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED ‘AS IS’, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.