hotplate 0.1.1 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/hotplate.gemspec +1 -0
- data/lib/hotplate/cli/main.rb +1 -7
- data/lib/hotplate/version.rb +1 -1
- metadata +16 -101
- data/lib/hotplate/gems/rubyzip-1.1.7/README.md +0 -271
- data/lib/hotplate/gems/rubyzip-1.1.7/Rakefile +0 -19
- data/lib/hotplate/gems/rubyzip-1.1.7/TODO +0 -15
- data/lib/hotplate/gems/rubyzip-1.1.7/lib/zip/central_directory.rb +0 -208
- data/lib/hotplate/gems/rubyzip-1.1.7/lib/zip/compressor.rb +0 -10
- data/lib/hotplate/gems/rubyzip-1.1.7/lib/zip/constants.rb +0 -63
- data/lib/hotplate/gems/rubyzip-1.1.7/lib/zip/crypto/encryption.rb +0 -11
- data/lib/hotplate/gems/rubyzip-1.1.7/lib/zip/crypto/null_encryption.rb +0 -45
- data/lib/hotplate/gems/rubyzip-1.1.7/lib/zip/crypto/traditional_encryption.rb +0 -99
- data/lib/hotplate/gems/rubyzip-1.1.7/lib/zip/decompressor.rb +0 -13
- data/lib/hotplate/gems/rubyzip-1.1.7/lib/zip/deflater.rb +0 -32
- data/lib/hotplate/gems/rubyzip-1.1.7/lib/zip/dos_time.rb +0 -49
- data/lib/hotplate/gems/rubyzip-1.1.7/lib/zip/entry.rb +0 -696
- data/lib/hotplate/gems/rubyzip-1.1.7/lib/zip/entry_set.rb +0 -86
- data/lib/hotplate/gems/rubyzip-1.1.7/lib/zip/errors.rb +0 -16
- data/lib/hotplate/gems/rubyzip-1.1.7/lib/zip/extra_field/generic.rb +0 -43
- data/lib/hotplate/gems/rubyzip-1.1.7/lib/zip/extra_field/ntfs.rb +0 -92
- data/lib/hotplate/gems/rubyzip-1.1.7/lib/zip/extra_field/old_unix.rb +0 -45
- data/lib/hotplate/gems/rubyzip-1.1.7/lib/zip/extra_field/universal_time.rb +0 -47
- data/lib/hotplate/gems/rubyzip-1.1.7/lib/zip/extra_field/unix.rb +0 -38
- data/lib/hotplate/gems/rubyzip-1.1.7/lib/zip/extra_field/zip64.rb +0 -67
- data/lib/hotplate/gems/rubyzip-1.1.7/lib/zip/extra_field/zip64_placeholder.rb +0 -16
- data/lib/hotplate/gems/rubyzip-1.1.7/lib/zip/extra_field.rb +0 -101
- data/lib/hotplate/gems/rubyzip-1.1.7/lib/zip/file.rb +0 -436
- data/lib/hotplate/gems/rubyzip-1.1.7/lib/zip/filesystem.rb +0 -626
- data/lib/hotplate/gems/rubyzip-1.1.7/lib/zip/inflater.rb +0 -66
- data/lib/hotplate/gems/rubyzip-1.1.7/lib/zip/input_stream.rb +0 -164
- data/lib/hotplate/gems/rubyzip-1.1.7/lib/zip/ioextras/abstract_input_stream.rb +0 -115
- data/lib/hotplate/gems/rubyzip-1.1.7/lib/zip/ioextras/abstract_output_stream.rb +0 -45
- data/lib/hotplate/gems/rubyzip-1.1.7/lib/zip/ioextras.rb +0 -38
- data/lib/hotplate/gems/rubyzip-1.1.7/lib/zip/null_compressor.rb +0 -15
- data/lib/hotplate/gems/rubyzip-1.1.7/lib/zip/null_decompressor.rb +0 -27
- data/lib/hotplate/gems/rubyzip-1.1.7/lib/zip/null_input_stream.rb +0 -10
- data/lib/hotplate/gems/rubyzip-1.1.7/lib/zip/output_stream.rb +0 -190
- data/lib/hotplate/gems/rubyzip-1.1.7/lib/zip/pass_thru_compressor.rb +0 -23
- data/lib/hotplate/gems/rubyzip-1.1.7/lib/zip/pass_thru_decompressor.rb +0 -41
- data/lib/hotplate/gems/rubyzip-1.1.7/lib/zip/streamable_directory.rb +0 -15
- data/lib/hotplate/gems/rubyzip-1.1.7/lib/zip/streamable_stream.rb +0 -56
- data/lib/hotplate/gems/rubyzip-1.1.7/lib/zip/version.rb +0 -3
- data/lib/hotplate/gems/rubyzip-1.1.7/lib/zip.rb +0 -63
- data/lib/hotplate/gems/rubyzip-1.1.7/samples/example.rb +0 -91
- data/lib/hotplate/gems/rubyzip-1.1.7/samples/example_filesystem.rb +0 -33
- data/lib/hotplate/gems/rubyzip-1.1.7/samples/example_recursive.rb +0 -48
- data/lib/hotplate/gems/rubyzip-1.1.7/samples/gtkRubyzip.rb +0 -86
- data/lib/hotplate/gems/rubyzip-1.1.7/samples/qtzip.rb +0 -101
- data/lib/hotplate/gems/rubyzip-1.1.7/samples/write_simple.rb +0 -13
- data/lib/hotplate/gems/rubyzip-1.1.7/samples/zipfind.rb +0 -74
- data/lib/hotplate/gems/rubyzip-1.1.7/test/basic_zip_file_test.rb +0 -64
- data/lib/hotplate/gems/rubyzip-1.1.7/test/central_directory_entry_test.rb +0 -73
- data/lib/hotplate/gems/rubyzip-1.1.7/test/central_directory_test.rb +0 -104
- data/lib/hotplate/gems/rubyzip-1.1.7/test/crypto/null_encryption_test.rb +0 -53
- data/lib/hotplate/gems/rubyzip-1.1.7/test/crypto/traditional_encryption_test.rb +0 -80
- 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 +0 -46
- 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 +0 -1504
- 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 +0 -1
- data/lib/hotplate/gems/rubyzip-1.1.7/test/data/notzippedruby.rb +0 -7
- 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 +0 -67
- data/lib/hotplate/gems/rubyzip-1.1.7/test/encryption_test.rb +0 -42
- data/lib/hotplate/gems/rubyzip-1.1.7/test/entry_set_test.rb +0 -138
- data/lib/hotplate/gems/rubyzip-1.1.7/test/entry_test.rb +0 -165
- data/lib/hotplate/gems/rubyzip-1.1.7/test/errors_test.rb +0 -36
- data/lib/hotplate/gems/rubyzip-1.1.7/test/extra_field_test.rb +0 -78
- data/lib/hotplate/gems/rubyzip-1.1.7/test/file_extract_directory_test.rb +0 -56
- data/lib/hotplate/gems/rubyzip-1.1.7/test/file_extract_test.rb +0 -90
- data/lib/hotplate/gems/rubyzip-1.1.7/test/file_split_test.rb +0 -60
- data/lib/hotplate/gems/rubyzip-1.1.7/test/file_test.rb +0 -559
- data/lib/hotplate/gems/rubyzip-1.1.7/test/filesystem/dir_iterator_test.rb +0 -62
- data/lib/hotplate/gems/rubyzip-1.1.7/test/filesystem/directory_test.rb +0 -131
- data/lib/hotplate/gems/rubyzip-1.1.7/test/filesystem/file_mutating_test.rb +0 -100
- data/lib/hotplate/gems/rubyzip-1.1.7/test/filesystem/file_nonmutating_test.rb +0 -514
- data/lib/hotplate/gems/rubyzip-1.1.7/test/filesystem/file_stat_test.rb +0 -66
- data/lib/hotplate/gems/rubyzip-1.1.7/test/gentestfiles.rb +0 -134
- data/lib/hotplate/gems/rubyzip-1.1.7/test/inflater_test.rb +0 -14
- data/lib/hotplate/gems/rubyzip-1.1.7/test/input_stream_test.rb +0 -170
- data/lib/hotplate/gems/rubyzip-1.1.7/test/ioextras/abstract_input_stream_test.rb +0 -103
- data/lib/hotplate/gems/rubyzip-1.1.7/test/ioextras/abstract_output_stream_test.rb +0 -106
- data/lib/hotplate/gems/rubyzip-1.1.7/test/ioextras/fake_io_test.rb +0 -18
- data/lib/hotplate/gems/rubyzip-1.1.7/test/local_entry_test.rb +0 -156
- data/lib/hotplate/gems/rubyzip-1.1.7/test/output_stream_test.rb +0 -129
- data/lib/hotplate/gems/rubyzip-1.1.7/test/pass_thru_compressor_test.rb +0 -31
- data/lib/hotplate/gems/rubyzip-1.1.7/test/pass_thru_decompressor_test.rb +0 -15
- data/lib/hotplate/gems/rubyzip-1.1.7/test/settings_test.rb +0 -92
- data/lib/hotplate/gems/rubyzip-1.1.7/test/test_helper.rb +0 -228
- data/lib/hotplate/gems/rubyzip-1.1.7/test/unicode_file_names_and_comments_test.rb +0 -52
- data/lib/hotplate/gems/rubyzip-1.1.7/test/zip64_full_test.rb +0 -53
- data/lib/hotplate/gems/rubyzip-1.1.7/test/zip64_support_test.rb +0 -15
@@ -1,514 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
require 'zip/filesystem'
|
3
|
-
|
4
|
-
class ZipFsFileNonmutatingTest < MiniTest::Test
|
5
|
-
def setup
|
6
|
-
@zipsha = Digest::SHA1.file("test/data/zipWithDirs.zip")
|
7
|
-
@zip_file = ::Zip::File.new("test/data/zipWithDirs.zip")
|
8
|
-
end
|
9
|
-
|
10
|
-
def teardown
|
11
|
-
@zip_file.close if @zip_file
|
12
|
-
assert_equal(@zipsha, Digest::SHA1.file("test/data/zipWithDirs.zip"))
|
13
|
-
end
|
14
|
-
|
15
|
-
def test_umask
|
16
|
-
assert_equal(::File.umask, @zip_file.file.umask)
|
17
|
-
@zip_file.file.umask(0006)
|
18
|
-
end
|
19
|
-
|
20
|
-
def test_exists?
|
21
|
-
assert(! @zip_file.file.exists?("notAFile"))
|
22
|
-
assert(@zip_file.file.exists?("file1"))
|
23
|
-
assert(@zip_file.file.exists?("dir1"))
|
24
|
-
assert(@zip_file.file.exists?("dir1/"))
|
25
|
-
assert(@zip_file.file.exists?("dir1/file12"))
|
26
|
-
assert(@zip_file.file.exist?("dir1/file12")) # notice, tests exist? alias of exists? !
|
27
|
-
|
28
|
-
@zip_file.dir.chdir "dir1/"
|
29
|
-
assert(!@zip_file.file.exists?("file1"))
|
30
|
-
assert(@zip_file.file.exists?("file12"))
|
31
|
-
end
|
32
|
-
|
33
|
-
def test_open_read
|
34
|
-
blockCalled = false
|
35
|
-
@zip_file.file.open("file1", "r") {
|
36
|
-
|f|
|
37
|
-
blockCalled = true
|
38
|
-
assert_equal("this is the entry 'file1' in my test archive!",
|
39
|
-
f.readline.chomp)
|
40
|
-
}
|
41
|
-
assert(blockCalled)
|
42
|
-
|
43
|
-
blockCalled = false
|
44
|
-
@zip_file.file.open("file1", "rb") { # test binary flag is ignored
|
45
|
-
|f|
|
46
|
-
blockCalled = true
|
47
|
-
assert_equal("this is the entry 'file1' in my test archive!",
|
48
|
-
f.readline.chomp)
|
49
|
-
}
|
50
|
-
assert(blockCalled)
|
51
|
-
|
52
|
-
blockCalled = false
|
53
|
-
@zip_file.dir.chdir "dir2"
|
54
|
-
@zip_file.file.open("file21", "r") {
|
55
|
-
|f|
|
56
|
-
blockCalled = true
|
57
|
-
assert_equal("this is the entry 'dir2/file21' in my test archive!",
|
58
|
-
f.readline.chomp)
|
59
|
-
}
|
60
|
-
assert(blockCalled)
|
61
|
-
@zip_file.dir.chdir "/"
|
62
|
-
|
63
|
-
assert_raises(Errno::ENOENT) {
|
64
|
-
@zip_file.file.open("noSuchEntry")
|
65
|
-
}
|
66
|
-
|
67
|
-
begin
|
68
|
-
is = @zip_file.file.open("file1")
|
69
|
-
assert_equal("this is the entry 'file1' in my test archive!",
|
70
|
-
is.readline.chomp)
|
71
|
-
ensure
|
72
|
-
is.close if is
|
73
|
-
end
|
74
|
-
end
|
75
|
-
|
76
|
-
def test_new
|
77
|
-
begin
|
78
|
-
is = @zip_file.file.new("file1")
|
79
|
-
assert_equal("this is the entry 'file1' in my test archive!",
|
80
|
-
is.readline.chomp)
|
81
|
-
ensure
|
82
|
-
is.close if is
|
83
|
-
end
|
84
|
-
begin
|
85
|
-
is = @zip_file.file.new("file1") {
|
86
|
-
fail "should not call block"
|
87
|
-
}
|
88
|
-
ensure
|
89
|
-
is.close if is
|
90
|
-
end
|
91
|
-
end
|
92
|
-
|
93
|
-
def test_symlink
|
94
|
-
assert_raises(NotImplementedError) {
|
95
|
-
@zip_file.file.symlink("file1", "aSymlink")
|
96
|
-
}
|
97
|
-
end
|
98
|
-
|
99
|
-
def test_size
|
100
|
-
assert_raises(Errno::ENOENT) { @zip_file.file.size("notAFile") }
|
101
|
-
assert_equal(72, @zip_file.file.size("file1"))
|
102
|
-
assert_equal(0, @zip_file.file.size("dir2/dir21"))
|
103
|
-
|
104
|
-
assert_equal(72, @zip_file.file.stat("file1").size)
|
105
|
-
assert_equal(0, @zip_file.file.stat("dir2/dir21").size)
|
106
|
-
end
|
107
|
-
|
108
|
-
def test_size?
|
109
|
-
assert_equal(nil, @zip_file.file.size?("notAFile"))
|
110
|
-
assert_equal(72, @zip_file.file.size?("file1"))
|
111
|
-
assert_equal(nil, @zip_file.file.size?("dir2/dir21"))
|
112
|
-
|
113
|
-
assert_equal(72, @zip_file.file.stat("file1").size?)
|
114
|
-
assert_equal(nil, @zip_file.file.stat("dir2/dir21").size?)
|
115
|
-
end
|
116
|
-
|
117
|
-
|
118
|
-
def test_file?
|
119
|
-
assert(@zip_file.file.file?("file1"))
|
120
|
-
assert(@zip_file.file.file?("dir2/file21"))
|
121
|
-
assert(! @zip_file.file.file?("dir1"))
|
122
|
-
assert(! @zip_file.file.file?("dir1/dir11"))
|
123
|
-
|
124
|
-
assert(@zip_file.file.stat("file1").file?)
|
125
|
-
assert(@zip_file.file.stat("dir2/file21").file?)
|
126
|
-
assert(! @zip_file.file.stat("dir1").file?)
|
127
|
-
assert(! @zip_file.file.stat("dir1/dir11").file?)
|
128
|
-
end
|
129
|
-
|
130
|
-
include ExtraAssertions
|
131
|
-
|
132
|
-
def test_dirname
|
133
|
-
assert_forwarded(File, :dirname, "retVal", "a/b/c/d") {
|
134
|
-
@zip_file.file.dirname("a/b/c/d")
|
135
|
-
}
|
136
|
-
end
|
137
|
-
|
138
|
-
def test_basename
|
139
|
-
assert_forwarded(File, :basename, "retVal", "a/b/c/d") {
|
140
|
-
@zip_file.file.basename("a/b/c/d")
|
141
|
-
}
|
142
|
-
end
|
143
|
-
|
144
|
-
def test_split
|
145
|
-
assert_forwarded(File, :split, "retVal", "a/b/c/d") {
|
146
|
-
@zip_file.file.split("a/b/c/d")
|
147
|
-
}
|
148
|
-
end
|
149
|
-
|
150
|
-
def test_join
|
151
|
-
assert_equal("a/b/c", @zip_file.file.join("a/b", "c"))
|
152
|
-
assert_equal("a/b/c/d", @zip_file.file.join("a/b", "c/d"))
|
153
|
-
assert_equal("/c/d", @zip_file.file.join("", "c/d"))
|
154
|
-
assert_equal("a/b/c/d", @zip_file.file.join("a", "b", "c", "d"))
|
155
|
-
end
|
156
|
-
|
157
|
-
def test_utime
|
158
|
-
t_now = ::Zip::DOSTime.now
|
159
|
-
t_bak = @zip_file.file.mtime("file1")
|
160
|
-
@zip_file.file.utime(t_now, "file1")
|
161
|
-
assert_equal(t_now, @zip_file.file.mtime("file1"))
|
162
|
-
@zip_file.file.utime(t_bak, "file1")
|
163
|
-
assert_equal(t_bak, @zip_file.file.mtime("file1"))
|
164
|
-
end
|
165
|
-
|
166
|
-
|
167
|
-
def assert_always_false(operation)
|
168
|
-
assert(! @zip_file.file.send(operation, "noSuchFile"))
|
169
|
-
assert(! @zip_file.file.send(operation, "file1"))
|
170
|
-
assert(! @zip_file.file.send(operation, "dir1"))
|
171
|
-
assert(! @zip_file.file.stat("file1").send(operation))
|
172
|
-
assert(! @zip_file.file.stat("dir1").send(operation))
|
173
|
-
end
|
174
|
-
|
175
|
-
def assert_true_if_entry_exists(operation)
|
176
|
-
assert(! @zip_file.file.send(operation, "noSuchFile"))
|
177
|
-
assert(@zip_file.file.send(operation, "file1"))
|
178
|
-
assert(@zip_file.file.send(operation, "dir1"))
|
179
|
-
assert(@zip_file.file.stat("file1").send(operation))
|
180
|
-
assert(@zip_file.file.stat("dir1").send(operation))
|
181
|
-
end
|
182
|
-
|
183
|
-
def test_pipe?
|
184
|
-
assert_always_false(:pipe?)
|
185
|
-
end
|
186
|
-
|
187
|
-
def test_blockdev?
|
188
|
-
assert_always_false(:blockdev?)
|
189
|
-
end
|
190
|
-
|
191
|
-
def test_symlink?
|
192
|
-
assert_always_false(:symlink?)
|
193
|
-
end
|
194
|
-
|
195
|
-
def test_socket?
|
196
|
-
assert_always_false(:socket?)
|
197
|
-
end
|
198
|
-
|
199
|
-
def test_chardev?
|
200
|
-
assert_always_false(:chardev?)
|
201
|
-
end
|
202
|
-
|
203
|
-
def test_truncate
|
204
|
-
assert_raises(StandardError, "truncate not supported") {
|
205
|
-
@zip_file.file.truncate("file1", 100)
|
206
|
-
}
|
207
|
-
end
|
208
|
-
|
209
|
-
def assert_e_n_o_e_n_t(operation, args = ["NoSuchFile"])
|
210
|
-
assert_raises(Errno::ENOENT) {
|
211
|
-
@zip_file.file.send(operation, *args)
|
212
|
-
}
|
213
|
-
end
|
214
|
-
|
215
|
-
def test_ftype
|
216
|
-
assert_e_n_o_e_n_t(:ftype)
|
217
|
-
assert_equal("file", @zip_file.file.ftype("file1"))
|
218
|
-
assert_equal("directory", @zip_file.file.ftype("dir1/dir11"))
|
219
|
-
assert_equal("directory", @zip_file.file.ftype("dir1/dir11/"))
|
220
|
-
end
|
221
|
-
|
222
|
-
def test_link
|
223
|
-
assert_raises(NotImplementedError) {
|
224
|
-
@zip_file.file.link("file1", "someOtherString")
|
225
|
-
}
|
226
|
-
end
|
227
|
-
|
228
|
-
def test_directory?
|
229
|
-
assert(! @zip_file.file.directory?("notAFile"))
|
230
|
-
assert(! @zip_file.file.directory?("file1"))
|
231
|
-
assert(! @zip_file.file.directory?("dir1/file11"))
|
232
|
-
assert(@zip_file.file.directory?("dir1"))
|
233
|
-
assert(@zip_file.file.directory?("dir1/"))
|
234
|
-
assert(@zip_file.file.directory?("dir2/dir21"))
|
235
|
-
|
236
|
-
assert(! @zip_file.file.stat("file1").directory?)
|
237
|
-
assert(! @zip_file.file.stat("dir1/file11").directory?)
|
238
|
-
assert(@zip_file.file.stat("dir1").directory?)
|
239
|
-
assert(@zip_file.file.stat("dir1/").directory?)
|
240
|
-
assert(@zip_file.file.stat("dir2/dir21").directory?)
|
241
|
-
end
|
242
|
-
|
243
|
-
def test_chown
|
244
|
-
assert_equal(2, @zip_file.file.chown(1,2, "dir1", "file1"))
|
245
|
-
assert_equal(1, @zip_file.file.stat("dir1").uid)
|
246
|
-
assert_equal(2, @zip_file.file.stat("dir1").gid)
|
247
|
-
assert_equal(2, @zip_file.file.chown(nil, nil, "dir1", "file1"))
|
248
|
-
end
|
249
|
-
|
250
|
-
def test_zero?
|
251
|
-
assert(! @zip_file.file.zero?("notAFile"))
|
252
|
-
assert(! @zip_file.file.zero?("file1"))
|
253
|
-
assert(@zip_file.file.zero?("dir1"))
|
254
|
-
blockCalled = false
|
255
|
-
::Zip::File.open("test/data/generated/5entry.zip") {
|
256
|
-
|zf|
|
257
|
-
blockCalled = true
|
258
|
-
assert(zf.file.zero?("test/data/generated/empty.txt"))
|
259
|
-
}
|
260
|
-
assert(blockCalled)
|
261
|
-
|
262
|
-
assert(! @zip_file.file.stat("file1").zero?)
|
263
|
-
assert(@zip_file.file.stat("dir1").zero?)
|
264
|
-
blockCalled = false
|
265
|
-
::Zip::File.open("test/data/generated/5entry.zip") {
|
266
|
-
|zf|
|
267
|
-
blockCalled = true
|
268
|
-
assert(zf.file.stat("test/data/generated/empty.txt").zero?)
|
269
|
-
}
|
270
|
-
assert(blockCalled)
|
271
|
-
end
|
272
|
-
|
273
|
-
def test_expand_path
|
274
|
-
::Zip::File.open("test/data/zipWithDirs.zip") {
|
275
|
-
|zf|
|
276
|
-
assert_equal("/", zf.file.expand_path("."))
|
277
|
-
zf.dir.chdir "dir1"
|
278
|
-
assert_equal("/dir1", zf.file.expand_path("."))
|
279
|
-
assert_equal("/dir1/file12", zf.file.expand_path("file12"))
|
280
|
-
assert_equal("/", zf.file.expand_path(".."))
|
281
|
-
assert_equal("/dir2/dir21", zf.file.expand_path("../dir2/dir21"))
|
282
|
-
}
|
283
|
-
end
|
284
|
-
|
285
|
-
def test_mtime
|
286
|
-
assert_equal(::Zip::DOSTime.at(1027694306),
|
287
|
-
@zip_file.file.mtime("dir2/file21"))
|
288
|
-
assert_equal(::Zip::DOSTime.at(1027690863),
|
289
|
-
@zip_file.file.mtime("dir2/dir21"))
|
290
|
-
assert_raises(Errno::ENOENT) {
|
291
|
-
@zip_file.file.mtime("noSuchEntry")
|
292
|
-
}
|
293
|
-
|
294
|
-
assert_equal(::Zip::DOSTime.at(1027694306),
|
295
|
-
@zip_file.file.stat("dir2/file21").mtime)
|
296
|
-
assert_equal(::Zip::DOSTime.at(1027690863),
|
297
|
-
@zip_file.file.stat("dir2/dir21").mtime)
|
298
|
-
end
|
299
|
-
|
300
|
-
def test_ctime
|
301
|
-
assert_nil(@zip_file.file.ctime("file1"))
|
302
|
-
assert_nil(@zip_file.file.stat("file1").ctime)
|
303
|
-
end
|
304
|
-
|
305
|
-
def test_atime
|
306
|
-
assert_nil(@zip_file.file.atime("file1"))
|
307
|
-
assert_nil(@zip_file.file.stat("file1").atime)
|
308
|
-
end
|
309
|
-
|
310
|
-
def test_ntfs_time
|
311
|
-
::Zip::File.open("test/data/ntfs.zip") do |zf|
|
312
|
-
t = ::Zip::DOSTime.at(1410496497.405178)
|
313
|
-
assert_equal(zf.file.mtime("data.txt"), t)
|
314
|
-
assert_equal(zf.file.atime("data.txt"), t)
|
315
|
-
assert_equal(zf.file.ctime("data.txt"), t)
|
316
|
-
end
|
317
|
-
end
|
318
|
-
|
319
|
-
def test_readable?
|
320
|
-
assert(! @zip_file.file.readable?("noSuchFile"))
|
321
|
-
assert(@zip_file.file.readable?("file1"))
|
322
|
-
assert(@zip_file.file.readable?("dir1"))
|
323
|
-
assert(@zip_file.file.stat("file1").readable?)
|
324
|
-
assert(@zip_file.file.stat("dir1").readable?)
|
325
|
-
end
|
326
|
-
|
327
|
-
def test_readable_real?
|
328
|
-
assert(! @zip_file.file.readable_real?("noSuchFile"))
|
329
|
-
assert(@zip_file.file.readable_real?("file1"))
|
330
|
-
assert(@zip_file.file.readable_real?("dir1"))
|
331
|
-
assert(@zip_file.file.stat("file1").readable_real?)
|
332
|
-
assert(@zip_file.file.stat("dir1").readable_real?)
|
333
|
-
end
|
334
|
-
|
335
|
-
def test_writable?
|
336
|
-
assert(! @zip_file.file.writable?("noSuchFile"))
|
337
|
-
assert(@zip_file.file.writable?("file1"))
|
338
|
-
assert(@zip_file.file.writable?("dir1"))
|
339
|
-
assert(@zip_file.file.stat("file1").writable?)
|
340
|
-
assert(@zip_file.file.stat("dir1").writable?)
|
341
|
-
end
|
342
|
-
|
343
|
-
def test_writable_real?
|
344
|
-
assert(! @zip_file.file.writable_real?("noSuchFile"))
|
345
|
-
assert(@zip_file.file.writable_real?("file1"))
|
346
|
-
assert(@zip_file.file.writable_real?("dir1"))
|
347
|
-
assert(@zip_file.file.stat("file1").writable_real?)
|
348
|
-
assert(@zip_file.file.stat("dir1").writable_real?)
|
349
|
-
end
|
350
|
-
|
351
|
-
def test_executable?
|
352
|
-
assert(! @zip_file.file.executable?("noSuchFile"))
|
353
|
-
assert(! @zip_file.file.executable?("file1"))
|
354
|
-
assert(@zip_file.file.executable?("dir1"))
|
355
|
-
assert(! @zip_file.file.stat("file1").executable?)
|
356
|
-
assert(@zip_file.file.stat("dir1").executable?)
|
357
|
-
end
|
358
|
-
|
359
|
-
def test_executable_real?
|
360
|
-
assert(! @zip_file.file.executable_real?("noSuchFile"))
|
361
|
-
assert(! @zip_file.file.executable_real?("file1"))
|
362
|
-
assert(@zip_file.file.executable_real?("dir1"))
|
363
|
-
assert(! @zip_file.file.stat("file1").executable_real?)
|
364
|
-
assert(@zip_file.file.stat("dir1").executable_real?)
|
365
|
-
end
|
366
|
-
|
367
|
-
def test_owned?
|
368
|
-
assert_true_if_entry_exists(:owned?)
|
369
|
-
end
|
370
|
-
|
371
|
-
def test_grpowned?
|
372
|
-
assert_true_if_entry_exists(:grpowned?)
|
373
|
-
end
|
374
|
-
|
375
|
-
def test_setgid?
|
376
|
-
assert_always_false(:setgid?)
|
377
|
-
end
|
378
|
-
|
379
|
-
def test_setuid?
|
380
|
-
assert_always_false(:setgid?)
|
381
|
-
end
|
382
|
-
|
383
|
-
def test_sticky?
|
384
|
-
assert_always_false(:sticky?)
|
385
|
-
end
|
386
|
-
|
387
|
-
def test_readlink
|
388
|
-
assert_raises(NotImplementedError) {
|
389
|
-
@zip_file.file.readlink("someString")
|
390
|
-
}
|
391
|
-
end
|
392
|
-
|
393
|
-
def test_stat
|
394
|
-
s = @zip_file.file.stat("file1")
|
395
|
-
assert(s.kind_of?(File::Stat)) # It pretends
|
396
|
-
assert_raises(Errno::ENOENT, "No such file or directory - noSuchFile") {
|
397
|
-
@zip_file.file.stat("noSuchFile")
|
398
|
-
}
|
399
|
-
end
|
400
|
-
|
401
|
-
def test_lstat
|
402
|
-
assert(@zip_file.file.lstat("file1").file?)
|
403
|
-
end
|
404
|
-
|
405
|
-
def test_pipe
|
406
|
-
assert_raises(NotImplementedError) {
|
407
|
-
@zip_file.file.pipe
|
408
|
-
}
|
409
|
-
end
|
410
|
-
|
411
|
-
def test_foreach
|
412
|
-
::Zip::File.open("test/data/generated/zipWithDir.zip") do |zf|
|
413
|
-
ref = []
|
414
|
-
File.foreach("test/data/file1.txt") { |e| ref << e }
|
415
|
-
index = 0
|
416
|
-
|
417
|
-
zf.file.foreach("test/data/file1.txt") do |l|
|
418
|
-
#Ruby replaces \n with \r\n automatically on windows
|
419
|
-
newline = Zip::RUNNING_ON_WINDOWS ? l.gsub(/\r\n/, "\n") : l
|
420
|
-
assert_equal(ref[index], newline)
|
421
|
-
index = index.next
|
422
|
-
end
|
423
|
-
assert_equal(ref.size, index)
|
424
|
-
end
|
425
|
-
|
426
|
-
::Zip::File.open("test/data/generated/zipWithDir.zip") do |zf|
|
427
|
-
ref = []
|
428
|
-
File.foreach("test/data/file1.txt", " ") { |e| ref << e }
|
429
|
-
index = 0
|
430
|
-
|
431
|
-
zf.file.foreach("test/data/file1.txt", " ") do |l|
|
432
|
-
#Ruby replaces \n with \r\n automatically on windows
|
433
|
-
newline = Zip::RUNNING_ON_WINDOWS ? l.gsub(/\r\n/, "\n") : l
|
434
|
-
assert_equal(ref[index], newline)
|
435
|
-
index = index.next
|
436
|
-
end
|
437
|
-
assert_equal(ref.size, index)
|
438
|
-
end
|
439
|
-
end
|
440
|
-
|
441
|
-
def test_glob
|
442
|
-
::Zip::File.open('test/data/globTest.zip') do |zf|
|
443
|
-
{
|
444
|
-
'globTest/foo.txt' => ['globTest/foo.txt'],
|
445
|
-
'*/foo.txt' => ['globTest/foo.txt'],
|
446
|
-
'**/foo.txt' => ['globTest/foo.txt','globTest/foo/bar/baz/foo.txt'],
|
447
|
-
'*/foo/**/*.txt' => ['globTest/foo/bar/baz/foo.txt']
|
448
|
-
}.each do |spec,expected_results|
|
449
|
-
results = zf.glob(spec)
|
450
|
-
assert results.all?{|entry| entry.is_a? ::Zip::Entry }
|
451
|
-
|
452
|
-
result_strings = results.map(&:to_s)
|
453
|
-
missing_matches = expected_results - result_strings
|
454
|
-
extra_matches = result_strings - expected_results
|
455
|
-
|
456
|
-
assert extra_matches.empty?, %Q{spec #{spec.inspect} has extra results #{extra_matches.inspect}}
|
457
|
-
assert missing_matches.empty?, %Q{spec #{spec.inspect} missing results #{missing_matches.inspect}}
|
458
|
-
end
|
459
|
-
end
|
460
|
-
|
461
|
-
::Zip::File.open('test/data/globTest.zip') do |zf|
|
462
|
-
results = []
|
463
|
-
zf.glob('**/foo.txt') do |match|
|
464
|
-
results << "<#{match.class.name}: #{match.to_s}>"
|
465
|
-
end
|
466
|
-
assert((not results.empty?), 'block not run, or run out of context')
|
467
|
-
assert_equal 2, results.size
|
468
|
-
assert_operator results, :include?, '<Zip::Entry: globTest/foo.txt>'
|
469
|
-
assert_operator results, :include?, '<Zip::Entry: globTest/foo/bar/baz/foo.txt>'
|
470
|
-
end
|
471
|
-
end
|
472
|
-
|
473
|
-
def test_popen
|
474
|
-
if Zip::RUNNING_ON_WINDOWS
|
475
|
-
#This is pretty much projectile vomit but it allows the test to be
|
476
|
-
#run on windows also
|
477
|
-
system_dir = ::File.popen('dir') { |f| f.read }.gsub(/Dir\(s\).*$/, '')
|
478
|
-
zipfile_dir = @zip_file.file.popen('dir') { |f| f.read }.gsub(/Dir\(s\).*$/, '')
|
479
|
-
assert_equal(system_dir, zipfile_dir)
|
480
|
-
else
|
481
|
-
assert_equal(::File.popen('ls') { |f| f.read },
|
482
|
-
@zip_file.file.popen('ls') { |f| f.read })
|
483
|
-
end
|
484
|
-
end
|
485
|
-
|
486
|
-
# Can be added later
|
487
|
-
# def test_select
|
488
|
-
# fail "implement test"
|
489
|
-
# end
|
490
|
-
|
491
|
-
def test_readlines
|
492
|
-
::Zip::File.open("test/data/generated/zipWithDir.zip") do |zf|
|
493
|
-
orig_file = ::File.readlines("test/data/file1.txt")
|
494
|
-
zip_file = zf.file.readlines("test/data/file1.txt")
|
495
|
-
|
496
|
-
#Ruby replaces \n with \r\n automatically on windows
|
497
|
-
zip_file.each { |l| l.gsub!(/\r\n/, "\n") } if Zip::RUNNING_ON_WINDOWS
|
498
|
-
|
499
|
-
assert_equal(orig_file, zip_file)
|
500
|
-
end
|
501
|
-
end
|
502
|
-
|
503
|
-
def test_read
|
504
|
-
::Zip::File.open("test/data/generated/zipWithDir.zip") do |zf|
|
505
|
-
orig_file = ::File.read("test/data/file1.txt")
|
506
|
-
|
507
|
-
#Ruby replaces \n with \r\n automatically on windows
|
508
|
-
zip_file = Zip::RUNNING_ON_WINDOWS ? \
|
509
|
-
zf.file.read("test/data/file1.txt").gsub(/\r\n/, "\n") : zf.file.read("test/data/file1.txt")
|
510
|
-
assert_equal(orig_file, zip_file)
|
511
|
-
end
|
512
|
-
end
|
513
|
-
|
514
|
-
end
|
@@ -1,66 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
require 'zip/filesystem'
|
3
|
-
|
4
|
-
class ZipFsFileStatTest < MiniTest::Test
|
5
|
-
|
6
|
-
def setup
|
7
|
-
@zip_file = ::Zip::File.new("test/data/zipWithDirs.zip")
|
8
|
-
end
|
9
|
-
|
10
|
-
def teardown
|
11
|
-
@zip_file.close if @zip_file
|
12
|
-
end
|
13
|
-
|
14
|
-
def test_blocks
|
15
|
-
assert_equal(nil, @zip_file.file.stat("file1").blocks)
|
16
|
-
end
|
17
|
-
|
18
|
-
def test_ino
|
19
|
-
assert_equal(0, @zip_file.file.stat("file1").ino)
|
20
|
-
end
|
21
|
-
|
22
|
-
def test_uid
|
23
|
-
assert_equal(0, @zip_file.file.stat("file1").uid)
|
24
|
-
end
|
25
|
-
|
26
|
-
def test_gid
|
27
|
-
assert_equal(0, @zip_file.file.stat("file1").gid)
|
28
|
-
end
|
29
|
-
|
30
|
-
def test_ftype
|
31
|
-
assert_equal("file", @zip_file.file.stat("file1").ftype)
|
32
|
-
assert_equal("directory", @zip_file.file.stat("dir1").ftype)
|
33
|
-
end
|
34
|
-
|
35
|
-
def test_mode
|
36
|
-
assert_equal(0600, @zip_file.file.stat("file1").mode & 0777)
|
37
|
-
assert_equal(0600, @zip_file.file.stat("file1").mode & 0777)
|
38
|
-
assert_equal(0755, @zip_file.file.stat("dir1").mode & 0777)
|
39
|
-
assert_equal(0755, @zip_file.file.stat("dir1").mode & 0777)
|
40
|
-
end
|
41
|
-
|
42
|
-
def test_dev
|
43
|
-
assert_equal(0, @zip_file.file.stat("file1").dev)
|
44
|
-
end
|
45
|
-
|
46
|
-
def test_rdev
|
47
|
-
assert_equal(0, @zip_file.file.stat("file1").rdev)
|
48
|
-
end
|
49
|
-
|
50
|
-
def test_rdev_major
|
51
|
-
assert_equal(0, @zip_file.file.stat("file1").rdev_major)
|
52
|
-
end
|
53
|
-
|
54
|
-
def test_rdev_minor
|
55
|
-
assert_equal(0, @zip_file.file.stat("file1").rdev_minor)
|
56
|
-
end
|
57
|
-
|
58
|
-
def test_nlink
|
59
|
-
assert_equal(1, @zip_file.file.stat("file1").nlink)
|
60
|
-
end
|
61
|
-
|
62
|
-
def test_blksize
|
63
|
-
assert_nil(@zip_file.file.stat("file1").blksize)
|
64
|
-
end
|
65
|
-
|
66
|
-
end
|