zip-container 2.2.0 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +8 -8
- data/.travis.yml +1 -0
- data/Changes.rdoc +14 -0
- data/Licence.rdoc +1 -1
- data/ReadMe.rdoc +20 -8
- data/lib/zip-container/container.rb +47 -19
- data/lib/zip-container/entries/directory.rb +10 -6
- data/lib/zip-container/entries/entry.rb +23 -18
- data/lib/zip-container/entries/file.rb +10 -7
- data/lib/zip-container/entries/managed.rb +18 -6
- data/lib/zip-container/exceptions.rb +17 -12
- data/test/tc_exceptions.rb +54 -5
- data/test/tc_managed_entries.rb +6 -6
- data/test/tc_read_dir.rb +8 -4
- data/test/tc_read_file.rb +13 -4
- data/test/tc_reserved_names.rb +1 -1
- data/version.yml +2 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
ZmQ3NGUzNmM1NmRlMDE4ZmRjY2NlODQyYTc4Zjc5NDRjYWI3NGJmOA==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
MTAwMjhkMjZhOTRhZjAwNThhMDg5OTM0ZjE4MmQyNGNjNjJlYzdmYQ==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
NThkZjFkYzkyMThkYjg3OGY5YThiYzBjNmU4YTRkYjY0M2MwYzg0NmEwYjdj
|
10
|
+
MTEzMDY0NTY1YmYyNmY3Nzk2YmUwNzcyNDAxMWUyMjUzZDZlMDQ0ZmFlNDVm
|
11
|
+
MDI0Zjc1ZTAxMWUzZTE5NWI0Y2YwNjc2MDBlYjljNjExZDllZTk=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
Yzk0OTM5NDY2NzViYjJjZjlhNDk1NGRjNDE2OGU5MzM5ZjMzMTM0NDY1ZDFj
|
14
|
+
M2FmNmQ5ZmI2MWZhODM2ZGYwMTFkOGQzNTdjNzNiYjU3YjY4NDlmYjBiMmUx
|
15
|
+
YWZkZDI4ZjYzZmRiNTk0M2M5NTA1N2U4NGQ4NjBhODcxZTQ0NTE=
|
data/.travis.yml
CHANGED
data/Changes.rdoc
CHANGED
@@ -1,5 +1,19 @@
|
|
1
1
|
= Changes log for the ZIP Container Ruby Gem
|
2
2
|
|
3
|
+
== Version 3.0.0
|
4
|
+
|
5
|
+
* Refactor the malformed container error constructor.
|
6
|
+
* Verifying entries only raises errors at the last moment.
|
7
|
+
* Redesign the verification system.
|
8
|
+
* Update badges to use SVG versions.
|
9
|
+
* Fix the documentation for updated verify methods.
|
10
|
+
* Fix Container#verify so that it returns consistent types.
|
11
|
+
* Rename ContainerError -> Error.
|
12
|
+
* Reword the exceptions so they don't specify "file".
|
13
|
+
* Add ruby 2.2.0 to the Travis test matrix.
|
14
|
+
* Add a compatibility note about ContainerError.
|
15
|
+
* Improve the Usage information in the ReadMe.
|
16
|
+
|
3
17
|
== Version 2.2.0
|
4
18
|
|
5
19
|
* Fix pathname bug in ZipContainer::Dir.
|
data/Licence.rdoc
CHANGED
data/ReadMe.rdoc
CHANGED
@@ -5,12 +5,12 @@ Contact:: mailto:support@mygrid.org.uk
|
|
5
5
|
Homepage:: http://mygrid.github.io/ruby-zip-container
|
6
6
|
Source code:: https://github.com/myGrid/ruby-zip-container
|
7
7
|
Licence:: BSD (See Licence file or http://www.opensource.org/licenses/bsd-license.php)
|
8
|
-
Copyright:: (c) 2013
|
8
|
+
Copyright:: (c) 2013-2015 The University of Manchester, UK
|
9
9
|
|
10
|
-
{<img src="https://badge.fury.io/rb/zip-container.
|
11
|
-
{<img src="https://codeclimate.com/github/myGrid/ruby-zip-container.
|
10
|
+
{<img src="https://badge.fury.io/rb/zip-container.svg" alt="Gem Version" />}[http://badge.fury.io/rb/zip-container]
|
11
|
+
{<img src="https://codeclimate.com/github/myGrid/ruby-zip-container.svg" />}[https://codeclimate.com/github/myGrid/ruby-zip-container]
|
12
12
|
{<img src="https://travis-ci.org/myGrid/ruby-zip-container.svg?branch=master" alt="Build Status" />}[https://travis-ci.org/myGrid/ruby-zip-container]
|
13
|
-
{<img src="https://coveralls.io/repos/myGrid/ruby-zip-container/badge.
|
13
|
+
{<img src="https://coveralls.io/repos/myGrid/ruby-zip-container/badge.svg?branch=master" alt="Coverage Status" />}[https://coveralls.io/r/myGrid/ruby-zip-container?branch=master]
|
14
14
|
|
15
15
|
== Synopsis
|
16
16
|
|
@@ -36,6 +36,11 @@ underlying rubyzip API (Zip::File) and allows this library to work with
|
|
36
36
|
ZipContainer::Container should not be used directly from version 2.0.0
|
37
37
|
onwards.
|
38
38
|
|
39
|
+
=== ContainerError
|
40
|
+
|
41
|
+
This class has been renamed in version 3.0.0. It is now simply called Error so
|
42
|
+
that it's fully qualified name is the more sensible ZipContainer::Error.
|
43
|
+
|
39
44
|
=== Rubyzip
|
40
45
|
|
41
46
|
Version 1.0.0 and up of this gem uses version 1.0.0 and up of the
|
@@ -46,10 +51,17 @@ in the rubyzip readme for a workaround.
|
|
46
51
|
|
47
52
|
== Usage
|
48
53
|
|
49
|
-
This library
|
50
|
-
|
51
|
-
|
52
|
-
|
54
|
+
This library has two entry points.
|
55
|
+
|
56
|
+
The main ZipContainer::File class largely mimics the rubyzip
|
57
|
+
{Zip::File}[http://www.rubydoc.info/gems/rubyzip/1.1.6/Zip/File] and
|
58
|
+
{Zip::FileSystem}[http://www.rubydoc.info/gems/rubyzip/1.1.6/Zip/FileSystem]
|
59
|
+
APIs so much of what you can do with them are supported for ZIP Containers.
|
60
|
+
There is also {API documentation}[http://mygrid.github.io/ruby-zip-container/]
|
61
|
+
with much more detail and any differences explained.
|
62
|
+
|
63
|
+
The ZipContainer::Dir class mimics, where possible, the core ruby
|
64
|
+
{Dir API}[http://ruby-doc.org/core-1.9.3/Dir.html].
|
53
65
|
|
54
66
|
There are some examples of how to use the library provided in the examples
|
55
67
|
directory. See the contents of the tests directory for even more.
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (c) 2014 The University of Manchester, UK.
|
1
|
+
# Copyright (c) 2014, 2015 The University of Manchester, UK.
|
2
2
|
#
|
3
3
|
# All rights reserved.
|
4
4
|
#
|
@@ -52,8 +52,8 @@ module ZipContainer
|
|
52
52
|
def initialize(location)
|
53
53
|
@container = open_container(location)
|
54
54
|
|
55
|
-
|
56
|
-
@mimetype = read_mimetype
|
55
|
+
@mimetype_error = verify_mimetype
|
56
|
+
@mimetype = read_mimetype if @mimetype_error.nil?
|
57
57
|
|
58
58
|
# Reserved entry names. Just the mimetype file by default.
|
59
59
|
register_reserved_name(MIMETYPE_FILE)
|
@@ -84,19 +84,26 @@ module ZipContainer
|
|
84
84
|
end
|
85
85
|
|
86
86
|
# :call-seq:
|
87
|
-
# verify(filename) ->
|
87
|
+
# verify(filename) -> Array
|
88
88
|
#
|
89
89
|
# Verify that the specified ZipContainer conforms to the specification.
|
90
|
-
# This method returns
|
91
|
-
#
|
90
|
+
# This method returns a list of problems with the container.
|
91
|
+
#
|
92
|
+
# Exceptions are still raised for fundamental file system errors.
|
92
93
|
def self.verify(filename)
|
93
|
-
|
94
|
-
|
95
|
-
rescue
|
96
|
-
return false
|
97
|
-
end
|
94
|
+
new(filename).verify
|
95
|
+
end
|
98
96
|
|
99
|
-
|
97
|
+
# :call-seq:
|
98
|
+
# verify?(filename) -> boolean
|
99
|
+
#
|
100
|
+
# Verify that the specified ZipContainer conforms to the specification.
|
101
|
+
# This method returns +false+ if there are any problems at all with the
|
102
|
+
# container.
|
103
|
+
#
|
104
|
+
# Exceptions are still raised for fundamental file system errors.
|
105
|
+
def self.verify?(filename)
|
106
|
+
new(filename).verify?
|
100
107
|
end
|
101
108
|
|
102
109
|
# :call-seq:
|
@@ -111,19 +118,40 @@ module ZipContainer
|
|
111
118
|
end
|
112
119
|
|
113
120
|
# :call-seq:
|
114
|
-
# verify
|
121
|
+
# verify -> Array
|
115
122
|
#
|
116
123
|
# Verify the contents of this ZipContainer file. All managed files and
|
117
124
|
# directories are checked to make sure that they exist, if required.
|
118
|
-
def verify
|
119
|
-
verify_managed_entries
|
125
|
+
def verify
|
126
|
+
@mimetype_error.nil? ? verify_managed_entries : [@mimetype_error]
|
120
127
|
end
|
121
128
|
|
122
|
-
|
129
|
+
# :call-seq:
|
130
|
+
# verify? -> true or false
|
131
|
+
#
|
132
|
+
# Verify the contents of this ZipContainer file. All managed files and
|
133
|
+
# directories are checked to make sure that they exist, if required.
|
134
|
+
#
|
135
|
+
# This method returns +false+ if there are any problems at all with the
|
136
|
+
# container.
|
137
|
+
def verify?
|
138
|
+
verify.empty? ? true : false
|
139
|
+
end
|
140
|
+
|
141
|
+
# :call-seq:
|
142
|
+
# verify!
|
143
|
+
#
|
144
|
+
# Verify the contents of this ZipContainer file. All managed files and
|
145
|
+
# directories are checked to make sure that they exist, if required.
|
146
|
+
#
|
147
|
+
# This method raises a MalformedContainerError if there are any problems
|
148
|
+
# with the container.
|
149
|
+
def verify!
|
150
|
+
unless @mimetype_error.nil?
|
151
|
+
raise MalformedContainerError.new(@mimetype_error)
|
152
|
+
end
|
123
153
|
|
124
|
-
|
125
|
-
message = verify_mimetype
|
126
|
-
raise MalformedContainerError.new(message) unless message.nil?
|
154
|
+
verify_managed_entries!
|
127
155
|
end
|
128
156
|
|
129
157
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (c) 2013 The University of Manchester, UK.
|
1
|
+
# Copyright (c) 2013-2015 The University of Manchester, UK.
|
2
2
|
#
|
3
3
|
# All rights reserved.
|
4
4
|
#
|
@@ -66,15 +66,19 @@ module ZipContainer
|
|
66
66
|
end
|
67
67
|
|
68
68
|
# :call-seq:
|
69
|
-
# verify
|
69
|
+
# verify -> Array
|
70
70
|
#
|
71
71
|
# Verify this ManagedDirectory for correctness. ManagedFiles registered
|
72
72
|
# within it are verified recursively.
|
73
73
|
#
|
74
|
-
#
|
75
|
-
|
76
|
-
|
77
|
-
|
74
|
+
# If it does not pass verification a list of reasons why it fails is
|
75
|
+
# returned. The empty list is returned if verification passes.
|
76
|
+
def verify
|
77
|
+
messages = super
|
78
|
+
|
79
|
+
@files.values.each { |f| messages + f.verify }
|
80
|
+
|
81
|
+
messages
|
78
82
|
end
|
79
83
|
|
80
84
|
end
|
@@ -103,38 +103,43 @@ module ZipContainer
|
|
103
103
|
# :startdoc:
|
104
104
|
|
105
105
|
# :call-seq:
|
106
|
-
# verify ->
|
106
|
+
# verify -> Array
|
107
107
|
#
|
108
|
-
# Verify this ManagedEntry
|
109
|
-
#
|
110
|
-
#
|
108
|
+
# Verify this ManagedEntry returning a list of reasons why it fails if it
|
109
|
+
# does so. The empty list is returned if verification passes.
|
110
|
+
#
|
111
|
+
# Subclasses should override this method if they require more complex
|
112
|
+
# verification to be done.
|
111
113
|
def verify
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
114
|
+
unless !@required || exists?
|
115
|
+
["Entry '#{full_name}' is required but missing."]
|
116
|
+
else
|
117
|
+
[]
|
116
118
|
end
|
117
|
-
|
118
|
-
true
|
119
119
|
end
|
120
120
|
|
121
|
-
|
121
|
+
# :call-seq:
|
122
|
+
# verify? -> true or false
|
123
|
+
#
|
124
|
+
# Verify this ManagedEntry by checking that it exists if it is required
|
125
|
+
# according to its Container specification and validating its contents if
|
126
|
+
# necessary.
|
127
|
+
def verify?
|
128
|
+
verify.empty?
|
129
|
+
end
|
122
130
|
|
123
131
|
# :call-seq:
|
124
132
|
# verify!
|
125
133
|
#
|
126
134
|
# Verify this ManagedEntry raising a MalformedContainerError if it
|
127
135
|
# fails.
|
128
|
-
#
|
129
|
-
# Subclasses should override this method if they require more complex
|
130
|
-
# verification to be done.
|
131
136
|
def verify!
|
132
|
-
|
133
|
-
|
134
|
-
"but missing.")
|
135
|
-
end
|
137
|
+
messages = verify
|
138
|
+
raise MalformedContainerError.new(messages) unless messages.empty?
|
136
139
|
end
|
137
140
|
|
141
|
+
protected
|
142
|
+
|
138
143
|
# :call-seq:
|
139
144
|
# container -> Container
|
140
145
|
#
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (c) 2013 The University of Manchester, UK.
|
1
|
+
# Copyright (c) 2013-2015 The University of Manchester, UK.
|
2
2
|
#
|
3
3
|
# All rights reserved.
|
4
4
|
#
|
@@ -73,18 +73,21 @@ module ZipContainer
|
|
73
73
|
end
|
74
74
|
|
75
75
|
# :call-seq:
|
76
|
-
# verify
|
76
|
+
# verify -> Array
|
77
77
|
#
|
78
78
|
# Verify this ManagedFile for correctness. The contents are validated if
|
79
79
|
# required.
|
80
80
|
#
|
81
|
-
#
|
82
|
-
|
83
|
-
|
81
|
+
# If it does not pass verification a list of reasons why it fails is
|
82
|
+
# returned. The empty list is returned if verification passes.
|
83
|
+
def verify
|
84
|
+
messages = super
|
85
|
+
|
84
86
|
unless (exists? ? validate : true)
|
85
|
-
|
86
|
-
"'#{full_name}' do not pass validation.")
|
87
|
+
messages << "The contents of file '#{full_name}' do not pass validation."
|
87
88
|
end
|
89
|
+
|
90
|
+
messages
|
88
91
|
end
|
89
92
|
|
90
93
|
protected
|
@@ -146,20 +146,32 @@ module ZipContainer
|
|
146
146
|
end
|
147
147
|
|
148
148
|
# :call-seq:
|
149
|
-
# verify_managed_entries
|
149
|
+
# verify_managed_entries -> Array
|
150
150
|
#
|
151
151
|
# All managed files and directories are checked to make sure that they
|
152
|
-
# exist, if required.
|
153
|
-
def verify_managed_entries
|
152
|
+
# exist and validate, if required.
|
153
|
+
def verify_managed_entries
|
154
|
+
messages = []
|
155
|
+
|
154
156
|
@directories.each_value do |dir|
|
155
|
-
dir.verify
|
157
|
+
messages += dir.verify
|
156
158
|
end
|
157
159
|
|
158
160
|
@files.each_value do |file|
|
159
|
-
file.verify
|
161
|
+
messages += file.verify
|
160
162
|
end
|
161
163
|
|
162
|
-
|
164
|
+
messages
|
165
|
+
end
|
166
|
+
|
167
|
+
# :call-seq:
|
168
|
+
# verify_managed_entries!
|
169
|
+
#
|
170
|
+
# All managed files and directories are checked to make sure that they
|
171
|
+
# exist and validate, if required.
|
172
|
+
def verify_managed_entries!
|
173
|
+
messages = verify_managed_entries
|
174
|
+
raise MalformedContainerError.new(messages) unless messages.empty?
|
163
175
|
end
|
164
176
|
|
165
177
|
protected
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (c) 2013
|
1
|
+
# Copyright (c) 2013-2015 The University of Manchester, UK.
|
2
2
|
#
|
3
3
|
# All rights reserved.
|
4
4
|
#
|
@@ -34,27 +34,32 @@
|
|
34
34
|
module ZipContainer
|
35
35
|
|
36
36
|
# The base of all exceptions raised by this library.
|
37
|
-
module
|
37
|
+
module Error
|
38
38
|
end
|
39
39
|
|
40
40
|
# Shadow Zip::Error so the rubyzip API doesn't leak out.
|
41
41
|
ZipError = ::Zip::Error
|
42
|
-
ZipError.send(:include,
|
42
|
+
ZipError.send(:include, Error)
|
43
43
|
|
44
44
|
# This exception is raised when a bad Container is detected.
|
45
45
|
class MalformedContainerError < RuntimeError
|
46
|
-
include
|
46
|
+
include Error
|
47
47
|
|
48
48
|
# :call-seq:
|
49
|
-
# new
|
49
|
+
# new
|
50
|
+
# new(reason)
|
51
|
+
# new(reason_list)
|
50
52
|
#
|
51
|
-
# Create a new MalformedContainerError with an optional reason
|
52
|
-
# the Container
|
53
|
+
# Create a new MalformedContainerError with an optional reason or list of
|
54
|
+
# reasons for why the Container is malformed.
|
53
55
|
def initialize(reason = nil)
|
54
|
-
if reason.nil?
|
55
|
-
super("Malformed Container
|
56
|
+
if reason.nil? || reason.empty?
|
57
|
+
super("Malformed Container.")
|
58
|
+
elsif reason.is_a?(Array)
|
59
|
+
reasons = reason.map { |r| " * #{r}\n" }
|
60
|
+
super("Malformed Container:\n#{reasons}")
|
56
61
|
else
|
57
|
-
super("Malformed Container
|
62
|
+
super("Malformed Container: #{reason}")
|
58
63
|
end
|
59
64
|
end
|
60
65
|
end
|
@@ -62,14 +67,14 @@ module ZipContainer
|
|
62
67
|
# This exception is raised when a clash occurs with a reserved or managed
|
63
68
|
# name.
|
64
69
|
class ReservedNameClashError < RuntimeError
|
65
|
-
include
|
70
|
+
include Error
|
66
71
|
|
67
72
|
# :call-seq:
|
68
73
|
# new(name)
|
69
74
|
#
|
70
75
|
# Create a new ReservedNameClashError with the name of the clash supplied.
|
71
76
|
def initialize(name)
|
72
|
-
super("'#{name}' is reserved for internal use in this ZipContainer
|
77
|
+
super("'#{name}' is reserved for internal use in this ZipContainer.")
|
73
78
|
end
|
74
79
|
end
|
75
80
|
|
data/test/tc_exceptions.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (c) 2014 The University of Manchester, UK.
|
1
|
+
# Copyright (c) 2014, 2015 The University of Manchester, UK.
|
2
2
|
#
|
3
3
|
# All rights reserved.
|
4
4
|
#
|
@@ -36,21 +36,70 @@ require 'zip-container'
|
|
36
36
|
class TestExceptions < Test::Unit::TestCase
|
37
37
|
|
38
38
|
def test_rescue_container_errors
|
39
|
-
assert_raise(ZipContainer::
|
39
|
+
assert_raise(ZipContainer::Error) do
|
40
40
|
raise ZipContainer::ZipError.new
|
41
41
|
end
|
42
42
|
|
43
|
-
assert_raise(ZipContainer::
|
43
|
+
assert_raise(ZipContainer::Error) do
|
44
44
|
raise ZipContainer::MalformedContainerError.new
|
45
45
|
end
|
46
46
|
|
47
|
-
assert_raise(ZipContainer::
|
47
|
+
assert_raise(ZipContainer::Error) do
|
48
48
|
raise ZipContainer::ReservedNameClashError.new("test")
|
49
49
|
end
|
50
50
|
|
51
|
-
assert_raise(ZipContainer::
|
51
|
+
assert_raise(ZipContainer::Error) do
|
52
52
|
raise Zip::ZipError.new
|
53
53
|
end
|
54
54
|
end
|
55
55
|
|
56
|
+
def test_malformed_container_error_nil
|
57
|
+
mce = nil
|
58
|
+
|
59
|
+
assert_nothing_raised do
|
60
|
+
mce = ZipContainer::MalformedContainerError.new(nil)
|
61
|
+
end
|
62
|
+
|
63
|
+
refute mce.message.empty?
|
64
|
+
refute mce.message.include?(':')
|
65
|
+
end
|
66
|
+
|
67
|
+
def test_malformed_container_error_empty_string
|
68
|
+
mce = nil
|
69
|
+
|
70
|
+
assert_nothing_raised do
|
71
|
+
mce = ZipContainer::MalformedContainerError.new("")
|
72
|
+
end
|
73
|
+
|
74
|
+
refute mce.message.empty?
|
75
|
+
refute mce.message.include?(':')
|
76
|
+
end
|
77
|
+
|
78
|
+
def test_malformed_container_error_string
|
79
|
+
mce = nil
|
80
|
+
message = "test"
|
81
|
+
|
82
|
+
assert_nothing_raised do
|
83
|
+
mce = ZipContainer::MalformedContainerError.new(message)
|
84
|
+
end
|
85
|
+
|
86
|
+
refute mce.message.empty?
|
87
|
+
assert mce.message.include?(':')
|
88
|
+
assert mce.message.include?(message)
|
89
|
+
end
|
90
|
+
|
91
|
+
def test_malformed_container_error_list
|
92
|
+
mce = nil
|
93
|
+
message = %w(test1 test2)
|
94
|
+
|
95
|
+
assert_nothing_raised do
|
96
|
+
mce = ZipContainer::MalformedContainerError.new(message)
|
97
|
+
end
|
98
|
+
|
99
|
+
refute mce.message.empty?
|
100
|
+
assert mce.message.include?(':')
|
101
|
+
assert mce.message.include?(' * test1')
|
102
|
+
assert mce.message.include?(' * test2')
|
103
|
+
end
|
104
|
+
|
56
105
|
end
|
data/test/tc_managed_entries.rb
CHANGED
@@ -112,7 +112,7 @@ class TestManagedEntries < Test::Unit::TestCase
|
|
112
112
|
# Check that the example ZipContainer file does not validate as a
|
113
113
|
# ManagedZipContainer.
|
114
114
|
def test_fail_verification
|
115
|
-
refute(ManagedZipContainer.verify($example))
|
115
|
+
refute(ManagedZipContainer.verify?($example))
|
116
116
|
|
117
117
|
assert_raises(ZipContainer::MalformedContainerError) do
|
118
118
|
ManagedZipContainer.verify!($example)
|
@@ -122,7 +122,7 @@ class TestManagedEntries < Test::Unit::TestCase
|
|
122
122
|
# Check that the example ZipContainer file does validate as an
|
123
123
|
# ExampleZipContainer.
|
124
124
|
def test_pass_verification
|
125
|
-
assert(ExampleZipContainer.verify($example))
|
125
|
+
assert(ExampleZipContainer.verify?($example))
|
126
126
|
|
127
127
|
assert_nothing_raised(ZipContainer::MalformedContainerError) do
|
128
128
|
ExampleZipContainer.verify!($example)
|
@@ -132,7 +132,7 @@ class TestManagedEntries < Test::Unit::TestCase
|
|
132
132
|
# Check that the example ZipContainer file does validate as an
|
133
133
|
# ExampleZipContainer2.
|
134
134
|
def test_pass_verification_2
|
135
|
-
assert(ExampleZipContainer2.verify($example))
|
135
|
+
assert(ExampleZipContainer2.verify?($example))
|
136
136
|
|
137
137
|
assert_nothing_raised(ZipContainer::MalformedContainerError) do
|
138
138
|
ExampleZipContainer2.verify!($example)
|
@@ -208,7 +208,7 @@ class TestManagedEntries < Test::Unit::TestCase
|
|
208
208
|
end
|
209
209
|
end
|
210
210
|
|
211
|
-
refute(ManagedZipContainer.verify(filename))
|
211
|
+
refute(ManagedZipContainer.verify?(filename))
|
212
212
|
assert_raises(ZipContainer::MalformedContainerError) do
|
213
213
|
ManagedZipContainer.verify!(filename)
|
214
214
|
end
|
@@ -250,7 +250,7 @@ class TestManagedEntries < Test::Unit::TestCase
|
|
250
250
|
end
|
251
251
|
end
|
252
252
|
|
253
|
-
assert(ManagedZipContainer.verify(filename))
|
253
|
+
assert(ManagedZipContainer.verify?(filename))
|
254
254
|
assert_nothing_raised(ZipContainer::MalformedContainerError) do
|
255
255
|
ManagedZipContainer.verify!(filename)
|
256
256
|
end
|
@@ -389,7 +389,7 @@ class TestManagedEntries < Test::Unit::TestCase
|
|
389
389
|
end
|
390
390
|
end
|
391
391
|
|
392
|
-
assert(ExampleZipContainer2.verify(filename))
|
392
|
+
assert(ExampleZipContainer2.verify?(filename))
|
393
393
|
assert_nothing_raised(ZipContainer::MalformedContainerError) do
|
394
394
|
ExampleZipContainer2.verify!(filename)
|
395
395
|
end
|
data/test/tc_read_dir.rb
CHANGED
@@ -42,7 +42,8 @@ class TestReadDir < Test::Unit::TestCase
|
|
42
42
|
ZipContainer::Dir.verify!($dir_null)
|
43
43
|
end
|
44
44
|
|
45
|
-
refute(ZipContainer::Dir.verify($dir_null))
|
45
|
+
refute(ZipContainer::Dir.verify($dir_null).empty?)
|
46
|
+
refute(ZipContainer::Dir.verify?($dir_null))
|
46
47
|
end
|
47
48
|
|
48
49
|
# Check that the empty container directory does verify.
|
@@ -51,7 +52,8 @@ class TestReadDir < Test::Unit::TestCase
|
|
51
52
|
ZipContainer::Dir.verify!($dir_empty)
|
52
53
|
end
|
53
54
|
|
54
|
-
assert(ZipContainer::Dir.verify($dir_empty))
|
55
|
+
assert(ZipContainer::Dir.verify($dir_empty).empty?)
|
56
|
+
assert(ZipContainer::Dir.verify?($dir_empty))
|
55
57
|
end
|
56
58
|
|
57
59
|
# Check that a mimetype entry that is a directory does not verify.
|
@@ -60,7 +62,8 @@ class TestReadDir < Test::Unit::TestCase
|
|
60
62
|
ZipContainer::Dir.verify!($dir_dir_mimetype)
|
61
63
|
end
|
62
64
|
|
63
|
-
refute(ZipContainer::Dir.verify($dir_dir_mimetype))
|
65
|
+
refute(ZipContainer::Dir.verify($dir_dir_mimetype).empty?)
|
66
|
+
refute(ZipContainer::Dir.verify?($dir_dir_mimetype))
|
64
67
|
end
|
65
68
|
|
66
69
|
# Check that a mimetype which is not readable does not verify. We have to
|
@@ -79,7 +82,8 @@ class TestReadDir < Test::Unit::TestCase
|
|
79
82
|
ZipContainer::Dir.verify!(container)
|
80
83
|
end
|
81
84
|
|
82
|
-
refute(ZipContainer::Dir.verify(container))
|
85
|
+
refute(ZipContainer::Dir.verify(container).empty?)
|
86
|
+
refute(ZipContainer::Dir.verify?(container))
|
83
87
|
end
|
84
88
|
end
|
85
89
|
|
data/test/tc_read_file.rb
CHANGED
@@ -37,11 +37,17 @@ class TestReadFile < Test::Unit::TestCase
|
|
37
37
|
|
38
38
|
# Check that the null file does not verify.
|
39
39
|
def test_verify_null_file
|
40
|
+
assert_raise(ZipContainer::ZipError) do
|
41
|
+
ZipContainer::File.verify($file_null)
|
42
|
+
end
|
43
|
+
|
40
44
|
assert_raise(ZipContainer::ZipError) do
|
41
45
|
ZipContainer::File.verify!($file_null)
|
42
46
|
end
|
43
47
|
|
44
|
-
|
48
|
+
assert_raise(ZipContainer::ZipError) do
|
49
|
+
ZipContainer::File.verify?($file_null)
|
50
|
+
end
|
45
51
|
end
|
46
52
|
|
47
53
|
# Check that the empty container file does verify.
|
@@ -50,7 +56,8 @@ class TestReadFile < Test::Unit::TestCase
|
|
50
56
|
ZipContainer::File.verify!($empty)
|
51
57
|
end
|
52
58
|
|
53
|
-
assert(ZipContainer::File.verify($empty))
|
59
|
+
assert(ZipContainer::File.verify($empty).empty?)
|
60
|
+
assert(ZipContainer::File.verify?($empty))
|
54
61
|
end
|
55
62
|
|
56
63
|
# Check that the empty zip file does not verify.
|
@@ -59,7 +66,8 @@ class TestReadFile < Test::Unit::TestCase
|
|
59
66
|
ZipContainer::File.verify!($empty_zip)
|
60
67
|
end
|
61
68
|
|
62
|
-
refute(ZipContainer::File.verify($empty_zip))
|
69
|
+
refute(ZipContainer::File.verify($empty_zip).empty?)
|
70
|
+
refute(ZipContainer::File.verify?($empty_zip))
|
63
71
|
end
|
64
72
|
|
65
73
|
# Check that a compressed mimetype file is detected.
|
@@ -68,7 +76,8 @@ class TestReadFile < Test::Unit::TestCase
|
|
68
76
|
ZipContainer::File.verify!($compressed_mimetype)
|
69
77
|
end
|
70
78
|
|
71
|
-
refute(ZipContainer::File.verify($compressed_mimetype))
|
79
|
+
refute(ZipContainer::File.verify($compressed_mimetype).empty?)
|
80
|
+
refute(ZipContainer::File.verify?($compressed_mimetype))
|
72
81
|
end
|
73
82
|
|
74
83
|
# Check the raw mimetype bytes
|
data/test/tc_reserved_names.rb
CHANGED
@@ -56,7 +56,7 @@ class TestReservedNames < Test::Unit::TestCase
|
|
56
56
|
|
57
57
|
# Check that the reserved names verify correctly.
|
58
58
|
def test_verify_reserved_name
|
59
|
-
assert(NewZipContainer.verify($example))
|
59
|
+
assert(NewZipContainer.verify?($example))
|
60
60
|
|
61
61
|
assert_nothing_raised(ZipContainer::MalformedContainerError) do
|
62
62
|
NewZipContainer.verify!($example)
|
data/version.yml
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: zip-container
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 3.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Robert Haines
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-01-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|