Menu

Post image 1
Post image 2
1 / 2
0

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

DEV Community·Ender Ahmet Yurt·24 days ago
#yC2nvZkx
#ruby#cli#rubygems#fullscreen#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. 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.…

Continue reading — create a free account

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

Read More