Skip to content

Commit

Permalink
fix frozen string literal error
Browse files Browse the repository at this point in the history
  • Loading branch information
taichi-ishitani authored and hainesr committed May 23, 2021
1 parent 496b4c1 commit ebb0c01
Show file tree
Hide file tree
Showing 15 changed files with 27 additions and 27 deletions.
2 changes: 1 addition & 1 deletion lib/zip/extra_field/ntfs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def pack_for_c_dir
# reserved 0 and tag 1
s = [0, 1].pack('Vv')

tag1 = ''.force_encoding(Encoding::BINARY)
tag1 = (+'').force_encoding(Encoding::BINARY)
if @mtime
tag1 << [to_ntfs_time(@mtime)].pack('Q<')
if @atime
Expand Down
2 changes: 1 addition & 1 deletion lib/zip/extra_field/zip64.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def pack_for_local

def pack_for_c_dir
# central directory entries contain only fields that didn't fit in the main entry part
packed = ''.force_encoding('BINARY')
packed = (+'').force_encoding('BINARY')
packed << [@original_size].pack('Q<') if @original_size
packed << [@compressed_size].pack('Q<') if @compressed_size
packed << [@relative_header_offset].pack('Q<') if @relative_header_offset
Expand Down
2 changes: 1 addition & 1 deletion lib/zip/file.rb
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ def open(file_name, create = false, options = {})

# Same as #open. But outputs data to a buffer instead of a file
def add_buffer
io = ::StringIO.new('')
io = ::StringIO.new(+'')
zf = ::Zip::File.new(io, true, true)
yield zf
zf.write_buffer(io)
Expand Down
4 changes: 2 additions & 2 deletions lib/zip/filesystem.rb
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ def directory?(filename)
end

def open(filename, mode = 'r', permissions = 0o644, &block)
mode.delete!('b') # ignore b option
mode = mode.tr('b', '') # ignore b option
case mode
when 'r'
@mapped_zip.get_input_stream(filename, &block)
Expand Down Expand Up @@ -619,7 +619,7 @@ def each
end

def expand_path(path)
expanded = path.start_with?('/') ? path : ::File.join(@pwd, path)
expanded = ::File.expand_path(path, @pwd)
expanded.gsub!(/\/\.(\/|$)/, '')
expanded.gsub!(/[^\/]+\/\.\.(\/|$)/, '')
expanded.empty? ? '/' : expanded
Expand Down
2 changes: 1 addition & 1 deletion lib/zip/inflater.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ def initialize(*args)
@zlib_inflater = ::Zlib::Inflate.new(-Zlib::MAX_WBITS)
end

def read(length = nil, outbuf = '')
def read(length = nil, outbuf = +'')
return (length.nil? || length.zero? ? '' : nil) if eof

while length.nil? || (@buffer.bytesize < length)
Expand Down
4 changes: 2 additions & 2 deletions lib/zip/ioextras.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ module IOExtras #:nodoc:

class << self
def copy_stream(ostream, istream)
ostream.write(istream.read(CHUNK_SIZE, '')) until istream.eof?
ostream.write(istream.read(CHUNK_SIZE, +'')) until istream.eof?
end

def copy_stream_n(ostream, istream, nbytes)
toread = nbytes
while toread > 0 && !istream.eof?
tr = toread > CHUNK_SIZE ? CHUNK_SIZE : toread
ostream.write(istream.read(tr, ''))
ostream.write(istream.read(tr, +''))
toread -= tr
end
end
Expand Down
6 changes: 3 additions & 3 deletions lib/zip/ioextras/abstract_input_stream.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ def initialize
super
@lineno = 0
@pos = 0
@output_buffer = ''
@output_buffer = +''
end

attr_accessor :lineno
attr_reader :pos

def read(number_of_bytes = nil, buf = '')
def read(number_of_bytes = nil, buf = +'')
tbuf = if @output_buffer.bytesize > 0
if number_of_bytes && number_of_bytes <= @output_buffer.bytesize
@output_buffer.slice!(0, number_of_bytes)
Expand Down Expand Up @@ -93,7 +93,7 @@ def ungetc(byte)

def flush
ret_val = @output_buffer
@output_buffer = ''
@output_buffer = +''
ret_val
end

Expand Down
2 changes: 1 addition & 1 deletion lib/zip/pass_thru_decompressor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ def initialize(*args)
@read_so_far = 0
end

def read(length = nil, outbuf = '')
def read(length = nil, outbuf = +'')
return (length.nil? || length.zero? ? '' : nil) if eof

if length.nil? || (@read_so_far + length) > decompressed_size
Expand Down
2 changes: 1 addition & 1 deletion test/encryption_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def test_encrypt

password = 'swordfish'

encrypted_zip = Zip::OutputStream.write_buffer(::StringIO.new(''), Zip::TraditionalEncrypter.new(password)) do |out|
encrypted_zip = Zip::OutputStream.write_buffer(::StringIO.new(+''), Zip::TraditionalEncrypter.new(password)) do |out|
out.put_next_entry(test_filename)
out.write content
end
Expand Down
2 changes: 1 addition & 1 deletion test/extra_field_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def test_bad_header_id
end

def test_ntfs
str = "\x0A\x00 \x00\x00\x00\x00\x00\x01\x00\x18\x00\xC0\x81\x17\xE8B\xCE\xCF\x01\xC0\x81\x17\xE8B\xCE\xCF\x01\xC0\x81\x17\xE8B\xCE\xCF\x01"
str = +"\x0A\x00 \x00\x00\x00\x00\x00\x01\x00\x18\x00\xC0\x81\x17\xE8B\xCE\xCF\x01\xC0\x81\x17\xE8B\xCE\xCF\x01\xC0\x81\x17\xE8B\xCE\xCF\x01"
extra = ::Zip::ExtraField.new(str)
assert(extra.member?('NTFS'))
t = ::Zip::DOSTime.at(1_410_496_497.405178)
Expand Down
2 changes: 1 addition & 1 deletion test/file_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,7 @@ def test_write_buffer
zf = ::Zip::File.new(TEST_ZIP.zip_name)
old_name = zf.entries.first
zf.rename(old_name, new_name)
io = ::StringIO.new('')
io = ::StringIO.new(+'')
buffer = zf.write_buffer(io)
File.open(TEST_ZIP.zip_name, 'wb') { |f| f.write buffer.string }
zf_read = ::Zip::File.new(TEST_ZIP.zip_name)
Expand Down
4 changes: 2 additions & 2 deletions test/input_stream_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ def test_rewind
assert_equal(TestZipFile::TEST_ZIP2.entry_names[0], e.name)

# Do a little reading
buf = ''
buf = +''
buf << zis.read(100)
assert_equal(100, zis.pos)
buf << (zis.gets || '')
Expand All @@ -143,7 +143,7 @@ def test_rewind

zis.rewind

buf2 = ''
buf2 = +''
buf2 << zis.read(100)
buf2 << (zis.gets || '')
buf2 << (zis.gets || '')
Expand Down
14 changes: 7 additions & 7 deletions test/ioextras/abstract_output_stream_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class TestOutputStream
attr_accessor :buffer

def initialize
@buffer = ''
@buffer = +''
end

def <<(data)
Expand Down Expand Up @@ -58,12 +58,12 @@ def test_print
assert_equal("hello world. You ok out there?\nI sure hope so!\n", @output_stream.buffer)

$, = 'X'
@output_stream.buffer = ''
@output_stream.buffer = +''
@output_stream.print('monkey', 'duck', 'zebra')
assert_equal("monkeyXduckXzebra\n", @output_stream.buffer)

$\ = nil
@output_stream.buffer = ''
@output_stream.buffer = +''
@output_stream.print(20)
assert_equal('20', @output_stream.buffer)
end
Expand All @@ -87,19 +87,19 @@ def test_puts
@output_stream.puts('hello', 'world')
assert_equal("\nhello\nworld\n", @output_stream.buffer)

@output_stream.buffer = ''
@output_stream.buffer = +''
@output_stream.puts("hello\n", "world\n")
assert_equal("hello\nworld\n", @output_stream.buffer)

@output_stream.buffer = ''
@output_stream.buffer = +''
@output_stream.puts(%W[hello\n world\n])
assert_equal("hello\nworld\n", @output_stream.buffer)

@output_stream.buffer = ''
@output_stream.buffer = +''
@output_stream.puts(%W[hello\n world\n], 'bingo')
assert_equal("hello\nworld\nbingo\n", @output_stream.buffer)

@output_stream.buffer = ''
@output_stream.buffer = +''
@output_stream.puts(16, 20, 50, 'hello')
assert_equal("16\n20\n50\nhello\n", @output_stream.buffer)
end
Expand Down
4 changes: 2 additions & 2 deletions test/output_stream_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def test_open
end

def test_write_buffer
io = ::StringIO.new('')
io = ::StringIO.new(+'')
buffer = ::Zip::OutputStream.write_buffer(io) do |zos|
zos.comment = TEST_ZIP.comment
write_test_zip(zos)
Expand All @@ -33,7 +33,7 @@ def test_write_buffer
end

def test_write_buffer_binmode
io = ::StringIO.new('')
io = ::StringIO.new(+'')
buffer = ::Zip::OutputStream.write_buffer(io) do |zos|
zos.comment = TEST_ZIP.comment
write_test_zip(zos)
Expand Down
2 changes: 1 addition & 1 deletion test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ class TestOutputStream
attr_accessor :buffer

def initialize
@buffer = ''
@buffer = +''
end

def <<(data)
Expand Down

0 comments on commit ebb0c01

Please sign in to comment.