https://github.com/enderahmetyurt/typed_print
TypedPrint provides zero-dependency, beautifully formatted table output for Ruby data structures with automatic column sizing, alignment options, custom headers, and column filtering.
https://github.com/enderahmetyurt/typed_print
cli console-output formatting pretty-print ruby rubygems table terminal
Last synced: about 2 months ago
JSON representation
TypedPrint provides zero-dependency, beautifully formatted table output for Ruby data structures with automatic column sizing, alignment options, custom headers, and column filtering.
- Host: GitHub
- URL: https://github.com/enderahmetyurt/typed_print
- Owner: enderahmetyurt
- License: mit
- Created: 2026-04-21T14:23:27.000Z (2 months ago)
- Default Branch: main
- Last Pushed: 2026-04-22T21:42:56.000Z (2 months ago)
- Last Synced: 2026-04-26T12:36:02.054Z (about 2 months ago)
- Topics: cli, console-output, formatting, pretty-print, ruby, rubygems, table, terminal
- Language: Ruby
- Homepage: https://rubygems.org/gems/typed_print
- Size: 19.5 KB
- Stars: 2
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.txt
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# TypedPrint
Beautiful, aligned table output for Ruby hashes and objects with zero dependencies.
[](https://badge.fury.io/rb/typed_print)
[](https://github.com/enderahmetyurt/typed_print/actions/workflows/main.yml)
[](https://www.ruby-lang.org/)
[](https://opensource.org/licenses/MIT)
[](https://rubygems.org/gems/typed_print)
## Features
- 🚀 Zero dependencies
- 📊 Automatic column width calculation
- 🎯 Smart type formatting (booleans, nil, strings)
- 📐 Column alignment (left, right, center)
- 🎨 Custom column headers
- 🔍 Column filtering
- 📝 Preserves original column order
- 📄 Markdown table output (v0.2.0+)
## Installation
Add this line to your application's Gemfile:
`gem 'typed_print'`
Or install it yourself:
`gem install typed_print`
## Usage
### Basic Usage
```ruby
require 'typed_print'
data = [
{ name: "Alice", score: 100, active: true },
{ name: "Bob", score: 42, active: false }
]
TypedPrint.print(data)
```
Output:
```
Name Score Active
------+------+-------
Alice 100 true
Bob 42 false
```
### Markdown Format (NEW in v0.2.0)
```ruby
TypedPrint.print(data, format: :markdown)
```
Output:
```
| Name | Score | Active |
|-------|-------|--------|
| Alice | 100 | true |
| Bob | 42 | false |
```
### Column Alignment
```ruby
TypedPrint.print(data, align: { score: :right })
```
Output:
```
Name Score Active
------+------+-------
Alice 100 true
Bob 42 false
```
### Filter Columns
```ruby
TypedPrint.print(data, only: [:name, :score])
```
Output:
```
Name Score
------+------
Alice 100
Bob 42
```
### Custom Headers
```ruby
TypedPrint.print(data, headers: { name: "Username", score: "Points", active: "Status" })
```
Output:
```
Username Points Status
---------+------+-------
Alice 100 true
Bob 42 false
```
### Return String Instead of Printing
```ruby
table_string = TypedPrint.table(data)
puts table_string.upcase
# Markdown format
markdown_string = TypedPrint.table(data, format: :markdown)
File.write("table.md", markdown_string)
````
### Working with Different Data Types
```ruby
mixed_data = [
{ name: "Product A", price: 29.99, in_stock: true, notes: nil },
{ name: "Product B", price: 49.99, in_stock: false, notes: "Limited edition" }
]
TypedPrint.print(mixed_data)
```
Output:
```
Name Price In_stock Notes
----------+-------+---------+-------------
Product A 29.99 true
Product B 49.99 false Limited edition
```
## API Reference
`TypedPrint.print(data, options)` Prints the formatted table to stdout and returns `nil`.
**Options:**
- `align: Hash` - Column alignment (`:left`, `:right`, `:center`), defaults to `:left`
- `only: Array` - Array of column symbols to display
- `headers: Hash` - Custom headers for columns
- `format: Symbol` - Output format (`:plain` or `:markdown`), defaults to `:plain`
`TypedPrint.table(data, options)` returns the formatted table as a string.
Same options as `print`.
## Development
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests.
To install this gem onto your local machine, run `bundle exec rake install`.
## Contributing
Bug reports and pull requests are welcome on GitHub at https://github.com/yourusername/typed_print.
## License
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).