1
0
Fork 0
mirror of https://github.com/awesome-print/awesome_print synced 2023-03-27 23:22:34 -04:00

Fix frozen string errors

This commit is contained in:
Dan Weinand 2019-08-25 01:18:19 -07:00
parent d427ca39b7
commit 613a9fb49f
5 changed files with 11 additions and 10 deletions

View file

@ -55,7 +55,7 @@ module AwesomePrint
hash
end
end
"#{object} " << awesome_hash(data)
"#{object} #{awesome_hash(data)}"
end
# Format ActiveRecord class object.
@ -95,7 +95,7 @@ module AwesomePrint
end
data.merge!({details: object.details, messages: object.messages})
"#{object} " << awesome_hash(data)
"#{object} #{awesome_hash(data)}"
end
end
end

View file

@ -31,7 +31,7 @@ module AwesomePrint
if options[:multiline]
multiline_array
else
'[ ' << array.map { |item| inspector.awesome(item) }.join(', ') << ' ]'
"[ #{array.map { |item| inspector.awesome(item) }.join(', ')} ]"
end
end

View file

@ -73,7 +73,7 @@ module AwesomePrint
keys.map! do |key|
plain_single_line do
[inspector.awesome(key), hash[key]]
[String.new(inspector.awesome(key)), hash[key]]
end
end
end

View file

@ -22,7 +22,7 @@ module AwesomePrint
object.respond_to?(property) ? :reader : nil
end
if accessor
["attr_#{accessor} :#{property}", var]
[String.new("attr_#{accessor} :#{property}"), var]
else
[var.to_s, var]
end
@ -60,7 +60,8 @@ module AwesomePrint
end
def awesome_instance
str = object.send(options[:class_name]).to_s
str = String.new
str << object.send(options[:class_name]).to_s
str << ":0x%08x" % (object.__id__ * 2) if options[:object_id]
str
end

View file

@ -492,7 +492,7 @@ EOS
describe 'File' do
it 'should display a file (plain)' do
File.open(__FILE__, 'r') do |f|
expect(f.ai(plain: true)).to eq("#{f.inspect}\n" << `ls -alF #{f.path}`.chop)
expect(f.ai(plain: true)).to eq("#{f.inspect}\n#{`ls -alF #{f.path}`.chop}")
end
end
end
@ -501,7 +501,7 @@ EOS
describe 'Dir' do
it 'should display a direcory (plain)' do
Dir.open(File.dirname(__FILE__)) do |d|
expect(d.ai(plain: true)).to eq("#{d.inspect}\n" << `ls -alF #{d.path}`.chop)
expect(d.ai(plain: true)).to eq("#{d.inspect}\n#{`ls -alF #{d.path}`.chop}")
end
end
end
@ -694,7 +694,7 @@ EOS
class My < File; end
my = File.new('/dev/null') rescue File.new('nul')
expect(my.ai(plain: true)).to eq("#{my.inspect}\n" << `ls -alF #{my.path}`.chop)
expect(my.ai(plain: true)).to eq("#{my.inspect}\n#{`ls -alF #{my.path}`.chop}")
end
it 'inherited from Dir should be displayed as Dir' do
@ -702,7 +702,7 @@ EOS
require 'tmpdir'
my = My.new(Dir.tmpdir)
expect(my.ai(plain: true)).to eq("#{my.inspect}\n" << `ls -alF #{my.path}`.chop)
expect(my.ai(plain: true)).to eq("#{my.inspect}\n#{`ls -alF #{my.path}`.chop}")
end
it 'should handle a class that defines its own #send method' do