crystal_fmt
Version, currently 0.3.13 versions
- 0.3.1latestDec 20, 2017
- 0.3.0not indexedDec 4, 2018
- 0.2.0not indexedDec 4, 2018
github.com/masukomi/crystal_fmt
produces text tables from a grid of strings
Installation
# Add this to your shard.yml
dependencies:
crystal_fmt:
github: masukomi/crystal_fmt
version: ~> 0.3.1Then run:
shards installshard.yml
- Crystal
0.23.1- License
- MIT
- Author
- masukomi
Dependencies
This version declares no dependencies.
README
Crystal Format (crystal_fmt)
Takes a grid of strings and produces a text table with custom borders, dividers, and header separator.
For example:
[["things", "stuff"],["a", "b"], ["c", nil]]
would be converted to...
| things | stuff |
| ------ | ----- |
| a | b |
| c | |
Inspired by the fmt egg for Chicken Scheme.
Installation
Add this to your application's shard.yml:
dependencies:
crystal_fmt:
github: masukomi/crystal_fmt
Usage
API Documentations is available here.
require "crystal_fmt"
# SIMPLE USAGE
table_data = Array(Array(String | Nil)).new
[["column 1", "column 2"], ["a", "b"], ["c", "d"]].each do |row|
table_data << row
end
t = Table.new(table_data)
t.format
# ^^^ produces
# | column 1 | column 2 |
# | -------- | -------- |
# | a | b |
# | c | d |
# CUSTOM DIVIDERS AND BORDERS
options = Hash(Symbol,String|Bool).new
options[:left_border] = "> "
options[:right_border] = " <"
options[:divider] = " . "
options[:header_divider] = "^"
t.format(options)
# Produces
# > column 1 . column 2 <
# > ^^^^^^^^ . ^^^^^^^^ <
# > a . b <
# > c . d <
Development
Before developing any feature please create an issue where you describe your idea.
Before working on a bug, please make sure there isn't already a GitHub Issue for it. If there is, make sure no-one's already working on it. If there isn't please create one.
If you have a useful sounding idea I'll probably want to merge it. If you've already coded up improvements for yourself, go ahead and file an Issue describing it and then make a PR.
Note: while I really want to add your contributions, no PR will be merged without passing unit tests.
Please ping me at @masukomi on Twitter so that I see your Issue promptly.
Contributing
- Fork it ( https://github.com/masukomi/crystal_fmt/fork )
- Create your feature branch (git checkout -b my-new-feature)
- Commit your changes (git commit -am 'Add some feature')
- Please include unit tests and documentation.
- Push to the branch (git push origin my-new-feature)
- Create a new Pull Request
- Poke @masukomi on Twitter to make sure it gets seen promptly.
Contributors
- masukomi masukomi - creator, maintainer
Documentation
Built from the current release. The first visit to a release nobody has asked for starts its build.
Links
This release
- Version
0.3.1- Tagged
- Dec 20, 2017
- Commit
e233f3084f02- Crystal
0.23.1- Indexed
- yes
Dependents
Repository
github.com/masukomi/crystal_fmt
Metadata
- Created
- Aug 12, 2026
- Updated
- Aug 15, 2026
- Synced
- Aug 15, 2026
- Versions
- 3