zip_kit 6.4.1 → 6.4.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.
data/rbi/zip_kit.rbi CHANGED
@@ -1034,11 +1034,6 @@ end, T.untyped)
1034
1034
  os_type = 3 # UNIX
1035
1035
  [VERSION_MADE_BY, os_type].pack("CC").freeze
1036
1036
  end, T.untyped)
1037
- C_UINT4 = T.let("V", T.untyped)
1038
- C_UINT2 = T.let("v", T.untyped)
1039
- C_UINT8 = T.let("Q<", T.untyped)
1040
- C_CHAR = T.let("C", T.untyped)
1041
- C_INT4 = T.let("l<", T.untyped)
1042
1037
 
1043
1038
  # sord duck - #<< looks like a duck type, replacing with untyped
1044
1039
  # Writes the local file header, that precedes the actual file _data_.
@@ -1201,27 +1196,53 @@ end, T.untyped)
1201
1196
  sig { params(t: T.untyped).returns(T.untyped) }
1202
1197
  def to_binary_dos_date(t); end
1203
1198
 
1204
- # sord omit - no YARD type given for "values_to_packspecs", using untyped
1205
- # sord omit - no YARD return type given, using untyped
1206
- # Unzips a given array of tuples of "numeric value, pack specifier" and then packs all the odd
1207
- # values using specifiers from all the even values. It is harder to explain than to show:
1208
- #
1209
- # pack_array([1, 'V', 2, 'v', 148, 'v]) #=> "\x01\x00\x00\x00\x02\x00\x94\x00"
1210
- #
1211
- # will do the following two transforms:
1212
- #
1213
- # [1, 'V', 2, 'v', 148, 'v] -> [1,2,148], ['V','v','v'] -> [1,2,148].pack('Vvv') -> "\x01\x00\x00\x00\x02\x00\x94\x00".
1214
- # This might seem like a "clever optimisation" but the issue is that `pack` needs an array allocated per call, and
1215
- # we output very verbosely - value-by-value. This might be quite a few array allocs. Using something like this
1216
- # helps us save the array allocs
1217
- sig { params(values_to_packspecs: T.untyped).returns(T.untyped) }
1218
- def pack_array(values_to_packspecs); end
1219
-
1220
1199
  # sord omit - no YARD type given for "unix_permissions_int", using untyped
1221
1200
  # sord omit - no YARD type given for "file_type_int", using untyped
1222
1201
  # sord omit - no YARD return type given, using untyped
1223
1202
  sig { params(unix_permissions_int: T.untyped, file_type_int: T.untyped).returns(T.untyped) }
1224
1203
  def generate_external_attrs(unix_permissions_int, file_type_int); end
1204
+
1205
+ # Collects the values of a ZIP record and packs them all with a single `Array#pack`.
1206
+ # Packing value-by-value allocates an Array and a String per value, and the ZIP headers have lots of values.
1207
+ # All integers are little-endian, as the ZIP format wants them.
1208
+ class PackBuffer
1209
+ sig { void }
1210
+ def initialize; end
1211
+
1212
+ # _@param_ `value` — a 1-byte unsigned int
1213
+ sig { params(value: Integer).returns(T.self_type) }
1214
+ def uint1(value); end
1215
+
1216
+ # _@param_ `value` — a 2-byte unsigned int
1217
+ sig { params(value: Integer).returns(T.self_type) }
1218
+ def uint2(value); end
1219
+
1220
+ # _@param_ `value` — a 4-byte unsigned int
1221
+ sig { params(value: Integer).returns(T.self_type) }
1222
+ def uint4(value); end
1223
+
1224
+ # _@param_ `value` — an 8-byte unsigned int
1225
+ sig { params(value: Integer).returns(T.self_type) }
1226
+ def uint8(value); end
1227
+
1228
+ # _@param_ `value` — a 4-byte signed int
1229
+ sig { params(value: Integer).returns(T.self_type) }
1230
+ def int4(value); end
1231
+
1232
+ # _@param_ `value` — a String whose bytes get appended as-is, regardless of its encoding
1233
+ sig { params(value: String).returns(T.self_type) }
1234
+ def bytes(value); end
1235
+
1236
+ # _@return_ — the packed values in binary encoding
1237
+ sig { returns(String) }
1238
+ def b; end
1239
+
1240
+ # sord omit - no YARD type given for "value", using untyped
1241
+ # sord omit - no YARD type given for "packspec", using untyped
1242
+ # sord omit - no YARD return type given, using untyped
1243
+ sig { params(value: T.untyped, packspec: T.untyped).returns(T.untyped) }
1244
+ def append(value, packspec); end
1245
+ end
1225
1246
  end
1226
1247
 
1227
1248
  # Acts as a converter between callers which send data to the `#<<` method (such as all the ZipKit
@@ -1355,6 +1376,10 @@ end, T.untyped)
1355
1376
  C_UINT4 = T.let("V", T.untyped)
1356
1377
  C_UINT2 = T.let("v", T.untyped)
1357
1378
  C_UINT8 = T.let("Q<", T.untyped)
1379
+ LOCAL_HEADER_FIXED_FIELDS_UNPACKSPEC = T.let("VvvvvvVVVvv", T.untyped)
1380
+ SIZE_OF_LOCAL_HEADER_FIXED_FIELDS = T.let(30, T.untyped)
1381
+ CDIR_ENTRY_FIXED_FIELDS_UNPACKSPEC = T.let("VvvvvvvVVVvvvvvVV", T.untyped)
1382
+ SIZE_OF_CDIR_ENTRY_FIXED_FIELDS = T.let(46, T.untyped)
1358
1383
  MAX_END_OF_CENTRAL_DIRECTORY_RECORD_SIZE = T.let(4 + # Offset of the start of central directory
1359
1384
  4 + # Size of the central directory
1360
1385
  2 + # Number of files in the cdir
@@ -1364,19 +1389,7 @@ end, T.untyped)
1364
1389
  2 + # Number of files in the cdir of this disk
1365
1390
  2 + # The comment size
1366
1391
  0xFFFF, T.untyped)
1367
- MAX_LOCAL_HEADER_SIZE = T.let(4 + # signature
1368
- 2 + # Version needed to extract
1369
- 2 + # gp flags
1370
- 2 + # storage mode
1371
- 2 + # dos time
1372
- 2 + # dos date
1373
- 4 + # CRC32
1374
- 4 + # Comp size
1375
- 4 + # Uncomp size
1376
- 2 + # Filename size
1377
- 2 + # Extra fields size
1378
- 0xFFFF + # Maximum filename size
1379
- 0xFFFF, T.untyped)
1392
+ LOCAL_HEADER_READ_SIZE = T.let(4 * 1024, T.untyped)
1380
1393
  SIZE_OF_USABLE_EOCD_RECORD = T.let(4 + # Signature
1381
1394
  2 + # Number of this disk
1382
1395
  2 + # Number of the disk with the EOCD record
@@ -1424,9 +1437,8 @@ end, T.untyped)
1424
1437
  # sord duck - #read looks like a duck type, replacing with untyped
1425
1438
  # Parse the local header entry and get the offset in the IO at which the
1426
1439
  # actual compressed data of the file starts within the ZIP.
1427
- # The method will eager-read the entire local header for the file
1428
- # (the maximum size the local header may use), starting at the given offset,
1429
- # and will then compute its size. That size plus the local header offset
1440
+ # The method will read the local header for the file, starting at the
1441
+ # given offset, and will then compute its size. That size plus the local header offset
1430
1442
  # given will be the compressed data offset of the entry (read starting at
1431
1443
  # this offset to get the data).
1432
1444
  #
@@ -1442,9 +1454,8 @@ end, T.untyped)
1442
1454
  # sord duck - #read looks like a duck type, replacing with untyped
1443
1455
  # sord omit - no YARD return type given, using untyped
1444
1456
  # Get the offset in the IO at which the actual compressed data of the file
1445
- # starts within the ZIP. The method will eager-read the entire local header
1446
- # for the file (the maximum size the local header may use), starting at the
1447
- # given offset, and will then compute its size. That size plus the local
1457
+ # starts within the ZIP. The method will read the local header for the file,
1458
+ # starting at the given offset, and will then compute its size. That size plus the local
1448
1459
  # header offset given will be the compressed data offset of the entry
1449
1460
  # (read starting at this offset to get the data).
1450
1461
  #
@@ -1512,6 +1523,12 @@ end, T.untyped)
1512
1523
  sig { params(io: T.untyped, signature_magic_number: T.untyped).returns(T.untyped) }
1513
1524
  def assert_signature(io, signature_magic_number); end
1514
1525
 
1526
+ # sord omit - no YARD type given for "readback", using untyped
1527
+ # sord omit - no YARD type given for "signature_magic_number", using untyped
1528
+ # sord omit - no YARD return type given, using untyped
1529
+ sig { params(readback: T.untyped, signature_magic_number: T.untyped).returns(T.untyped) }
1530
+ def assert_signature_value(readback, signature_magic_number); end
1531
+
1515
1532
  # sord omit - no YARD type given for "io", using untyped
1516
1533
  # sord omit - no YARD type given for "n", using untyped
1517
1534
  # sord omit - no YARD return type given, using untyped
@@ -2301,9 +2318,12 @@ end, T.untyped)
2301
2318
  #
2302
2319
  # * `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
2303
2320
  # calculate a lax ETag value and thus won't start buffering your response out of nowhere
2304
- # * `content-encoding` will be set to `identity`. This is so that proxies or the Rack middleware that applies compression to the response (like gzip)
2305
- # is not going to try to compress your response. It also tells the receiving browsers (or downstream proxies) that they should not attempt to
2306
- # open or uncompress the response before saving it or passing it onwards.
2321
+ # * `cache-control` will be set to `no-transform`. This is so that `Rack::Deflater` and proxies which compress responses (like gzip)
2322
+ # are not going to try to compress your response again (and, with `Rack::Deflater` set to `sync: false`, buffer all of it to do so).
2323
+ # It says nothing about caching, so add your own directives to it if you need them, and keep `no-transform` in there
2324
+ # * `content-encoding` will be set to `identity`. This tells the receiving browsers (or downstream proxies) that they should not attempt to
2325
+ # open or uncompress the response before saving it or passing it onwards. Note that it does _not_ stop `Rack::Deflater`, which compresses
2326
+ # responses with `content-encoding: identity` just the same
2307
2327
  # * `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
2308
2328
  #
2309
2329
  # These header values are known to get as close as possible to guaranteeing streaming on most environments where Ruby web applications may be hosted.
data/rbi/zip_kit.rbs CHANGED
@@ -910,11 +910,6 @@ module ZipKit
910
910
  FILE_TYPE_FILE: untyped
911
911
  FILE_TYPE_DIRECTORY: untyped
912
912
  MADE_BY_SIGNATURE: untyped
913
- C_UINT4: untyped
914
- C_UINT2: untyped
915
- C_UINT8: untyped
916
- C_CHAR: untyped
917
- C_INT4: untyped
918
913
 
919
914
  # sord duck - #<< looks like a duck type, replacing with untyped
920
915
  # Writes the local file header, that precedes the actual file _data_.
@@ -1060,25 +1055,43 @@ module ZipKit
1060
1055
  # sord omit - no YARD return type given, using untyped
1061
1056
  def to_binary_dos_date: (untyped t) -> untyped
1062
1057
 
1063
- # sord omit - no YARD type given for "values_to_packspecs", using untyped
1064
- # sord omit - no YARD return type given, using untyped
1065
- # Unzips a given array of tuples of "numeric value, pack specifier" and then packs all the odd
1066
- # values using specifiers from all the even values. It is harder to explain than to show:
1067
- #
1068
- # pack_array([1, 'V', 2, 'v', 148, 'v]) #=> "\x01\x00\x00\x00\x02\x00\x94\x00"
1069
- #
1070
- # will do the following two transforms:
1071
- #
1072
- # [1, 'V', 2, 'v', 148, 'v] -> [1,2,148], ['V','v','v'] -> [1,2,148].pack('Vvv') -> "\x01\x00\x00\x00\x02\x00\x94\x00".
1073
- # This might seem like a "clever optimisation" but the issue is that `pack` needs an array allocated per call, and
1074
- # we output very verbosely - value-by-value. This might be quite a few array allocs. Using something like this
1075
- # helps us save the array allocs
1076
- def pack_array: (untyped values_to_packspecs) -> untyped
1077
-
1078
1058
  # sord omit - no YARD type given for "unix_permissions_int", using untyped
1079
1059
  # sord omit - no YARD type given for "file_type_int", using untyped
1080
1060
  # sord omit - no YARD return type given, using untyped
1081
1061
  def generate_external_attrs: (untyped unix_permissions_int, untyped file_type_int) -> untyped
1062
+
1063
+ # Collects the values of a ZIP record and packs them all with a single `Array#pack`.
1064
+ # Packing value-by-value allocates an Array and a String per value, and the ZIP headers have lots of values.
1065
+ # All integers are little-endian, as the ZIP format wants them.
1066
+ class PackBuffer
1067
+ def initialize: () -> void
1068
+
1069
+ # _@param_ `value` — a 1-byte unsigned int
1070
+ def uint1: (Integer value) -> self
1071
+
1072
+ # _@param_ `value` — a 2-byte unsigned int
1073
+ def uint2: (Integer value) -> self
1074
+
1075
+ # _@param_ `value` — a 4-byte unsigned int
1076
+ def uint4: (Integer value) -> self
1077
+
1078
+ # _@param_ `value` — an 8-byte unsigned int
1079
+ def uint8: (Integer value) -> self
1080
+
1081
+ # _@param_ `value` — a 4-byte signed int
1082
+ def int4: (Integer value) -> self
1083
+
1084
+ # _@param_ `value` — a String whose bytes get appended as-is, regardless of its encoding
1085
+ def bytes: (String value) -> self
1086
+
1087
+ # _@return_ — the packed values in binary encoding
1088
+ def b: () -> String
1089
+
1090
+ # sord omit - no YARD type given for "value", using untyped
1091
+ # sord omit - no YARD type given for "packspec", using untyped
1092
+ # sord omit - no YARD return type given, using untyped
1093
+ def append: (untyped value, untyped packspec) -> untyped
1094
+ end
1082
1095
  end
1083
1096
 
1084
1097
  # Acts as a converter between callers which send data to the `#<<` method (such as all the ZipKit
@@ -1198,8 +1211,12 @@ module ZipKit
1198
1211
  C_UINT4: untyped
1199
1212
  C_UINT2: untyped
1200
1213
  C_UINT8: untyped
1214
+ LOCAL_HEADER_FIXED_FIELDS_UNPACKSPEC: untyped
1215
+ SIZE_OF_LOCAL_HEADER_FIXED_FIELDS: untyped
1216
+ CDIR_ENTRY_FIXED_FIELDS_UNPACKSPEC: untyped
1217
+ SIZE_OF_CDIR_ENTRY_FIXED_FIELDS: untyped
1201
1218
  MAX_END_OF_CENTRAL_DIRECTORY_RECORD_SIZE: untyped
1202
- MAX_LOCAL_HEADER_SIZE: untyped
1219
+ LOCAL_HEADER_READ_SIZE: untyped
1203
1220
  SIZE_OF_USABLE_EOCD_RECORD: untyped
1204
1221
 
1205
1222
  # sord duck - #tell looks like a duck type, replacing with untyped
@@ -1239,9 +1256,8 @@ module ZipKit
1239
1256
  # sord duck - #read looks like a duck type with an equivalent RBS interface, replacing with _Reader
1240
1257
  # Parse the local header entry and get the offset in the IO at which the
1241
1258
  # actual compressed data of the file starts within the ZIP.
1242
- # The method will eager-read the entire local header for the file
1243
- # (the maximum size the local header may use), starting at the given offset,
1244
- # and will then compute its size. That size plus the local header offset
1259
+ # The method will read the local header for the file, starting at the
1260
+ # given offset, and will then compute its size. That size plus the local header offset
1245
1261
  # given will be the compressed data offset of the entry (read starting at
1246
1262
  # this offset to get the data).
1247
1263
  #
@@ -1256,9 +1272,8 @@ module ZipKit
1256
1272
  # sord duck - #read looks like a duck type with an equivalent RBS interface, replacing with _Reader
1257
1273
  # sord omit - no YARD return type given, using untyped
1258
1274
  # Get the offset in the IO at which the actual compressed data of the file
1259
- # starts within the ZIP. The method will eager-read the entire local header
1260
- # for the file (the maximum size the local header may use), starting at the
1261
- # given offset, and will then compute its size. That size plus the local
1275
+ # starts within the ZIP. The method will read the local header for the file,
1276
+ # starting at the given offset, and will then compute its size. That size plus the local
1262
1277
  # header offset given will be the compressed data offset of the entry
1263
1278
  # (read starting at this offset to get the data).
1264
1279
  #
@@ -1317,6 +1332,11 @@ module ZipKit
1317
1332
  # sord omit - no YARD return type given, using untyped
1318
1333
  def assert_signature: (untyped io, untyped signature_magic_number) -> untyped
1319
1334
 
1335
+ # sord omit - no YARD type given for "readback", using untyped
1336
+ # sord omit - no YARD type given for "signature_magic_number", using untyped
1337
+ # sord omit - no YARD return type given, using untyped
1338
+ def assert_signature_value: (untyped readback, untyped signature_magic_number) -> untyped
1339
+
1320
1340
  # sord omit - no YARD type given for "io", using untyped
1321
1341
  # sord omit - no YARD type given for "n", using untyped
1322
1342
  # sord omit - no YARD return type given, using untyped
@@ -2020,9 +2040,12 @@ module ZipKit
2020
2040
  #
2021
2041
  # * `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
2022
2042
  # calculate a lax ETag value and thus won't start buffering your response out of nowhere
2023
- # * `content-encoding` will be set to `identity`. This is so that proxies or the Rack middleware that applies compression to the response (like gzip)
2024
- # is not going to try to compress your response. It also tells the receiving browsers (or downstream proxies) that they should not attempt to
2025
- # open or uncompress the response before saving it or passing it onwards.
2043
+ # * `cache-control` will be set to `no-transform`. This is so that `Rack::Deflater` and proxies which compress responses (like gzip)
2044
+ # are not going to try to compress your response again (and, with `Rack::Deflater` set to `sync: false`, buffer all of it to do so).
2045
+ # It says nothing about caching, so add your own directives to it if you need them, and keep `no-transform` in there
2046
+ # * `content-encoding` will be set to `identity`. This tells the receiving browsers (or downstream proxies) that they should not attempt to
2047
+ # open or uncompress the response before saving it or passing it onwards. Note that it does _not_ stop `Rack::Deflater`, which compresses
2048
+ # responses with `content-encoding: identity` just the same
2026
2049
  # * `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
2027
2050
  #
2028
2051
  # These header values are known to get as close as possible to guaranteeing streaming on most environments where Ruby web applications may be hosted.
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.4.1
4
+ version: 6.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Julik Tarkhanov
@@ -11,7 +11,7 @@ authors:
11
11
  - Felix Bünemann
12
12
  bindir: exe
13
13
  cert_chain: []
14
- date: 2026-10-08 00:00:00.000000000 Z
14
+ date: 2026-11-14 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: bundler