hotplate 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Gemfile +4 -0
- data/Rakefile +1 -0
- data/bin/toast +2 -0
- data/hotplate.gemspec +30 -0
- data/lib/hotplate/cli/build.rb +51 -0
- data/lib/hotplate/cli/init.rb +64 -0
- data/lib/hotplate/cli/main.rb +39 -0
- data/lib/hotplate/gems/rubyzip-1.1.7/README.md +271 -0
- data/lib/hotplate/gems/rubyzip-1.1.7/Rakefile +19 -0
- data/lib/hotplate/gems/rubyzip-1.1.7/TODO +15 -0
- data/lib/hotplate/gems/rubyzip-1.1.7/lib/zip/central_directory.rb +208 -0
- data/lib/hotplate/gems/rubyzip-1.1.7/lib/zip/compressor.rb +10 -0
- data/lib/hotplate/gems/rubyzip-1.1.7/lib/zip/constants.rb +63 -0
- data/lib/hotplate/gems/rubyzip-1.1.7/lib/zip/crypto/encryption.rb +11 -0
- data/lib/hotplate/gems/rubyzip-1.1.7/lib/zip/crypto/null_encryption.rb +45 -0
- data/lib/hotplate/gems/rubyzip-1.1.7/lib/zip/crypto/traditional_encryption.rb +99 -0
- data/lib/hotplate/gems/rubyzip-1.1.7/lib/zip/decompressor.rb +13 -0
- data/lib/hotplate/gems/rubyzip-1.1.7/lib/zip/deflater.rb +32 -0
- data/lib/hotplate/gems/rubyzip-1.1.7/lib/zip/dos_time.rb +49 -0
- data/lib/hotplate/gems/rubyzip-1.1.7/lib/zip/entry.rb +696 -0
- data/lib/hotplate/gems/rubyzip-1.1.7/lib/zip/entry_set.rb +86 -0
- data/lib/hotplate/gems/rubyzip-1.1.7/lib/zip/errors.rb +16 -0
- data/lib/hotplate/gems/rubyzip-1.1.7/lib/zip/extra_field/generic.rb +43 -0
- data/lib/hotplate/gems/rubyzip-1.1.7/lib/zip/extra_field/ntfs.rb +92 -0
- data/lib/hotplate/gems/rubyzip-1.1.7/lib/zip/extra_field/old_unix.rb +45 -0
- data/lib/hotplate/gems/rubyzip-1.1.7/lib/zip/extra_field/universal_time.rb +47 -0
- data/lib/hotplate/gems/rubyzip-1.1.7/lib/zip/extra_field/unix.rb +38 -0
- data/lib/hotplate/gems/rubyzip-1.1.7/lib/zip/extra_field/zip64.rb +67 -0
- data/lib/hotplate/gems/rubyzip-1.1.7/lib/zip/extra_field/zip64_placeholder.rb +16 -0
- data/lib/hotplate/gems/rubyzip-1.1.7/lib/zip/extra_field.rb +101 -0
- data/lib/hotplate/gems/rubyzip-1.1.7/lib/zip/file.rb +436 -0
- data/lib/hotplate/gems/rubyzip-1.1.7/lib/zip/filesystem.rb +626 -0
- data/lib/hotplate/gems/rubyzip-1.1.7/lib/zip/inflater.rb +66 -0
- data/lib/hotplate/gems/rubyzip-1.1.7/lib/zip/input_stream.rb +164 -0
- data/lib/hotplate/gems/rubyzip-1.1.7/lib/zip/ioextras/abstract_input_stream.rb +115 -0
- data/lib/hotplate/gems/rubyzip-1.1.7/lib/zip/ioextras/abstract_output_stream.rb +45 -0
- data/lib/hotplate/gems/rubyzip-1.1.7/lib/zip/ioextras.rb +38 -0
- data/lib/hotplate/gems/rubyzip-1.1.7/lib/zip/null_compressor.rb +15 -0
- data/lib/hotplate/gems/rubyzip-1.1.7/lib/zip/null_decompressor.rb +27 -0
- data/lib/hotplate/gems/rubyzip-1.1.7/lib/zip/null_input_stream.rb +10 -0
- data/lib/hotplate/gems/rubyzip-1.1.7/lib/zip/output_stream.rb +190 -0
- data/lib/hotplate/gems/rubyzip-1.1.7/lib/zip/pass_thru_compressor.rb +23 -0
- data/lib/hotplate/gems/rubyzip-1.1.7/lib/zip/pass_thru_decompressor.rb +41 -0
- data/lib/hotplate/gems/rubyzip-1.1.7/lib/zip/streamable_directory.rb +15 -0
- data/lib/hotplate/gems/rubyzip-1.1.7/lib/zip/streamable_stream.rb +56 -0
- data/lib/hotplate/gems/rubyzip-1.1.7/lib/zip/version.rb +3 -0
- data/lib/hotplate/gems/rubyzip-1.1.7/lib/zip.rb +63 -0
- data/lib/hotplate/gems/rubyzip-1.1.7/samples/example.rb +91 -0
- data/lib/hotplate/gems/rubyzip-1.1.7/samples/example_filesystem.rb +33 -0
- data/lib/hotplate/gems/rubyzip-1.1.7/samples/example_recursive.rb +48 -0
- data/lib/hotplate/gems/rubyzip-1.1.7/samples/gtkRubyzip.rb +86 -0
- data/lib/hotplate/gems/rubyzip-1.1.7/samples/qtzip.rb +101 -0
- data/lib/hotplate/gems/rubyzip-1.1.7/samples/write_simple.rb +13 -0
- data/lib/hotplate/gems/rubyzip-1.1.7/samples/zipfind.rb +74 -0
- data/lib/hotplate/gems/rubyzip-1.1.7/test/basic_zip_file_test.rb +64 -0
- data/lib/hotplate/gems/rubyzip-1.1.7/test/central_directory_entry_test.rb +73 -0
- data/lib/hotplate/gems/rubyzip-1.1.7/test/central_directory_test.rb +104 -0
- data/lib/hotplate/gems/rubyzip-1.1.7/test/crypto/null_encryption_test.rb +53 -0
- data/lib/hotplate/gems/rubyzip-1.1.7/test/crypto/traditional_encryption_test.rb +80 -0
- data/lib/hotplate/gems/rubyzip-1.1.7/test/data/WarnInvalidDate.zip +0 -0
- data/lib/hotplate/gems/rubyzip-1.1.7/test/data/file1.txt +46 -0
- data/lib/hotplate/gems/rubyzip-1.1.7/test/data/file1.txt.deflatedData +0 -0
- data/lib/hotplate/gems/rubyzip-1.1.7/test/data/file2.txt +1504 -0
- data/lib/hotplate/gems/rubyzip-1.1.7/test/data/globTest/foo/bar/baz/foo.txt +0 -0
- data/lib/hotplate/gems/rubyzip-1.1.7/test/data/globTest/foo.txt +0 -0
- data/lib/hotplate/gems/rubyzip-1.1.7/test/data/globTest/food.txt +0 -0
- data/lib/hotplate/gems/rubyzip-1.1.7/test/data/globTest.zip +0 -0
- data/lib/hotplate/gems/rubyzip-1.1.7/test/data/mimetype +1 -0
- data/lib/hotplate/gems/rubyzip-1.1.7/test/data/notzippedruby.rb +7 -0
- data/lib/hotplate/gems/rubyzip-1.1.7/test/data/ntfs.zip +0 -0
- data/lib/hotplate/gems/rubyzip-1.1.7/test/data/rubycode.zip +0 -0
- data/lib/hotplate/gems/rubyzip-1.1.7/test/data/rubycode2.zip +0 -0
- data/lib/hotplate/gems/rubyzip-1.1.7/test/data/testDirectory.bin +0 -0
- data/lib/hotplate/gems/rubyzip-1.1.7/test/data/zip64-sample.zip +0 -0
- data/lib/hotplate/gems/rubyzip-1.1.7/test/data/zipWithDirs.zip +0 -0
- data/lib/hotplate/gems/rubyzip-1.1.7/test/data/zipWithEncryption.zip +0 -0
- data/lib/hotplate/gems/rubyzip-1.1.7/test/deflater_test.rb +67 -0
- data/lib/hotplate/gems/rubyzip-1.1.7/test/encryption_test.rb +42 -0
- data/lib/hotplate/gems/rubyzip-1.1.7/test/entry_set_test.rb +138 -0
- data/lib/hotplate/gems/rubyzip-1.1.7/test/entry_test.rb +165 -0
- data/lib/hotplate/gems/rubyzip-1.1.7/test/errors_test.rb +36 -0
- data/lib/hotplate/gems/rubyzip-1.1.7/test/extra_field_test.rb +78 -0
- data/lib/hotplate/gems/rubyzip-1.1.7/test/file_extract_directory_test.rb +56 -0
- data/lib/hotplate/gems/rubyzip-1.1.7/test/file_extract_test.rb +90 -0
- data/lib/hotplate/gems/rubyzip-1.1.7/test/file_split_test.rb +60 -0
- data/lib/hotplate/gems/rubyzip-1.1.7/test/file_test.rb +559 -0
- data/lib/hotplate/gems/rubyzip-1.1.7/test/filesystem/dir_iterator_test.rb +62 -0
- data/lib/hotplate/gems/rubyzip-1.1.7/test/filesystem/directory_test.rb +131 -0
- data/lib/hotplate/gems/rubyzip-1.1.7/test/filesystem/file_mutating_test.rb +100 -0
- data/lib/hotplate/gems/rubyzip-1.1.7/test/filesystem/file_nonmutating_test.rb +514 -0
- data/lib/hotplate/gems/rubyzip-1.1.7/test/filesystem/file_stat_test.rb +66 -0
- data/lib/hotplate/gems/rubyzip-1.1.7/test/gentestfiles.rb +134 -0
- data/lib/hotplate/gems/rubyzip-1.1.7/test/inflater_test.rb +14 -0
- data/lib/hotplate/gems/rubyzip-1.1.7/test/input_stream_test.rb +170 -0
- data/lib/hotplate/gems/rubyzip-1.1.7/test/ioextras/abstract_input_stream_test.rb +103 -0
- data/lib/hotplate/gems/rubyzip-1.1.7/test/ioextras/abstract_output_stream_test.rb +106 -0
- data/lib/hotplate/gems/rubyzip-1.1.7/test/ioextras/fake_io_test.rb +18 -0
- data/lib/hotplate/gems/rubyzip-1.1.7/test/local_entry_test.rb +156 -0
- data/lib/hotplate/gems/rubyzip-1.1.7/test/output_stream_test.rb +129 -0
- data/lib/hotplate/gems/rubyzip-1.1.7/test/pass_thru_compressor_test.rb +31 -0
- data/lib/hotplate/gems/rubyzip-1.1.7/test/pass_thru_decompressor_test.rb +15 -0
- data/lib/hotplate/gems/rubyzip-1.1.7/test/settings_test.rb +92 -0
- data/lib/hotplate/gems/rubyzip-1.1.7/test/test_helper.rb +228 -0
- data/lib/hotplate/gems/rubyzip-1.1.7/test/unicode_file_names_and_comments_test.rb +52 -0
- data/lib/hotplate/gems/rubyzip-1.1.7/test/zip64_full_test.rb +53 -0
- data/lib/hotplate/gems/rubyzip-1.1.7/test/zip64_support_test.rb +15 -0
- data/lib/hotplate/java/build.gradle +38 -0
- data/lib/hotplate/java/gradle/wrapper/gradle-wrapper.jar +0 -0
- data/lib/hotplate/java/gradle/wrapper/gradle-wrapper.properties +6 -0
- data/lib/hotplate/java/gradlew +164 -0
- data/lib/hotplate/java/gradlew.bat +90 -0
- data/lib/hotplate/java/template.java +25 -0
- data/lib/hotplate/version.rb +3 -0
- data/lib/hotplate.rb +2 -0
- metadata +186 -0
File without changes
|
File without changes
|
File without changes
|
Binary file
|
@@ -0,0 +1 @@
|
|
1
|
+
application/epub+zip
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -0,0 +1,67 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class DeflaterTest < MiniTest::Test
|
4
|
+
include CrcTest
|
5
|
+
|
6
|
+
DEFLATER_TEST_FILE = 'test/data/generated/deflatertest.bin'
|
7
|
+
BEST_COMP_FILE = 'test/data/generated/compressiontest_best_compression.bin'
|
8
|
+
DEFAULT_COMP_FILE = 'test/data/generated/compressiontest_default_compression.bin'
|
9
|
+
NO_COMP_FILE = 'test/data/generated/compressiontest_no_compression.bin'
|
10
|
+
|
11
|
+
def test_outputOperator
|
12
|
+
txt = load_file("test/data/file2.txt")
|
13
|
+
deflate(txt, DEFLATER_TEST_FILE)
|
14
|
+
inflatedTxt = inflate(DEFLATER_TEST_FILE)
|
15
|
+
assert_equal(txt, inflatedTxt)
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_default_compression
|
19
|
+
txt = load_file("test/data/file2.txt")
|
20
|
+
|
21
|
+
Zip.default_compression = ::Zlib::BEST_COMPRESSION
|
22
|
+
deflate(txt, BEST_COMP_FILE)
|
23
|
+
Zip.default_compression = ::Zlib::DEFAULT_COMPRESSION
|
24
|
+
deflate(txt, DEFAULT_COMP_FILE)
|
25
|
+
Zip.default_compression = ::Zlib::NO_COMPRESSION
|
26
|
+
deflate(txt, NO_COMP_FILE)
|
27
|
+
|
28
|
+
best = File.size(BEST_COMP_FILE)
|
29
|
+
default = File.size(DEFAULT_COMP_FILE)
|
30
|
+
no = File.size(NO_COMP_FILE)
|
31
|
+
|
32
|
+
assert(best < default)
|
33
|
+
assert(best < no)
|
34
|
+
assert(default < no)
|
35
|
+
end
|
36
|
+
|
37
|
+
|
38
|
+
private
|
39
|
+
def load_file(fileName)
|
40
|
+
txt = nil
|
41
|
+
File.open(fileName, "rb") { |f| txt = f.read }
|
42
|
+
end
|
43
|
+
|
44
|
+
def deflate(data, fileName)
|
45
|
+
File.open(fileName, "wb") {
|
46
|
+
|file|
|
47
|
+
deflater = ::Zip::Deflater.new(file)
|
48
|
+
deflater << data
|
49
|
+
deflater.finish
|
50
|
+
assert_equal(deflater.size, data.size)
|
51
|
+
file << "trailing data for zlib with -MAX_WBITS"
|
52
|
+
}
|
53
|
+
end
|
54
|
+
|
55
|
+
def inflate(fileName)
|
56
|
+
txt = nil
|
57
|
+
File.open(fileName, "rb") {
|
58
|
+
|file|
|
59
|
+
inflater = ::Zip::Inflater.new(file)
|
60
|
+
txt = inflater.sysread
|
61
|
+
}
|
62
|
+
end
|
63
|
+
|
64
|
+
def test_crc
|
65
|
+
run_crc_test(::Zip::Deflater)
|
66
|
+
end
|
67
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class EncryptionTest < MiniTest::Test
|
4
|
+
ENCRYPT_ZIP_TEST_FILE = 'test/data/zipWithEncryption.zip'
|
5
|
+
INPUT_FILE1 = 'test/data/file1.txt'
|
6
|
+
|
7
|
+
def setup
|
8
|
+
@default_compression = Zip.default_compression
|
9
|
+
Zip.default_compression = ::Zlib::DEFAULT_COMPRESSION
|
10
|
+
end
|
11
|
+
|
12
|
+
def teardown
|
13
|
+
Zip.default_compression = @default_compression
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_encrypt
|
17
|
+
test_file = open(ENCRYPT_ZIP_TEST_FILE, 'rb').read
|
18
|
+
|
19
|
+
@rand = [250, 143, 107, 13, 143, 22, 155, 75, 228, 150, 12]
|
20
|
+
@output = ::Zip::DOSTime.stub(:now, ::Zip::DOSTime.new(2014, 12, 17, 15, 56, 24)) do
|
21
|
+
Random.stub(:rand, lambda { |range| @rand.shift }) do
|
22
|
+
Zip::OutputStream.write_buffer(::StringIO.new(''), Zip::TraditionalEncrypter.new('password')) do |zos|
|
23
|
+
zos.put_next_entry('file1.txt')
|
24
|
+
zos.write open(INPUT_FILE1).read
|
25
|
+
end.string
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
@output.unpack("C*").each_with_index do |c, i|
|
30
|
+
assert_equal test_file[i].ord, c
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def test_decrypt
|
35
|
+
Zip::InputStream.open(ENCRYPT_ZIP_TEST_FILE, 0, Zip::TraditionalDecrypter.new('password')) do |zis|
|
36
|
+
entry = zis.get_next_entry
|
37
|
+
assert_equal 'file1.txt', entry.name
|
38
|
+
assert_equal 1327, entry.size
|
39
|
+
assert_equal open(INPUT_FILE1, 'r').read, zis.read
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,138 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class ZipEntrySetTest < MiniTest::Test
|
4
|
+
ZIP_ENTRIES = [
|
5
|
+
::Zip::Entry.new("zipfile.zip", "name1", "comment1"),
|
6
|
+
::Zip::Entry.new("zipfile.zip", "name3", "comment1"),
|
7
|
+
::Zip::Entry.new("zipfile.zip", "name2", "comment1"),
|
8
|
+
::Zip::Entry.new("zipfile.zip", "name4", "comment1"),
|
9
|
+
::Zip::Entry.new("zipfile.zip", "name5", "comment1"),
|
10
|
+
::Zip::Entry.new("zipfile.zip", "name6", "comment1")
|
11
|
+
]
|
12
|
+
|
13
|
+
def setup
|
14
|
+
@zipEntrySet = ::Zip::EntrySet.new(ZIP_ENTRIES)
|
15
|
+
end
|
16
|
+
|
17
|
+
def teardown
|
18
|
+
::Zip.reset!
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_include
|
22
|
+
assert(@zipEntrySet.include?(ZIP_ENTRIES.first))
|
23
|
+
assert(!@zipEntrySet.include?(::Zip::Entry.new("different.zip", "different", "aComment")))
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_size
|
27
|
+
assert_equal(ZIP_ENTRIES.size, @zipEntrySet.size)
|
28
|
+
assert_equal(ZIP_ENTRIES.size, @zipEntrySet.length)
|
29
|
+
@zipEntrySet << ::Zip::Entry.new("a", "b", "c")
|
30
|
+
assert_equal(ZIP_ENTRIES.size + 1, @zipEntrySet.length)
|
31
|
+
end
|
32
|
+
|
33
|
+
def test_add
|
34
|
+
zes = ::Zip::EntrySet.new
|
35
|
+
entry1 = ::Zip::Entry.new("zf.zip", "name1")
|
36
|
+
entry2 = ::Zip::Entry.new("zf.zip", "name2")
|
37
|
+
zes << entry1
|
38
|
+
assert(zes.include?(entry1))
|
39
|
+
zes.push(entry2)
|
40
|
+
assert(zes.include?(entry2))
|
41
|
+
end
|
42
|
+
|
43
|
+
def test_delete
|
44
|
+
assert_equal(ZIP_ENTRIES.size, @zipEntrySet.size)
|
45
|
+
entry = @zipEntrySet.delete(ZIP_ENTRIES.first)
|
46
|
+
assert_equal(ZIP_ENTRIES.size - 1, @zipEntrySet.size)
|
47
|
+
assert_equal(ZIP_ENTRIES.first, entry)
|
48
|
+
|
49
|
+
entry = @zipEntrySet.delete(ZIP_ENTRIES.first)
|
50
|
+
assert_equal(ZIP_ENTRIES.size - 1, @zipEntrySet.size)
|
51
|
+
assert_nil(entry)
|
52
|
+
end
|
53
|
+
|
54
|
+
def test_each
|
55
|
+
# Used each instead each_with_index due the bug in jRuby
|
56
|
+
count = 0
|
57
|
+
@zipEntrySet.each do |entry|
|
58
|
+
assert(ZIP_ENTRIES.include?(entry))
|
59
|
+
count += 1
|
60
|
+
end
|
61
|
+
assert_equal(ZIP_ENTRIES.size, count)
|
62
|
+
end
|
63
|
+
|
64
|
+
def test_entries
|
65
|
+
assert_equal(ZIP_ENTRIES, @zipEntrySet.entries)
|
66
|
+
end
|
67
|
+
|
68
|
+
def test_entries_with_sort
|
69
|
+
::Zip.sort_entries = true
|
70
|
+
assert_equal(ZIP_ENTRIES.sort, @zipEntrySet.entries)
|
71
|
+
::Zip.sort_entries = false
|
72
|
+
assert_equal(ZIP_ENTRIES, @zipEntrySet.entries)
|
73
|
+
end
|
74
|
+
|
75
|
+
def test_entries_sorted_in_each
|
76
|
+
::Zip.sort_entries = true
|
77
|
+
arr = []
|
78
|
+
@zipEntrySet.each do |entry|
|
79
|
+
arr << entry
|
80
|
+
end
|
81
|
+
assert_equal(ZIP_ENTRIES.sort, arr)
|
82
|
+
end
|
83
|
+
|
84
|
+
def test_compound
|
85
|
+
newEntry = ::Zip::Entry.new("zf.zip", "new entry", "new entry's comment")
|
86
|
+
assert_equal(ZIP_ENTRIES.size, @zipEntrySet.size)
|
87
|
+
@zipEntrySet << newEntry
|
88
|
+
assert_equal(ZIP_ENTRIES.size + 1, @zipEntrySet.size)
|
89
|
+
assert(@zipEntrySet.include?(newEntry))
|
90
|
+
|
91
|
+
@zipEntrySet.delete(newEntry)
|
92
|
+
assert_equal(ZIP_ENTRIES.size, @zipEntrySet.size)
|
93
|
+
end
|
94
|
+
|
95
|
+
def test_dup
|
96
|
+
copy = @zipEntrySet.dup
|
97
|
+
assert_equal(@zipEntrySet, copy)
|
98
|
+
|
99
|
+
# demonstrate that this is a deep copy
|
100
|
+
copy.entries[0].name = "a totally different name"
|
101
|
+
assert(@zipEntrySet != copy)
|
102
|
+
end
|
103
|
+
|
104
|
+
def test_parent
|
105
|
+
entries = [
|
106
|
+
::Zip::Entry.new("zf.zip", "a/"),
|
107
|
+
::Zip::Entry.new("zf.zip", "a/b/"),
|
108
|
+
::Zip::Entry.new("zf.zip", "a/b/c/")
|
109
|
+
]
|
110
|
+
entrySet = ::Zip::EntrySet.new(entries)
|
111
|
+
|
112
|
+
assert_equal(nil, entrySet.parent(entries[0]))
|
113
|
+
assert_equal(entries[0], entrySet.parent(entries[1]))
|
114
|
+
assert_equal(entries[1], entrySet.parent(entries[2]))
|
115
|
+
end
|
116
|
+
|
117
|
+
def test_glob
|
118
|
+
res = @zipEntrySet.glob('name[2-4]')
|
119
|
+
assert_equal(3, res.size)
|
120
|
+
assert_equal(ZIP_ENTRIES[1, 3].sort, res.sort)
|
121
|
+
end
|
122
|
+
|
123
|
+
def test_glob2
|
124
|
+
entries = [
|
125
|
+
::Zip::Entry.new("zf.zip", "a/"),
|
126
|
+
::Zip::Entry.new("zf.zip", "a/b/b1"),
|
127
|
+
::Zip::Entry.new("zf.zip", "a/b/c/"),
|
128
|
+
::Zip::Entry.new("zf.zip", "a/b/c/c1")
|
129
|
+
]
|
130
|
+
entrySet = ::Zip::EntrySet.new(entries)
|
131
|
+
|
132
|
+
assert_equal(entries[0, 1], entrySet.glob("*"))
|
133
|
+
# assert_equal(entries[FIXME], entrySet.glob("**"))
|
134
|
+
# res = entrySet.glob('a*')
|
135
|
+
# assert_equal(entries.size, res.size)
|
136
|
+
# assert_equal(entrySet.map { |e| e.name }, res.map { |e| e.name })
|
137
|
+
end
|
138
|
+
end
|
@@ -0,0 +1,165 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class ZipEntryTest < MiniTest::Test
|
4
|
+
TEST_ZIPFILE = "someZipFile.zip"
|
5
|
+
TEST_COMMENT = "a comment"
|
6
|
+
TEST_COMPRESSED_SIZE = 1234
|
7
|
+
TEST_CRC = 325324
|
8
|
+
TEST_EXTRA = "Some data here"
|
9
|
+
TEST_COMPRESSIONMETHOD = ::Zip::Entry::DEFLATED
|
10
|
+
TEST_NAME = "entry name"
|
11
|
+
TEST_SIZE = 8432
|
12
|
+
TEST_ISDIRECTORY = false
|
13
|
+
TEST_TIME = Time.now
|
14
|
+
|
15
|
+
def test_constructorAndGetters
|
16
|
+
entry = ::Zip::Entry.new(TEST_ZIPFILE,
|
17
|
+
TEST_NAME,
|
18
|
+
TEST_COMMENT,
|
19
|
+
TEST_EXTRA,
|
20
|
+
TEST_COMPRESSED_SIZE,
|
21
|
+
TEST_CRC,
|
22
|
+
TEST_COMPRESSIONMETHOD,
|
23
|
+
TEST_SIZE,
|
24
|
+
TEST_TIME)
|
25
|
+
|
26
|
+
assert_equal(TEST_COMMENT, entry.comment)
|
27
|
+
assert_equal(TEST_COMPRESSED_SIZE, entry.compressed_size)
|
28
|
+
assert_equal(TEST_CRC, entry.crc)
|
29
|
+
assert_instance_of(::Zip::ExtraField, entry.extra)
|
30
|
+
assert_equal(TEST_COMPRESSIONMETHOD, entry.compression_method)
|
31
|
+
assert_equal(TEST_NAME, entry.name)
|
32
|
+
assert_equal(TEST_SIZE, entry.size)
|
33
|
+
assert_equal(TEST_TIME, entry.time)
|
34
|
+
end
|
35
|
+
|
36
|
+
def test_is_directoryAndIsFile
|
37
|
+
assert(::Zip::Entry.new(TEST_ZIPFILE, "hello").file?)
|
38
|
+
assert(!::Zip::Entry.new(TEST_ZIPFILE, "hello").directory?)
|
39
|
+
|
40
|
+
assert(::Zip::Entry.new(TEST_ZIPFILE, "dir/hello").file?)
|
41
|
+
assert(!::Zip::Entry.new(TEST_ZIPFILE, "dir/hello").directory?)
|
42
|
+
|
43
|
+
assert(::Zip::Entry.new(TEST_ZIPFILE, "hello/").directory?)
|
44
|
+
assert(!::Zip::Entry.new(TEST_ZIPFILE, "hello/").file?)
|
45
|
+
|
46
|
+
assert(::Zip::Entry.new(TEST_ZIPFILE, "dir/hello/").directory?)
|
47
|
+
assert(!::Zip::Entry.new(TEST_ZIPFILE, "dir/hello/").file?)
|
48
|
+
end
|
49
|
+
|
50
|
+
def test_equality
|
51
|
+
entry1 = ::Zip::Entry.new("file.zip", "name", "isNotCompared",
|
52
|
+
"something extra", 123, 1234,
|
53
|
+
::Zip::Entry::DEFLATED, 10000)
|
54
|
+
entry2 = ::Zip::Entry.new("file.zip", "name", "isNotComparedXXX",
|
55
|
+
"something extra", 123, 1234,
|
56
|
+
::Zip::Entry::DEFLATED, 10000)
|
57
|
+
entry3 = ::Zip::Entry.new("file.zip", "name2", "isNotComparedXXX",
|
58
|
+
"something extra", 123, 1234,
|
59
|
+
::Zip::Entry::DEFLATED, 10000)
|
60
|
+
entry4 = ::Zip::Entry.new("file.zip", "name2", "isNotComparedXXX",
|
61
|
+
"something extraXX", 123, 1234,
|
62
|
+
::Zip::Entry::DEFLATED, 10000)
|
63
|
+
entry5 = ::Zip::Entry.new("file.zip", "name2", "isNotComparedXXX",
|
64
|
+
"something extraXX", 12, 1234,
|
65
|
+
::Zip::Entry::DEFLATED, 10000)
|
66
|
+
entry6 = ::Zip::Entry.new("file.zip", "name2", "isNotComparedXXX",
|
67
|
+
"something extraXX", 12, 123,
|
68
|
+
::Zip::Entry::DEFLATED, 10000)
|
69
|
+
entry7 = ::Zip::Entry.new("file.zip", "name2", "isNotComparedXXX",
|
70
|
+
"something extraXX", 12, 123,
|
71
|
+
::Zip::Entry::STORED, 10000)
|
72
|
+
entry8 = ::Zip::Entry.new("file.zip", "name2", "isNotComparedXXX",
|
73
|
+
"something extraXX", 12, 123,
|
74
|
+
::Zip::Entry::STORED, 100000)
|
75
|
+
|
76
|
+
assert_equal(entry1, entry1)
|
77
|
+
assert_equal(entry1, entry2)
|
78
|
+
|
79
|
+
assert(entry2 != entry3)
|
80
|
+
assert(entry3 != entry4)
|
81
|
+
assert(entry4 != entry5)
|
82
|
+
assert(entry5 != entry6)
|
83
|
+
assert(entry6 != entry7)
|
84
|
+
assert(entry7 != entry8)
|
85
|
+
|
86
|
+
assert(entry7 != "hello")
|
87
|
+
assert(entry7 != 12)
|
88
|
+
end
|
89
|
+
|
90
|
+
def test_compare
|
91
|
+
assert_equal(0, (::Zip::Entry.new("zf.zip", "a") <=> ::Zip::Entry.new("zf.zip", "a")))
|
92
|
+
assert_equal(1, (::Zip::Entry.new("zf.zip", "b") <=> ::Zip::Entry.new("zf.zip", "a")))
|
93
|
+
assert_equal(-1, (::Zip::Entry.new("zf.zip", "a") <=> ::Zip::Entry.new("zf.zip", "b")))
|
94
|
+
|
95
|
+
entries = [
|
96
|
+
::Zip::Entry.new("zf.zip", "5"),
|
97
|
+
::Zip::Entry.new("zf.zip", "1"),
|
98
|
+
::Zip::Entry.new("zf.zip", "3"),
|
99
|
+
::Zip::Entry.new("zf.zip", "4"),
|
100
|
+
::Zip::Entry.new("zf.zip", "0"),
|
101
|
+
::Zip::Entry.new("zf.zip", "2")
|
102
|
+
]
|
103
|
+
|
104
|
+
entries.sort!
|
105
|
+
assert_equal("0", entries[0].to_s)
|
106
|
+
assert_equal("1", entries[1].to_s)
|
107
|
+
assert_equal("2", entries[2].to_s)
|
108
|
+
assert_equal("3", entries[3].to_s)
|
109
|
+
assert_equal("4", entries[4].to_s)
|
110
|
+
assert_equal("5", entries[5].to_s)
|
111
|
+
end
|
112
|
+
|
113
|
+
def test_parentAsString
|
114
|
+
entry1 = ::Zip::Entry.new("zf.zip", "aa")
|
115
|
+
entry2 = ::Zip::Entry.new("zf.zip", "aa/")
|
116
|
+
entry3 = ::Zip::Entry.new("zf.zip", "aa/bb")
|
117
|
+
entry4 = ::Zip::Entry.new("zf.zip", "aa/bb/")
|
118
|
+
entry5 = ::Zip::Entry.new("zf.zip", "aa/bb/cc")
|
119
|
+
entry6 = ::Zip::Entry.new("zf.zip", "aa/bb/cc/")
|
120
|
+
|
121
|
+
assert_equal(nil, entry1.parent_as_string)
|
122
|
+
assert_equal(nil, entry2.parent_as_string)
|
123
|
+
assert_equal("aa/", entry3.parent_as_string)
|
124
|
+
assert_equal("aa/", entry4.parent_as_string)
|
125
|
+
assert_equal("aa/bb/", entry5.parent_as_string)
|
126
|
+
assert_equal("aa/bb/", entry6.parent_as_string)
|
127
|
+
end
|
128
|
+
|
129
|
+
def test_entry_name_cannot_start_with_slash
|
130
|
+
assert_raises(::Zip::EntryNameError) { ::Zip::Entry.new("zf.zip", "/hej/der") }
|
131
|
+
end
|
132
|
+
|
133
|
+
def test_store_file_without_compression
|
134
|
+
File.delete('/tmp/no_compress.zip') if File.exist?('/tmp/no_compress.zip')
|
135
|
+
files = Dir[File.join('test/data/globTest', '**', '**')]
|
136
|
+
|
137
|
+
Zip.setup do |z|
|
138
|
+
z.write_zip64_support = false
|
139
|
+
end
|
140
|
+
|
141
|
+
zipfile = Zip::File.open('/tmp/no_compress.zip', Zip::File::CREATE)
|
142
|
+
mimetype_entry = Zip::Entry.new(zipfile, #@zipfile
|
143
|
+
'mimetype', #@name
|
144
|
+
'', #@comment
|
145
|
+
'', #@extra
|
146
|
+
0, #@compressed_size
|
147
|
+
0, #@crc
|
148
|
+
Zip::Entry::STORED) #@comppressed_method
|
149
|
+
|
150
|
+
zipfile.add(mimetype_entry, 'test/data/mimetype')
|
151
|
+
|
152
|
+
files.each do |file|
|
153
|
+
zipfile.add(file.sub("test/data/globTest/", ''), file)
|
154
|
+
end
|
155
|
+
zipfile.close
|
156
|
+
|
157
|
+
f= File.open('/tmp/no_compress.zip', 'rb')
|
158
|
+
first_100_bytes = f.read(100)
|
159
|
+
f.close
|
160
|
+
|
161
|
+
assert_match(/mimetypeapplication\/epub\+zip/, first_100_bytes)
|
162
|
+
end
|
163
|
+
|
164
|
+
|
165
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'test_helper'
|
3
|
+
|
4
|
+
class ErrorsTest < MiniTest::Test
|
5
|
+
|
6
|
+
def test_rescue_legacy_zip_error
|
7
|
+
raise ::Zip::Error
|
8
|
+
rescue ::Zip::ZipError
|
9
|
+
end
|
10
|
+
|
11
|
+
def test_rescue_legacy_zip_entry_exists_error
|
12
|
+
raise ::Zip::EntryExistsError
|
13
|
+
rescue ::Zip::ZipEntryExistsError
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_rescue_legacy_zip_destination_file_exists_error
|
17
|
+
raise ::Zip::DestinationFileExistsError
|
18
|
+
rescue ::Zip::ZipDestinationFileExistsError
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_rescue_legacy_zip_compression_method_error
|
22
|
+
raise ::Zip::CompressionMethodError
|
23
|
+
rescue ::Zip::ZipCompressionMethodError
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_rescue_legacy_zip_entry_name_error
|
27
|
+
raise ::Zip::EntryNameError
|
28
|
+
rescue ::Zip::ZipEntryNameError
|
29
|
+
end
|
30
|
+
|
31
|
+
def test_rescue_legacy_zip_internal_error
|
32
|
+
raise ::Zip::InternalError
|
33
|
+
rescue ::Zip::ZipInternalError
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
@@ -0,0 +1,78 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class ZipExtraFieldTest < MiniTest::Test
|
4
|
+
def test_new
|
5
|
+
extra_pure = ::Zip::ExtraField.new("")
|
6
|
+
extra_withstr = ::Zip::ExtraField.new("foo")
|
7
|
+
assert_instance_of(::Zip::ExtraField, extra_pure)
|
8
|
+
assert_instance_of(::Zip::ExtraField, extra_withstr)
|
9
|
+
end
|
10
|
+
|
11
|
+
def test_unknownfield
|
12
|
+
extra = ::Zip::ExtraField.new("foo")
|
13
|
+
assert_equal(extra["Unknown"], "foo")
|
14
|
+
extra.merge("a")
|
15
|
+
assert_equal(extra["Unknown"], "fooa")
|
16
|
+
extra.merge("barbaz")
|
17
|
+
assert_equal(extra.to_s, "fooabarbaz")
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_ntfs
|
21
|
+
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"
|
22
|
+
extra = ::Zip::ExtraField.new(str)
|
23
|
+
assert(extra.member?("NTFS"))
|
24
|
+
t = ::Zip::DOSTime.at(1410496497.405178)
|
25
|
+
assert_equal(t, extra['NTFS'].mtime)
|
26
|
+
assert_equal(t, extra['NTFS'].atime)
|
27
|
+
assert_equal(t, extra['NTFS'].ctime)
|
28
|
+
end
|
29
|
+
|
30
|
+
def test_merge
|
31
|
+
str = "UT\x5\0\x3\250$\r@Ux\0\0"
|
32
|
+
extra1 = ::Zip::ExtraField.new("")
|
33
|
+
extra2 = ::Zip::ExtraField.new(str)
|
34
|
+
assert(!extra1.member?("UniversalTime"))
|
35
|
+
assert(extra2.member?("UniversalTime"))
|
36
|
+
extra1.merge(str)
|
37
|
+
assert_equal(extra1["UniversalTime"].mtime, extra2["UniversalTime"].mtime)
|
38
|
+
end
|
39
|
+
|
40
|
+
def test_length
|
41
|
+
str = "UT\x5\0\x3\250$\r@Ux\0\0Te\0\0testit"
|
42
|
+
extra = ::Zip::ExtraField.new(str)
|
43
|
+
assert_equal(extra.local_size, extra.to_local_bin.size)
|
44
|
+
assert_equal(extra.c_dir_size, extra.to_c_dir_bin.size)
|
45
|
+
extra.merge("foo")
|
46
|
+
assert_equal(extra.local_size, extra.to_local_bin.size)
|
47
|
+
assert_equal(extra.c_dir_size, extra.to_c_dir_bin.size)
|
48
|
+
end
|
49
|
+
|
50
|
+
|
51
|
+
def test_to_s
|
52
|
+
str = "UT\x5\0\x3\250$\r@Ux\0\0Te\0\0testit"
|
53
|
+
extra = ::Zip::ExtraField.new(str)
|
54
|
+
assert_instance_of(String, extra.to_s)
|
55
|
+
|
56
|
+
s = extra.to_s
|
57
|
+
extra.merge("foo")
|
58
|
+
assert_equal(s.length + 3, extra.to_s.length)
|
59
|
+
end
|
60
|
+
|
61
|
+
def test_equality
|
62
|
+
str = "UT\x5\0\x3\250$\r@"
|
63
|
+
extra1 = ::Zip::ExtraField.new(str)
|
64
|
+
extra2 = ::Zip::ExtraField.new(str)
|
65
|
+
extra3 = ::Zip::ExtraField.new(str)
|
66
|
+
assert_equal(extra1, extra2)
|
67
|
+
|
68
|
+
extra2["UniversalTime"].mtime = ::Zip::DOSTime.now
|
69
|
+
assert(extra1 != extra2)
|
70
|
+
|
71
|
+
extra3.create("IUnix")
|
72
|
+
assert(extra1 != extra3)
|
73
|
+
|
74
|
+
extra1.create("IUnix")
|
75
|
+
assert_equal(extra1, extra3)
|
76
|
+
end
|
77
|
+
|
78
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class ZipFileExtractDirectoryTest < MiniTest::Test
|
4
|
+
include CommonZipFileFixture
|
5
|
+
|
6
|
+
TEST_OUT_NAME = "test/data/generated/emptyOutDir"
|
7
|
+
|
8
|
+
def open_zip(&aProc)
|
9
|
+
assert(aProc != nil)
|
10
|
+
::Zip::File.open(TestZipFile::TEST_ZIP4.zip_name, &aProc)
|
11
|
+
end
|
12
|
+
|
13
|
+
def extract_test_dir(&aProc)
|
14
|
+
open_zip {
|
15
|
+
|zf|
|
16
|
+
zf.extract(TestFiles::EMPTY_TEST_DIR, TEST_OUT_NAME, &aProc)
|
17
|
+
}
|
18
|
+
end
|
19
|
+
|
20
|
+
def setup
|
21
|
+
super
|
22
|
+
|
23
|
+
Dir.rmdir(TEST_OUT_NAME) if File.directory? TEST_OUT_NAME
|
24
|
+
File.delete(TEST_OUT_NAME) if File.exist? TEST_OUT_NAME
|
25
|
+
end
|
26
|
+
|
27
|
+
def test_extractDirectory
|
28
|
+
extract_test_dir
|
29
|
+
assert(File.directory?(TEST_OUT_NAME))
|
30
|
+
end
|
31
|
+
|
32
|
+
def test_extractDirectoryExistsAsDir
|
33
|
+
Dir.mkdir TEST_OUT_NAME
|
34
|
+
extract_test_dir
|
35
|
+
assert(File.directory?(TEST_OUT_NAME))
|
36
|
+
end
|
37
|
+
|
38
|
+
def test_extractDirectoryExistsAsFile
|
39
|
+
File.open(TEST_OUT_NAME, "w") { |f| f.puts "something" }
|
40
|
+
assert_raises(::Zip::DestinationFileExistsError) { extract_test_dir }
|
41
|
+
end
|
42
|
+
|
43
|
+
def test_extractDirectoryExistsAsFileOverwrite
|
44
|
+
File.open(TEST_OUT_NAME, "w") { |f| f.puts "something" }
|
45
|
+
gotCalled = false
|
46
|
+
extract_test_dir {
|
47
|
+
|entry, destPath|
|
48
|
+
gotCalled = true
|
49
|
+
assert_equal(TEST_OUT_NAME, destPath)
|
50
|
+
assert(entry.directory?)
|
51
|
+
true
|
52
|
+
}
|
53
|
+
assert(gotCalled)
|
54
|
+
assert(File.directory?(TEST_OUT_NAME))
|
55
|
+
end
|
56
|
+
end
|