awesome-print / awesome_print

Pretty print your Ruby objects with style -- in full color and with proper indentation
http://github.com/michaeldv/awesome_print
MIT License
4.07k stars 454 forks source link

Changed option :raw to true as default. #191

Open mattmartini opened 9 years ago

mattmartini commented 9 years ago

In response to Issue #190 AP upgrade loses functionality in displaying objects. https://github.com/michaeldv/awesome_print/issues/190

Expected behavior is that Objects are recursively formatted. The default setting is reversed to true.

maurogeorge commented 9 years ago

@mattmartini thanks for the PR. I will review soon.

maurogeorge commented 9 years ago

Do you think it is possible that we have formatted objects like

#<Item:0x7ffbb19c12d8
    @count = 0,
    attr_accessor :quantity = 3,
    attr_reader :name = "box",
    attr_reader :value = 2.5
>

without touch the the raw option and the AR, Mongoid and Ripple. What I understand about nested objects is like something:

Raw as false

#<Item:0x7ffbb19c12d8
    @count = 0,
    attr_accessor :quantity = 3,
    attr_reader :name = "box",
    attr_reader :value = 2.5
    attr_reader :child = #<Item:0x007ffc1c93aad9 @name="box", @quantity=3, @value=2.5, @count=0>
>

Raw as true

#<Item:0x7ffbb19c12d8
    @count = 0,
    attr_accessor :quantity = 3,
    attr_reader :name = "box",
    attr_reader :value = 2.5
    attr_reader :child = #<Item:0x007ffc1c93aad9
                                       @name="box",
                                       @quantity=3,
                                       @value=2.5
                                       @count=0
                                  >
>

I think this is the expected behavior. What you think?

Thanks for the PR :+1:

mattmartini commented 9 years ago

Mauro, Please let me know how you would like me to proceed. I thought that we had said that the expected behavior should be that object instance variables and accessors are shown by default. Since the current behavior is the opposite with the :raw defaulting to false, changing the default to true would reverse this and thus achieve the intended behavior. I'm open to your ideas. Matt

OK, It seems we were writing at the same time. I just saw your comment. I will look into it.

mattmartini commented 9 years ago

So what you would like is that objects behave as if :raw was true for the first level, but not to recurse. I agree with this, and will attempt the changes. Would we need a new switch to turn this behavior off? Seems like without this behavior we might as well tun AP off, so I don't think so.

maurogeorge commented 9 years ago

@mattmartini I guess that the idea, agree with you :smile: Thanks :heart:

gerrywastaken commented 8 years ago

Just to help me keep track of this PR and for anybody else who taking a look: @waldyr added a comment on the associated issue asking about the status of the PR: https://github.com/awesome-print/awesome_print/issues/190#issuecomment-227912949