rbs 3.1.3 → 3.2.0.pre.1
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/ruby.yml +0 -6
- data/CHANGELOG.md +68 -0
- data/Gemfile +0 -6
- data/Gemfile.lock +12 -21
- data/README.md +1 -1
- data/Rakefile +44 -0
- data/Steepfile +3 -3
- data/core/array.rbs +0 -8
- data/core/builtin.rbs +28 -8
- data/core/constants.rbs +13 -5
- data/core/exception.rbs +1 -1
- data/core/global_variables.rbs +27 -27
- data/core/io.rbs +163 -172
- data/core/kernel.rbs +7 -4
- data/core/module.rbs +34 -32
- data/core/object.rbs +2 -2
- data/core/string_io.rbs +9 -0
- data/core/thread.rbs +25 -1
- data/core/time.rbs +3 -3
- data/docs/CONTRIBUTING.md +1 -1
- data/docs/rbs_by_example.md +16 -35
- data/docs/repo.md +1 -1
- data/docs/sigs.md +7 -7
- data/docs/stdlib.md +2 -3
- data/docs/syntax.md +40 -40
- data/lib/rbs/cli.rb +15 -4
- data/lib/rbs/collection/installer.rb +5 -2
- data/lib/rbs/collection/sources/stdlib.rb +5 -1
- data/lib/rbs/errors.rb +8 -1
- data/lib/rbs/file_finder.rb +1 -1
- data/lib/rbs/prototype/rb.rb +64 -6
- data/lib/rbs/prototype/rbi.rb +2 -6
- data/lib/rbs/prototype/runtime.rb +29 -8
- data/lib/rbs/subtractor.rb +17 -0
- data/lib/rbs/type_name.rb +4 -4
- data/lib/rbs/version.rb +1 -1
- data/rbs.gemspec +1 -1
- data/schema/decls.json +1 -1
- data/sig/errors.rbs +54 -0
- data/sig/parser.rbs +2 -2
- data/sig/prototype/rb.rbs +9 -1
- data/sig/subtractor.rbs +4 -0
- data/stdlib/logger/0/logger.rbs +1 -1
- data/stdlib/observable/0/observable.rbs +219 -0
- data/stdlib/uri/0/common.rbs +24 -0
- data/stdlib/zlib/0/buf_error.rbs +79 -0
- data/stdlib/zlib/0/data_error.rbs +79 -0
- data/stdlib/zlib/0/deflate.rbs +276 -0
- data/stdlib/zlib/0/error.rbs +89 -0
- data/stdlib/zlib/0/gzip_file/crc_error.rbs +115 -0
- data/stdlib/zlib/0/gzip_file/error.rbs +128 -0
- data/stdlib/zlib/0/gzip_file/length_error.rbs +115 -0
- data/stdlib/zlib/0/gzip_file/no_footer.rbs +114 -0
- data/stdlib/zlib/0/gzip_file.rbs +228 -0
- data/stdlib/zlib/0/gzip_reader.rbs +362 -0
- data/stdlib/zlib/0/gzip_writer.rbs +237 -0
- data/stdlib/zlib/0/inflate.rbs +249 -0
- data/stdlib/zlib/0/mem_error.rbs +79 -0
- data/stdlib/zlib/0/need_dict.rbs +82 -0
- data/stdlib/zlib/0/stream_end.rbs +80 -0
- data/stdlib/zlib/0/stream_error.rbs +80 -0
- data/stdlib/zlib/0/version_error.rbs +80 -0
- data/stdlib/zlib/0/zstream.rbs +270 -0
- metadata +24 -8
- data/stdlib/prime/0/integer-extension.rbs +0 -41
- data/stdlib/prime/0/manifest.yaml +0 -2
- data/stdlib/prime/0/prime.rbs +0 -372
@@ -0,0 +1,362 @@
|
|
1
|
+
# <!-- rdoc-file=ext/zlib/zlib.c -->
|
2
|
+
# This module provides access to the [zlib library](http://zlib.net). Zlib is
|
3
|
+
# designed to be a portable, free, general-purpose, legally unencumbered -- that
|
4
|
+
# is, not covered by any patents -- lossless data-compression library for use on
|
5
|
+
# virtually any computer hardware and operating system.
|
6
|
+
#
|
7
|
+
# The zlib compression library provides in-memory compression and decompression
|
8
|
+
# functions, including integrity checks of the uncompressed data.
|
9
|
+
#
|
10
|
+
# The zlib compressed data format is described in RFC 1950, which is a wrapper
|
11
|
+
# around a deflate stream which is described in RFC 1951.
|
12
|
+
#
|
13
|
+
# The library also supports reading and writing files in gzip (.gz) format with
|
14
|
+
# an interface similar to that of IO. The gzip format is described in RFC 1952
|
15
|
+
# which is also a wrapper around a deflate stream.
|
16
|
+
#
|
17
|
+
# The zlib format was designed to be compact and fast for use in memory and on
|
18
|
+
# communications channels. The gzip format was designed for single-file
|
19
|
+
# compression on file systems, has a larger header than zlib to maintain
|
20
|
+
# directory information, and uses a different, slower check method than zlib.
|
21
|
+
#
|
22
|
+
# See your system's zlib.h for further information about zlib
|
23
|
+
#
|
24
|
+
# ## Sample usage
|
25
|
+
#
|
26
|
+
# Using the wrapper to compress strings with default parameters is quite simple:
|
27
|
+
#
|
28
|
+
# require "zlib"
|
29
|
+
#
|
30
|
+
# data_to_compress = File.read("don_quixote.txt")
|
31
|
+
#
|
32
|
+
# puts "Input size: #{data_to_compress.size}"
|
33
|
+
# #=> Input size: 2347740
|
34
|
+
#
|
35
|
+
# data_compressed = Zlib::Deflate.deflate(data_to_compress)
|
36
|
+
#
|
37
|
+
# puts "Compressed size: #{data_compressed.size}"
|
38
|
+
# #=> Compressed size: 887238
|
39
|
+
#
|
40
|
+
# uncompressed_data = Zlib::Inflate.inflate(data_compressed)
|
41
|
+
#
|
42
|
+
# puts "Uncompressed data is: #{uncompressed_data}"
|
43
|
+
# #=> Uncompressed data is: The Project Gutenberg EBook of Don Quixote...
|
44
|
+
#
|
45
|
+
# ## Class tree
|
46
|
+
#
|
47
|
+
# * Zlib::Deflate
|
48
|
+
# * Zlib::Inflate
|
49
|
+
# * Zlib::ZStream
|
50
|
+
# * Zlib::Error
|
51
|
+
# * Zlib::StreamEnd
|
52
|
+
# * Zlib::NeedDict
|
53
|
+
# * Zlib::DataError
|
54
|
+
# * Zlib::StreamError
|
55
|
+
# * Zlib::MemError
|
56
|
+
# * Zlib::BufError
|
57
|
+
# * Zlib::VersionError
|
58
|
+
# * Zlib::InProgressError
|
59
|
+
#
|
60
|
+
#
|
61
|
+
#
|
62
|
+
# (if you have GZIP_SUPPORT)
|
63
|
+
# * Zlib::GzipReader
|
64
|
+
# * Zlib::GzipWriter
|
65
|
+
# * Zlib::GzipFile
|
66
|
+
# * Zlib::GzipFile::Error
|
67
|
+
# * Zlib::GzipFile::LengthError
|
68
|
+
# * Zlib::GzipFile::CRCError
|
69
|
+
# * Zlib::GzipFile::NoFooter
|
70
|
+
#
|
71
|
+
module Zlib
|
72
|
+
# <!-- rdoc-file=ext/zlib/zlib.c -->
|
73
|
+
# Zlib::GzipReader is the class for reading a gzipped file. GzipReader should
|
74
|
+
# be used as an IO, or -IO-like, object.
|
75
|
+
#
|
76
|
+
# Zlib::GzipReader.open('hoge.gz') {|gz|
|
77
|
+
# print gz.read
|
78
|
+
# }
|
79
|
+
#
|
80
|
+
# File.open('hoge.gz') do |f|
|
81
|
+
# gz = Zlib::GzipReader.new(f)
|
82
|
+
# print gz.read
|
83
|
+
# gz.close
|
84
|
+
# end
|
85
|
+
#
|
86
|
+
# ## Method Catalogue
|
87
|
+
#
|
88
|
+
# The following methods in Zlib::GzipReader are just like their counterparts in
|
89
|
+
# IO, but they raise Zlib::Error or Zlib::GzipFile::Error exception if an error
|
90
|
+
# was found in the gzip file.
|
91
|
+
# * #each
|
92
|
+
# * #each_line
|
93
|
+
# * #each_byte
|
94
|
+
# * #gets
|
95
|
+
# * #getc
|
96
|
+
# * #lineno
|
97
|
+
# * #lineno=
|
98
|
+
# * #read
|
99
|
+
# * #readchar
|
100
|
+
# * #readline
|
101
|
+
# * #readlines
|
102
|
+
# * #ungetc
|
103
|
+
#
|
104
|
+
#
|
105
|
+
# Be careful of the footer of the gzip file. A gzip file has the checksum of
|
106
|
+
# pre-compressed data in its footer. GzipReader checks all uncompressed data
|
107
|
+
# against that checksum at the following cases, and if it fails, raises
|
108
|
+
# `Zlib::GzipFile::NoFooter`, `Zlib::GzipFile::CRCError`, or
|
109
|
+
# `Zlib::GzipFile::LengthError` exception.
|
110
|
+
#
|
111
|
+
# * When an reading request is received beyond the end of file (the end of
|
112
|
+
# compressed data). That is, when Zlib::GzipReader#read,
|
113
|
+
# Zlib::GzipReader#gets, or some other methods for reading returns nil.
|
114
|
+
# * When Zlib::GzipFile#close method is called after the object reaches the
|
115
|
+
# end of file.
|
116
|
+
# * When Zlib::GzipReader#unused method is called after the object reaches the
|
117
|
+
# end of file.
|
118
|
+
#
|
119
|
+
#
|
120
|
+
# The rest of the methods are adequately described in their own documentation.
|
121
|
+
#
|
122
|
+
class GzipReader < Zlib::GzipFile
|
123
|
+
include Enumerable[String]
|
124
|
+
|
125
|
+
# <!--
|
126
|
+
# rdoc-file=ext/zlib/zlib.c
|
127
|
+
# - Zlib::GzipReader.open(filename) {|gz| ... }
|
128
|
+
# -->
|
129
|
+
# Opens a file specified by `filename` as a gzipped file, and returns a
|
130
|
+
# GzipReader object associated with that file. Further details of this method
|
131
|
+
# are in Zlib::GzipReader.new and ZLib::GzipFile.wrap.
|
132
|
+
#
|
133
|
+
def self.open: (String filename) { (instance gz) -> void } -> instance
|
134
|
+
|
135
|
+
# <!--
|
136
|
+
# rdoc-file=ext/zlib/zlib.c
|
137
|
+
# - Zlib::GzipReader.zcat(io, options = {}, &block) => nil
|
138
|
+
# - Zlib::GzipReader.zcat(io, options = {}) => string
|
139
|
+
# -->
|
140
|
+
# Decompresses all gzip data in the `io`, handling multiple gzip streams until
|
141
|
+
# the end of the `io`. There should not be any non-gzip data after the gzip
|
142
|
+
# streams.
|
143
|
+
#
|
144
|
+
# If a block is given, it is yielded strings of uncompressed data, and the
|
145
|
+
# method returns `nil`. If a block is not given, the method returns the
|
146
|
+
# concatenation of all uncompressed data in all gzip streams.
|
147
|
+
#
|
148
|
+
def self.zcat: (IO io, **untyped) -> String
|
149
|
+
| (IO io, **untyped) { (String chunk) -> void } -> nil
|
150
|
+
|
151
|
+
public
|
152
|
+
|
153
|
+
# <!--
|
154
|
+
# rdoc-file=ext/zlib/zlib.c
|
155
|
+
# - each(*args)
|
156
|
+
# -->
|
157
|
+
# See Zlib::GzipReader documentation for a description.
|
158
|
+
#
|
159
|
+
def each: (*untyped) { (String) -> void } -> void
|
160
|
+
|
161
|
+
# <!--
|
162
|
+
# rdoc-file=ext/zlib/zlib.c
|
163
|
+
# - each_byte()
|
164
|
+
# -->
|
165
|
+
# See Zlib::GzipReader documentation for a description.
|
166
|
+
#
|
167
|
+
def each_byte: () { (String) -> void } -> void
|
168
|
+
|
169
|
+
# <!--
|
170
|
+
# rdoc-file=ext/zlib/zlib.c
|
171
|
+
# - each_char()
|
172
|
+
# -->
|
173
|
+
# See Zlib::GzipReader documentation for a description.
|
174
|
+
#
|
175
|
+
def each_char: () { (String) -> void } -> void
|
176
|
+
|
177
|
+
# <!-- rdoc-file=ext/zlib/zlib.c -->
|
178
|
+
# See Zlib::GzipReader documentation for a description.
|
179
|
+
#
|
180
|
+
def each_line: (*untyped) { (String) -> void } -> void
|
181
|
+
|
182
|
+
# <!--
|
183
|
+
# rdoc-file=ext/zlib/zlib.c
|
184
|
+
# - eof()
|
185
|
+
# -->
|
186
|
+
# Returns `true` or `false` whether the stream has reached the end.
|
187
|
+
#
|
188
|
+
def eof: () -> bool
|
189
|
+
|
190
|
+
# <!-- rdoc-file=ext/zlib/zlib.c -->
|
191
|
+
# Returns `true` or `false` whether the stream has reached the end.
|
192
|
+
#
|
193
|
+
def eof?: () -> bool
|
194
|
+
|
195
|
+
# <!--
|
196
|
+
# rdoc-file=ext/zlib/zlib.c
|
197
|
+
# - external_encoding()
|
198
|
+
# -->
|
199
|
+
# See Zlib::GzipReader documentation for a description.
|
200
|
+
#
|
201
|
+
def external_encoding: () -> Encoding
|
202
|
+
|
203
|
+
# <!--
|
204
|
+
# rdoc-file=ext/zlib/zlib.c
|
205
|
+
# - getbyte()
|
206
|
+
# -->
|
207
|
+
# See Zlib::GzipReader documentation for a description.
|
208
|
+
#
|
209
|
+
def getbyte: () -> Integer?
|
210
|
+
|
211
|
+
# <!--
|
212
|
+
# rdoc-file=ext/zlib/zlib.c
|
213
|
+
# - getc()
|
214
|
+
# -->
|
215
|
+
# See Zlib::GzipReader documentation for a description.
|
216
|
+
#
|
217
|
+
def getc: () -> String?
|
218
|
+
|
219
|
+
# <!--
|
220
|
+
# rdoc-file=ext/zlib/zlib.c
|
221
|
+
# - gets(*args)
|
222
|
+
# -->
|
223
|
+
# See Zlib::GzipReader documentation for a description. However, note that this
|
224
|
+
# method can return `nil` even if #eof? returns false, unlike the behavior of
|
225
|
+
# File#gets.
|
226
|
+
#
|
227
|
+
def gets: (?String sep, ?Integer limit) -> String?
|
228
|
+
|
229
|
+
# <!--
|
230
|
+
# rdoc-file=ext/zlib/zlib.c
|
231
|
+
# - lineno()
|
232
|
+
# -->
|
233
|
+
# The line number of the last row read from this file.
|
234
|
+
#
|
235
|
+
def lineno: () -> Integer
|
236
|
+
|
237
|
+
# <!--
|
238
|
+
# rdoc-file=ext/zlib/zlib.c
|
239
|
+
# - lineno=(p1)
|
240
|
+
# -->
|
241
|
+
# Specify line number of the last row read from this file.
|
242
|
+
#
|
243
|
+
def lineno=: (Integer arg0) -> Integer
|
244
|
+
|
245
|
+
# <!--
|
246
|
+
# rdoc-file=ext/zlib/zlib.c
|
247
|
+
# - pos()
|
248
|
+
# -->
|
249
|
+
# Total number of output bytes output so far.
|
250
|
+
#
|
251
|
+
def pos: () -> Integer
|
252
|
+
|
253
|
+
# <!--
|
254
|
+
# rdoc-file=ext/zlib/zlib.c
|
255
|
+
# - read(p1 = v1)
|
256
|
+
# -->
|
257
|
+
# See Zlib::GzipReader documentation for a description.
|
258
|
+
#
|
259
|
+
def read: (?int? length, ?string outbuf) -> String?
|
260
|
+
|
261
|
+
# <!--
|
262
|
+
# rdoc-file=ext/zlib/zlib.c
|
263
|
+
# - readbyte()
|
264
|
+
# -->
|
265
|
+
# See Zlib::GzipReader documentation for a description.
|
266
|
+
#
|
267
|
+
def readbyte: () -> Integer
|
268
|
+
|
269
|
+
# <!--
|
270
|
+
# rdoc-file=ext/zlib/zlib.c
|
271
|
+
# - readchar()
|
272
|
+
# -->
|
273
|
+
# See Zlib::GzipReader documentation for a description.
|
274
|
+
#
|
275
|
+
def readchar: () -> String
|
276
|
+
|
277
|
+
# <!--
|
278
|
+
# rdoc-file=ext/zlib/zlib.c
|
279
|
+
# - readline(*args)
|
280
|
+
# -->
|
281
|
+
# See Zlib::GzipReader documentation for a description.
|
282
|
+
#
|
283
|
+
def readline: (?String sep, ?Integer limit) -> String
|
284
|
+
|
285
|
+
# <!--
|
286
|
+
# rdoc-file=ext/zlib/zlib.c
|
287
|
+
# - readlines(*args)
|
288
|
+
# -->
|
289
|
+
# See Zlib::GzipReader documentation for a description.
|
290
|
+
#
|
291
|
+
def readlines: (?String sep, ?Integer limit) -> ::Array[String]
|
292
|
+
|
293
|
+
# <!--
|
294
|
+
# rdoc-file=ext/zlib/zlib.c
|
295
|
+
# - gzipreader.readpartial(maxlen [, outbuf]) => string, outbuf
|
296
|
+
# -->
|
297
|
+
# Reads at most *maxlen* bytes from the gziped stream but it blocks only if
|
298
|
+
# *gzipreader* has no data immediately available. If the optional *outbuf*
|
299
|
+
# argument is present, it must reference a String, which will receive the data.
|
300
|
+
# It raises `EOFError` on end of file.
|
301
|
+
#
|
302
|
+
def readpartial: (int maxlen, ?string outbuf) -> String
|
303
|
+
|
304
|
+
# <!--
|
305
|
+
# rdoc-file=ext/zlib/zlib.c
|
306
|
+
# - rewind()
|
307
|
+
# -->
|
308
|
+
# Resets the position of the file pointer to the point created the GzipReader
|
309
|
+
# object. The associated IO object needs to respond to the `seek` method.
|
310
|
+
#
|
311
|
+
def rewind: () -> Integer
|
312
|
+
|
313
|
+
# <!-- rdoc-file=ext/zlib/zlib.c -->
|
314
|
+
# Total number of output bytes output so far.
|
315
|
+
#
|
316
|
+
def tell: () -> Integer
|
317
|
+
|
318
|
+
# <!--
|
319
|
+
# rdoc-file=ext/zlib/zlib.c
|
320
|
+
# - ungetbyte(p1)
|
321
|
+
# -->
|
322
|
+
# See Zlib::GzipReader documentation for a description.
|
323
|
+
#
|
324
|
+
def ungetbyte: (String | Integer arg0) -> NilClass
|
325
|
+
|
326
|
+
# <!--
|
327
|
+
# rdoc-file=ext/zlib/zlib.c
|
328
|
+
# - ungetc(p1)
|
329
|
+
# -->
|
330
|
+
# See Zlib::GzipReader documentation for a description.
|
331
|
+
#
|
332
|
+
def ungetc: (String arg0) -> NilClass
|
333
|
+
|
334
|
+
# <!--
|
335
|
+
# rdoc-file=ext/zlib/zlib.c
|
336
|
+
# - unused()
|
337
|
+
# -->
|
338
|
+
# Returns the rest of the data which had read for parsing gzip format, or `nil`
|
339
|
+
# if the whole gzip file is not parsed yet.
|
340
|
+
#
|
341
|
+
def unused: () -> String?
|
342
|
+
|
343
|
+
private
|
344
|
+
|
345
|
+
# <!--
|
346
|
+
# rdoc-file=ext/zlib/zlib.c
|
347
|
+
# - Zlib::GzipReader.new(io, options = {})
|
348
|
+
# -->
|
349
|
+
# Creates a GzipReader object associated with `io`. The GzipReader object reads
|
350
|
+
# gzipped data from `io`, and parses/decompresses it. The `io` must have a
|
351
|
+
# `read` method that behaves same as the IO#read.
|
352
|
+
#
|
353
|
+
# The `options` hash may be used to set the encoding of the data.
|
354
|
+
# `:external_encoding`, `:internal_encoding` and `:encoding` may be set as in
|
355
|
+
# IO::new.
|
356
|
+
#
|
357
|
+
# If the gzip file header is incorrect, raises an Zlib::GzipFile::Error
|
358
|
+
# exception.
|
359
|
+
#
|
360
|
+
def initialize: (_Reader io, **untyped opts) -> void
|
361
|
+
end
|
362
|
+
end
|
@@ -0,0 +1,237 @@
|
|
1
|
+
# <!-- rdoc-file=ext/zlib/zlib.c -->
|
2
|
+
# This module provides access to the [zlib library](http://zlib.net). Zlib is
|
3
|
+
# designed to be a portable, free, general-purpose, legally unencumbered -- that
|
4
|
+
# is, not covered by any patents -- lossless data-compression library for use on
|
5
|
+
# virtually any computer hardware and operating system.
|
6
|
+
#
|
7
|
+
# The zlib compression library provides in-memory compression and decompression
|
8
|
+
# functions, including integrity checks of the uncompressed data.
|
9
|
+
#
|
10
|
+
# The zlib compressed data format is described in RFC 1950, which is a wrapper
|
11
|
+
# around a deflate stream which is described in RFC 1951.
|
12
|
+
#
|
13
|
+
# The library also supports reading and writing files in gzip (.gz) format with
|
14
|
+
# an interface similar to that of IO. The gzip format is described in RFC 1952
|
15
|
+
# which is also a wrapper around a deflate stream.
|
16
|
+
#
|
17
|
+
# The zlib format was designed to be compact and fast for use in memory and on
|
18
|
+
# communications channels. The gzip format was designed for single-file
|
19
|
+
# compression on file systems, has a larger header than zlib to maintain
|
20
|
+
# directory information, and uses a different, slower check method than zlib.
|
21
|
+
#
|
22
|
+
# See your system's zlib.h for further information about zlib
|
23
|
+
#
|
24
|
+
# ## Sample usage
|
25
|
+
#
|
26
|
+
# Using the wrapper to compress strings with default parameters is quite simple:
|
27
|
+
#
|
28
|
+
# require "zlib"
|
29
|
+
#
|
30
|
+
# data_to_compress = File.read("don_quixote.txt")
|
31
|
+
#
|
32
|
+
# puts "Input size: #{data_to_compress.size}"
|
33
|
+
# #=> Input size: 2347740
|
34
|
+
#
|
35
|
+
# data_compressed = Zlib::Deflate.deflate(data_to_compress)
|
36
|
+
#
|
37
|
+
# puts "Compressed size: #{data_compressed.size}"
|
38
|
+
# #=> Compressed size: 887238
|
39
|
+
#
|
40
|
+
# uncompressed_data = Zlib::Inflate.inflate(data_compressed)
|
41
|
+
#
|
42
|
+
# puts "Uncompressed data is: #{uncompressed_data}"
|
43
|
+
# #=> Uncompressed data is: The Project Gutenberg EBook of Don Quixote...
|
44
|
+
#
|
45
|
+
# ## Class tree
|
46
|
+
#
|
47
|
+
# * Zlib::Deflate
|
48
|
+
# * Zlib::Inflate
|
49
|
+
# * Zlib::ZStream
|
50
|
+
# * Zlib::Error
|
51
|
+
# * Zlib::StreamEnd
|
52
|
+
# * Zlib::NeedDict
|
53
|
+
# * Zlib::DataError
|
54
|
+
# * Zlib::StreamError
|
55
|
+
# * Zlib::MemError
|
56
|
+
# * Zlib::BufError
|
57
|
+
# * Zlib::VersionError
|
58
|
+
# * Zlib::InProgressError
|
59
|
+
#
|
60
|
+
#
|
61
|
+
#
|
62
|
+
# (if you have GZIP_SUPPORT)
|
63
|
+
# * Zlib::GzipReader
|
64
|
+
# * Zlib::GzipWriter
|
65
|
+
# * Zlib::GzipFile
|
66
|
+
# * Zlib::GzipFile::Error
|
67
|
+
# * Zlib::GzipFile::LengthError
|
68
|
+
# * Zlib::GzipFile::CRCError
|
69
|
+
# * Zlib::GzipFile::NoFooter
|
70
|
+
#
|
71
|
+
module Zlib
|
72
|
+
# <!-- rdoc-file=ext/zlib/zlib.c -->
|
73
|
+
# Zlib::GzipWriter is a class for writing gzipped files. GzipWriter should be
|
74
|
+
# used with an instance of IO, or IO-like, object.
|
75
|
+
#
|
76
|
+
# Following two example generate the same result.
|
77
|
+
#
|
78
|
+
# Zlib::GzipWriter.open('hoge.gz') do |gz|
|
79
|
+
# gz.write 'jugemu jugemu gokou no surikire...'
|
80
|
+
# end
|
81
|
+
#
|
82
|
+
# File.open('hoge.gz', 'w') do |f|
|
83
|
+
# gz = Zlib::GzipWriter.new(f)
|
84
|
+
# gz.write 'jugemu jugemu gokou no surikire...'
|
85
|
+
# gz.close
|
86
|
+
# end
|
87
|
+
#
|
88
|
+
# To make like gzip(1) does, run following:
|
89
|
+
#
|
90
|
+
# orig = 'hoge.txt'
|
91
|
+
# Zlib::GzipWriter.open('hoge.gz') do |gz|
|
92
|
+
# gz.mtime = File.mtime(orig)
|
93
|
+
# gz.orig_name = orig
|
94
|
+
# gz.write IO.binread(orig)
|
95
|
+
# end
|
96
|
+
#
|
97
|
+
# NOTE: Due to the limitation of Ruby's finalizer, you must explicitly close
|
98
|
+
# GzipWriter objects by Zlib::GzipWriter#close etc. Otherwise, GzipWriter will
|
99
|
+
# be not able to write the gzip footer and will generate a broken gzip file.
|
100
|
+
#
|
101
|
+
class GzipWriter < Zlib::GzipFile
|
102
|
+
# <!--
|
103
|
+
# rdoc-file=ext/zlib/zlib.c
|
104
|
+
# - Zlib::GzipWriter.open(filename, level=nil, strategy=nil) { |gz| ... }
|
105
|
+
# -->
|
106
|
+
# Opens a file specified by `filename` for writing gzip compressed data, and
|
107
|
+
# returns a GzipWriter object associated with that file. Further details of
|
108
|
+
# this method are found in Zlib::GzipWriter.new and Zlib::GzipFile.wrap.
|
109
|
+
#
|
110
|
+
def self.open: (String filename) { (instance gz) -> void } -> instance
|
111
|
+
|
112
|
+
public
|
113
|
+
|
114
|
+
# <!--
|
115
|
+
# rdoc-file=ext/zlib/zlib.c
|
116
|
+
# - <<(p1)
|
117
|
+
# -->
|
118
|
+
# Same as IO.
|
119
|
+
#
|
120
|
+
def <<: (_ToS obj) -> self
|
121
|
+
|
122
|
+
# <!--
|
123
|
+
# rdoc-file=ext/zlib/zlib.c
|
124
|
+
# - comment=(p1)
|
125
|
+
# -->
|
126
|
+
# Specify the comment (`str`) in the gzip header.
|
127
|
+
#
|
128
|
+
def comment=: (String arg0) -> void
|
129
|
+
|
130
|
+
# <!--
|
131
|
+
# rdoc-file=ext/zlib/zlib.c
|
132
|
+
# - flush(flush=nil)
|
133
|
+
# -->
|
134
|
+
# Flushes all the internal buffers of the GzipWriter object. The meaning of
|
135
|
+
# `flush` is same as in Zlib::Deflate#deflate. `Zlib::SYNC_FLUSH` is used if
|
136
|
+
# `flush` is omitted. It is no use giving flush `Zlib::NO_FLUSH`.
|
137
|
+
#
|
138
|
+
def flush: (?Integer flush) -> String
|
139
|
+
|
140
|
+
# <!--
|
141
|
+
# rdoc-file=ext/zlib/zlib.c
|
142
|
+
# - mtime=(p1)
|
143
|
+
# -->
|
144
|
+
# Specify the modification time (`mtime`) in the gzip header. Using an Integer.
|
145
|
+
#
|
146
|
+
# Setting the mtime in the gzip header does not effect the mtime of the file
|
147
|
+
# generated. Different utilities that expand the gzipped files may use the mtime
|
148
|
+
# header. For example the gunzip utility can use the `-N` flag which will set
|
149
|
+
# the resultant file's mtime to the value in the header. By default many tools
|
150
|
+
# will set the mtime of the expanded file to the mtime of the gzipped file, not
|
151
|
+
# the mtime in the header.
|
152
|
+
#
|
153
|
+
# If you do not set an mtime, the default value will be the time when
|
154
|
+
# compression started. Setting a value of 0 indicates no time stamp is
|
155
|
+
# available.
|
156
|
+
#
|
157
|
+
def mtime=: (string | _ToPath | IO file_name) -> Time
|
158
|
+
|
159
|
+
# <!--
|
160
|
+
# rdoc-file=ext/zlib/zlib.c
|
161
|
+
# - orig_name=(p1)
|
162
|
+
# -->
|
163
|
+
# Specify the original name (`str`) in the gzip header.
|
164
|
+
#
|
165
|
+
def orig_name=: (String arg0) -> void
|
166
|
+
|
167
|
+
# <!--
|
168
|
+
# rdoc-file=ext/zlib/zlib.c
|
169
|
+
# - pos()
|
170
|
+
# -->
|
171
|
+
# Total number of input bytes read so far.
|
172
|
+
#
|
173
|
+
def pos: () -> Integer
|
174
|
+
|
175
|
+
# <!--
|
176
|
+
# rdoc-file=ext/zlib/zlib.c
|
177
|
+
# - print(*args)
|
178
|
+
# -->
|
179
|
+
# Same as IO.
|
180
|
+
#
|
181
|
+
def print: (*untyped arg0) -> NilClass
|
182
|
+
|
183
|
+
# <!--
|
184
|
+
# rdoc-file=ext/zlib/zlib.c
|
185
|
+
# - printf(*args)
|
186
|
+
# -->
|
187
|
+
# Same as IO.
|
188
|
+
#
|
189
|
+
def printf: (String format_string, *untyped arg0) -> NilClass
|
190
|
+
|
191
|
+
# <!--
|
192
|
+
# rdoc-file=ext/zlib/zlib.c
|
193
|
+
# - putc(p1)
|
194
|
+
# -->
|
195
|
+
# Same as IO.
|
196
|
+
#
|
197
|
+
def putc: (Numeric | String arg0) -> untyped
|
198
|
+
|
199
|
+
# <!--
|
200
|
+
# rdoc-file=ext/zlib/zlib.c
|
201
|
+
# - puts(*args)
|
202
|
+
# -->
|
203
|
+
# Same as IO.
|
204
|
+
#
|
205
|
+
def puts: (*untyped arg0) -> NilClass
|
206
|
+
|
207
|
+
# <!-- rdoc-file=ext/zlib/zlib.c -->
|
208
|
+
# Total number of input bytes read so far.
|
209
|
+
#
|
210
|
+
def tell: () -> Integer
|
211
|
+
|
212
|
+
# <!--
|
213
|
+
# rdoc-file=ext/zlib/zlib.c
|
214
|
+
# - write(*args)
|
215
|
+
# -->
|
216
|
+
# Same as IO.
|
217
|
+
#
|
218
|
+
def write: (*_ToS string) -> Integer
|
219
|
+
|
220
|
+
private
|
221
|
+
|
222
|
+
# <!--
|
223
|
+
# rdoc-file=ext/zlib/zlib.c
|
224
|
+
# - Zlib::GzipWriter.new(io, level = nil, strategy = nil, options = {})
|
225
|
+
# -->
|
226
|
+
# Creates a GzipWriter object associated with `io`. `level` and `strategy`
|
227
|
+
# should be the same as the arguments of Zlib::Deflate.new. The GzipWriter
|
228
|
+
# object writes gzipped data to `io`. `io` must respond to the `write` method
|
229
|
+
# that behaves the same as IO#write.
|
230
|
+
#
|
231
|
+
# The `options` hash may be used to set the encoding of the data.
|
232
|
+
# `:external_encoding`, `:internal_encoding` and `:encoding` may be set as in
|
233
|
+
# IO::new.
|
234
|
+
#
|
235
|
+
def initialize: (_Writer io, Integer level, Integer strategy, **untyped opts) -> void
|
236
|
+
end
|
237
|
+
end
|