diff --git a/CHANGELOG.md b/CHANGELOG.md index 70f70c8..04fc04c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ ## Unreleased +- Preserve user defined color defaults + ## V1.6.0 - Use pager with Pry #96 diff --git a/lib/amazing_print/inspector.rb b/lib/amazing_print/inspector.rb index 4cd9bad..a7b4e67 100644 --- a/lib/amazing_print/inspector.rb +++ b/lib/amazing_print/inspector.rb @@ -192,7 +192,7 @@ def dotfile_readable?(dotfile) #--------------------------------------------------------------------------- def merge_custom_defaults! load_dotfile - merge_options!(AmazingPrint.defaults) if AmazingPrint.defaults.is_a?(Hash) + merge_options!(AmazingPrint.defaults.dup) if AmazingPrint.defaults.is_a?(Hash) rescue StandardError => e warn "Could not load '.aprc' from ENV['HOME']: #{e}" end diff --git a/spec/misc_spec.rb b/spec/misc_spec.rb index 3ba0755..af7a52c 100644 --- a/spec/misc_spec.rb +++ b/spec/misc_spec.rb @@ -139,6 +139,17 @@ def ==(other) } EOS end + + it 'preserves user color defaults' do + COLORIZED_123 = "\e[0;34m123\e[0m" + + AmazingPrint.force_colors = true + AmazingPrint.defaults = { color: { integer: :blueish } } + out = 123.ai + expect(out).to eq COLORIZED_123 + out = 123.ai + expect(out).to eq COLORIZED_123 + end end #------------------------------------------------------------------------------