Skip to content

Commit

Permalink
Document or hide classes from the docs.
Browse files Browse the repository at this point in the history
  • Loading branch information
hainesr committed Nov 7, 2022
1 parent 0c5802d commit 4f2979a
Show file tree
Hide file tree
Showing 27 changed files with 71 additions and 55 deletions.
2 changes: 1 addition & 1 deletion lib/zip/central_directory.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
require_relative 'dirtyable'

module Zip
class CentralDirectory
class CentralDirectory # :nodoc:
extend Forwardable
include Dirtyable

Expand Down
2 changes: 1 addition & 1 deletion lib/zip/compressor.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

module Zip
class Compressor #:nodoc:all
class Compressor # :nodoc:all
def finish; end
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/zip/crypto/decrypted_io.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

module Zip
class DecryptedIo #:nodoc:all
class DecryptedIo # :nodoc:all
CHUNK_SIZE = 32_768

def initialize(io, decrypter)
Expand Down
4 changes: 2 additions & 2 deletions lib/zip/crypto/encryption.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# frozen_string_literal: true

module Zip
class Encrypter #:nodoc:all
class Encrypter # :nodoc:all
end

class Decrypter
class Decrypter # :nodoc:all
end
end

Expand Down
4 changes: 2 additions & 2 deletions lib/zip/crypto/null_encryption.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def gp_flags
end
end

class NullEncrypter < Encrypter
class NullEncrypter < Encrypter # :nodoc:
include NullEncryption

def header(_mtime)
Expand All @@ -29,7 +29,7 @@ def data_descriptor(_crc32, _compressed_size, _uncomprssed_size)
def reset!; end
end

class NullDecrypter < Decrypter
class NullDecrypter < Decrypter # :nodoc:
include NullEncryption

def decrypt(data)
Expand Down
4 changes: 2 additions & 2 deletions lib/zip/crypto/traditional_encryption.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def decrypt_byte
end
end

class TraditionalEncrypter < Encrypter
class TraditionalEncrypter < Encrypter # :nodoc:
include TraditionalEncryption

def header(mtime)
Expand Down Expand Up @@ -72,7 +72,7 @@ def encode(num)
end
end

class TraditionalDecrypter < Decrypter
class TraditionalDecrypter < Decrypter # :nodoc:
include TraditionalEncryption

def decrypt(data)
Expand Down
2 changes: 1 addition & 1 deletion lib/zip/decompressor.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

module Zip
class Decompressor #:nodoc:all
class Decompressor # :nodoc:all
CHUNK_SIZE = 32_768

def self.decompressor_classes
Expand Down
2 changes: 1 addition & 1 deletion lib/zip/deflater.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

module Zip
class Deflater < Compressor #:nodoc:all
class Deflater < Compressor # :nodoc:all
def initialize(output_stream, level = Zip.default_compression, encrypter = NullEncrypter.new)
super()
@output_stream = output_stream
Expand Down
2 changes: 1 addition & 1 deletion lib/zip/dos_time.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
require 'rubygems'

module Zip
class DOSTime < Time #:nodoc:all
class DOSTime < Time # :nodoc:all
# MS-DOS File Date and Time format as used in Interrupt 21H Function 57H:

# Register CX, the Time:
Expand Down
1 change: 1 addition & 0 deletions lib/zip/entry.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
require_relative 'dirtyable'

module Zip
# Zip::Entry represents an entry in a Zip archive.
class Entry
include Dirtyable

Expand Down
2 changes: 1 addition & 1 deletion lib/zip/entry_set.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

module Zip
class EntrySet #:nodoc:all
class EntrySet # :nodoc:all
include Enumerable

attr_reader :entry_set
Expand Down
14 changes: 14 additions & 0 deletions lib/zip/errors.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
# frozen_string_literal: true

module Zip
# The superclass for all rubyzip error types. Simply rescue this one if
# you don't need to know what sort of error has been raised.
class Error < StandardError; end

# Error raised if an unsupported compression method is used.
class CompressionMethodError < Error
attr_reader :compression_method

Expand All @@ -16,6 +19,7 @@ def message
end
end

# Error raised if there is a problem while decompressing an archive entry.
class DecompressionError < Error
attr_reader :zlib_error

Expand All @@ -29,6 +33,8 @@ def message
end
end

# Error raised when trying to extract an archive entry over an
# existing file.
class DestinationExistsError < Error
def initialize(destination)
super()
Expand All @@ -41,6 +47,8 @@ def message
end
end

# Error raised when trying to add an entry to an archive where the
# entry name already exists.
class EntryExistsError < Error
def initialize(source, name)
super()
Expand All @@ -53,6 +61,7 @@ def message
end
end

# Error raised when an entry name is invalid.
class EntryNameError < Error
def initialize(name = nil)
super()
Expand All @@ -68,6 +77,8 @@ def message
end
end

# Error raised if an entry is larger on extraction than it is advertised
# to be.
class EntrySizeError < Error
attr_reader :entry

Expand All @@ -81,12 +92,15 @@ def message
end
end

# Error raised if a split archive is read. Rubyzip does not support reading
# split archives.
class SplitArchiveError < Error
def message
'Rubyzip cannot extract from split archives at this time.'
end
end

# Error raised if there is not enough metadata for the entry to be streamed.
class StreamingError < Error
attr_reader :entry

Expand Down
2 changes: 1 addition & 1 deletion lib/zip/extra_field.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

module Zip
class ExtraField < Hash
class ExtraField < Hash # :nodoc:all
ID_MAP = {}

def initialize(binstr = nil, local: false)
Expand Down
2 changes: 1 addition & 1 deletion lib/zip/extra_field/generic.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

module Zip
class ExtraField::Generic
class ExtraField::Generic # :nodoc:
def self.register_map
return unless const_defined?(:HEADER_ID)

Expand Down
2 changes: 1 addition & 1 deletion lib/zip/extra_field/ntfs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
module Zip
# PKWARE NTFS Extra Field (0x000a)
# Only Tag 0x0001 is supported
class ExtraField::NTFS < ExtraField::Generic
class ExtraField::NTFS < ExtraField::Generic # :nodoc:
HEADER_ID = [0x000A].pack('v')
register_map

Expand Down
2 changes: 1 addition & 1 deletion lib/zip/extra_field/old_unix.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

module Zip
# Olf Info-ZIP Extra for UNIX uid/gid and file timestampes
class ExtraField::OldUnix < ExtraField::Generic
class ExtraField::OldUnix < ExtraField::Generic # :nodoc:
HEADER_ID = 'UX'
register_map

Expand Down
2 changes: 1 addition & 1 deletion lib/zip/extra_field/universal_time.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

module Zip
# Info-ZIP Additional timestamp field
class ExtraField::UniversalTime < ExtraField::Generic
class ExtraField::UniversalTime < ExtraField::Generic # :nodoc:
HEADER_ID = 'UT'
register_map

Expand Down
2 changes: 1 addition & 1 deletion lib/zip/extra_field/unix.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

module Zip
# Info-ZIP Extra for UNIX uid/gid
class ExtraField::IUnix < ExtraField::Generic
class ExtraField::IUnix < ExtraField::Generic # :nodoc:
HEADER_ID = 'Ux'
register_map

Expand Down
2 changes: 1 addition & 1 deletion lib/zip/extra_field/unknown.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

module Zip
# A class to hold unknown extra fields so that they are preserved.
class ExtraField::Unknown
class ExtraField::Unknown # :nodoc:
def initialize
@local_bin = +''
@cdir_bin = +''
Expand Down
2 changes: 1 addition & 1 deletion lib/zip/extra_field/zip64.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

module Zip
# Info-ZIP Extra for Zip64 size
class ExtraField::Zip64 < ExtraField::Generic
class ExtraField::Zip64 < ExtraField::Generic # :nodoc:
attr_accessor :compressed_size, :disk_start_number,
:original_size, :relative_header_offset

Expand Down
2 changes: 1 addition & 1 deletion lib/zip/extra_field/zip64_placeholder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module Zip
# placeholder to reserve space for a Zip64 extra information record, for the
# local file header only, that we won't know if we'll need until after
# we write the file data
class ExtraField::Zip64Placeholder < ExtraField::Generic
class ExtraField::Zip64Placeholder < ExtraField::Generic # :nodoc:
HEADER_ID = ['9999'].pack('H*') # this ID is used by other libraries such as .NET's Ionic.zip
register_map

Expand Down
57 changes: 29 additions & 28 deletions lib/zip/file.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,48 +5,49 @@
require_relative 'file_split'

module Zip
# ZipFile is modeled after java.util.zip.ZipFile from the Java SDK.
# The most important methods are those inherited from
# ZipCentralDirectory for accessing information about the entries in
# the archive and methods such as get_input_stream and
# get_output_stream for reading from and writing entries to the
# Zip::File is modeled after java.util.zip.ZipFile from the Java SDK.
# The most important methods are those for accessing information about
# the entries in
# the archive and methods such as `get_input_stream` and
# `get_output_stream` for reading from and writing entries to the
# archive. The class includes a few convenience methods such as
# #extract for extracting entries to the filesystem, and #remove,
# #replace, #rename and #mkdir for making simple modifications to
# `extract` for extracting entries to the filesystem, and `remove`,
# `replace`, `rename` and `mkdir` for making simple modifications to
# the archive.
#
# Modifications to a zip archive are not committed until #commit or
# #close is called. The method #open accepts a block following
# the pattern from File.open offering a simple way to
# Modifications to a zip archive are not committed until `commit` or
# `close` is called. The method `open` accepts a block following
# the pattern from ::File.open offering a simple way to
# automatically close the archive when the block returns.
#
# The following example opens zip archive <code>my.zip</code>
# The following example opens zip archive `my.zip`
# (creating it if it doesn't exist) and adds an entry
# <code>first.txt</code> and a directory entry <code>a_dir</code>
# `first.txt` and a directory entry `a_dir`
# to it.
#
# require 'zip'
# ```
# require 'zip'
#
# Zip::File.open("my.zip", create: true) {
# |zipfile|
# zipfile.get_output_stream("first.txt") { |f| f.puts "Hello from ZipFile" }
# zipfile.mkdir("a_dir")
# }
# Zip::File.open('my.zip', create: true) do |zipfile|
# zipfile.get_output_stream('first.txt') { |f| f.puts 'Hello from Zip::File' }
# zipfile.mkdir('a_dir')
# end
# ```
#
# The next example reopens <code>my.zip</code> writes the contents of
# <code>first.txt</code> to standard out and deletes the entry from
# The next example reopens `my.zip`, writes the contents of
# `first.txt` to standard out and deletes the entry from
# the archive.
#
# require 'zip'
# ```
# require 'zip'
#
# Zip::File.open("my.zip", create: true) {
# |zipfile|
# puts zipfile.read("first.txt")
# zipfile.remove("first.txt")
# }
# Zip::File.open('my.zip', create: true) do |zipfile|
# puts zipfile.read('first.txt')
# zipfile.remove('first.txt')
# end
#
# ZipFileSystem offers an alternative API that emulates ruby's
# interface for accessing the filesystem, ie. the File and Dir classes.
# Zip::FileSystem offers an alternative API that emulates ruby's
# interface for accessing the filesystem, ie. the ::File and ::Dir classes.
class File
extend Forwardable
extend FileSplit
Expand Down
2 changes: 1 addition & 1 deletion lib/zip/inflater.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

module Zip
class Inflater < Decompressor #:nodoc:all
class Inflater < Decompressor # :nodoc:all
def initialize(*args)
super

Expand Down
2 changes: 1 addition & 1 deletion lib/zip/null_compressor.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

module Zip
class NullCompressor < Compressor #:nodoc:all
class NullCompressor < Compressor # :nodoc:all
include Singleton

def <<(_data)
Expand Down
2 changes: 1 addition & 1 deletion lib/zip/pass_thru_compressor.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

module Zip
class PassThruCompressor < Compressor #:nodoc:all
class PassThruCompressor < Compressor # :nodoc:all
def initialize(output_stream)
super()
@output_stream = output_stream
Expand Down
2 changes: 1 addition & 1 deletion lib/zip/pass_thru_decompressor.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

module Zip
class PassThruDecompressor < Decompressor #:nodoc:all
class PassThruDecompressor < Decompressor # :nodoc:all
def initialize(*args)
super
@read_so_far = 0
Expand Down
2 changes: 1 addition & 1 deletion lib/zip/streamable_directory.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

module Zip
class StreamableDirectory < Entry
class StreamableDirectory < Entry # :nodoc:
def initialize(zipfile, entry, src_path = nil, permission = nil)
super(zipfile, entry)

Expand Down

0 comments on commit 4f2979a

Please sign in to comment.