module ZipContainer::ReservedNames
This module provides support for reserved names.
Public Instance Methods
Source
# File lib/zip-container/reserved_names.rb, line 72 def reserved_entry?(entry) name = Util.entry_name(entry) reserved_names.map(&:downcase).include? name.downcase end
Is the given entry in the reserved list of names? A String or a Zip::Entry object can be passed in here.
Source
# File lib/zip-container/reserved_names.rb, line 63 def reserved_names @reserved_names ||= [] end
Return a list of reserved file and directory names for this ZipContainer
file.
Reserved files and directories must be accessed directly by methods within Container
(or subclasses of Container
). This is because they are fundamental to the format and might need to exhibit certain properties (such as no compression) that must be preserved. The “mimetype” file is an example of such a reserved entry.
To add a reserved name to a subclass of Container
simply add it to the list in the constructor (you must call the super constructor first!):
class MyContainer < ZipContainer::Container
def initialize(filename) super(filename)
register_reserved_name("my_reserved_name")
end end
Protected Instance Methods
Source
# File lib/zip-container/reserved_names.rb, line 83 def register_reserved_name(name) @reserved_names ||= [] @reserved_names << name unless @reserved_names.include? name end
Add a reserved name to the list.