fix rubocop Style/SpaceAroundOperators cop
This commit is contained in:
parent
5ea5710b18
commit
8d6f23ba9a
|
@ -267,11 +267,6 @@ Style/Semicolon:
|
||||||
Style/SignalException:
|
Style/SignalException:
|
||||||
Enabled: false
|
Enabled: false
|
||||||
|
|
||||||
# Offense count: 53
|
|
||||||
# Cop supports --auto-correct.
|
|
||||||
Style/SpaceAroundOperators:
|
|
||||||
Enabled: false
|
|
||||||
|
|
||||||
# Offense count: 30
|
# Offense count: 30
|
||||||
# Cop supports --auto-correct.
|
# Cop supports --auto-correct.
|
||||||
Style/SpecialGlobalVars:
|
Style/SpecialGlobalVars:
|
||||||
|
|
|
@ -6,7 +6,7 @@ module Zip
|
||||||
|
|
||||||
LOCAL_ENTRY_SIGNATURE = 0x04034b50
|
LOCAL_ENTRY_SIGNATURE = 0x04034b50
|
||||||
LOCAL_ENTRY_STATIC_HEADER_LENGTH = 30
|
LOCAL_ENTRY_STATIC_HEADER_LENGTH = 30
|
||||||
LOCAL_ENTRY_TRAILING_DESCRIPTOR_LENGTH = 4+4+4
|
LOCAL_ENTRY_TRAILING_DESCRIPTOR_LENGTH = 4 + 4 + 4
|
||||||
VERSION_MADE_BY = 52 # this library's version
|
VERSION_MADE_BY = 52 # this library's version
|
||||||
VERSION_NEEDED_TO_EXTRACT = 20
|
VERSION_NEEDED_TO_EXTRACT = 20
|
||||||
VERSION_NEEDED_TO_EXTRACT_ZIP64 = 45
|
VERSION_NEEDED_TO_EXTRACT_ZIP64 = 45
|
||||||
|
|
|
@ -3,7 +3,7 @@ module Zip
|
||||||
CHUNK_SIZE = 32768
|
CHUNK_SIZE = 32768
|
||||||
def initialize(input_stream)
|
def initialize(input_stream)
|
||||||
super()
|
super()
|
||||||
@input_stream=input_stream
|
@input_stream = input_stream
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -13,7 +13,7 @@ module Zip
|
||||||
# bits 9-15 year (four digit year minus 1980)
|
# bits 9-15 year (four digit year minus 1980)
|
||||||
|
|
||||||
def to_binary_dos_time
|
def to_binary_dos_time
|
||||||
(sec/2) +
|
(sec / 2) +
|
||||||
(min << 5) +
|
(min << 5) +
|
||||||
(hour << 11)
|
(hour << 11)
|
||||||
end
|
end
|
||||||
|
@ -26,7 +26,7 @@ module Zip
|
||||||
|
|
||||||
# Dos time is only stored with two seconds accuracy
|
# Dos time is only stored with two seconds accuracy
|
||||||
def dos_equals(other)
|
def dos_equals(other)
|
||||||
to_i/2 == other.to_i/2
|
to_i / 2 == other.to_i / 2
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.parse_binary_dos_format(binaryDosDate, binaryDosTime)
|
def self.parse_binary_dos_format(binaryDosDate, binaryDosTime)
|
||||||
|
|
|
@ -514,8 +514,8 @@ module Zip
|
||||||
when 'file'
|
when 'file'
|
||||||
if name_is_directory?
|
if name_is_directory?
|
||||||
raise ArgumentError,
|
raise ArgumentError,
|
||||||
"entry name '#{newEntry}' indicates directory entry, but "+
|
"entry name '#{newEntry}' indicates directory entry, but " +
|
||||||
"'#{src_path}' is not a directory"
|
"'#{src_path}' is not a directory"
|
||||||
end
|
end
|
||||||
:file
|
:file
|
||||||
when 'directory'
|
when 'directory'
|
||||||
|
@ -524,8 +524,8 @@ module Zip
|
||||||
when 'link'
|
when 'link'
|
||||||
if name_is_directory?
|
if name_is_directory?
|
||||||
raise ArgumentError,
|
raise ArgumentError,
|
||||||
"entry name '#{newEntry}' indicates directory entry, but "+
|
"entry name '#{newEntry}' indicates directory entry, but " +
|
||||||
"'#{src_path}' is not a directory"
|
"'#{src_path}' is not a directory"
|
||||||
end
|
end
|
||||||
:symlink
|
:symlink
|
||||||
else
|
else
|
||||||
|
@ -550,7 +550,7 @@ module Zip
|
||||||
def parent_as_string
|
def parent_as_string
|
||||||
entry_name = name.chomp('/')
|
entry_name = name.chomp('/')
|
||||||
slash_index = entry_name.rindex('/')
|
slash_index = entry_name.rindex('/')
|
||||||
slash_index ? entry_name.slice(0, slash_index+1) : nil
|
slash_index ? entry_name.slice(0, slash_index + 1) : nil
|
||||||
end
|
end
|
||||||
|
|
||||||
def get_raw_input_stream(&block)
|
def get_raw_input_stream(&block)
|
||||||
|
@ -597,8 +597,8 @@ module Zip
|
||||||
::FileUtils.rm_f dest_path
|
::FileUtils.rm_f dest_path
|
||||||
else
|
else
|
||||||
raise ::Zip::DestinationFileExistsError,
|
raise ::Zip::DestinationFileExistsError,
|
||||||
"Cannot create directory '#{dest_path}'. "+
|
"Cannot create directory '#{dest_path}'. " +
|
||||||
'A file already exists with that name'
|
'A file already exists with that name'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
::FileUtils.mkdir_p(dest_path)
|
::FileUtils.mkdir_p(dest_path)
|
||||||
|
@ -622,13 +622,13 @@ module Zip
|
||||||
return
|
return
|
||||||
else
|
else
|
||||||
raise ::Zip::DestinationFileExistsError,
|
raise ::Zip::DestinationFileExistsError,
|
||||||
"Cannot create symlink '#{dest_path}'. "+
|
"Cannot create symlink '#{dest_path}'. " +
|
||||||
'A symlink already exists with that name'
|
'A symlink already exists with that name'
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
raise ::Zip::DestinationFileExistsError,
|
raise ::Zip::DestinationFileExistsError,
|
||||||
"Cannot create symlink '#{dest_path}'. "+
|
"Cannot create symlink '#{dest_path}'. " +
|
||||||
'A file already exists with that name'
|
'A file already exists with that name'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -61,7 +61,7 @@ module Zip
|
||||||
@entry_set[to_key(entry.parent_as_string)]
|
@entry_set[to_key(entry.parent_as_string)]
|
||||||
end
|
end
|
||||||
|
|
||||||
def glob(pattern, flags = ::File::FNM_PATHNAME|::File::FNM_DOTMATCH)
|
def glob(pattern, flags = ::File::FNM_PATHNAME | ::File::FNM_DOTMATCH)
|
||||||
entries.map do |entry|
|
entries.map do |entry|
|
||||||
next nil unless ::File.fnmatch(pattern, entry.name.chomp('/'), flags)
|
next nil unless ::File.fnmatch(pattern, entry.name.chomp('/'), flags)
|
||||||
yield(entry) if block_given?
|
yield(entry) if block_given?
|
||||||
|
|
|
@ -180,7 +180,7 @@ module Zip
|
||||||
def save_splited_part(zip_file, partial_zip_file_name, zip_file_size, szip_file_index, segment_size, segment_count)
|
def save_splited_part(zip_file, partial_zip_file_name, zip_file_size, szip_file_index, segment_size, segment_count)
|
||||||
ssegment_size = zip_file_size - zip_file.pos
|
ssegment_size = zip_file_size - zip_file.pos
|
||||||
ssegment_size = segment_size if ssegment_size > segment_size
|
ssegment_size = segment_size if ssegment_size > segment_size
|
||||||
szip_file_name = "#{partial_zip_file_name}.#{'%03d'%(szip_file_index)}"
|
szip_file_name = "#{partial_zip_file_name}.#{'%03d' % (szip_file_index)}"
|
||||||
::File.open(szip_file_name, 'wb') do |szip_file|
|
::File.open(szip_file_name, 'wb') do |szip_file|
|
||||||
if szip_file_index == 1
|
if szip_file_index == 1
|
||||||
ssegment_size = put_split_signature(szip_file, segment_size)
|
ssegment_size = put_split_signature(szip_file, segment_size)
|
||||||
|
@ -379,8 +379,8 @@ module Zip
|
||||||
srcPathIsDirectory = ::File.directory?(srcPath)
|
srcPathIsDirectory = ::File.directory?(srcPath)
|
||||||
if newEntry.is_directory && !srcPathIsDirectory
|
if newEntry.is_directory && !srcPathIsDirectory
|
||||||
raise ArgumentError,
|
raise ArgumentError,
|
||||||
"entry name '#{newEntry}' indicates directory entry, but "+
|
"entry name '#{newEntry}' indicates directory entry, but " +
|
||||||
"'#{srcPath}' is not a directory"
|
"'#{srcPath}' is not a directory"
|
||||||
elsif !newEntry.is_directory && srcPathIsDirectory
|
elsif !newEntry.is_directory && srcPathIsDirectory
|
||||||
newEntry.name += '/'
|
newEntry.name += '/'
|
||||||
end
|
end
|
||||||
|
|
|
@ -534,7 +534,7 @@ module Zip
|
||||||
|
|
||||||
def read
|
def read
|
||||||
raise IOError, 'closed directory' if @fileNames == nil
|
raise IOError, 'closed directory' if @fileNames == nil
|
||||||
@fileNames[(@index+=1)-1]
|
@fileNames[(@index += 1) - 1]
|
||||||
end
|
end
|
||||||
|
|
||||||
def rewind
|
def rewind
|
||||||
|
@ -602,7 +602,7 @@ module Zip
|
||||||
# and removes trailing slash on directories
|
# and removes trailing slash on directories
|
||||||
def each
|
def each
|
||||||
@zipFile.each do |e|
|
@zipFile.each do |e|
|
||||||
yield('/'+e.to_s.chomp('/'))
|
yield('/' + e.to_s.chomp('/'))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -72,7 +72,7 @@ puts "Zip file splitted in #{part_zips_count} parts"
|
||||||
# Track splitting an archive
|
# Track splitting an archive
|
||||||
Zip::File.split('large_zip_file.zip', 1048576, true, 'part_zip_file') do
|
Zip::File.split('large_zip_file.zip', 1048576, true, 'part_zip_file') do
|
||||||
|part_count, part_index, chunk_bytes, segment_bytes|
|
|part_count, part_index, chunk_bytes, segment_bytes|
|
||||||
puts "#{part_index} of #{part_count} part splitting: #{(chunk_bytes.to_f/segment_bytes.to_f * 100).to_i}%"
|
puts "#{part_index} of #{part_count} part splitting: #{(chunk_bytes.to_f / segment_bytes.to_f * 100).to_i}%"
|
||||||
end
|
end
|
||||||
|
|
||||||
# For other examples, look at zip.rb and ziptest.rb
|
# For other examples, look at zip.rb and ziptest.rb
|
||||||
|
|
|
@ -37,7 +37,7 @@ class ZipFileGenerator
|
||||||
puts 'Deflating ' + diskFilePath
|
puts 'Deflating ' + diskFilePath
|
||||||
if File.directory?(diskFilePath)
|
if File.directory?(diskFilePath)
|
||||||
io.mkdir(zipFilePath)
|
io.mkdir(zipFilePath)
|
||||||
subdir =Dir.entries(diskFilePath); subdir.delete('.'); subdir.delete('..')
|
subdir = Dir.entries(diskFilePath); subdir.delete('.'); subdir.delete('..')
|
||||||
writeEntries(subdir, zipFilePath, io)
|
writeEntries(subdir, zipFilePath, io)
|
||||||
else
|
else
|
||||||
io.get_output_stream(zipFilePath) { |f| f.puts(File.open(diskFilePath, 'rb').read()) }
|
io.get_output_stream(zipFilePath) { |f| f.puts(File.open(diskFilePath, 'rb').read()) }
|
||||||
|
|
|
@ -72,7 +72,7 @@ class MainApp < Gtk::Window
|
||||||
@zipfile.each do |entry|
|
@zipfile.each do |entry|
|
||||||
@clist.append([entry.name,
|
@clist.append([entry.name,
|
||||||
entry.size.to_s,
|
entry.size.to_s,
|
||||||
(100.0*entry.compressedSize/entry.size).to_s+'%'])
|
(100.0 * entry.compressedSize / entry.size).to_s + '%'])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#!/usr/bin/env ruby
|
#!/usr/bin/env ruby
|
||||||
|
|
||||||
$VERBOSE=true
|
$VERBOSE = true
|
||||||
|
|
||||||
$: << '../lib'
|
$: << '../lib'
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@ class BasicZipFileTest < MiniTest::Test
|
||||||
|
|
||||||
def setup
|
def setup
|
||||||
@zip_file = ::Zip::File.new(TestZipFile::TEST_ZIP2.zip_name)
|
@zip_file = ::Zip::File.new(TestZipFile::TEST_ZIP2.zip_name)
|
||||||
@testEntryNameIndex=0
|
@testEntryNameIndex = 0
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_entries
|
def test_entries
|
||||||
|
|
|
@ -58,7 +58,7 @@ class ZipCentralDirectoryEntryTest < MiniTest::Test
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_ReadEntryFromTruncatedZipFile
|
def test_ReadEntryFromTruncatedZipFile
|
||||||
fragment=''
|
fragment = ''
|
||||||
File.open('test/data/testDirectory.bin') { |f| fragment = f.read(12) } # cdir entry header is at least 46 bytes
|
File.open('test/data/testDirectory.bin') { |f| fragment = f.read(12) } # cdir entry header is at least 46 bytes
|
||||||
fragment.extend(IOizeString)
|
fragment.extend(IOizeString)
|
||||||
entry = ::Zip::Entry.new
|
entry = ::Zip::Entry.new
|
||||||
|
|
|
@ -27,7 +27,7 @@ class ZipCentralDirectoryTest < MiniTest::Test
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_ReadFromTruncatedZipFile
|
def test_ReadFromTruncatedZipFile
|
||||||
fragment=''
|
fragment = ''
|
||||||
File.open('test/data/testDirectory.bin', 'rb') { |f| fragment = f.read }
|
File.open('test/data/testDirectory.bin', 'rb') { |f| fragment = f.read }
|
||||||
fragment.slice!(12) # removed part of first cdir entry. eocd structure still complete
|
fragment.slice!(12) # removed part of first cdir entry. eocd structure still complete
|
||||||
fragment.extend(IOizeString)
|
fragment.extend(IOizeString)
|
||||||
|
|
|
@ -154,7 +154,7 @@ class ZipEntryTest < MiniTest::Test
|
||||||
end
|
end
|
||||||
zipfile.close
|
zipfile.close
|
||||||
|
|
||||||
f= File.open('/tmp/no_compress.zip', 'rb')
|
f = File.open('/tmp/no_compress.zip', 'rb')
|
||||||
first_100_bytes = f.read(100)
|
first_100_bytes = f.read(100)
|
||||||
f.close
|
f.close
|
||||||
|
|
||||||
|
|
|
@ -47,20 +47,20 @@ class ZipFileTest < MiniTest::Test
|
||||||
zf.get_output_stream('newEntry.txt') do |os|
|
zf.get_output_stream('newEntry.txt') do |os|
|
||||||
os.write 'Putting stuff in newEntry.txt'
|
os.write 'Putting stuff in newEntry.txt'
|
||||||
end
|
end
|
||||||
assert_equal(entryCount+1, zf.size)
|
assert_equal(entryCount + 1, zf.size)
|
||||||
assert_equal('Putting stuff in newEntry.txt', zf.read('newEntry.txt'))
|
assert_equal('Putting stuff in newEntry.txt', zf.read('newEntry.txt'))
|
||||||
|
|
||||||
zf.get_output_stream(zf.get_entry('test/data/generated/empty.txt')) do |os|
|
zf.get_output_stream(zf.get_entry('test/data/generated/empty.txt')) do |os|
|
||||||
os.write 'Putting stuff in data/generated/empty.txt'
|
os.write 'Putting stuff in data/generated/empty.txt'
|
||||||
end
|
end
|
||||||
assert_equal(entryCount+1, zf.size)
|
assert_equal(entryCount + 1, zf.size)
|
||||||
assert_equal('Putting stuff in data/generated/empty.txt', zf.read('test/data/generated/empty.txt'))
|
assert_equal('Putting stuff in data/generated/empty.txt', zf.read('test/data/generated/empty.txt'))
|
||||||
|
|
||||||
custom_entry_args = [ZipEntryTest::TEST_COMMENT, ZipEntryTest::TEST_EXTRA, ZipEntryTest::TEST_COMPRESSED_SIZE, ZipEntryTest::TEST_CRC, ::Zip::Entry::STORED, ZipEntryTest::TEST_SIZE, ZipEntryTest::TEST_TIME]
|
custom_entry_args = [ZipEntryTest::TEST_COMMENT, ZipEntryTest::TEST_EXTRA, ZipEntryTest::TEST_COMPRESSED_SIZE, ZipEntryTest::TEST_CRC, ::Zip::Entry::STORED, ZipEntryTest::TEST_SIZE, ZipEntryTest::TEST_TIME]
|
||||||
zf.get_output_stream('entry_with_custom_args.txt', nil, *custom_entry_args) do |os|
|
zf.get_output_stream('entry_with_custom_args.txt', nil, *custom_entry_args) do |os|
|
||||||
os.write 'Some data'
|
os.write 'Some data'
|
||||||
end
|
end
|
||||||
assert_equal(entryCount+2, zf.size)
|
assert_equal(entryCount + 2, zf.size)
|
||||||
entry = zf.get_entry('entry_with_custom_args.txt')
|
entry = zf.get_entry('entry_with_custom_args.txt')
|
||||||
assert_equal(custom_entry_args[0], entry.comment)
|
assert_equal(custom_entry_args[0], entry.comment)
|
||||||
assert_equal(custom_entry_args[2], entry.compressed_size)
|
assert_equal(custom_entry_args[2], entry.compressed_size)
|
||||||
|
@ -75,7 +75,7 @@ class ZipFileTest < MiniTest::Test
|
||||||
end
|
end
|
||||||
|
|
||||||
::Zip::File.open(TEST_ZIP.zip_name) do |zf|
|
::Zip::File.open(TEST_ZIP.zip_name) do |zf|
|
||||||
assert_equal(entryCount+3, zf.size)
|
assert_equal(entryCount + 3, zf.size)
|
||||||
assert_equal('Putting stuff in newEntry.txt', zf.read('newEntry.txt'))
|
assert_equal('Putting stuff in newEntry.txt', zf.read('newEntry.txt'))
|
||||||
assert_equal('Putting stuff in data/generated/empty.txt', zf.read('test/data/generated/empty.txt'))
|
assert_equal('Putting stuff in data/generated/empty.txt', zf.read('test/data/generated/empty.txt'))
|
||||||
assert_equal(File.open('test/data/generated/5entry.zip', 'rb').read, zf.read('entry.bin'))
|
assert_equal(File.open('test/data/generated/5entry.zip', 'rb').read, zf.read('entry.bin'))
|
||||||
|
@ -151,7 +151,7 @@ class ZipFileTest < MiniTest::Test
|
||||||
zf.add(TestFiles::EMPTY_TEST_DIR, TestFiles::EMPTY_TEST_DIR)
|
zf.add(TestFiles::EMPTY_TEST_DIR, TestFiles::EMPTY_TEST_DIR)
|
||||||
end
|
end
|
||||||
::Zip::File.open(TEST_ZIP.zip_name) do |zf|
|
::Zip::File.open(TEST_ZIP.zip_name) do |zf|
|
||||||
dirEntry = zf.entries.detect { |e| e.name == TestFiles::EMPTY_TEST_DIR+'/' }
|
dirEntry = zf.entries.detect { |e| e.name == TestFiles::EMPTY_TEST_DIR + '/' }
|
||||||
assert(dirEntry.directory?)
|
assert(dirEntry.directory?)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -21,11 +21,11 @@ class TestFiles
|
||||||
Dir.mkdir 'test/data/generated' unless Dir.exist?('test/data/generated')
|
Dir.mkdir 'test/data/generated' unless Dir.exist?('test/data/generated')
|
||||||
|
|
||||||
ASCII_TEST_FILES.each_with_index do |filename, index|
|
ASCII_TEST_FILES.each_with_index do |filename, index|
|
||||||
create_random_ascii(filename, 1E4 * (index+1))
|
create_random_ascii(filename, 1E4 * (index + 1))
|
||||||
end
|
end
|
||||||
|
|
||||||
BINARY_TEST_FILES.each_with_index do |filename, index|
|
BINARY_TEST_FILES.each_with_index do |filename, index|
|
||||||
create_random_binary(filename, 1E4 * (index+1))
|
create_random_binary(filename, 1E4 * (index + 1))
|
||||||
end
|
end
|
||||||
|
|
||||||
ensure_dir(EMPTY_TEST_DIR)
|
ensure_dir(EMPTY_TEST_DIR)
|
||||||
|
@ -61,8 +61,8 @@ class TestZipFile
|
||||||
attr_accessor :zip_name, :entry_names, :comment
|
attr_accessor :zip_name, :entry_names, :comment
|
||||||
|
|
||||||
def initialize(zip_name, entry_names, comment = '')
|
def initialize(zip_name, entry_names, comment = '')
|
||||||
@zip_name=zip_name
|
@zip_name = zip_name
|
||||||
@entry_names=entry_names
|
@entry_names = entry_names
|
||||||
@comment = comment
|
@comment = comment
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -75,14 +75,14 @@ class TestZipFile
|
||||||
::File.chmod(0640, 'test/data/generated/empty_chmod640.txt')
|
::File.chmod(0640, 'test/data/generated/empty_chmod640.txt')
|
||||||
|
|
||||||
File.open('test/data/generated/short.txt', 'w') { |file| file << 'ABCDEF' }
|
File.open('test/data/generated/short.txt', 'w') { |file| file << 'ABCDEF' }
|
||||||
ziptestTxt=''
|
ziptestTxt = ''
|
||||||
File.open('test/data/file2.txt') { |file| ziptestTxt=file.read }
|
File.open('test/data/file2.txt') { |file| ziptestTxt = file.read }
|
||||||
File.open('test/data/generated/longAscii.txt', 'w') do |file|
|
File.open('test/data/generated/longAscii.txt', 'w') do |file|
|
||||||
file << ziptestTxt while file.tell < 1E5
|
file << ziptestTxt while file.tell < 1E5
|
||||||
end
|
end
|
||||||
|
|
||||||
testBinaryPattern=''
|
testBinaryPattern = ''
|
||||||
File.open('test/data/generated/empty.zip') { |file| testBinaryPattern=file.read }
|
File.open('test/data/generated/empty.zip') { |file| testBinaryPattern = file.read }
|
||||||
testBinaryPattern *= 4
|
testBinaryPattern *= 4
|
||||||
|
|
||||||
File.open('test/data/generated/longBinary.bin', 'wb') do |file|
|
File.open('test/data/generated/longBinary.bin', 'wb') do |file|
|
||||||
|
|
|
@ -18,8 +18,8 @@ class AbstractInputStreamTest < MiniTest::Test
|
||||||
end
|
end
|
||||||
|
|
||||||
def sysread(charsToRead, _buf = nil)
|
def sysread(charsToRead, _buf = nil)
|
||||||
retVal=@contents[@readPointer, charsToRead]
|
retVal = @contents[@readPointer, charsToRead]
|
||||||
@readPointer+=charsToRead
|
@readPointer += charsToRead
|
||||||
retVal
|
retVal
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -54,8 +54,8 @@ class AbstractInputStreamTest < MiniTest::Test
|
||||||
end
|
end
|
||||||
|
|
||||||
LONG_LINES = [
|
LONG_LINES = [
|
||||||
'x'*48 + "\r\n",
|
'x' * 48 + "\r\n",
|
||||||
'y'*49 + "\r\n",
|
'y' * 49 + "\r\n",
|
||||||
'rest'
|
'rest'
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -69,7 +69,7 @@ class AbstractInputStreamTest < MiniTest::Test
|
||||||
def test_getsWithSepAndIndex
|
def test_getsWithSepAndIndex
|
||||||
io = TestAbstractInputStream.new(LONG_LINES.join)
|
io = TestAbstractInputStream.new(LONG_LINES.join)
|
||||||
assert_equal('x', io.gets("\r\n", 1))
|
assert_equal('x', io.gets("\r\n", 1))
|
||||||
assert_equal('x'*47 + "\r", io.gets("\r\n", 48))
|
assert_equal('x' * 47 + "\r", io.gets("\r\n", 48))
|
||||||
assert_equal("\n", io.gets(nil, 1))
|
assert_equal("\n", io.gets(nil, 1))
|
||||||
assert_equal('yy', io.gets(nil, 2))
|
assert_equal('yy', io.gets(nil, 2))
|
||||||
end
|
end
|
||||||
|
@ -80,10 +80,10 @@ class AbstractInputStreamTest < MiniTest::Test
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_each_line
|
def test_each_line
|
||||||
lineNumber=0
|
lineNumber = 0
|
||||||
@io.each_line do |line|
|
@io.each_line do |line|
|
||||||
assert_equal(TEST_LINES[lineNumber], line)
|
assert_equal(TEST_LINES[lineNumber], line)
|
||||||
lineNumber+=1
|
lineNumber += 1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -43,7 +43,7 @@ class ZipLocalEntryTest < MiniTest::Test
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_read_local_entryFromTruncatedZipFile
|
def test_read_local_entryFromTruncatedZipFile
|
||||||
zipFragment=''
|
zipFragment = ''
|
||||||
::File.open(TestZipFile::TEST_ZIP2.zip_name) { |f| zipFragment = f.read(12) } # local header is at least 30 bytes
|
::File.open(TestZipFile::TEST_ZIP2.zip_name) { |f| zipFragment = f.read(12) } # local header is at least 30 bytes
|
||||||
zipFragment.extend(IOizeString).reset
|
zipFragment.extend(IOizeString).reset
|
||||||
entry = ::Zip::Entry.new
|
entry = ::Zip::Entry.new
|
||||||
|
|
|
@ -39,7 +39,7 @@ module IOizeString
|
||||||
if newPos < 0 || newPos >= size
|
if newPos < 0 || newPos >= size
|
||||||
raise Errno::EINVAL
|
raise Errno::EINVAL
|
||||||
else
|
else
|
||||||
@tell=newPos
|
@tell = newPos
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -80,7 +80,7 @@ module DecompressorTests
|
||||||
|
|
||||||
assert(!@decompressor.input_finished?)
|
assert(!@decompressor.input_finished?)
|
||||||
buf = @decompressor.produce_input
|
buf = @decompressor.produce_input
|
||||||
assert_equal(@refText[100...(100+buf.length)], buf)
|
assert_equal(@refText[100...(100 + buf.length)], buf)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -100,7 +100,7 @@ module AssertEntry
|
||||||
actual = zis.read
|
actual = zis.read
|
||||||
if (expected != actual)
|
if (expected != actual)
|
||||||
if (expected && actual) && (expected.length > 400 || actual.length > 400)
|
if (expected && actual) && (expected.length > 400 || actual.length > 400)
|
||||||
zipEntryFilename=entryName+'.zipEntry'
|
zipEntryFilename = entryName + '.zipEntry'
|
||||||
File.open(zipEntryFilename, 'wb') { |entryfile| entryfile << actual }
|
File.open(zipEntryFilename, 'wb') { |entryfile| entryfile << actual }
|
||||||
fail("File '#{filename}' is different from '#{zipEntryFilename}'")
|
fail("File '#{filename}' is different from '#{zipEntryFilename}'")
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in New Issue