Menu

I built a Ruby gem so I don't have to squint at hash dumps anymore
πŸ–ΌοΈ

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

DEV CommunityΒ·Ender Ahmet YurtΒ·6 months ago
#yC2nvZkx
#ruby#cli#rubygems#enter#exit
Reading 0:00
15s threshold

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.…

Continue reading β€” create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.