diff --git a/lib/awesome_print/formatter.rb b/lib/awesome_print/formatter.rb index 3019c50..6364e89 100755 --- a/lib/awesome_print/formatter.rb +++ b/lib/awesome_print/formatter.rb @@ -63,8 +63,8 @@ module AwesomePrint def awesome_self(object, type) if @options[:raw] && object.instance_variables.any? awesome_object(object) - elsif object == ENV - awesome_hash(object.to_hash) + elsif object.eql?(ENV) # See https://github.com/michaeldv/awesome_print/issues/134 + awesome_hash(ENV.to_hash) else colorize(object.inspect.to_s, type) end diff --git a/spec/misc_spec.rb b/spec/misc_spec.rb index 2d21ee6..d359ca6 100644 --- a/spec/misc_spec.rb +++ b/spec/misc_spec.rb @@ -57,6 +57,13 @@ describe "AwesomePrint" do ENV.ai(:plain => true).should == ENV.to_hash.ai(:plain => true) ENV.ai.should == ENV.to_hash.ai end + + # See https://github.com/michaeldv/awesome_print/issues/134 + it "IPAddr workaround" do + require "ipaddr" + ipaddr = IPAddr.new("3ffe:505:2::1") + ipaddr.ai.should == "#" + end end #------------------------------------------------------------------------------