Merge branch 'master' into force-entry-names-encoding-option
This commit is contained in:
commit
deb6616c5f
|
@ -1,2 +1,6 @@
|
|||
inherit_from:
|
||||
- .rubocop_rubyzip.yml
|
||||
AllCops:
|
||||
TargetRubyVersion: 1.9
|
||||
Style/MutableConstant:
|
||||
Enabled: false # Because some existent code relies on mutable constant
|
||||
|
|
|
@ -52,7 +52,7 @@ Zip::File.open(zipfile_name, Zip::File::CREATE) do |zipfile|
|
|||
# Two arguments:
|
||||
# - The name of the file as it will appear in the archive
|
||||
# - The original file, including the path to find it
|
||||
zipfile.add(filename, folder + '/' + filename)
|
||||
zipfile.add(filename, File.join(folder, filename))
|
||||
end
|
||||
zipfile.get_output_stream("myFile") { |os| os.write "myFile contains just this" }
|
||||
end
|
||||
|
|
|
@ -96,7 +96,7 @@ module Zip
|
|||
@size_in_bytes = Entry.read_zip_64_long(buf)
|
||||
@cdir_offset = Entry.read_zip_64_long(buf)
|
||||
@zip_64_extensible = buf.slice!(0, buf.bytesize)
|
||||
raise Error, 'Zip consistency problem while reading eocd structure' unless buf.size == 0
|
||||
raise Error, 'Zip consistency problem while reading eocd structure' unless buf.empty?
|
||||
end
|
||||
|
||||
def read_e_o_c_d(buf) #:nodoc:
|
||||
|
@ -113,7 +113,7 @@ module Zip
|
|||
else
|
||||
buf.read(comment_length)
|
||||
end
|
||||
raise Error, 'Zip consistency problem while reading eocd structure' unless buf.size == 0
|
||||
raise Error, 'Zip consistency problem while reading eocd structure' unless buf.empty?
|
||||
end
|
||||
|
||||
def read_central_directory_entries(io) #:nodoc:
|
||||
|
@ -130,7 +130,7 @@ module Zip
|
|||
|
||||
def read_from_stream(io) #:nodoc:
|
||||
buf = start_buf(io)
|
||||
if self.zip64_file?(buf)
|
||||
if zip64_file?(buf)
|
||||
read_64_e_o_c_d(buf)
|
||||
else
|
||||
read_e_o_c_d(buf)
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
module Zip
|
||||
class Compressor #:nodoc:all
|
||||
def finish
|
||||
end
|
||||
def finish; end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -11,9 +11,9 @@ module Zip
|
|||
VERSION_NEEDED_TO_EXTRACT = 20
|
||||
VERSION_NEEDED_TO_EXTRACT_ZIP64 = 45
|
||||
|
||||
FILE_TYPE_FILE = 010
|
||||
FILE_TYPE_DIR = 004
|
||||
FILE_TYPE_SYMLINK = 012
|
||||
FILE_TYPE_FILE = 0o10
|
||||
FILE_TYPE_DIR = 0o04
|
||||
FILE_TYPE_SYMLINK = 0o12
|
||||
|
||||
FSTYPE_FAT = 0
|
||||
FSTYPE_AMIGA = 1
|
||||
|
|
|
@ -24,8 +24,7 @@ module Zip
|
|||
''
|
||||
end
|
||||
|
||||
def reset!
|
||||
end
|
||||
def reset!; end
|
||||
end
|
||||
|
||||
class NullDecrypter < Decrypter
|
||||
|
@ -35,8 +34,7 @@ module Zip
|
|||
data
|
||||
end
|
||||
|
||||
def reset!(_header)
|
||||
end
|
||||
def reset!(_header); end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ module Zip
|
|||
end
|
||||
|
||||
def to_binary_dos_date
|
||||
(day) +
|
||||
day +
|
||||
(month << 5) +
|
||||
((year - 1980) << 9)
|
||||
end
|
||||
|
|
|
@ -99,7 +99,7 @@ module Zip
|
|||
end
|
||||
|
||||
# Dynamic checkers
|
||||
%w(directory file symlink).each do |k|
|
||||
%w[directory file symlink].each do |k|
|
||||
define_method "#{k}?" do
|
||||
file_type_is?(k.to_sym)
|
||||
end
|
||||
|
@ -239,7 +239,7 @@ module Zip
|
|||
@name = io.read(@name_length)
|
||||
extra = io.read(@extra_length)
|
||||
|
||||
@name.gsub!('\\', '/')
|
||||
@name.tr!('\\', '/')
|
||||
if ::Zip.force_entry_names_encoding
|
||||
@name.force_encoding(::Zip.force_entry_names_encoding)
|
||||
end
|
||||
|
@ -266,8 +266,8 @@ module Zip
|
|||
@time.to_binary_dos_time, # @last_mod_time ,
|
||||
@time.to_binary_dos_date, # @last_mod_date ,
|
||||
@crc,
|
||||
(zip64 && zip64.compressed_size) ? 0xFFFFFFFF : @compressed_size,
|
||||
(zip64 && zip64.original_size) ? 0xFFFFFFFF : @size,
|
||||
zip64 && zip64.compressed_size ? 0xFFFFFFFF : @compressed_size,
|
||||
zip64 && zip64.original_size ? 0xFFFFFFFF : @size,
|
||||
name_size,
|
||||
@extra ? @extra.local_size : 0].pack('VvvvvvVVVvv')
|
||||
end
|
||||
|
@ -311,7 +311,7 @@ module Zip
|
|||
def set_ftype_from_c_dir_entry
|
||||
@ftype = case @fstype
|
||||
when ::Zip::FSTYPE_UNIX
|
||||
@unix_perms = (@external_file_attributes >> 16) & 07777
|
||||
@unix_perms = (@external_file_attributes >> 16) & 0o7777
|
||||
case (@external_file_attributes >> 28)
|
||||
when ::Zip::FILE_TYPE_DIR
|
||||
:directory
|
||||
|
@ -390,14 +390,14 @@ module Zip
|
|||
stat = file_stat(path)
|
||||
@unix_uid = stat.uid
|
||||
@unix_gid = stat.gid
|
||||
@unix_perms = stat.mode & 07777
|
||||
@unix_perms = stat.mode & 0o7777
|
||||
end
|
||||
|
||||
def set_unix_permissions_on_path(dest_path)
|
||||
# BUG: does not update timestamps into account
|
||||
# ignore setuid/setgid bits by default. honor if @restore_ownership
|
||||
unix_perms_mask = 01777
|
||||
unix_perms_mask = 07777 if @restore_ownership
|
||||
unix_perms_mask = 0o1777
|
||||
unix_perms_mask = 0o7777 if @restore_ownership
|
||||
::FileUtils.chmod(@unix_perms & unix_perms_mask, dest_path) if @restore_permissions && @unix_perms
|
||||
::FileUtils.chown(@unix_uid, @unix_gid, dest_path) if @restore_ownership && @unix_uid && @unix_gid && ::Process.egid == 0
|
||||
# File::utimes()
|
||||
|
@ -424,15 +424,15 @@ module Zip
|
|||
@time.to_binary_dos_time, # @last_mod_time ,
|
||||
@time.to_binary_dos_date, # @last_mod_date ,
|
||||
@crc,
|
||||
(zip64 && zip64.compressed_size) ? 0xFFFFFFFF : @compressed_size,
|
||||
(zip64 && zip64.original_size) ? 0xFFFFFFFF : @size,
|
||||
zip64 && zip64.compressed_size ? 0xFFFFFFFF : @compressed_size,
|
||||
zip64 && zip64.original_size ? 0xFFFFFFFF : @size,
|
||||
name_size,
|
||||
@extra ? @extra.c_dir_size : 0,
|
||||
comment_size,
|
||||
(zip64 && zip64.disk_start_number) ? 0xFFFF : 0, # disk number start
|
||||
zip64 && zip64.disk_start_number ? 0xFFFF : 0, # disk number start
|
||||
@internal_file_attributes, # file type (binary=0, text=1)
|
||||
@external_file_attributes, # native filesystem attributes
|
||||
(zip64 && zip64.relative_header_offset) ? 0xFFFFFFFF : @local_header_offset,
|
||||
zip64 && zip64.relative_header_offset ? 0xFFFFFFFF : @local_header_offset,
|
||||
@name,
|
||||
@extra,
|
||||
@comment
|
||||
|
@ -445,18 +445,18 @@ module Zip
|
|||
when ::Zip::FSTYPE_UNIX
|
||||
ft = case @ftype
|
||||
when :file
|
||||
@unix_perms ||= 0644
|
||||
@unix_perms ||= 0o644
|
||||
::Zip::FILE_TYPE_FILE
|
||||
when :directory
|
||||
@unix_perms ||= 0755
|
||||
@unix_perms ||= 0o755
|
||||
::Zip::FILE_TYPE_DIR
|
||||
when :symlink
|
||||
@unix_perms ||= 0755
|
||||
@unix_perms ||= 0o755
|
||||
::Zip::FILE_TYPE_SYMLINK
|
||||
end
|
||||
|
||||
unless ft.nil?
|
||||
@external_file_attributes = (ft << 12 | (@unix_perms & 07777)) << 16
|
||||
@external_file_attributes = (ft << 12 | (@unix_perms & 0o7777)) << 16
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -470,7 +470,7 @@ module Zip
|
|||
def ==(other)
|
||||
return false unless other.class == self.class
|
||||
# Compares contents of local entry and exposed fields
|
||||
keys_equal = %w(compression_method crc compressed_size size name extra filepath).all? do |k|
|
||||
keys_equal = %w[compression_method crc compressed_size size name extra filepath].all? do |k|
|
||||
other.__send__(k.to_sym) == __send__(k.to_sym)
|
||||
end
|
||||
keys_equal && time.dos_equals(other.time)
|
||||
|
|
|
@ -33,9 +33,9 @@ module Zip
|
|||
entry if @entry_set.delete(to_key(entry))
|
||||
end
|
||||
|
||||
def each(&block)
|
||||
def each
|
||||
@entry_set = sorted_entries.dup.each do |_, value|
|
||||
block.call(value)
|
||||
yield(value)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ module Zip
|
|||
|
||||
def extra_field_type_exist(binstr, id, len, i)
|
||||
field_name = ID_MAP[id].name
|
||||
if self.member?(field_name)
|
||||
if member?(field_name)
|
||||
self[field_name].merge(binstr[i, len + 4])
|
||||
else
|
||||
field_obj = ID_MAP[id].new(binstr[i, len + 4])
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
module Zip
|
||||
class ExtraField::Generic
|
||||
def self.register_map
|
||||
if self.const_defined?(:HEADER_ID)
|
||||
if const_defined?(:HEADER_ID)
|
||||
::Zip::ExtraField::ID_MAP[const_get(:HEADER_ID)] = self
|
||||
end
|
||||
end
|
||||
|
|
|
@ -6,8 +6,7 @@ module Zip
|
|||
HEADER_ID = ['9999'].pack('H*') # this ID is used by other libraries such as .NET's Ionic.zip
|
||||
register_map
|
||||
|
||||
def initialize(_binstr = nil)
|
||||
end
|
||||
def initialize(_binstr = nil); end
|
||||
|
||||
def pack_for_local
|
||||
"\x00" * 16
|
||||
|
|
|
@ -69,16 +69,15 @@ module Zip
|
|||
@name = file_name
|
||||
@comment = ''
|
||||
@create = create ? true : false # allow any truthy value to mean true
|
||||
case
|
||||
when !buffer && ::File.size?(file_name)
|
||||
if !buffer && ::File.size?(file_name)
|
||||
@create = false
|
||||
@file_permissions = ::File.stat(file_name).mode
|
||||
::File.open(name, 'rb') do |f|
|
||||
read_from_stream(f)
|
||||
end
|
||||
when @create
|
||||
elsif @create
|
||||
@entry_set = EntrySet.new
|
||||
when ::File.zero?(file_name)
|
||||
elsif ::File.zero?(file_name)
|
||||
raise Error, "File #{file_name} has zero size. Did you mean to pass the create flag?"
|
||||
else
|
||||
raise Error, "File #{file_name} not found"
|
||||
|
@ -151,10 +150,9 @@ module Zip
|
|||
end
|
||||
|
||||
def get_segment_size_for_split(segment_size)
|
||||
case
|
||||
when MIN_SEGMENT_SIZE > segment_size
|
||||
if MIN_SEGMENT_SIZE > segment_size
|
||||
MIN_SEGMENT_SIZE
|
||||
when MAX_SEGMENT_SIZE < segment_size
|
||||
elsif MAX_SEGMENT_SIZE < segment_size
|
||||
MAX_SEGMENT_SIZE
|
||||
else
|
||||
segment_size
|
||||
|
@ -162,8 +160,10 @@ module Zip
|
|||
end
|
||||
|
||||
def get_partial_zip_file_name(zip_file_name, partial_zip_file_name)
|
||||
unless partial_zip_file_name.nil?
|
||||
partial_zip_file_name = zip_file_name.sub(/#{::File.basename(zip_file_name)}\z/,
|
||||
partial_zip_file_name + ::File.extname(zip_file_name)) unless partial_zip_file_name.nil?
|
||||
partial_zip_file_name + ::File.extname(zip_file_name))
|
||||
end
|
||||
partial_zip_file_name ||= zip_file_name
|
||||
partial_zip_file_name
|
||||
end
|
||||
|
@ -366,7 +366,7 @@ module Zip
|
|||
end
|
||||
|
||||
# Creates a directory
|
||||
def mkdir(entryName, permissionInt = 0755)
|
||||
def mkdir(entryName, permissionInt = 0o755)
|
||||
raise Errno::EEXIST, "File exists - #{entryName}" if find_entry(entryName)
|
||||
entryName = entryName.dup.to_s
|
||||
entryName << '/' unless entryName.end_with?('/')
|
||||
|
|
|
@ -142,9 +142,9 @@ module Zip
|
|||
|
||||
def ftype
|
||||
if file?
|
||||
return 'file'
|
||||
'file'
|
||||
elsif directory?
|
||||
return 'directory'
|
||||
'directory'
|
||||
else
|
||||
raise StandardError, 'Unknown file type'
|
||||
end
|
||||
|
@ -198,30 +198,30 @@ module Zip
|
|||
alias grpowned? exists?
|
||||
|
||||
def readable?(fileName)
|
||||
unix_mode_cmp(fileName, 0444)
|
||||
unix_mode_cmp(fileName, 0o444)
|
||||
end
|
||||
alias readable_real? readable?
|
||||
|
||||
def writable?(fileName)
|
||||
unix_mode_cmp(fileName, 0222)
|
||||
unix_mode_cmp(fileName, 0o222)
|
||||
end
|
||||
alias writable_real? writable?
|
||||
|
||||
def executable?(fileName)
|
||||
unix_mode_cmp(fileName, 0111)
|
||||
unix_mode_cmp(fileName, 0o111)
|
||||
end
|
||||
alias executable_real? executable?
|
||||
|
||||
def setuid?(fileName)
|
||||
unix_mode_cmp(fileName, 04000)
|
||||
unix_mode_cmp(fileName, 0o4000)
|
||||
end
|
||||
|
||||
def setgid?(fileName)
|
||||
unix_mode_cmp(fileName, 02000)
|
||||
unix_mode_cmp(fileName, 0o2000)
|
||||
end
|
||||
|
||||
def sticky?(fileName)
|
||||
unix_mode_cmp(fileName, 01000)
|
||||
unix_mode_cmp(fileName, 0o1000)
|
||||
end
|
||||
|
||||
def umask(*args)
|
||||
|
@ -237,8 +237,8 @@ module Zip
|
|||
expand_path(fileName) == '/' || (!entry.nil? && entry.directory?)
|
||||
end
|
||||
|
||||
def open(fileName, openMode = 'r', permissionInt = 0644, &block)
|
||||
openMode.gsub!('b', '') # ignore b option
|
||||
def open(fileName, openMode = 'r', permissionInt = 0o644, &block)
|
||||
openMode.delete!('b') # ignore b option
|
||||
case openMode
|
||||
when 'r'
|
||||
@mappedZip.get_input_stream(fileName, &block)
|
||||
|
@ -260,7 +260,7 @@ module Zip
|
|||
# Returns nil for not found and nil for directories
|
||||
def size?(fileName)
|
||||
entry = @mappedZip.find_entry(fileName)
|
||||
(entry.nil? || entry.directory?) ? nil : entry.size
|
||||
entry.nil? || entry.directory? ? nil : entry.size
|
||||
end
|
||||
|
||||
def chown(ownerInt, groupInt, *filenames)
|
||||
|
@ -498,7 +498,7 @@ module Zip
|
|||
alias rmdir delete
|
||||
alias unlink delete
|
||||
|
||||
def mkdir(entryName, permissionInt = 0755)
|
||||
def mkdir(entryName, permissionInt = 0o755)
|
||||
@mappedZip.mkdir(entryName, permissionInt)
|
||||
end
|
||||
|
||||
|
@ -586,7 +586,7 @@ module Zip
|
|||
&continueOnExistsProc)
|
||||
end
|
||||
|
||||
def mkdir(fileName, permissionInt = 0755)
|
||||
def mkdir(fileName, permissionInt = 0o755)
|
||||
@zipFile.mkdir(expand_to_entry(fileName), permissionInt)
|
||||
end
|
||||
|
||||
|
|
|
@ -129,7 +129,7 @@ module Zip
|
|||
end
|
||||
if @current_entry && @current_entry.gp_flags & 8 == 8 && @current_entry.crc == 0 \
|
||||
&& @current_entry.compressed_size == 0 \
|
||||
&& @current_entry.size == 0 && !@internal
|
||||
&& @current_entry.empty? && !@internal
|
||||
raise GPFBit3Error,
|
||||
'General purpose flag Bit 3 is set so not possible to get proper info from local header.' \
|
||||
'Please use ::Zip::File instead of ::Zip::InputStream'
|
||||
|
@ -140,12 +140,11 @@ module Zip
|
|||
end
|
||||
|
||||
def get_decompressor
|
||||
case
|
||||
when @current_entry.nil?
|
||||
if @current_entry.nil?
|
||||
::Zip::NullDecompressor
|
||||
when @current_entry.compression_method == ::Zip::Entry::STORED
|
||||
elsif @current_entry.compression_method == ::Zip::Entry::STORED
|
||||
::Zip::PassThruDecompressor.new(@archive_io, @current_entry.size)
|
||||
when @current_entry.compression_method == ::Zip::Entry::DEFLATED
|
||||
elsif @current_entry.compression_method == ::Zip::Entry::DEFLATED
|
||||
header = @archive_io.read(@decrypter.header_bytesize)
|
||||
@decrypter.reset!(header)
|
||||
::Zip::Inflater.new(@archive_io, @decrypter)
|
||||
|
|
|
@ -33,7 +33,7 @@ module Zip
|
|||
sysread(number_of_bytes, buf)
|
||||
end
|
||||
|
||||
if tbuf.nil? || tbuf.length == 0
|
||||
if tbuf.nil? || tbuf.empty?
|
||||
return nil if number_of_bytes
|
||||
return ''
|
||||
end
|
||||
|
|
|
@ -15,7 +15,7 @@ module Zip
|
|||
end
|
||||
|
||||
def printf(a_format_string, *params)
|
||||
self << sprintf(a_format_string, *params)
|
||||
self << format(a_format_string, *params)
|
||||
end
|
||||
|
||||
def putc(an_object)
|
||||
|
|
|
@ -87,10 +87,10 @@ module Zip
|
|||
# +entry+ can be a ZipEntry object or a string.
|
||||
def put_next_entry(entry_name, comment = nil, extra = nil, compression_method = Entry::DEFLATED, level = Zip.default_compression)
|
||||
raise Error, 'zip stream is closed' if @closed
|
||||
if entry_name.kind_of?(Entry)
|
||||
new_entry = entry_name
|
||||
new_entry = if entry_name.kind_of?(Entry)
|
||||
entry_name
|
||||
else
|
||||
new_entry = Entry.new(@file_name, entry_name.to_s)
|
||||
Entry.new(@file_name, entry_name.to_s)
|
||||
end
|
||||
new_entry.comment = comment unless comment.nil?
|
||||
unless extra.nil?
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
#-*- encoding: utf-8 -*-
|
||||
|
||||
lib = File.expand_path('../lib', __FILE__)
|
||||
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
||||
require 'zip/version'
|
||||
|
@ -11,7 +12,7 @@ Gem::Specification.new do |s|
|
|||
s.homepage = 'http://github.com/rubyzip/rubyzip'
|
||||
s.platform = Gem::Platform::RUBY
|
||||
s.summary = 'rubyzip is a ruby module for reading and writing zip files'
|
||||
s.files = Dir.glob('{samples,lib}/**/*.rb') + %w(README.md TODO Rakefile)
|
||||
s.files = Dir.glob('{samples,lib}/**/*.rb') + %w[README.md TODO Rakefile]
|
||||
s.test_files = Dir.glob('test/**/*')
|
||||
s.require_paths = ['lib']
|
||||
s.license = 'BSD 2-Clause'
|
||||
|
@ -20,4 +21,5 @@ Gem::Specification.new do |s|
|
|||
s.add_development_dependency 'pry', '~> 0.10'
|
||||
s.add_development_dependency 'minitest', '~> 5.4'
|
||||
s.add_development_dependency 'coveralls', '~> 0.7'
|
||||
s.add_development_dependency 'rubocop', '~> 0.49.1'
|
||||
end
|
||||
|
|
|
@ -19,7 +19,7 @@ class ZipFileGenerator
|
|||
|
||||
# Zip the input directory.
|
||||
def write
|
||||
entries = Dir.entries(@input_dir) - %w(. ..)
|
||||
entries = Dir.entries(@input_dir) - %w[. ..]
|
||||
|
||||
::Zip::File.open(@output_file, ::Zip::File::CREATE) do |io|
|
||||
write_entries entries, '', io
|
||||
|
@ -45,7 +45,7 @@ class ZipFileGenerator
|
|||
|
||||
def recursively_deflate_directory(disk_file_path, io, zip_file_path)
|
||||
io.mkdir zip_file_path
|
||||
subdir = Dir.entries(disk_file_path) - %w(. ..)
|
||||
subdir = Dir.entries(disk_file_path) - %w[. ..]
|
||||
write_entries subdir, zip_file_path, io
|
||||
end
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ class MainApp < Gtk::Window
|
|||
sw.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC)
|
||||
box.pack_start(sw, true, true, 0)
|
||||
|
||||
@clist = Gtk::CList.new(%w(Name Size Compression))
|
||||
@clist = Gtk::CList.new(%w[Name Size Compression])
|
||||
@clist.set_selection_mode(Gtk::SELECTION_BROWSE)
|
||||
@clist.set_column_width(0, 120)
|
||||
@clist.set_column_width(1, 120)
|
||||
|
|
|
@ -65,7 +65,7 @@ class ZipDialog < ZipDialogUI
|
|||
end
|
||||
puts "selected_items.size = #{selected_items.size}"
|
||||
puts "unselected_items.size = #{unselected_items.size}"
|
||||
items = selected_items.size > 0 ? selected_items : unselected_items
|
||||
items = !selected_items.empty? ? selected_items : unselected_items
|
||||
puts "items.size = #{items.size}"
|
||||
|
||||
d = Qt::FileDialog.get_existing_directory(nil, self)
|
||||
|
|
|
@ -31,7 +31,7 @@ module Zip
|
|||
end
|
||||
end
|
||||
|
||||
if __FILE__ == $0
|
||||
if $0 == __FILE__
|
||||
module ZipFindConsoleRunner
|
||||
PATH_ARG_INDEX = 0
|
||||
FILENAME_PATTERN_ARG_INDEX = 1
|
||||
|
@ -47,7 +47,7 @@ if __FILE__ == $0
|
|||
end
|
||||
|
||||
def self.check_args(args)
|
||||
if (args.size != 3)
|
||||
if args.size != 3
|
||||
usage
|
||||
exit
|
||||
end
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
# encoding: utf-8
|
||||
|
||||
require 'test_helper'
|
||||
|
||||
class ErrorsTest < MiniTest::Test
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
require 'test_helper'
|
||||
|
||||
class FilePermissionsTest < MiniTest::Test
|
||||
|
||||
ZIPNAME = File.join(File.dirname(__FILE__), "umask.zip")
|
||||
FILENAME = File.join(File.dirname(__FILE__), "umask.txt")
|
||||
ZIPNAME = File.join(File.dirname(__FILE__), 'umask.zip')
|
||||
FILENAME = File.join(File.dirname(__FILE__), 'umask.txt')
|
||||
|
||||
def teardown
|
||||
::File.unlink(ZIPNAME)
|
||||
|
@ -16,7 +15,7 @@ class FilePermissionsTest < MiniTest::Test
|
|||
end
|
||||
|
||||
def test_umask_000
|
||||
set_umask(0000) do
|
||||
set_umask(0o000) do
|
||||
create_files
|
||||
end
|
||||
|
||||
|
@ -24,7 +23,7 @@ class FilePermissionsTest < MiniTest::Test
|
|||
end
|
||||
|
||||
def test_umask_066
|
||||
set_umask(0066) do
|
||||
set_umask(0o066) do
|
||||
create_files
|
||||
end
|
||||
|
||||
|
@ -32,7 +31,7 @@ class FilePermissionsTest < MiniTest::Test
|
|||
end
|
||||
|
||||
def test_umask_027
|
||||
set_umask(0027) do
|
||||
set_umask(0o027) do
|
||||
create_files
|
||||
end
|
||||
|
||||
|
@ -48,7 +47,7 @@ class FilePermissionsTest < MiniTest::Test
|
|||
|
||||
def create_files
|
||||
::Zip::File.open(ZIPNAME, ::Zip::File::CREATE) do |zip|
|
||||
zip.comment = "test"
|
||||
zip.comment = 'test'
|
||||
end
|
||||
|
||||
::File.open(FILENAME, 'w') do |file|
|
||||
|
@ -57,13 +56,10 @@ class FilePermissionsTest < MiniTest::Test
|
|||
end
|
||||
|
||||
# If anything goes wrong, make sure the umask is restored.
|
||||
def set_umask(umask, &block)
|
||||
begin
|
||||
def set_umask(umask)
|
||||
saved_umask = ::File.umask(umask)
|
||||
yield
|
||||
ensure
|
||||
::File.umask(saved_umask)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -142,15 +142,15 @@ class ZipFileTest < MiniTest::Test
|
|||
|
||||
def test_recover_permissions_after_add_files_to_archive
|
||||
srcZip = TEST_ZIP.zip_name
|
||||
::File.chmod(0664, srcZip)
|
||||
::File.chmod(0o664, srcZip)
|
||||
srcFile = 'test/data/file2.txt'
|
||||
entryName = 'newEntryName.rb'
|
||||
assert_equal(::File.stat(srcZip).mode, 0100664)
|
||||
assert_equal(::File.stat(srcZip).mode, 0o100664)
|
||||
assert(::File.exist?(srcZip))
|
||||
zf = ::Zip::File.new(srcZip, ::Zip::File::CREATE)
|
||||
zf.add(entryName, srcFile)
|
||||
zf.close
|
||||
assert_equal(::File.stat(srcZip).mode, 0100664)
|
||||
assert_equal(::File.stat(srcZip).mode, 0o100664)
|
||||
end
|
||||
|
||||
def test_add_existing_entry_name
|
||||
|
@ -234,7 +234,7 @@ class ZipFileTest < MiniTest::Test
|
|||
zf.mkdir('test')
|
||||
arr << 'test/'
|
||||
arr_renamed << 'Ztest/'
|
||||
%w(a b c d).each do |f|
|
||||
%w[a b c d].each do |f|
|
||||
zf.get_output_stream("test/#{f}") { |file| file.puts 'aaaa' }
|
||||
arr << "test/#{f}"
|
||||
arr_renamed << "Ztest/#{f}"
|
||||
|
@ -434,7 +434,6 @@ class ZipFileTest < MiniTest::Test
|
|||
filename_to_remove = originalEntries.map(&:to_s).find { |name| name.match('longBinary') }
|
||||
zf.remove(filename_to_remove)
|
||||
assert_not_contains(zf, filename_to_remove)
|
||||
|
||||
ensure
|
||||
zf.close
|
||||
end
|
||||
|
@ -558,7 +557,7 @@ class ZipFileTest < MiniTest::Test
|
|||
entry_count = 0
|
||||
File.open 'test/data/oddExtraField.zip', 'rb' do |zip_io|
|
||||
Zip::File.open_buffer zip_io.read do |zip|
|
||||
zip.each do |zip_entry|
|
||||
zip.each do |_zip_entry|
|
||||
entry_count += 1
|
||||
end
|
||||
end
|
||||
|
|
|
@ -2,7 +2,7 @@ require 'test_helper'
|
|||
require 'zip/filesystem'
|
||||
|
||||
class ZipFsDirIteratorTest < MiniTest::Test
|
||||
FILENAME_ARRAY = %w(f1 f2 f3 f4 f5 f6)
|
||||
FILENAME_ARRAY = %w[f1 f2 f3 f4 f5 f6]
|
||||
|
||||
def setup
|
||||
@dirIt = ::Zip::FileSystem::ZipFsDirIterator.new(FILENAME_ARRAY)
|
||||
|
|
|
@ -51,10 +51,10 @@ class ZipFsDirectoryTest < MiniTest::Test
|
|||
zf.dir.chdir 'file1'
|
||||
end
|
||||
|
||||
assert_equal(%w(dir1 dir2 file1).sort, zf.dir.entries('.').sort)
|
||||
assert_equal(%w[dir1 dir2 file1].sort, zf.dir.entries('.').sort)
|
||||
zf.dir.chdir 'dir1'
|
||||
assert_equal('/dir1', zf.dir.pwd)
|
||||
assert_equal(%w(dir11 file11 file12), zf.dir.entries('.').sort)
|
||||
assert_equal(%w[dir11 file11 file12], zf.dir.entries('.').sort)
|
||||
|
||||
zf.dir.chdir '../dir2/dir21'
|
||||
assert_equal('/dir2/dir21', zf.dir.pwd)
|
||||
|
@ -77,11 +77,11 @@ class ZipFsDirectoryTest < MiniTest::Test
|
|||
|
||||
entries = []
|
||||
zf.dir.foreach('.') { |e| entries << e }
|
||||
assert_equal(%w(dir1 dir2 file1).sort, entries.sort)
|
||||
assert_equal(%w[dir1 dir2 file1].sort, entries.sort)
|
||||
|
||||
entries = []
|
||||
zf.dir.foreach('dir1') { |e| entries << e }
|
||||
assert_equal(%w(dir11 file11 file12), entries.sort)
|
||||
assert_equal(%w[dir11 file11 file12], entries.sort)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -110,11 +110,11 @@ class ZipFsDirectoryTest < MiniTest::Test
|
|||
end
|
||||
|
||||
d = zf.dir.new('.')
|
||||
assert_equal(%w(file1 dir1 dir2).sort, d.entries.sort)
|
||||
assert_equal(%w[file1 dir1 dir2].sort, d.entries.sort)
|
||||
d.close
|
||||
|
||||
zf.dir.open('dir1') do |dir|
|
||||
assert_equal(%w(dir11 file11 file12).sort, dir.entries.sort)
|
||||
assert_equal(%w[dir11 file11 file12].sort, dir.entries.sort)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -7,8 +7,7 @@ class ZipFsFileMutatingTest < MiniTest::Test
|
|||
FileUtils.cp('test/data/zipWithDirs.zip', TEST_ZIP)
|
||||
end
|
||||
|
||||
def teardown
|
||||
end
|
||||
def teardown; end
|
||||
|
||||
def test_delete
|
||||
do_test_delete_or_unlink(:delete)
|
||||
|
@ -51,11 +50,11 @@ class ZipFsFileMutatingTest < MiniTest::Test
|
|||
|
||||
def test_chmod
|
||||
::Zip::File.open(TEST_ZIP) do |zf|
|
||||
zf.file.chmod(0765, 'file1')
|
||||
zf.file.chmod(0o765, 'file1')
|
||||
end
|
||||
|
||||
::Zip::File.open(TEST_ZIP) do |zf|
|
||||
assert_equal(0100765, zf.file.stat('file1').mode)
|
||||
assert_equal(0o100765, zf.file.stat('file1').mode)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -14,11 +14,11 @@ class ZipFsFileNonmutatingTest < MiniTest::Test
|
|||
|
||||
def test_umask
|
||||
assert_equal(::File.umask, @zip_file.file.umask)
|
||||
@zip_file.file.umask(0006)
|
||||
@zip_file.file.umask(0o006)
|
||||
end
|
||||
|
||||
def test_exists?
|
||||
assert(! @zip_file.file.exists?('notAFile'))
|
||||
assert(!@zip_file.file.exists?('notAFile'))
|
||||
assert(@zip_file.file.exists?('file1'))
|
||||
assert(@zip_file.file.exists?('dir1'))
|
||||
assert(@zip_file.file.exists?('dir1/'))
|
||||
|
@ -114,13 +114,13 @@ class ZipFsFileNonmutatingTest < MiniTest::Test
|
|||
def test_file?
|
||||
assert(@zip_file.file.file?('file1'))
|
||||
assert(@zip_file.file.file?('dir2/file21'))
|
||||
assert(! @zip_file.file.file?('dir1'))
|
||||
assert(! @zip_file.file.file?('dir1/dir11'))
|
||||
assert(!@zip_file.file.file?('dir1'))
|
||||
assert(!@zip_file.file.file?('dir1/dir11'))
|
||||
|
||||
assert(@zip_file.file.stat('file1').file?)
|
||||
assert(@zip_file.file.stat('dir2/file21').file?)
|
||||
assert(! @zip_file.file.stat('dir1').file?)
|
||||
assert(! @zip_file.file.stat('dir1/dir11').file?)
|
||||
assert(!@zip_file.file.stat('dir1').file?)
|
||||
assert(!@zip_file.file.stat('dir1/dir11').file?)
|
||||
end
|
||||
|
||||
include ExtraAssertions
|
||||
|
@ -160,15 +160,15 @@ class ZipFsFileNonmutatingTest < MiniTest::Test
|
|||
end
|
||||
|
||||
def assert_always_false(operation)
|
||||
assert(! @zip_file.file.send(operation, 'noSuchFile'))
|
||||
assert(! @zip_file.file.send(operation, 'file1'))
|
||||
assert(! @zip_file.file.send(operation, 'dir1'))
|
||||
assert(! @zip_file.file.stat('file1').send(operation))
|
||||
assert(! @zip_file.file.stat('dir1').send(operation))
|
||||
assert(!@zip_file.file.send(operation, 'noSuchFile'))
|
||||
assert(!@zip_file.file.send(operation, 'file1'))
|
||||
assert(!@zip_file.file.send(operation, 'dir1'))
|
||||
assert(!@zip_file.file.stat('file1').send(operation))
|
||||
assert(!@zip_file.file.stat('dir1').send(operation))
|
||||
end
|
||||
|
||||
def assert_true_if_entry_exists(operation)
|
||||
assert(! @zip_file.file.send(operation, 'noSuchFile'))
|
||||
assert(!@zip_file.file.send(operation, 'noSuchFile'))
|
||||
assert(@zip_file.file.send(operation, 'file1'))
|
||||
assert(@zip_file.file.send(operation, 'dir1'))
|
||||
assert(@zip_file.file.stat('file1').send(operation))
|
||||
|
@ -221,15 +221,15 @@ class ZipFsFileNonmutatingTest < MiniTest::Test
|
|||
end
|
||||
|
||||
def test_directory?
|
||||
assert(! @zip_file.file.directory?('notAFile'))
|
||||
assert(! @zip_file.file.directory?('file1'))
|
||||
assert(! @zip_file.file.directory?('dir1/file11'))
|
||||
assert(!@zip_file.file.directory?('notAFile'))
|
||||
assert(!@zip_file.file.directory?('file1'))
|
||||
assert(!@zip_file.file.directory?('dir1/file11'))
|
||||
assert(@zip_file.file.directory?('dir1'))
|
||||
assert(@zip_file.file.directory?('dir1/'))
|
||||
assert(@zip_file.file.directory?('dir2/dir21'))
|
||||
|
||||
assert(! @zip_file.file.stat('file1').directory?)
|
||||
assert(! @zip_file.file.stat('dir1/file11').directory?)
|
||||
assert(!@zip_file.file.stat('file1').directory?)
|
||||
assert(!@zip_file.file.stat('dir1/file11').directory?)
|
||||
assert(@zip_file.file.stat('dir1').directory?)
|
||||
assert(@zip_file.file.stat('dir1/').directory?)
|
||||
assert(@zip_file.file.stat('dir2/dir21').directory?)
|
||||
|
@ -243,8 +243,8 @@ class ZipFsFileNonmutatingTest < MiniTest::Test
|
|||
end
|
||||
|
||||
def test_zero?
|
||||
assert(! @zip_file.file.zero?('notAFile'))
|
||||
assert(! @zip_file.file.zero?('file1'))
|
||||
assert(!@zip_file.file.zero?('notAFile'))
|
||||
assert(!@zip_file.file.zero?('file1'))
|
||||
assert(@zip_file.file.zero?('dir1'))
|
||||
blockCalled = false
|
||||
::Zip::File.open('test/data/generated/5entry.zip') do |zf|
|
||||
|
@ -253,7 +253,7 @@ class ZipFsFileNonmutatingTest < MiniTest::Test
|
|||
end
|
||||
assert(blockCalled)
|
||||
|
||||
assert(! @zip_file.file.stat('file1').zero?)
|
||||
assert(!@zip_file.file.stat('file1').zero?)
|
||||
assert(@zip_file.file.stat('dir1').zero?)
|
||||
blockCalled = false
|
||||
::Zip::File.open('test/data/generated/5entry.zip') do |zf|
|
||||
|
@ -309,7 +309,7 @@ class ZipFsFileNonmutatingTest < MiniTest::Test
|
|||
end
|
||||
|
||||
def test_readable?
|
||||
assert(! @zip_file.file.readable?('noSuchFile'))
|
||||
assert(!@zip_file.file.readable?('noSuchFile'))
|
||||
assert(@zip_file.file.readable?('file1'))
|
||||
assert(@zip_file.file.readable?('dir1'))
|
||||
assert(@zip_file.file.stat('file1').readable?)
|
||||
|
@ -317,7 +317,7 @@ class ZipFsFileNonmutatingTest < MiniTest::Test
|
|||
end
|
||||
|
||||
def test_readable_real?
|
||||
assert(! @zip_file.file.readable_real?('noSuchFile'))
|
||||
assert(!@zip_file.file.readable_real?('noSuchFile'))
|
||||
assert(@zip_file.file.readable_real?('file1'))
|
||||
assert(@zip_file.file.readable_real?('dir1'))
|
||||
assert(@zip_file.file.stat('file1').readable_real?)
|
||||
|
@ -325,7 +325,7 @@ class ZipFsFileNonmutatingTest < MiniTest::Test
|
|||
end
|
||||
|
||||
def test_writable?
|
||||
assert(! @zip_file.file.writable?('noSuchFile'))
|
||||
assert(!@zip_file.file.writable?('noSuchFile'))
|
||||
assert(@zip_file.file.writable?('file1'))
|
||||
assert(@zip_file.file.writable?('dir1'))
|
||||
assert(@zip_file.file.stat('file1').writable?)
|
||||
|
@ -333,7 +333,7 @@ class ZipFsFileNonmutatingTest < MiniTest::Test
|
|||
end
|
||||
|
||||
def test_writable_real?
|
||||
assert(! @zip_file.file.writable_real?('noSuchFile'))
|
||||
assert(!@zip_file.file.writable_real?('noSuchFile'))
|
||||
assert(@zip_file.file.writable_real?('file1'))
|
||||
assert(@zip_file.file.writable_real?('dir1'))
|
||||
assert(@zip_file.file.stat('file1').writable_real?)
|
||||
|
@ -341,18 +341,18 @@ class ZipFsFileNonmutatingTest < MiniTest::Test
|
|||
end
|
||||
|
||||
def test_executable?
|
||||
assert(! @zip_file.file.executable?('noSuchFile'))
|
||||
assert(! @zip_file.file.executable?('file1'))
|
||||
assert(!@zip_file.file.executable?('noSuchFile'))
|
||||
assert(!@zip_file.file.executable?('file1'))
|
||||
assert(@zip_file.file.executable?('dir1'))
|
||||
assert(! @zip_file.file.stat('file1').executable?)
|
||||
assert(!@zip_file.file.stat('file1').executable?)
|
||||
assert(@zip_file.file.stat('dir1').executable?)
|
||||
end
|
||||
|
||||
def test_executable_real?
|
||||
assert(! @zip_file.file.executable_real?('noSuchFile'))
|
||||
assert(! @zip_file.file.executable_real?('file1'))
|
||||
assert(!@zip_file.file.executable_real?('noSuchFile'))
|
||||
assert(!@zip_file.file.executable_real?('file1'))
|
||||
assert(@zip_file.file.executable_real?('dir1'))
|
||||
assert(! @zip_file.file.stat('file1').executable_real?)
|
||||
assert(!@zip_file.file.stat('file1').executable_real?)
|
||||
assert(@zip_file.file.stat('dir1').executable_real?)
|
||||
end
|
||||
|
||||
|
@ -455,7 +455,7 @@ class ZipFsFileNonmutatingTest < MiniTest::Test
|
|||
zf.glob('**/foo.txt') do |match|
|
||||
results << "<#{match.class.name}: #{match}>"
|
||||
end
|
||||
assert((!results.empty?), 'block not run, or run out of context')
|
||||
assert(!results.empty?, 'block not run, or run out of context')
|
||||
assert_equal 2, results.size
|
||||
assert_operator results, :include?, '<Zip::Entry: globTest/foo.txt>'
|
||||
assert_operator results, :include?, '<Zip::Entry: globTest/foo/bar/baz/foo.txt>'
|
||||
|
|
|
@ -32,10 +32,10 @@ class ZipFsFileStatTest < MiniTest::Test
|
|||
end
|
||||
|
||||
def test_mode
|
||||
assert_equal(0600, @zip_file.file.stat('file1').mode & 0777)
|
||||
assert_equal(0600, @zip_file.file.stat('file1').mode & 0777)
|
||||
assert_equal(0755, @zip_file.file.stat('dir1').mode & 0777)
|
||||
assert_equal(0755, @zip_file.file.stat('dir1').mode & 0777)
|
||||
assert_equal(0o600, @zip_file.file.stat('file1').mode & 0o777)
|
||||
assert_equal(0o600, @zip_file.file.stat('file1').mode & 0o777)
|
||||
assert_equal(0o755, @zip_file.file.stat('dir1').mode & 0o777)
|
||||
assert_equal(0o755, @zip_file.file.stat('dir1').mode & 0o777)
|
||||
end
|
||||
|
||||
def test_dev
|
||||
|
|
|
@ -76,7 +76,7 @@ class TestZipFile
|
|||
|
||||
File.open('test/data/generated/empty.txt', 'w') {}
|
||||
File.open('test/data/generated/empty_chmod640.txt', 'w') {}
|
||||
::File.chmod(0640, 'test/data/generated/empty_chmod640.txt')
|
||||
::File.chmod(0o640, 'test/data/generated/empty_chmod640.txt')
|
||||
|
||||
File.open('test/data/generated/short.txt', 'w') { |file| file << 'ABCDEF' }
|
||||
ziptestTxt = ''
|
||||
|
@ -118,9 +118,9 @@ class TestZipFile
|
|||
end
|
||||
|
||||
TEST_ZIP1 = TestZipFile.new('test/data/generated/empty.zip', [])
|
||||
TEST_ZIP2 = TestZipFile.new('test/data/generated/5entry.zip', %w(test/data/generated/longAscii.txt test/data/generated/empty.txt test/data/generated/empty_chmod640.txt test/data/generated/short.txt test/data/generated/longBinary.bin),
|
||||
TEST_ZIP2 = TestZipFile.new('test/data/generated/5entry.zip', %w[test/data/generated/longAscii.txt test/data/generated/empty.txt test/data/generated/empty_chmod640.txt test/data/generated/short.txt test/data/generated/longBinary.bin],
|
||||
'my zip comment')
|
||||
TEST_ZIP3 = TestZipFile.new('test/data/generated/test1.zip', %w(test/data/file1.txt))
|
||||
TEST_ZIP3 = TestZipFile.new('test/data/generated/test1.zip', %w[test/data/file1.txt])
|
||||
TEST_ZIP4 = TestZipFile.new('test/data/generated/zipWithDir.zip', ['test/data/file1.txt',
|
||||
TestFiles::EMPTY_TEST_DIR])
|
||||
end
|
||||
|
|
|
@ -70,7 +70,7 @@ class ZipInputStreamTest < MiniTest::Test
|
|||
entry = zis.get_next_entry # longAscii.txt
|
||||
assert_equal(false, zis.eof?)
|
||||
assert_equal(TestZipFile::TEST_ZIP2.entry_names[0], entry.name)
|
||||
assert zis.gets.length > 0
|
||||
assert !zis.gets.empty?
|
||||
assert_equal(false, zis.eof?)
|
||||
entry = zis.get_next_entry # empty.txt
|
||||
assert_equal(TestZipFile::TEST_ZIP2.entry_names[1], entry.name)
|
||||
|
@ -84,10 +84,10 @@ class ZipInputStreamTest < MiniTest::Test
|
|||
assert_equal(true, zis.eof?)
|
||||
entry = zis.get_next_entry # short.txt
|
||||
assert_equal(TestZipFile::TEST_ZIP2.entry_names[3], entry.name)
|
||||
assert zis.gets.length > 0
|
||||
assert !zis.gets.empty?
|
||||
entry = zis.get_next_entry # longBinary.bin
|
||||
assert_equal(TestZipFile::TEST_ZIP2.entry_names[4], entry.name)
|
||||
assert zis.gets.length > 0
|
||||
assert !zis.gets.empty?
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -97,7 +97,7 @@ class ZipInputStreamTest < MiniTest::Test
|
|||
entry = zis.get_next_entry # longAscii.txt
|
||||
assert_equal(false, zis.eof?)
|
||||
assert_equal(TestZipFile::TEST_ZIP2.entry_names[0], entry.name)
|
||||
assert zis.gets.length > 0
|
||||
assert !zis.gets.empty?
|
||||
assert_equal(false, zis.eof?)
|
||||
entry = zis.get_next_entry # empty.txt
|
||||
assert_equal(TestZipFile::TEST_ZIP2.entry_names[1], entry.name)
|
||||
|
@ -111,10 +111,10 @@ class ZipInputStreamTest < MiniTest::Test
|
|||
assert_equal(true, zis.eof?)
|
||||
entry = zis.get_next_entry # short.txt
|
||||
assert_equal(TestZipFile::TEST_ZIP2.entry_names[3], entry.name)
|
||||
assert zis.gets.length > 0
|
||||
assert !zis.gets.empty?
|
||||
entry = zis.get_next_entry # longBinary.bin
|
||||
assert_equal(TestZipFile::TEST_ZIP2.entry_names[4], entry.name)
|
||||
assert zis.gets.length > 0
|
||||
assert !zis.gets.empty?
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -92,11 +92,11 @@ class AbstractOutputStreamTest < MiniTest::Test
|
|||
assert_equal("hello\nworld\n", @output_stream.buffer)
|
||||
|
||||
@output_stream.buffer = ''
|
||||
@output_stream.puts(["hello\n", "world\n"])
|
||||
@output_stream.puts(%W[hello\n world\n])
|
||||
assert_equal("hello\nworld\n", @output_stream.buffer)
|
||||
|
||||
@output_stream.buffer = ''
|
||||
@output_stream.puts(["hello\n", "world\n"], 'bingo')
|
||||
@output_stream.puts(%W[hello\n world\n], 'bingo')
|
||||
assert_equal("hello\nworld\nbingo\n", @output_stream.buffer)
|
||||
|
||||
@output_stream.buffer = ''
|
||||
|
|
|
@ -103,7 +103,7 @@ module AssertEntry
|
|||
File.open(filename, 'rb') do |file|
|
||||
expected = file.read
|
||||
actual = zis.read
|
||||
if (expected != actual)
|
||||
if expected != actual
|
||||
if (expected && actual) && (expected.length > 400 || actual.length > 400)
|
||||
zipEntryFilename = entryName + '.zipEntry'
|
||||
File.open(zipEntryFilename, 'wb') { |entryfile| entryfile << actual }
|
||||
|
@ -118,7 +118,7 @@ module AssertEntry
|
|||
def self.assert_contents(filename, aString)
|
||||
fileContents = ''
|
||||
File.open(filename, 'rb') { |f| fileContents = f.read }
|
||||
if (fileContents != aString)
|
||||
if fileContents != aString
|
||||
if fileContents.length > 400 || aString.length > 400
|
||||
stringFile = filename + '.other'
|
||||
File.open(stringFile, 'wb') { |f| f << aString }
|
||||
|
|
|
@ -36,7 +36,7 @@ if ENV['FULL_ZIP64_TEST']
|
|||
end
|
||||
|
||||
::Zip::File.open(test_filename) do |zf|
|
||||
assert_equal %w(first_file.txt huge_file last_file.txt), zf.entries.map(&:name)
|
||||
assert_equal %w[first_file.txt huge_file last_file.txt], zf.entries.map(&:name)
|
||||
assert_equal first_text, zf.read('first_file.txt')
|
||||
assert_equal last_text, zf.read('last_file.txt')
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue