Skip to content

Commit

Permalink
Bump for Ruby 3.3 compatibility, update CI
Browse files Browse the repository at this point in the history
  • Loading branch information
julik committed Apr 4, 2024
1 parent b50e21d commit 3be97e9
Show file tree
Hide file tree
Showing 9 changed files with 117 additions and 117 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
matrix:
ruby:
- '2.6'
- '3.2'
- '3.3'
steps:
- name: Checkout
uses: actions/checkout@v4
Expand Down
16 changes: 8 additions & 8 deletions lib/zip_kit/block_deflate.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class ZipKit::BlockDeflate
# `output_io` can also be a {ZipKit::Streamer} to expedite ops.
#
# @param output_io [IO] the stream to write to (should respond to `:<<`)
# @return [Fixnum] number of bytes written to `output_io`
# @return [Integer] number of bytes written to `output_io`
def self.write_terminator(output_io)
output_io << END_MARKER
END_MARKER.bytesize
Expand All @@ -65,7 +65,7 @@ def self.write_terminator(output_io)
# The returned string can be spliced into another deflate stream.
#
# @param bytes [String] Bytes to compress
# @param level [Fixnum] Zlib compression level (defaults to `Zlib::DEFAULT_COMPRESSION`)
# @param level [Integer] Zlib compression level (defaults to `Zlib::DEFAULT_COMPRESSION`)
# @return [String] compressed bytes
def self.deflate_chunk(bytes, level: Zlib::DEFAULT_COMPRESSION)
raise "Invalid Zlib compression level #{level}" unless VALID_COMPRESSIONS.include?(level)
Expand All @@ -90,9 +90,9 @@ def self.deflate_chunk(bytes, level: Zlib::DEFAULT_COMPRESSION)
#
# @param input_io [IO] the stream to read from (should respond to `:read`)
# @param output_io [IO] the stream to write to (should respond to `:<<`)
# @param level [Fixnum] Zlib compression level (defaults to `Zlib::DEFAULT_COMPRESSION`)
# @param block_size [Fixnum] The block size to use (defaults to `DEFAULT_BLOCKSIZE`)
# @return [Fixnum] number of bytes written to `output_io`
# @param level [Integer] Zlib compression level (defaults to `Zlib::DEFAULT_COMPRESSION`)
# @param block_size [Integer] The block size to use (defaults to `DEFAULT_BLOCKSIZE`)
# @return [Integer] number of bytes written to `output_io`
def self.deflate_in_blocks_and_terminate(input_io,
output_io,
level: Zlib::DEFAULT_COMPRESSION,
Expand All @@ -110,9 +110,9 @@ def self.deflate_in_blocks_and_terminate(input_io,
#
# @param input_io [IO] the stream to read from (should respond to `:read`)
# @param output_io [IO] the stream to write to (should respond to `:<<`)
# @param level [Fixnum] Zlib compression level (defaults to `Zlib::DEFAULT_COMPRESSION`)
# @param block_size [Fixnum] The block size to use (defaults to `DEFAULT_BLOCKSIZE`)
# @return [Fixnum] number of bytes written to `output_io`
# @param level [Integer] Zlib compression level (defaults to `Zlib::DEFAULT_COMPRESSION`)
# @param block_size [Integer] The block size to use (defaults to `DEFAULT_BLOCKSIZE`)
# @return [Integer] number of bytes written to `output_io`
def self.deflate_in_blocks(input_io,
output_io,
level: Zlib::DEFAULT_COMPRESSION,
Expand Down
34 changes: 17 additions & 17 deletions lib/zip_kit/file_reader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -86,46 +86,46 @@ def message
# the Entry object used in Streamer for ZIP writing, since during writing more
# data can be kept in memory for immediate use.
class ZipEntry
# @return [Fixnum] bit-packed version signature of the program that made the archive
# @return [Integer] bit-packed version signature of the program that made the archive
attr_accessor :made_by

# @return [Fixnum] ZIP version support needed to extract this file
# @return [Integer] ZIP version support needed to extract this file
attr_accessor :version_needed_to_extract

# @return [Fixnum] bit-packed general purpose flags
# @return [Integer] bit-packed general purpose flags
attr_accessor :gp_flags

# @return [Fixnum] Storage mode (0 for stored, 8 for deflate)
# @return [Integer] Storage mode (0 for stored, 8 for deflate)
attr_accessor :storage_mode

# @return [Fixnum] the bit-packed DOS time
# @return [Integer] the bit-packed DOS time
attr_accessor :dos_time

# @return [Fixnum] the bit-packed DOS date
# @return [Integer] the bit-packed DOS date
attr_accessor :dos_date

# @return [Fixnum] the CRC32 checksum of this file
# @return [Integer] the CRC32 checksum of this file
attr_accessor :crc32

# @return [Fixnum] size of compressed file data in the ZIP
# @return [Integer] size of compressed file data in the ZIP
attr_accessor :compressed_size

# @return [Fixnum] size of the file once uncompressed
# @return [Integer] size of the file once uncompressed
attr_accessor :uncompressed_size

# @return [String] the filename
attr_accessor :filename

# @return [Fixnum] disk number where this file starts
# @return [Integer] disk number where this file starts
attr_accessor :disk_number_start

# @return [Fixnum] internal attributes of the file
# @return [Integer] internal attributes of the file
attr_accessor :internal_attrs

# @return [Fixnum] external attributes of the file
# @return [Integer] external attributes of the file
attr_accessor :external_attrs

# @return [Fixnum] at what offset the local file header starts
# @return [Integer] at what offset the local file header starts
# in your original IO object
attr_accessor :local_file_header_offset

Expand All @@ -151,7 +151,7 @@ def extractor_from(from_io)
end
end

# @return [Fixnum] at what offset you should start reading
# @return [Integer] at what offset you should start reading
# for the compressed data in your original IO object
def compressed_data_offset
@compressed_data_offset || raise(LocalHeaderPending)
Expand Down Expand Up @@ -298,7 +298,7 @@ def read_zip_straight_ahead(io:)
# this offset to get the data).
#
# @param io[#read] an IO-ish object the ZIP file can be read from
# @return [Array<ZipEntry, Fixnum>] the parsed local header entry and
# @return [Array<ZipEntry, Integer>] the parsed local header entry and
# the compressed data offset
def read_local_file_header(io:)
local_file_header_offset = io.tell
Expand Down Expand Up @@ -365,8 +365,8 @@ def read_local_file_header(io:)
# (read starting at this offset to get the data).
#
# @param io[#seek, #read] an IO-ish object the ZIP file can be read from
# @param local_file_header_offset[Fixnum] absolute offset (0-based) where the
# local file header is supposed to begin @return [Fixnum] absolute offset
# @param local_file_header_offset[Integer] absolute offset (0-based) where the
# local file header is supposed to begin @return [Integer] absolute offset
# (0-based) of where the compressed data begins for this file within the ZIP
def get_compressed_data_offset(io:, local_file_header_offset:)
seek(io, local_file_header_offset)
Expand Down
4 changes: 2 additions & 2 deletions lib/zip_kit/remote_io.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def size
# so if you are at offset 0 in the IO of size 10, doing a `read(20)`
# will only return you 10 bytes of result, and not raise any exceptions.
#
# @param n_bytes[Fixnum, nil] how many bytes to read, or `nil` to read all the way to the end
# @param n_bytes[Integer, nil] how many bytes to read, or `nil` to read all the way to the end
# @return [String] the read bytes
def read(n_bytes = nil)
# If the resource is empty there is nothing to read
Expand All @@ -62,7 +62,7 @@ def read(n_bytes = nil)

# Returns the current pointer position within the IO
#
# @return [Fixnum]
# @return [Integer]
def tell
@pos
end
Expand Down
6 changes: 3 additions & 3 deletions lib/zip_kit/size_estimator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def self.estimate(**kwargs_for_streamer_new)
# Add a fake entry to the archive, to see how big it is going to be in the end.
#
# @param filename [String] the name of the file (filenames are variable-width in the ZIP)
# @param size [Fixnum] size of the uncompressed entry
# @param size [Integer] size of the uncompressed entry
# @param use_data_descriptor[Boolean] whether the entry uses a postfix
# data descriptor to specify size
# @return self
Expand All @@ -54,8 +54,8 @@ def add_stored_entry(filename:, size:, use_data_descriptor: false)
# Add a fake entry to the archive, to see how big it is going to be in the end.
#
# @param filename [String] the name of the file (filenames are variable-width in the ZIP)
# @param uncompressed_size [Fixnum] size of the uncompressed entry
# @param compressed_size [Fixnum] size of the compressed entry
# @param uncompressed_size [Integer] size of the uncompressed entry
# @param compressed_size [Integer] size of the compressed entry
# @param use_data_descriptor[Boolean] whether the entry uses a postfix data
# descriptor to specify size
# @return self
Expand Down
10 changes: 5 additions & 5 deletions lib/zip_kit/stream_crc32.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class ZipKit::StreamCRC32
# Compute a CRC32 value from an IO object. The object should respond to `read` and `eof?`
#
# @param io[IO] the IO to read the data from
# @return [Fixnum] the computed CRC32 value
# @return [Integer] the computed CRC32 value
def self.from_io(io)
# If we can specify the string capacity upfront we will not have to resize
# the string during operation. This saves time but is only available on
Expand All @@ -43,17 +43,17 @@ def <<(blob)

# Returns the CRC32 value computed so far
#
# @return [Fixnum] the updated CRC32 value for all the blobs so far
# @return [Integer] the updated CRC32 value for all the blobs so far
def to_i
@crc
end

# Appends a known CRC32 value to the current one, and combines the
# contained CRC32 value in-place.
#
# @param crc32[Fixnum] the CRC32 value to append
# @param blob_size[Fixnum] the size of the daata the `crc32` is computed from
# @return [Fixnum] the updated CRC32 value for all the blobs so far
# @param crc32[Integer] the CRC32 value to append
# @param blob_size[Integer] the size of the daata the `crc32` is computed from
# @return [Integer] the updated CRC32 value for all the blobs so far
def append(crc32, blob_size)
@crc = Zlib.crc32_combine(@crc, crc32, blob_size)
end
Expand Down
2 changes: 1 addition & 1 deletion lib/zip_kit/write_shovel.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ module ZipKit::WriteShovel
# a target for `IO.copy_stream(from, to)`
#
# @param bytes[String] the binary string to write (part of the uncompressed file)
# @return [Fixnum] the number of bytes written (will always be the bytesize of `bytes`)
# @return [Integer] the number of bytes written (will always be the bytesize of `bytes`)
def write(bytes)
self << bytes
bytes.bytesize
Expand Down
40 changes: 20 additions & 20 deletions lib/zip_kit/zip_writer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,12 @@ class ZipKit::ZipWriter
#
# @param io[#<<] the buffer to write the local file header to
# @param filename[String] the name of the file in the archive
# @param compressed_size[Fixnum] The size of the compressed (or stored) data - how much space it uses in the ZIP
# @param uncompressed_size[Fixnum] The size of the file once extracted
# @param crc32[Fixnum] The CRC32 checksum of the file
# @param compressed_size[Integer] The size of the compressed (or stored) data - how much space it uses in the ZIP
# @param uncompressed_size[Integer] The size of the file once extracted
# @param crc32[Integer] The CRC32 checksum of the file
# @param mtime[Time] the modification time to be recorded in the ZIP
# @param gp_flags[Fixnum] bit-packed general purpose flags
# @param storage_mode[Fixnum] 8 for deflated, 0 for stored...
# @param gp_flags[Integer] bit-packed general purpose flags
# @param storage_mode[Integer] 8 for deflated, 0 for stored...
# @return [void]
def write_local_file_header(io:, filename:, compressed_size:, uncompressed_size:, crc32:, gp_flags:, mtime:, storage_mode:)
requires_zip64 = compressed_size > FOUR_BYTE_MAX_UINT || uncompressed_size > FOUR_BYTE_MAX_UINT
Expand Down Expand Up @@ -136,11 +136,11 @@ def write_local_file_header(io:, filename:, compressed_size:, uncompressed_size:
#
# @param io[#<<] the buffer to write the local file header to
# @param filename[String] the name of the file in the archive
# @param compressed_size[Fixnum] The size of the compressed (or stored) data - how much space it uses in the ZIP
# @param uncompressed_size[Fixnum] The size of the file once extracted
# @param crc32[Fixnum] The CRC32 checksum of the file
# @param compressed_size[Integer] The size of the compressed (or stored) data - how much space it uses in the ZIP
# @param uncompressed_size[Integer] The size of the file once extracted
# @param crc32[Integer] The CRC32 checksum of the file
# @param mtime[Time] the modification time to be recorded in the ZIP
# @param gp_flags[Fixnum] bit-packed general purpose flags
# @param gp_flags[Integer] bit-packed general purpose flags
# @param unix_permissions[Integer] the permissions for the file, or nil for the default to be used
# @return [void]
def write_central_directory_file_header(io:,
Expand Down Expand Up @@ -253,9 +253,9 @@ def write_central_directory_file_header(io:,
# the data descriptor will have the sizes written out as 8-byte values instead of 4-byte values.
#
# @param io[#<<] the buffer to write the local file header to
# @param crc32[Fixnum] The CRC32 checksum of the file
# @param compressed_size[Fixnum] The size of the compressed (or stored) data - how much space it uses in the ZIP
# @param uncompressed_size[Fixnum] The size of the file once extracted
# @param crc32[Integer] The CRC32 checksum of the file
# @param compressed_size[Integer] The size of the compressed (or stored) data - how much space it uses in the ZIP
# @param uncompressed_size[Integer] The size of the file once extracted
# @return [void]
def write_data_descriptor(io:, compressed_size:, uncompressed_size:, crc32:)
# Although not originally assigned a signature, the value
Expand All @@ -282,9 +282,9 @@ def write_data_descriptor(io:, compressed_size:, uncompressed_size:, crc32:)
# Writes the "end of central directory record" (including the Zip6 salient bits if necessary)
#
# @param io[#<<] the buffer to write the central directory to.
# @param start_of_central_directory_location[Fixnum] byte offset of the start of central directory form the beginning of ZIP file
# @param central_directory_size[Fixnum] the size of the central directory (only file headers) in bytes
# @param num_files_in_archive[Fixnum] How many files the archive contains
# @param start_of_central_directory_location[Integer] byte offset of the start of central directory form the beginning of ZIP file
# @param central_directory_size[Integer] the size of the central directory (only file headers) in bytes
# @param num_files_in_archive[Integer] How many files the archive contains
# @param comment[String] the comment for the archive (defaults to ZIP_KIT_COMMENT)
# @return [void]
def write_end_of_central_directory(io:, start_of_central_directory_location:, central_directory_size:, num_files_in_archive:, comment: ZIP_KIT_COMMENT)
Expand Down Expand Up @@ -386,8 +386,8 @@ def write_end_of_central_directory(io:, start_of_central_directory_location:, ce

# Writes the Zip64 extra field for the local file header. Will be used by `write_local_file_header` when any sizes given to it warrant that.
#
# @param compressed_size[Fixnum] The size of the compressed (or stored) data - how much space it uses in the ZIP
# @param uncompressed_size[Fixnum] The size of the file once extracted
# @param compressed_size[Integer] The size of the compressed (or stored) data - how much space it uses in the ZIP
# @param uncompressed_size[Integer] The size of the file once extracted
# @return [String]
def zip_64_extra_for_local_file_header(compressed_size:, uncompressed_size:)
data_and_packspecs = [
Expand Down Expand Up @@ -460,9 +460,9 @@ def timestamp_extra_for_local_file_header(mtime)
# Writes the Zip64 extra field for the central directory header.It differs from the extra used in the local file header because it
# also contains the location of the local file header in the ZIP as an 8-byte int.
#
# @param compressed_size[Fixnum] The size of the compressed (or stored) data - how much space it uses in the ZIP
# @param uncompressed_size[Fixnum] The size of the file once extracted
# @param local_file_header_location[Fixnum] Byte offset of the start of the local file header from the beginning of the ZIP archive
# @param compressed_size[Integer] The size of the compressed (or stored) data - how much space it uses in the ZIP
# @param uncompressed_size[Integer] The size of the file once extracted
# @param local_file_header_location[Integer] Byte offset of the start of the local file header from the beginning of the ZIP archive
# @return [String]
def zip_64_extra_for_central_directory_file_header(compressed_size:, uncompressed_size:, local_file_header_location:)
data_and_packspecs = [
Expand Down
Loading

0 comments on commit 3be97e9

Please sign in to comment.