Open maciejpk opened 6 years ago
I've also found myself wanting this, the example above can be patched in (i.e in ~/.pryrc) like so:
require "awesome_print"
module AwesomePrint
module Formatters
class ArrayFormatter
alias old_gen generate_printable_array
def generate_printable_array
options[:multiline] = false
old_gen
end
end
end
end
AwesomePrint.pry!
Doesn't support depth, and if you want to start printing out complex objects it will wrap and look very ugly, but for a quick hack it does the trick pretty well.
This is actually a feature request that shouldn't be hard to implement. What I actually would like to have, is a depth of "awesome printing", so when for example I have an array like:
then for
depth == 2
it would print it the usual way, which would beap arr
, but if thedepth == 1
then it would be displayed like in the above manner.Reason for this feature? Pluck command. Let's take an
ActiveRecord
and do something like thisap User.where(...).pluck(:id, :created_at, :updated_at)
It would be printed in an ugly way, which would be something alikewhen instead I would like it to show each record as a row, so that would look something like this