Pass glob through from ZipFileNameMapper.
Just pass the basic glob straight through to the underlying Zip::File implementation.
This commit is contained in:
parent
8887b70349
commit
1673da744d
|
@ -573,6 +573,10 @@ module Zip
|
|||
@zipFile.get_output_stream(expand_to_entry(fileName), permissionInt, &aProc)
|
||||
end
|
||||
|
||||
def glob(*args, &block)
|
||||
@zipFile.glob(*args, &block)
|
||||
end
|
||||
|
||||
def read(fileName)
|
||||
@zipFile.read(expand_to_entry(fileName))
|
||||
end
|
||||
|
|
|
@ -3,6 +3,7 @@ require 'zip/filesystem'
|
|||
|
||||
class ZipFsDirectoryTest < MiniTest::Test
|
||||
TEST_ZIP = 'test/data/generated/zipWithDirs_copy.zip'
|
||||
GLOB_TEST_ZIP = 'test/data/globTest.zip'
|
||||
|
||||
def setup
|
||||
FileUtils.cp('test/data/zipWithDirs.zip', TEST_ZIP)
|
||||
|
@ -93,11 +94,23 @@ class ZipFsDirectoryTest < MiniTest::Test
|
|||
end
|
||||
end
|
||||
|
||||
# Globbing not supported yet
|
||||
# def test_glob
|
||||
# # test alias []-operator too
|
||||
# fail "implement test"
|
||||
# end
|
||||
def test_glob
|
||||
globbed_files = [
|
||||
'globTest/foo/bar/baz/foo.txt',
|
||||
'globTest/foo.txt',
|
||||
'globTest/food.txt'
|
||||
]
|
||||
|
||||
::Zip::File.open(GLOB_TEST_ZIP) do |zf|
|
||||
zf.dir.glob('**/*.txt') do |f|
|
||||
assert globbed_files.include?(f.name)
|
||||
end
|
||||
|
||||
zf.dir.glob('globTest/foo/**/*.txt') do |f|
|
||||
assert_equal globbed_files[0], f.name
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def test_open_new
|
||||
::Zip::File.open(TEST_ZIP) do |zf|
|
||||
|
|
Loading…
Reference in New Issue