mirror of
https://github.com/awesome-print/awesome_print
synced 2023-03-27 23:22:34 -04:00
Merge AwesomePrint.defaults when defined in ~/.irbrc
This commit is contained in:
parent
fa958455ca
commit
a939430d16
2 changed files with 18 additions and 4 deletions
|
@ -129,10 +129,8 @@ module AwesomePrint
|
|||
#------------------------------------------------------------------------------
|
||||
def merge_custom_defaults!
|
||||
dotfile = File.join(ENV["HOME"], ".aprc")
|
||||
if File.readable?(dotfile)
|
||||
load dotfile
|
||||
merge_options!(AwesomePrint.defaults)
|
||||
end
|
||||
load dotfile if File.readable?(dotfile)
|
||||
merge_options!(AwesomePrint.defaults) if AwesomePrint.defaults.is_a?(Hash)
|
||||
rescue => e
|
||||
$stderr.puts "Could not load #{dotfile}: #{e}"
|
||||
end
|
||||
|
|
|
@ -86,4 +86,20 @@ EOS
|
|||
markup.ai(:html => true).should == '<pre><kbd style="color:brown">" &<hello>"</kbd></pre>'
|
||||
end
|
||||
end
|
||||
|
||||
describe "AwesomePrint.defaults" do
|
||||
# See https://github.com/michaeldv/awesome_print/issues/98
|
||||
it "should properly merge the defaults" do
|
||||
AwesomePrint.defaults = { :indent => -2, :sort_keys => true }
|
||||
hash = { [0, 0, 255] => :yellow, :red => "rgb(255, 0, 0)", "magenta" => "rgb(255, 0, 255)" }
|
||||
out = hash.ai(:plain => true)
|
||||
out.should == <<-EOS.strip
|
||||
{
|
||||
[ 0, 0, 255 ] => :yellow,
|
||||
"magenta" => "rgb(255, 0, 255)",
|
||||
:red => "rgb(255, 0, 0)"
|
||||
}
|
||||
EOS
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue