-
Notifications
You must be signed in to change notification settings - Fork 454
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
options classname and object_id #296
base: master
Are you sure you want to change the base?
Conversation
@aars There was previously talk about adding custom formatters but I'm not sure how far anybody got. I agree with you that this change seems very niche. Perhaps if you explained the use case for changing the name of the class that is printed I might understand better if this will be useful for others. |
Customer formatters would supersede this. This is some actual (but contrived) test output I have. #<SureBase::Expression::Operator:0x007fb574dd3138
@op="divide",
@input=0,
@output=nil,
@args=
[#<SureBase::Expression::Operator:0x007fb574dd28a0
@op="divide",
@input=0,
@output=nil,
@args=
[#<SureBase::Expression::Setter:0x007fb574dd2468
@output=nil,
@getset_data=nil,
@args=
[#<SureBase::Expression::Operator:0x007fb574dd2058
@op="add",
@input=0,
@output=nil,
@args=
[#<SureBase::Expression::Value:0x007fb574dd1bf8 @expr=12, @output=nil>,
#<SureBase::Expression::Value:0x007fb574dd1810 @expr=10, @output=nil>]>]>,
#<SureBase::Expression::Value:0x007fb574dd1518 @expr=11, @output=nil>]>]>, The long classnames and object_id's aren't very important in this "view". The structure of the data and the instance variables are. So I though, by giving the user control over that line as well, readability could be improved if necessary. And so, I did this:
[2] #<Operator::divide
@input = 0,
@output = nil,
attr_reader :args = [
[0] #<Operator::divide
@input = 0,
@output = nil,
attr_reader :args = [
[0] #<Setter['some_value']
@output = nil,
@getset_data = nil,
attr_reader :args = [
[0] #<Operator::add
@input = 0,
@output = nil,
attr_reader :args = [
[0] #<Value[12]
@expr = 12,
@output = nil
>,
[1] #<Value[10]
@expr = 10,
@output = nil
>
]
>
]
>,
[1] #<Value[11]
@expr = 11,
@output = nil
>
]
>
]
>, Here I removed But I can totally see how this feature would be not only much better suited as a custom formatter, but might even invite more of these somewhat trivial, not-that-useful-too-most-people feature-PRs, and would clutter up the AP options. (the inconsistency in use of |
If I want to look into writing custom formatter support, any tips on where to start? Any work been done? Or, any other libs out there with good custom formatter implementations we could copy or be inspired by? Logger maybe? |
PS: I made a booboo. Fixed it, waiting for the CI. |
While a custom formatter would be ideal in the mean time if there were simply a way to turn off the object_id (id) within the output of an object that would be fantastic. |
@matthewhively I'd suggest getting my changes to I don't know what's up with the CI in here. But I would agree that custom formatters would be a better feature, so I don't mind this not getting merged. Though I am currently running my own version of AP with this PR included. |
@aars Yes, I see that this PR does indeed provide the functionality I want. That is exactly why I replied to it. I wanted to provide another use case in the hope that this might get merged. |
hey @aars, this has been a million years ignored (sorry!) but i see the value in this -- and since we've not been good at updating ap, i figured work done but not perfect > nothing happening. I'd love this if you could rebase on the conflict, if not i'll try to get to it soon! thx. |
I think I can manage that yes. Sometime this week. |
@aars: hey! just wanted to ping ya on this. It'd be great to get this rebase done, and get this work merged into the next release. I like this pr, and would love to see your hard work land! thanks. 👍 🥇 |
Ugh! Sorry. Hectic weeks (uh.. yeah.. since June... Ok... not an excuse... :D ) I've got some more github related stuff to do this week. I've put this on my todo list. |
Adds options to customize object classname and object_id output.
What do you think about this?
I don't think this is useful for many people, and it's probably better to introduce a way to add custom formatters (there isn't any at the moment, right?)
If it does seem useful, I think the new non-boolean/int option
classname
is probably a bad idea. A simpleuse_to_s
switch would probably do, no?For me personally, this combined with
sort_vars
options gives me great control over the output. Let me know what you think.Cheers.