zip_kit 6.3.0 → 6.3.2
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 +4 -4
- data/.github/workflows/ci.yml +31 -8
- data/CHANGELOG.md +9 -0
- data/IMPLEMENTATION_DETAILS.md +9 -35
- data/README.md +25 -11
- data/RUBYZIP_DIFFERENCES.md +1 -4
- data/lib/zip_kit/block_deflate.rb +8 -8
- data/lib/zip_kit/file_reader.rb +17 -17
- data/lib/zip_kit/output_enumerator.rb +11 -0
- data/lib/zip_kit/rails_streaming.rb +1 -1
- data/lib/zip_kit/railtie.rb +3 -1
- data/lib/zip_kit/remote_io.rb +4 -4
- data/lib/zip_kit/size_estimator.rb +14 -8
- data/lib/zip_kit/stream_crc32.rb +5 -5
- data/lib/zip_kit/streamer/heuristic.rb +8 -0
- data/lib/zip_kit/streamer.rb +23 -5
- data/lib/zip_kit/version.rb +1 -1
- data/lib/zip_kit/write_shovel.rb +1 -1
- data/lib/zip_kit/zip_writer.rb +20 -20
- data/rbi/zip_kit.rbi +75 -66
- data/zip_kit.gemspec +2 -0
- metadata +31 -9
- data/.document +0 -5
- data/.rspec +0 -1
- data/bench/buffered_crc32_bench.rb +0 -109
data/lib/zip_kit/write_shovel.rb
CHANGED
@@ -14,7 +14,7 @@ module ZipKit::WriteShovel
|
|
14
14
|
# a target for `IO.copy_stream(from, to)`
|
15
15
|
#
|
16
16
|
# @param bytes[String] the binary string to write (part of the uncompressed file)
|
17
|
-
# @return [
|
17
|
+
# @return [Integer] the number of bytes written (will always be the bytesize of `bytes`)
|
18
18
|
def write(bytes)
|
19
19
|
self << bytes
|
20
20
|
bytes.bytesize
|
data/lib/zip_kit/zip_writer.rb
CHANGED
@@ -64,12 +64,12 @@ class ZipKit::ZipWriter
|
|
64
64
|
#
|
65
65
|
# @param io[#<<] the buffer to write the local file header to
|
66
66
|
# @param filename[String] the name of the file in the archive
|
67
|
-
# @param compressed_size[
|
68
|
-
# @param uncompressed_size[
|
69
|
-
# @param crc32[
|
67
|
+
# @param compressed_size[Integer] The size of the compressed (or stored) data - how much space it uses in the ZIP
|
68
|
+
# @param uncompressed_size[Integer] The size of the file once extracted
|
69
|
+
# @param crc32[Integer] The CRC32 checksum of the file
|
70
70
|
# @param mtime[Time] the modification time to be recorded in the ZIP
|
71
|
-
# @param gp_flags[
|
72
|
-
# @param storage_mode[
|
71
|
+
# @param gp_flags[Integer] bit-packed general purpose flags
|
72
|
+
# @param storage_mode[Integer] 8 for deflated, 0 for stored...
|
73
73
|
# @return [void]
|
74
74
|
def write_local_file_header(io:, filename:, compressed_size:, uncompressed_size:, crc32:, gp_flags:, mtime:, storage_mode:)
|
75
75
|
requires_zip64 = compressed_size > FOUR_BYTE_MAX_UINT || uncompressed_size > FOUR_BYTE_MAX_UINT
|
@@ -136,11 +136,11 @@ class ZipKit::ZipWriter
|
|
136
136
|
#
|
137
137
|
# @param io[#<<] the buffer to write the local file header to
|
138
138
|
# @param filename[String] the name of the file in the archive
|
139
|
-
# @param compressed_size[
|
140
|
-
# @param uncompressed_size[
|
141
|
-
# @param crc32[
|
139
|
+
# @param compressed_size[Integer] The size of the compressed (or stored) data - how much space it uses in the ZIP
|
140
|
+
# @param uncompressed_size[Integer] The size of the file once extracted
|
141
|
+
# @param crc32[Integer] The CRC32 checksum of the file
|
142
142
|
# @param mtime[Time] the modification time to be recorded in the ZIP
|
143
|
-
# @param gp_flags[
|
143
|
+
# @param gp_flags[Integer] bit-packed general purpose flags
|
144
144
|
# @param unix_permissions[Integer] the permissions for the file, or nil for the default to be used
|
145
145
|
# @return [void]
|
146
146
|
def write_central_directory_file_header(io:,
|
@@ -253,9 +253,9 @@ class ZipKit::ZipWriter
|
|
253
253
|
# the data descriptor will have the sizes written out as 8-byte values instead of 4-byte values.
|
254
254
|
#
|
255
255
|
# @param io[#<<] the buffer to write the local file header to
|
256
|
-
# @param crc32[
|
257
|
-
# @param compressed_size[
|
258
|
-
# @param uncompressed_size[
|
256
|
+
# @param crc32[Integer] The CRC32 checksum of the file
|
257
|
+
# @param compressed_size[Integer] The size of the compressed (or stored) data - how much space it uses in the ZIP
|
258
|
+
# @param uncompressed_size[Integer] The size of the file once extracted
|
259
259
|
# @return [void]
|
260
260
|
def write_data_descriptor(io:, compressed_size:, uncompressed_size:, crc32:)
|
261
261
|
# Although not originally assigned a signature, the value
|
@@ -282,9 +282,9 @@ class ZipKit::ZipWriter
|
|
282
282
|
# Writes the "end of central directory record" (including the Zip6 salient bits if necessary)
|
283
283
|
#
|
284
284
|
# @param io[#<<] the buffer to write the central directory to.
|
285
|
-
# @param start_of_central_directory_location[
|
286
|
-
# @param central_directory_size[
|
287
|
-
# @param num_files_in_archive[
|
285
|
+
# @param start_of_central_directory_location[Integer] byte offset of the start of central directory form the beginning of ZIP file
|
286
|
+
# @param central_directory_size[Integer] the size of the central directory (only file headers) in bytes
|
287
|
+
# @param num_files_in_archive[Integer] How many files the archive contains
|
288
288
|
# @param comment[String] the comment for the archive (defaults to ZIP_KIT_COMMENT)
|
289
289
|
# @return [void]
|
290
290
|
def write_end_of_central_directory(io:, start_of_central_directory_location:, central_directory_size:, num_files_in_archive:, comment: ZIP_KIT_COMMENT)
|
@@ -386,8 +386,8 @@ class ZipKit::ZipWriter
|
|
386
386
|
|
387
387
|
# 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.
|
388
388
|
#
|
389
|
-
# @param compressed_size[
|
390
|
-
# @param uncompressed_size[
|
389
|
+
# @param compressed_size[Integer] The size of the compressed (or stored) data - how much space it uses in the ZIP
|
390
|
+
# @param uncompressed_size[Integer] The size of the file once extracted
|
391
391
|
# @return [String]
|
392
392
|
def zip_64_extra_for_local_file_header(compressed_size:, uncompressed_size:)
|
393
393
|
data_and_packspecs = [
|
@@ -460,9 +460,9 @@ class ZipKit::ZipWriter
|
|
460
460
|
# Writes the Zip64 extra field for the central directory header.It differs from the extra used in the local file header because it
|
461
461
|
# also contains the location of the local file header in the ZIP as an 8-byte int.
|
462
462
|
#
|
463
|
-
# @param compressed_size[
|
464
|
-
# @param uncompressed_size[
|
465
|
-
# @param local_file_header_location[
|
463
|
+
# @param compressed_size[Integer] The size of the compressed (or stored) data - how much space it uses in the ZIP
|
464
|
+
# @param uncompressed_size[Integer] The size of the file once extracted
|
465
|
+
# @param local_file_header_location[Integer] Byte offset of the start of the local file header from the beginning of the ZIP archive
|
466
466
|
# @return [String]
|
467
467
|
def zip_64_extra_for_central_directory_file_header(compressed_size:, uncompressed_size:, local_file_header_location:)
|
468
468
|
data_and_packspecs = [
|
data/rbi/zip_kit.rbi
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# typed: strong
|
2
2
|
module ZipKit
|
3
|
-
VERSION = T.let("6.3.
|
3
|
+
VERSION = T.let("6.3.1", T.untyped)
|
4
4
|
|
5
5
|
class Railtie < Rails::Railtie
|
6
6
|
end
|
@@ -572,7 +572,7 @@ module ZipKit
|
|
572
572
|
# _@param_ `bytes` — the binary string to write (part of the uncompressed file)
|
573
573
|
#
|
574
574
|
# _@return_ — the number of bytes written (will always be the bytesize of `bytes`)
|
575
|
-
sig { params(bytes: String).returns(
|
575
|
+
sig { params(bytes: String).returns(Integer) }
|
576
576
|
def write(bytes); end
|
577
577
|
|
578
578
|
# Is used internally by Streamer to keep track of entries in the archive during writing.
|
@@ -686,7 +686,7 @@ module ZipKit
|
|
686
686
|
# _@param_ `bytes` — the binary string to write (part of the uncompressed file)
|
687
687
|
#
|
688
688
|
# _@return_ — the number of bytes written (will always be the bytesize of `bytes`)
|
689
|
-
sig { params(bytes: String).returns(
|
689
|
+
sig { params(bytes: String).returns(Integer) }
|
690
690
|
def write(bytes); end
|
691
691
|
end
|
692
692
|
|
@@ -755,7 +755,7 @@ module ZipKit
|
|
755
755
|
# _@param_ `bytes` — the binary string to write (part of the uncompressed file)
|
756
756
|
#
|
757
757
|
# _@return_ — the number of bytes written (will always be the bytesize of `bytes`)
|
758
|
-
sig { params(bytes: String).returns(
|
758
|
+
sig { params(bytes: String).returns(Integer) }
|
759
759
|
def write(bytes); end
|
760
760
|
end
|
761
761
|
|
@@ -793,7 +793,7 @@ module ZipKit
|
|
793
793
|
# _@param_ `bytes` — the binary string to write (part of the uncompressed file)
|
794
794
|
#
|
795
795
|
# _@return_ — the number of bytes written (will always be the bytesize of `bytes`)
|
796
|
-
sig { params(bytes: String).returns(
|
796
|
+
sig { params(bytes: String).returns(Integer) }
|
797
797
|
def write(bytes); end
|
798
798
|
end
|
799
799
|
end
|
@@ -835,11 +835,11 @@ module ZipKit
|
|
835
835
|
# _@param_ `n_bytes` — how many bytes to read, or `nil` to read all the way to the end
|
836
836
|
#
|
837
837
|
# _@return_ — the read bytes
|
838
|
-
sig { params(n_bytes: T.nilable(
|
838
|
+
sig { params(n_bytes: T.nilable(Integer)).returns(String) }
|
839
839
|
def read(n_bytes = nil); end
|
840
840
|
|
841
841
|
# Returns the current pointer position within the IO
|
842
|
-
sig { returns(
|
842
|
+
sig { returns(Integer) }
|
843
843
|
def tell; end
|
844
844
|
|
845
845
|
# Only used internally when reading the remote ZIP.
|
@@ -933,12 +933,12 @@ end, T.untyped)
|
|
933
933
|
params(
|
934
934
|
io: T.untyped,
|
935
935
|
filename: String,
|
936
|
-
compressed_size:
|
937
|
-
uncompressed_size:
|
938
|
-
crc32:
|
939
|
-
gp_flags:
|
936
|
+
compressed_size: Integer,
|
937
|
+
uncompressed_size: Integer,
|
938
|
+
crc32: Integer,
|
939
|
+
gp_flags: Integer,
|
940
940
|
mtime: Time,
|
941
|
-
storage_mode:
|
941
|
+
storage_mode: Integer
|
942
942
|
).void
|
943
943
|
end
|
944
944
|
def write_local_file_header(io:, filename:, compressed_size:, uncompressed_size:, crc32:, gp_flags:, mtime:, storage_mode:); end
|
@@ -968,12 +968,12 @@ end, T.untyped)
|
|
968
968
|
params(
|
969
969
|
io: T.untyped,
|
970
970
|
local_file_header_location: T.untyped,
|
971
|
-
gp_flags:
|
971
|
+
gp_flags: Integer,
|
972
972
|
storage_mode: T.untyped,
|
973
|
-
compressed_size:
|
974
|
-
uncompressed_size:
|
973
|
+
compressed_size: Integer,
|
974
|
+
uncompressed_size: Integer,
|
975
975
|
mtime: Time,
|
976
|
-
crc32:
|
976
|
+
crc32: Integer,
|
977
977
|
filename: String,
|
978
978
|
unix_permissions: T.nilable(Integer)
|
979
979
|
).void
|
@@ -995,9 +995,9 @@ end, T.untyped)
|
|
995
995
|
sig do
|
996
996
|
params(
|
997
997
|
io: T.untyped,
|
998
|
-
compressed_size:
|
999
|
-
uncompressed_size:
|
1000
|
-
crc32:
|
998
|
+
compressed_size: Integer,
|
999
|
+
uncompressed_size: Integer,
|
1000
|
+
crc32: Integer
|
1001
1001
|
).void
|
1002
1002
|
end
|
1003
1003
|
def write_data_descriptor(io:, compressed_size:, uncompressed_size:, crc32:); end
|
@@ -1017,9 +1017,9 @@ end, T.untyped)
|
|
1017
1017
|
sig do
|
1018
1018
|
params(
|
1019
1019
|
io: T.untyped,
|
1020
|
-
start_of_central_directory_location:
|
1021
|
-
central_directory_size:
|
1022
|
-
num_files_in_archive:
|
1020
|
+
start_of_central_directory_location: Integer,
|
1021
|
+
central_directory_size: Integer,
|
1022
|
+
num_files_in_archive: Integer,
|
1023
1023
|
comment: String
|
1024
1024
|
).void
|
1025
1025
|
end
|
@@ -1030,7 +1030,7 @@ end, T.untyped)
|
|
1030
1030
|
# _@param_ `compressed_size` — The size of the compressed (or stored) data - how much space it uses in the ZIP
|
1031
1031
|
#
|
1032
1032
|
# _@param_ `uncompressed_size` — The size of the file once extracted
|
1033
|
-
sig { params(compressed_size:
|
1033
|
+
sig { params(compressed_size: Integer, uncompressed_size: Integer).returns(String) }
|
1034
1034
|
def zip_64_extra_for_local_file_header(compressed_size:, uncompressed_size:); end
|
1035
1035
|
|
1036
1036
|
# sord omit - no YARD type given for "mtime", using untyped
|
@@ -1053,7 +1053,7 @@ end, T.untyped)
|
|
1053
1053
|
# _@param_ `uncompressed_size` — The size of the file once extracted
|
1054
1054
|
#
|
1055
1055
|
# _@param_ `local_file_header_location` — Byte offset of the start of the local file header from the beginning of the ZIP archive
|
1056
|
-
sig { params(compressed_size:
|
1056
|
+
sig { params(compressed_size: Integer, uncompressed_size: Integer, local_file_header_location: Integer).returns(String) }
|
1057
1057
|
def zip_64_extra_for_central_directory_file_header(compressed_size:, uncompressed_size:, local_file_header_location:); end
|
1058
1058
|
|
1059
1059
|
# sord omit - no YARD type given for "t", using untyped
|
@@ -1126,7 +1126,7 @@ end, T.untyped)
|
|
1126
1126
|
# _@param_ `bytes` — the binary string to write (part of the uncompressed file)
|
1127
1127
|
#
|
1128
1128
|
# _@return_ — the number of bytes written (will always be the bytesize of `bytes`)
|
1129
|
-
sig { params(bytes: String).returns(
|
1129
|
+
sig { params(bytes: String).returns(Integer) }
|
1130
1130
|
def write(bytes); end
|
1131
1131
|
end
|
1132
1132
|
|
@@ -1286,7 +1286,7 @@ end, T.untyped)
|
|
1286
1286
|
# _@param_ `io` — an IO-ish object the ZIP file can be read from
|
1287
1287
|
#
|
1288
1288
|
# _@return_ — the parsed local header entry and
|
1289
|
-
sig { params(io: T.untyped).returns(T::Array[T.any(ZipEntry,
|
1289
|
+
sig { params(io: T.untyped).returns(T::Array[T.any(ZipEntry, Integer)]) }
|
1290
1290
|
def read_local_file_header(io:); end
|
1291
1291
|
|
1292
1292
|
# sord duck - #seek looks like a duck type, replacing with untyped
|
@@ -1299,13 +1299,13 @@ end, T.untyped)
|
|
1299
1299
|
# header offset given will be the compressed data offset of the entry
|
1300
1300
|
# (read starting at this offset to get the data).
|
1301
1301
|
#
|
1302
|
-
# local file header is supposed to begin @return [
|
1302
|
+
# local file header is supposed to begin @return [Integer] absolute offset
|
1303
1303
|
# (0-based) of where the compressed data begins for this file within the ZIP
|
1304
1304
|
#
|
1305
1305
|
# _@param_ `io` — an IO-ish object the ZIP file can be read from
|
1306
1306
|
#
|
1307
1307
|
# _@param_ `local_file_header_offset` — absolute offset (0-based) where the
|
1308
|
-
sig { params(io: T.untyped, local_file_header_offset:
|
1308
|
+
sig { params(io: T.untyped, local_file_header_offset: Integer).returns(T.untyped) }
|
1309
1309
|
def get_compressed_data_offset(io:, local_file_header_offset:); end
|
1310
1310
|
|
1311
1311
|
# Parse an IO handle to a ZIP archive into an array of Entry objects, reading from the end
|
@@ -1502,7 +1502,7 @@ end, T.untyped)
|
|
1502
1502
|
|
1503
1503
|
# _@return_ — at what offset you should start reading
|
1504
1504
|
# for the compressed data in your original IO object
|
1505
|
-
sig { returns(
|
1505
|
+
sig { returns(Integer) }
|
1506
1506
|
def compressed_data_offset; end
|
1507
1507
|
|
1508
1508
|
# Tells whether the compressed data offset is already known for this entry
|
@@ -1514,7 +1514,7 @@ end, T.untyped)
|
|
1514
1514
|
sig { returns(T::Boolean) }
|
1515
1515
|
def uses_data_descriptor?; end
|
1516
1516
|
|
1517
|
-
# sord infer - inferred type of parameter "offset" as
|
1517
|
+
# sord infer - inferred type of parameter "offset" as Integer using getter's return type
|
1518
1518
|
# sord omit - no YARD return type given, using untyped
|
1519
1519
|
# Sets the offset at which the compressed data for this file starts in the ZIP.
|
1520
1520
|
# By default, the value will be set by the Reader for you. If you use delayed
|
@@ -1522,43 +1522,43 @@ end, T.untyped)
|
|
1522
1522
|
#
|
1523
1523
|
# entry.compressed_data_offset = reader.get_compressed_data_offset(io: file,
|
1524
1524
|
# local_file_header_offset: entry.local_header_offset)
|
1525
|
-
sig { params(offset:
|
1525
|
+
sig { params(offset: Integer).returns(T.untyped) }
|
1526
1526
|
def compressed_data_offset=(offset); end
|
1527
1527
|
|
1528
1528
|
# _@return_ — bit-packed version signature of the program that made the archive
|
1529
|
-
sig { returns(
|
1529
|
+
sig { returns(Integer) }
|
1530
1530
|
attr_accessor :made_by
|
1531
1531
|
|
1532
1532
|
# _@return_ — ZIP version support needed to extract this file
|
1533
|
-
sig { returns(
|
1533
|
+
sig { returns(Integer) }
|
1534
1534
|
attr_accessor :version_needed_to_extract
|
1535
1535
|
|
1536
1536
|
# _@return_ — bit-packed general purpose flags
|
1537
|
-
sig { returns(
|
1537
|
+
sig { returns(Integer) }
|
1538
1538
|
attr_accessor :gp_flags
|
1539
1539
|
|
1540
1540
|
# _@return_ — Storage mode (0 for stored, 8 for deflate)
|
1541
|
-
sig { returns(
|
1541
|
+
sig { returns(Integer) }
|
1542
1542
|
attr_accessor :storage_mode
|
1543
1543
|
|
1544
1544
|
# _@return_ — the bit-packed DOS time
|
1545
|
-
sig { returns(
|
1545
|
+
sig { returns(Integer) }
|
1546
1546
|
attr_accessor :dos_time
|
1547
1547
|
|
1548
1548
|
# _@return_ — the bit-packed DOS date
|
1549
|
-
sig { returns(
|
1549
|
+
sig { returns(Integer) }
|
1550
1550
|
attr_accessor :dos_date
|
1551
1551
|
|
1552
1552
|
# _@return_ — the CRC32 checksum of this file
|
1553
|
-
sig { returns(
|
1553
|
+
sig { returns(Integer) }
|
1554
1554
|
attr_accessor :crc32
|
1555
1555
|
|
1556
1556
|
# _@return_ — size of compressed file data in the ZIP
|
1557
|
-
sig { returns(
|
1557
|
+
sig { returns(Integer) }
|
1558
1558
|
attr_accessor :compressed_size
|
1559
1559
|
|
1560
1560
|
# _@return_ — size of the file once uncompressed
|
1561
|
-
sig { returns(
|
1561
|
+
sig { returns(Integer) }
|
1562
1562
|
attr_accessor :uncompressed_size
|
1563
1563
|
|
1564
1564
|
# _@return_ — the filename
|
@@ -1566,20 +1566,20 @@ end, T.untyped)
|
|
1566
1566
|
attr_accessor :filename
|
1567
1567
|
|
1568
1568
|
# _@return_ — disk number where this file starts
|
1569
|
-
sig { returns(
|
1569
|
+
sig { returns(Integer) }
|
1570
1570
|
attr_accessor :disk_number_start
|
1571
1571
|
|
1572
1572
|
# _@return_ — internal attributes of the file
|
1573
|
-
sig { returns(
|
1573
|
+
sig { returns(Integer) }
|
1574
1574
|
attr_accessor :internal_attrs
|
1575
1575
|
|
1576
1576
|
# _@return_ — external attributes of the file
|
1577
|
-
sig { returns(
|
1577
|
+
sig { returns(Integer) }
|
1578
1578
|
attr_accessor :external_attrs
|
1579
1579
|
|
1580
1580
|
# _@return_ — at what offset the local file header starts
|
1581
1581
|
# in your original IO object
|
1582
|
-
sig { returns(
|
1582
|
+
sig { returns(Integer) }
|
1583
1583
|
attr_accessor :local_file_header_offset
|
1584
1584
|
|
1585
1585
|
# _@return_ — the file comment
|
@@ -1635,7 +1635,7 @@ end, T.untyped)
|
|
1635
1635
|
# _@param_ `io` — the IO to read the data from
|
1636
1636
|
#
|
1637
1637
|
# _@return_ — the computed CRC32 value
|
1638
|
-
sig { params(io: IO).returns(
|
1638
|
+
sig { params(io: IO).returns(Integer) }
|
1639
1639
|
def self.from_io(io); end
|
1640
1640
|
|
1641
1641
|
# Creates a new streaming CRC32 calculator
|
@@ -1651,7 +1651,7 @@ end, T.untyped)
|
|
1651
1651
|
# Returns the CRC32 value computed so far
|
1652
1652
|
#
|
1653
1653
|
# _@return_ — the updated CRC32 value for all the blobs so far
|
1654
|
-
sig { returns(
|
1654
|
+
sig { returns(Integer) }
|
1655
1655
|
def to_i; end
|
1656
1656
|
|
1657
1657
|
# Appends a known CRC32 value to the current one, and combines the
|
@@ -1662,7 +1662,7 @@ end, T.untyped)
|
|
1662
1662
|
# _@param_ `blob_size` — the size of the daata the `crc32` is computed from
|
1663
1663
|
#
|
1664
1664
|
# _@return_ — the updated CRC32 value for all the blobs so far
|
1665
|
-
sig { params(crc32:
|
1665
|
+
sig { params(crc32: Integer, blob_size: Integer).returns(Integer) }
|
1666
1666
|
def append(crc32, blob_size); end
|
1667
1667
|
|
1668
1668
|
# Writes the given data to the output stream. Allows the object to be used as
|
@@ -1671,7 +1671,7 @@ end, T.untyped)
|
|
1671
1671
|
# _@param_ `bytes` — the binary string to write (part of the uncompressed file)
|
1672
1672
|
#
|
1673
1673
|
# _@return_ — the number of bytes written (will always be the bytesize of `bytes`)
|
1674
|
-
sig { params(bytes: String).returns(
|
1674
|
+
sig { params(bytes: String).returns(Integer) }
|
1675
1675
|
def write(bytes); end
|
1676
1676
|
end
|
1677
1677
|
|
@@ -1741,7 +1741,7 @@ end, T.untyped)
|
|
1741
1741
|
# _@param_ `bytes` — the binary string to write (part of the uncompressed file)
|
1742
1742
|
#
|
1743
1743
|
# _@return_ — the number of bytes written (will always be the bytesize of `bytes`)
|
1744
|
-
sig { params(bytes: String).returns(
|
1744
|
+
sig { params(bytes: String).returns(Integer) }
|
1745
1745
|
def write(bytes); end
|
1746
1746
|
end
|
1747
1747
|
|
@@ -1801,7 +1801,7 @@ end, T.untyped)
|
|
1801
1801
|
# _@param_ `output_io` — the stream to write to (should respond to `:<<`)
|
1802
1802
|
#
|
1803
1803
|
# _@return_ — number of bytes written to `output_io`
|
1804
|
-
sig { params(output_io: IO).returns(
|
1804
|
+
sig { params(output_io: IO).returns(Integer) }
|
1805
1805
|
def self.write_terminator(output_io); end
|
1806
1806
|
|
1807
1807
|
# Compress a given binary string and flush the deflate stream at byte boundary.
|
@@ -1812,7 +1812,7 @@ end, T.untyped)
|
|
1812
1812
|
# _@param_ `level` — Zlib compression level (defaults to `Zlib::DEFAULT_COMPRESSION`)
|
1813
1813
|
#
|
1814
1814
|
# _@return_ — compressed bytes
|
1815
|
-
sig { params(bytes: String, level:
|
1815
|
+
sig { params(bytes: String, level: Integer).returns(String) }
|
1816
1816
|
def self.deflate_chunk(bytes, level: Zlib::DEFAULT_COMPRESSION); end
|
1817
1817
|
|
1818
1818
|
# Compress the contents of input_io into output_io, in blocks
|
@@ -1838,9 +1838,9 @@ end, T.untyped)
|
|
1838
1838
|
params(
|
1839
1839
|
input_io: IO,
|
1840
1840
|
output_io: IO,
|
1841
|
-
level:
|
1842
|
-
block_size:
|
1843
|
-
).returns(
|
1841
|
+
level: Integer,
|
1842
|
+
block_size: Integer
|
1843
|
+
).returns(Integer)
|
1844
1844
|
end
|
1845
1845
|
def self.deflate_in_blocks_and_terminate(input_io, output_io, level: Zlib::DEFAULT_COMPRESSION, block_size: DEFAULT_BLOCKSIZE); end
|
1846
1846
|
|
@@ -1864,9 +1864,9 @@ end, T.untyped)
|
|
1864
1864
|
params(
|
1865
1865
|
input_io: IO,
|
1866
1866
|
output_io: IO,
|
1867
|
-
level:
|
1868
|
-
block_size:
|
1869
|
-
).returns(
|
1867
|
+
level: Integer,
|
1868
|
+
block_size: Integer
|
1869
|
+
).returns(Integer)
|
1870
1870
|
end
|
1871
1871
|
def self.deflate_in_blocks(input_io, output_io, level: Zlib::DEFAULT_COMPRESSION, block_size: DEFAULT_BLOCKSIZE); end
|
1872
1872
|
end
|
@@ -1892,21 +1892,19 @@ end, T.untyped)
|
|
1892
1892
|
# _@param_ `kwargs_for_streamer_new` — Any options to pass to Streamer, see {Streamer#initialize}
|
1893
1893
|
#
|
1894
1894
|
# _@return_ — the size of the resulting archive, in bytes
|
1895
|
-
sig { params(kwargs_for_streamer_new: T.untyped, blk: T.proc.params(
|
1895
|
+
sig { params(kwargs_for_streamer_new: T.untyped, blk: T.proc.params(estimator: SizeEstimator).void).returns(Integer) }
|
1896
1896
|
def self.estimate(**kwargs_for_streamer_new, &blk); end
|
1897
1897
|
|
1898
1898
|
# Add a fake entry to the archive, to see how big it is going to be in the end.
|
1899
1899
|
#
|
1900
|
-
# data descriptor to specify size
|
1901
|
-
#
|
1902
1900
|
# _@param_ `filename` — the name of the file (filenames are variable-width in the ZIP)
|
1903
1901
|
#
|
1904
1902
|
# _@param_ `size` — size of the uncompressed entry
|
1905
1903
|
#
|
1906
|
-
# _@param_ `use_data_descriptor` — whether the entry
|
1904
|
+
# _@param_ `use_data_descriptor` — whether there is going to be a data descriptor written after the entry body, to specify size. You must enable this if you are going to be using {Streamer#write_stored_file} as otherwise your estimated size is not going to be accurate
|
1907
1905
|
#
|
1908
1906
|
# _@return_ — self
|
1909
|
-
sig { params(filename: String, size:
|
1907
|
+
sig { params(filename: String, size: Integer, use_data_descriptor: T::Boolean).returns(T.untyped) }
|
1910
1908
|
def add_stored_entry(filename:, size:, use_data_descriptor: false); end
|
1911
1909
|
|
1912
1910
|
# Add a fake entry to the archive, to see how big it is going to be in the end.
|
@@ -1917,14 +1915,14 @@ end, T.untyped)
|
|
1917
1915
|
#
|
1918
1916
|
# _@param_ `compressed_size` — size of the compressed entry
|
1919
1917
|
#
|
1920
|
-
# _@param_ `use_data_descriptor` — whether
|
1918
|
+
# _@param_ `use_data_descriptor` — whether there is going to be a data descriptor written after the entry body, to specify size. You must enable this if you are going to be using {Streamer#write_deflated_file} as otherwise your estimated size is not going to be accurate
|
1921
1919
|
#
|
1922
1920
|
# _@return_ — self
|
1923
1921
|
sig do
|
1924
1922
|
params(
|
1925
1923
|
filename: String,
|
1926
|
-
uncompressed_size:
|
1927
|
-
compressed_size:
|
1924
|
+
uncompressed_size: Integer,
|
1925
|
+
compressed_size: Integer,
|
1928
1926
|
use_data_descriptor: T::Boolean
|
1929
1927
|
).returns(T.untyped)
|
1930
1928
|
end
|
@@ -1972,7 +1970,7 @@ end, T.untyped)
|
|
1972
1970
|
# _@param_ `bytes` — the binary string to write (part of the uncompressed file)
|
1973
1971
|
#
|
1974
1972
|
# _@return_ — the number of bytes written (will always be the bytesize of `bytes`)
|
1975
|
-
sig { params(bytes: String).returns(
|
1973
|
+
sig { params(bytes: String).returns(Integer) }
|
1976
1974
|
def write(bytes); end
|
1977
1975
|
end
|
1978
1976
|
|
@@ -2102,6 +2100,17 @@ end, T.untyped)
|
|
2102
2100
|
# ones - for example, specific content types are needed for files which are, technically, ZIP files
|
2103
2101
|
# but are of a file format built "on top" of ZIPs - such as ODTs, [pkpass files](https://developer.apple.com/documentation/walletpasses/building_a_pass)
|
2104
2102
|
# and ePubs.
|
2103
|
+
#
|
2104
|
+
# More value, however, is in the "technical" headers this method will provide. It will take the following steps to make sure streaming works correctly.
|
2105
|
+
#
|
2106
|
+
# * `Last-Modified` will be set to "now" so that the response is considered "fresh" by `Rack::ETag`. This is done so that `Rack::ETag` won't try to
|
2107
|
+
# calculate a lax ETag value and thus won't start buffering your response out of nowhere
|
2108
|
+
# * `Content-Encoding` will be set to `identity`. This is so that proxies or the Rack middleware that applies compression to the response (like gzip)
|
2109
|
+
# is not going to try to compress your response. It also tells the receiving browsers (or downstream proxies) that they should not attempt to
|
2110
|
+
# open or uncompress the response before saving it or passing it onwards.
|
2111
|
+
# * `X-Accel-Buffering` will be set to 'no` - this tells both nginx and the Google Cloud load balancer that the response should not be buffered
|
2112
|
+
#
|
2113
|
+
# These header values are known to get as close as possible to guaranteeing streaming on most environments where Ruby web applications may be hosted.
|
2105
2114
|
sig { returns(T::Hash[T.untyped, T.untyped]) }
|
2106
2115
|
def self.streaming_http_headers; end
|
2107
2116
|
|
data/zip_kit.gemspec
CHANGED
@@ -40,6 +40,8 @@ Gem::Specification.new do |spec|
|
|
40
40
|
spec.add_development_dependency "standard", "1.28.5" # Very specific version of standard for 2.6 with _known_ settings
|
41
41
|
spec.add_development_dependency "magic_frozen_string_literal"
|
42
42
|
spec.add_development_dependency "puma"
|
43
|
+
spec.add_development_dependency "mutex_m" # Some deps use it but it is no longer in stdlib since 3.4
|
44
|
+
spec.add_development_dependency "bigdecimal" # Some deps use it but it is no longer in stdlib since 3.4
|
43
45
|
spec.add_development_dependency "rails", "~> 5" # For testing RailsStreaming against an actual Rails controller
|
44
46
|
spec.add_development_dependency "actionpack", "~> 5" # For testing RailsStreaming against an actual Rails controller
|
45
47
|
spec.add_development_dependency "nokogiri", "~> 1", ">= 1.13" # Rails 5 does by mistake use an older Nokogiri otherwise
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: zip_kit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 6.3.
|
4
|
+
version: 6.3.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Julik Tarkhanov
|
@@ -9,10 +9,9 @@ authors:
|
|
9
9
|
- Dmitry Tymchuk
|
10
10
|
- David Bosveld
|
11
11
|
- Felix Bünemann
|
12
|
-
autorequire:
|
13
12
|
bindir: exe
|
14
13
|
cert_chain: []
|
15
|
-
date:
|
14
|
+
date: 2025-02-25 00:00:00.000000000 Z
|
16
15
|
dependencies:
|
17
16
|
- !ruby/object:Gem::Dependency
|
18
17
|
name: bundler
|
@@ -216,6 +215,34 @@ dependencies:
|
|
216
215
|
- - ">="
|
217
216
|
- !ruby/object:Gem::Version
|
218
217
|
version: '0'
|
218
|
+
- !ruby/object:Gem::Dependency
|
219
|
+
name: mutex_m
|
220
|
+
requirement: !ruby/object:Gem::Requirement
|
221
|
+
requirements:
|
222
|
+
- - ">="
|
223
|
+
- !ruby/object:Gem::Version
|
224
|
+
version: '0'
|
225
|
+
type: :development
|
226
|
+
prerelease: false
|
227
|
+
version_requirements: !ruby/object:Gem::Requirement
|
228
|
+
requirements:
|
229
|
+
- - ">="
|
230
|
+
- !ruby/object:Gem::Version
|
231
|
+
version: '0'
|
232
|
+
- !ruby/object:Gem::Dependency
|
233
|
+
name: bigdecimal
|
234
|
+
requirement: !ruby/object:Gem::Requirement
|
235
|
+
requirements:
|
236
|
+
- - ">="
|
237
|
+
- !ruby/object:Gem::Version
|
238
|
+
version: '0'
|
239
|
+
type: :development
|
240
|
+
prerelease: false
|
241
|
+
version_requirements: !ruby/object:Gem::Requirement
|
242
|
+
requirements:
|
243
|
+
- - ">="
|
244
|
+
- !ruby/object:Gem::Version
|
245
|
+
version: '0'
|
219
246
|
- !ruby/object:Gem::Dependency
|
220
247
|
name: rails
|
221
248
|
requirement: !ruby/object:Gem::Requirement
|
@@ -299,10 +326,8 @@ executables: []
|
|
299
326
|
extensions: []
|
300
327
|
extra_rdoc_files: []
|
301
328
|
files:
|
302
|
-
- ".document"
|
303
329
|
- ".github/workflows/ci.yml"
|
304
330
|
- ".gitignore"
|
305
|
-
- ".rspec"
|
306
331
|
- ".standard.yml"
|
307
332
|
- ".yardopts"
|
308
333
|
- CHANGELOG.md
|
@@ -314,7 +339,6 @@ files:
|
|
314
339
|
- README.md
|
315
340
|
- RUBYZIP_DIFFERENCES.md
|
316
341
|
- Rakefile
|
317
|
-
- bench/buffered_crc32_bench.rb
|
318
342
|
- examples/archive_size_estimate.rb
|
319
343
|
- examples/config.ru
|
320
344
|
- examples/deferred_write.rb
|
@@ -359,7 +383,6 @@ licenses:
|
|
359
383
|
- MIT
|
360
384
|
metadata:
|
361
385
|
allowed_push_host: https://rubygems.org
|
362
|
-
post_install_message:
|
363
386
|
rdoc_options: []
|
364
387
|
require_paths:
|
365
388
|
- lib
|
@@ -374,8 +397,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
374
397
|
- !ruby/object:Gem::Version
|
375
398
|
version: '0'
|
376
399
|
requirements: []
|
377
|
-
rubygems_version: 3.
|
378
|
-
signing_key:
|
400
|
+
rubygems_version: 3.6.2
|
379
401
|
specification_version: 4
|
380
402
|
summary: Stream out ZIP files from Ruby. Successor to zip_tricks.
|
381
403
|
test_files: []
|
data/.document
DELETED
data/.rspec
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
--color
|