First off, great lib! Thanks!
I was missing this feature, so here is a PR.
Motivation: To unclutter/customize the output of pp and/or Object.inspect I override instance_variables to return only the instance variables I care about, in the order I care about them. For example, if one of the instance variables is a somewhat large Hash, you might want to print that last, as to improve readability of all other vars.
pp was easily forced to not sort the array by monkeypatching the sort method for the specific array with instance variables (or, their keys). But AwesomePrint maps the vars to a new array and sorts them later.
This PR adds a sort_vars option (default true, nothing breaks) to disable this sorting.
Let me know what you think. If anything can be approved if you like the feature, etc.
Hi!
First off, great lib! Thanks! I was missing this feature, so here is a PR.
Motivation: To unclutter/customize the output of
pp
and/orObject.inspect
I overrideinstance_variables
to return only the instance variables I care about, in the order I care about them. For example, if one of the instance variables is a somewhat large Hash, you might want to print that last, as to improve readability of all other vars.pp
was easily forced to not sort the array by monkeypatching thesort
method for the specific array with instance variables (or, their keys). But AwesomePrint maps the vars to a new array and sorts them later. This PR adds asort_vars
option (defaulttrue
, nothing breaks) to disable this sorting.Let me know what you think. If anything can be approved if you like the feature, etc.
Cheers!