Pretty print object as executable code
forthrin opened this issue · 0 comments
forthrin commented
If there a way to make this (or another) gem print objects on a form that:
- generates the same object (ie. can be preceded by
foo =
and run as code) - passes Rubocop validation
- 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.