awesome-print/awesome_print

Pretty print object as executable code

forthrin opened this issue · 0 comments

If there a way to make this (or another) gem print objects on a form that:

  1. generates the same object (ie. can be preceded by foo = and run as code)
  2. passes Rubocop validation
  3. has smart options for things like
  • contracting short arrays on a single line
  • replacing (recent) timestamps with Time.now
  • replace JSON with {...}.to_json
  • replace query URLs with something like "https://domain/path/?#{URI.encode_www_form({a: 1, b: 2, ...})"
one = [
  false, 42, %w[forty two],
  { now: Time.now, class: Time, distance: 4.2e+43 }
]
ap(one)
[
  false, 42, %w[forty two],
  { now: Time.now, class: Time, distance: 4.2e+43 }
]

For me personally it doesn't need support for classes, methods, etc. as I assume that's the 80% of the Pareto principle.