DEV Community

Cover image for I built a Ruby gem so I don't have to squint at hash dumps anymore
Ender Ahmet Yurt
Ender Ahmet Yurt

Posted on

I built a Ruby gem so I don't have to squint at hash dumps anymore

Zero-dependency tables and Markdown support

I love Ruby. I love the console. I do not love this:

{:name=>"Alice", :score=>100, :active=>true}
{:name=>"Bob", :score=>42, :active=>false}
Enter fullscreen mode Exit fullscreen mode

When you have 20 of these in a row, good luck reading anything.

So I built a tiny gem called typed_print.

What does it do?

One thing. Just one.

It turns hashes into clean, aligned tables.

require 'typed_print'

data = [
  { name: "Alice", score: 100, active: true },
  { name: "Bob", score: 42, active: false }
]

TypedPrint.print(data)
Enter fullscreen mode Exit fullscreen mode

Output

 Name  Score Active 
------+------+-------
Alice   100 true   
Bob      42 false  
Enter fullscreen mode Exit fullscreen mode

That's it. No magic. No mental parsing.

Why not just use pp or awesome_print?

  • pp is fine, but still hard to scan.
  • awesome_print is great, but sometimes you don't want colors, JSON support, or 10 dependencies.

I wanted something that:

  • Has zero required dependencies
  • Only does tables
  • Works everywhere (Rails, Rake tasks, plain Ruby scripts, even minimal Docker containers)

What can you do with it?

1. Align columns

TypedPrint.print(data, align: { score: :right })
Enter fullscreen mode Exit fullscreen mode

2. Show only what you need

TypedPrint.print(data, only: [:name, :score])
Enter fullscreen mode Exit fullscreen mode

3. Custom headers

TypedPrint.print(data, headers: { name: "User", score: "Points" })
Enter fullscreen mode Exit fullscreen mode

4. Markdown output (great for docs)

TypedPrint.print(data, format: :markdown)
Enter fullscreen mode Exit fullscreen mode

Outputs a proper markdown table you can copy into GitHub READMEs.

5. Colors! (v0.3.0)

TypedPrint.print(data, color: true)
Enter fullscreen mode Exit fullscreen mode

Or full control:

TypedPrint.print(data, colors: { name: :cyan, score: :green, active: :yellow })
Enter fullscreen mode Exit fullscreen mode
  • Pastel is optional. If you don't have it, colors are ignored. No errors.

Example with different data types

mixed = [
  { name: "Product A", price: 29.99, in_stock: true, notes: nil },
  { name: "Product B", price: 49.99, in_stock: false, notes: "Limited" }
]

TypedPrint.print(mixed)
Enter fullscreen mode Exit fullscreen mode

Output:

   Name      Price In_stock Notes        
----------+-------+---------+-------------
Product A   29.99 true                  
Product B   49.99 false    Limited edition
Enter fullscreen mode Exit fullscreen mode

It handles nil, booleans, numbers, and strings automatically.

What about performance?

It's lightweight. Zero dependencies means no hidden bloat.
I've tested it with 10,000 rows. Still fast enough for CLI tools and debugging.
For massive datasets? You probably shouldn't print them to the terminal anyway.

Who is this for?

  • Rails developers who debug in the console
  • CLI tool authors who want clean output
  • Anyone who logs hashes and wants them readable
  • People who are tired of pp

Links

What's next?

I'm keeping it simple. No roadmap to become a bloated framework.

But if you have an idea that fits the "zero-dependency, just tables" philosophy – open an issue. I shipped markdown support within hours of a user request (that was v0.2.0).

Try it

gem install typed_print
Enter fullscreen mode Exit fullscreen mode

That's it. You're done.

If you find it useful, let me know. If you find a bug, also let me know.

Thanks for reading πŸ™

Top comments (11)

Collapse
 
coridev profile image
Cor E

nice. I love ruby but haven't had a chance to use it in a while. Most corp projects are all Python. Great gem!

Collapse
 
eayurt profile image
Ender Ahmet Yurt

Thanks! Means a lot coming from a fellow Ruby lover. Python may pay the bills, but Ruby stays in the heart. ❀️ Hope you get to use it more often!

Collapse
 
coridev profile image
Cor E

I love that saying! Absolutely! My next personal project is going to be in Ruby :P

Collapse
 
lcmd007 profile image
Andy Stewart

As a developer, I know the pain of squinting at messy Hash dumps in the console. I really appreciate the 'zero-dependency, do one thing well' philosophy of typed_print. It brings much-needed clarity back to CLI outputβ€”the Markdown support, in particular, is a lifesaver for documentation. Great work!

Collapse
 
eayurt profile image
Ender Ahmet Yurt

Wow, thank you! πŸ™ You summed up the whole philosophy better than I could. "Do one thing well" – exactly that. The markdown feature was actually a user suggestion (v0.2.0). Best decision ever.

Really appreciate the kind words. Means a lot. ❀️

Collapse
 
lcmd007 profile image
Andy Stewart

Spot on! That’s the beauty of the Unix philosophy. The Markdown addition proves that the best architecture 'grows' from user needs. Achieving that level of surgical simplicity and giving users true 'control' is exactly what we strive for as developers. Keep up the great work!

Collapse
 
prachub profile image
PracHub

You made a smart choice by focusing on making hash outputs readable without adding extra dependencies. The Markdown format option is great for those who appreciate self-documenting code samples. I'm curious about how "typed_print" deals with deeply nested hashes, as some tools struggle with that. By the way, I've been using prachub.com for system design questions, and their follow-up prompts have been more helpful than random forum threads. I'll definitely keep using them for my next mock interview.

Collapse
 
sabarishcodes profile image
Sabarish Rajamohan

This is awesome. I have always found it hard to see large outputs, and reading through them.

I especially like the markdown dump, since now every other AI tool prefers markdown now.
Any plans to extend this to other input types?

Collapse
 
eayurt profile image
Ender Ahmet Yurt

Thank you! πŸ™

Great point about AI tools and markdown – hadn't thought of that but you're totally right.

Other input types?

Currently just arrays of hashes. But JSON and CSV are on my radar. What did you have in mind?

Open to ideas if you want to open an issue on GitHub!

Thanks again πŸ™Œ

btw you can use like that

require 'csv'
data = CSV.parse(File.read("file.csv"), headers: true).map(&:to_h)
TypedPrint.print(data)
Enter fullscreen mode Exit fullscreen mode

Some comments may only be visible to logged-in visitors. Sign in to view all comments.