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.08k stars 454 forks source link

defaults are forgotten after one print #209

Open jsvd opened 8 years ago

jsvd commented 8 years ago
jruby-1.7.22 :011 > AwesomePrint.defaults = { :color => { :test => :green } }
 => {:color=>{:test=>:green}} 
jruby-1.7.22 :012 > class Test;end
 => nil 
jruby-1.7.22 :013 > Test.new.awesome_inspect
 => "\e[1;32m#<Test:0xbff34c6>\e[0m" 
jruby-1.7.22 :014 > Test.new.awesome_inspect
 => "#<Test:0x1522d8a0>"
booch commented 6 years ago

Oddly, it only seems to be the colors that get forgotten. My indentation and indexing settings work properly.

RST-J commented 5 years ago

I have the same issue, is there a way around this?

In my .irbrc I have

AwesomePrint.defaults = {
  indent: 2,
  ruby19_syntax: true,
  color: {
    array: :blue,
    hash: :blue
  }
}
AwesomePrint.irb!

And just like @booch reports, indentation keeps working but the coloring is lost after the first print out.

RST-J commented 5 years ago

I found the reason: The color option is deleted from the defaults here and hence only regarded once. I'll prepare a pull request to fix that.

TheRealest commented 5 years ago

This is still an issue. Current workaround is the ~/.aprc file for color defaults, which won't disappear after the first print.

RST-J commented 5 years ago

Which unfortunately does not work, if one uses a containerized development environment, where ~ is not the home directory of my user on my machine. For this the way to go is the .irbrc approach.