Skip to content

Commit

Permalink
Merge pull request #114 from joast/preserve-user-color-defaults
Browse files Browse the repository at this point in the history
Preserve user color defaults
  • Loading branch information
HarlemSquirrel authored Dec 19, 2024
2 parents 3472f78 + 3e46053 commit 9dcae94
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## Unreleased

- Preserve user defined color defaults

## V1.6.0

- Use pager with Pry #96
Expand Down
2 changes: 1 addition & 1 deletion lib/amazing_print/inspector.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 11 additions & 0 deletions spec/misc_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

#------------------------------------------------------------------------------
Expand Down

0 comments on commit 9dcae94

Please sign in to comment.