ucf 0.5.0 → 0.6.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.
- data/Changes.rdoc +5 -0
- data/Rakefile +5 -4
- data/ReadMe.rdoc +8 -1
- data/examples/{create_ucf.rb → create-ucf} +15 -5
- data/examples/ucfinfo +2 -2
- data/examples/{verify_ucf.rb → verify-ucf} +11 -4
- data/lib/ucf.rb +0 -6
- data/lib/ucf/container.rb +22 -433
- data/lib/ucf/meta-inf.rb +9 -5
- data/test/tc_create.rb +4 -5
- data/test/tc_managed_entries.rb +20 -18
- data/test/tc_read.rb +5 -4
- data/test/tc_reserved_names.rb +31 -30
- data/test/ts_ucf.rb +1 -3
- data/ucf.gemspec +8 -14
- data/version.yml +1 -1
- metadata +11 -15
- data/lib/ucf/entries/directory.rb +0 -71
- data/lib/ucf/entries/entry.rb +0 -134
- data/lib/ucf/entries/file.rb +0 -101
- data/lib/ucf/entries/managed.rb +0 -183
- data/lib/ucf/entries/reserved.rb +0 -88
- data/lib/ucf/exceptions.rb +0 -70
data/lib/ucf/entries/reserved.rb
DELETED
@@ -1,88 +0,0 @@
|
|
1
|
-
# Copyright (c) 2013 The University of Manchester, UK.
|
2
|
-
#
|
3
|
-
# All rights reserved.
|
4
|
-
#
|
5
|
-
# Redistribution and use in source and binary forms, with or without
|
6
|
-
# modification, are permitted provided that the following conditions are met:
|
7
|
-
#
|
8
|
-
# * Redistributions of source code must retain the above copyright notice,
|
9
|
-
# this list of conditions and the following disclaimer.
|
10
|
-
#
|
11
|
-
# * Redistributions in binary form must reproduce the above copyright notice,
|
12
|
-
# this list of conditions and the following disclaimer in the documentation
|
13
|
-
# and/or other materials provided with the distribution.
|
14
|
-
#
|
15
|
-
# * Neither the names of The University of Manchester nor the names of its
|
16
|
-
# contributors may be used to endorse or promote products derived from this
|
17
|
-
# software without specific prior written permission.
|
18
|
-
#
|
19
|
-
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
20
|
-
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
21
|
-
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
22
|
-
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
23
|
-
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
24
|
-
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
25
|
-
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
26
|
-
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
27
|
-
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
28
|
-
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
29
|
-
# POSSIBILITY OF SUCH DAMAGE.
|
30
|
-
#
|
31
|
-
# Author: Robert Haines
|
32
|
-
|
33
|
-
require 'zip/zip_entry'
|
34
|
-
|
35
|
-
module UCF
|
36
|
-
|
37
|
-
# This module provides support for reserved names.
|
38
|
-
module ReservedNames
|
39
|
-
|
40
|
-
# :call-seq:
|
41
|
-
# reserved_names -> Array
|
42
|
-
#
|
43
|
-
# Return a list of reserved file and directory names for this UCF
|
44
|
-
# document.
|
45
|
-
#
|
46
|
-
# Reserved files and directories must be accessed directly by methods
|
47
|
-
# within Container (or subclasses of Container). This is because they are
|
48
|
-
# fundamental to the format and might need to exhibit certain properties
|
49
|
-
# (such as no compression) that must be preserved. The "mimetype" file is
|
50
|
-
# an example of such a reserved entry.
|
51
|
-
#
|
52
|
-
# To add a reserved name to a subclass of Container simply add it to the
|
53
|
-
# list in the constructor (you must call the super constructor first!):
|
54
|
-
#
|
55
|
-
# class MyContainer < UCF::Container
|
56
|
-
# def initialize(filename)
|
57
|
-
# super(filename)
|
58
|
-
#
|
59
|
-
# register_reserved_name("my_reserved_name")
|
60
|
-
# end
|
61
|
-
# end
|
62
|
-
def reserved_names
|
63
|
-
@reserved_names ||= []
|
64
|
-
end
|
65
|
-
|
66
|
-
# :call-seq:
|
67
|
-
# reserved_entry?(entry) -> boolean
|
68
|
-
#
|
69
|
-
# Is the given entry in the reserved list of names? A String or a
|
70
|
-
# Zip::ZipEntry object can be passed in here.
|
71
|
-
def reserved_entry?(entry)
|
72
|
-
name = entry.kind_of?(::Zip::ZipEntry) ? entry.name : entry
|
73
|
-
name.chop! if name.end_with? "/"
|
74
|
-
reserved_names.map { |n| n.downcase }.include? name.downcase
|
75
|
-
end
|
76
|
-
|
77
|
-
protected
|
78
|
-
|
79
|
-
# :call-seq:
|
80
|
-
# register_reserved_name(name)
|
81
|
-
#
|
82
|
-
# Add a reserved name to the list.
|
83
|
-
def register_reserved_name(name)
|
84
|
-
@reserved_names ||= []
|
85
|
-
@reserved_names << name unless @reserved_names.include? name
|
86
|
-
end
|
87
|
-
end
|
88
|
-
end
|
data/lib/ucf/exceptions.rb
DELETED
@@ -1,70 +0,0 @@
|
|
1
|
-
# Copyright (c) 2013 The University of Manchester, UK.
|
2
|
-
#
|
3
|
-
# All rights reserved.
|
4
|
-
#
|
5
|
-
# Redistribution and use in source and binary forms, with or without
|
6
|
-
# modification, are permitted provided that the following conditions are met:
|
7
|
-
#
|
8
|
-
# * Redistributions of source code must retain the above copyright notice,
|
9
|
-
# this list of conditions and the following disclaimer.
|
10
|
-
#
|
11
|
-
# * Redistributions in binary form must reproduce the above copyright notice,
|
12
|
-
# this list of conditions and the following disclaimer in the documentation
|
13
|
-
# and/or other materials provided with the distribution.
|
14
|
-
#
|
15
|
-
# * Neither the names of The University of Manchester nor the names of its
|
16
|
-
# contributors may be used to endorse or promote products derived from this
|
17
|
-
# software without specific prior written permission.
|
18
|
-
#
|
19
|
-
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
20
|
-
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
21
|
-
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
22
|
-
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
23
|
-
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
24
|
-
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
25
|
-
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
26
|
-
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
27
|
-
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
28
|
-
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
29
|
-
# POSSIBILITY OF SUCH DAMAGE.
|
30
|
-
#
|
31
|
-
# Author: Robert Haines
|
32
|
-
|
33
|
-
#
|
34
|
-
module UCF
|
35
|
-
|
36
|
-
# The base class of all other exceptions raised by this library.
|
37
|
-
class UCFError < RuntimeError
|
38
|
-
end
|
39
|
-
|
40
|
-
# This exception is raised when a bad UCF is detected.
|
41
|
-
class MalformedUCFError < UCFError
|
42
|
-
|
43
|
-
# :call-seq:
|
44
|
-
# new(reason = "")
|
45
|
-
#
|
46
|
-
# Create a new MalformedUCFError with an optional reason for why the UCF
|
47
|
-
# document is malformed.
|
48
|
-
def initialize(reason = nil)
|
49
|
-
if reason.nil?
|
50
|
-
super("Malformed UCF Document.")
|
51
|
-
else
|
52
|
-
super("Malformed UCF Document: #{reason}")
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
# This exception is raised when a clash occurs with a reserved or managed
|
58
|
-
# name.
|
59
|
-
class ReservedNameClashError < UCFError
|
60
|
-
|
61
|
-
# :call-seq:
|
62
|
-
# new(name)
|
63
|
-
#
|
64
|
-
# Create a new ReservedNameClashError with the name of the clash supplied.
|
65
|
-
def initialize(name)
|
66
|
-
super("'#{name}' is reserved for internal use in this UCF document.")
|
67
|
-
end
|
68
|
-
end
|
69
|
-
|
70
|
-
end
|