rbs 0.7.0 → 0.11.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -42,6 +42,9 @@ end
42
42
  class JSON::Ext::Generator::State
43
43
  end
44
44
 
45
+ class JSON::Ext::Parser
46
+ end
47
+
45
48
  module JSON::Pure
46
49
  end
47
50
 
@@ -51,6 +54,9 @@ end
51
54
  class JSON::Pure::Generator::State
52
55
  end
53
56
 
57
+ class JSON::Pure::Parser
58
+ end
59
+
54
60
  type json_generator = singleton(::JSON::Ext::Generator) | singleton(::JSON::Pure::Generator)
55
61
  type json_parser = singleton(::JSON::Ext::Parser) | singleton(::JSON::Pure::Parser)
56
62
  type json_state = singleton(JSON::Ext::Generator::State) | singleton(JSON::Pure::Generator::State)
@@ -0,0 +1,159 @@
1
+ # Creates and manages pseudo terminals (PTYs). See also
2
+ # http://en.wikipedia.org/wiki/Pseudo_terminal
3
+ #
4
+ # PTY allows you to allocate new terminals using ::open or ::spawn a new
5
+ # terminal with a specific command.
6
+ #
7
+ # ## Example
8
+ #
9
+ # In this example we will change the buffering type in the `factor` command,
10
+ # assuming that factor uses stdio for stdout buffering.
11
+ #
12
+ # If IO.pipe is used instead of PTY.open, this code deadlocks because factor's
13
+ # stdout is fully buffered.
14
+ #
15
+ # # start by requiring the standard library PTY
16
+ # require 'pty'
17
+ #
18
+ # master, slave = PTY.open
19
+ # read, write = IO.pipe
20
+ # pid = spawn("factor", :in=>read, :out=>slave)
21
+ # read.close # we dont need the read
22
+ # slave.close # or the slave
23
+ #
24
+ # # pipe "42" to the factor command
25
+ # write.puts "42"
26
+ # # output the response from factor
27
+ # p master.gets #=> "42: 2 3 7\n"
28
+ #
29
+ # # pipe "144" to factor and print out the response
30
+ # write.puts "144"
31
+ # p master.gets #=> "144: 2 2 2 2 3 3\n"
32
+ # write.close # close the pipe
33
+ #
34
+ # # The result of read operation when pty slave is closed is platform
35
+ # # dependent.
36
+ # ret = begin
37
+ # master.gets # FreeBSD returns nil.
38
+ # rescue Errno::EIO # GNU/Linux raises EIO.
39
+ # nil
40
+ # end
41
+ # p ret #=> nil
42
+ #
43
+ # ## License
44
+ #
45
+ # C) Copyright 1998 by Akinori Ito.
46
+ #
47
+ # This software may be redistributed freely for this purpose, in full
48
+ # or in part, provided that this entire copyright notice is included
49
+ # on any copies of this software and applications and derivations thereof.
50
+ #
51
+ # This software is provided on an "as is" basis, without warranty of any
52
+ # kind, either expressed or implied, as to any matter including, but not
53
+ # limited to warranty of fitness of purpose, or merchantability, or
54
+ # results obtained from use of this software.
55
+ #
56
+ module PTY
57
+ # Checks the status of the child process specified by `pid`. Returns `nil` if
58
+ # the process is still alive.
59
+ #
60
+ # If the process is not alive, and `raise` was true, a PTY::ChildExited
61
+ # exception will be raised. Otherwise it will return a Process::Status instance.
62
+ #
63
+ # `pid`
64
+ # : The process id of the process to check
65
+ # `raise`
66
+ # : If `true` and the process identified by `pid` is no longer alive a
67
+ # PTY::ChildExited is raised.
68
+ def self.check: (Integer pid) -> (Process::Status | nil)
69
+ | (Integer pid, FalseClass raise) -> (Process::Status | nil)
70
+ | (Integer pid, TrueClass raise) -> nil
71
+
72
+ # Spawns the specified command on a newly allocated pty. You can also use the
73
+ # alias ::getpty.
74
+ #
75
+ # The command's controlling tty is set to the slave device of the pty and its
76
+ # standard input/output/error is redirected to the slave device.
77
+ #
78
+ # `command` and `command_line` are the full commands to run, given a String. Any
79
+ # additional `arguments` will be passed to the command.
80
+ #
81
+ # ### Return values
82
+ #
83
+ # In the non-block form this returns an array of size three, `[r, w, pid]`.
84
+ #
85
+ # In the block form these same values will be yielded to the block:
86
+ #
87
+ # `r`
88
+ # : A readable IO that contains the command's standard output and standard
89
+ # error
90
+ # `w`
91
+ # : A writable IO that is the command's standard input
92
+ # `pid`
93
+ # : The process identifier for the command.
94
+ def self.getpty: (*String command) -> [ IO, IO, Integer ]
95
+ | (*String command) { ([ IO ,IO , Integer ]) -> untyped } -> untyped
96
+
97
+ # Allocates a pty (pseudo-terminal).
98
+ #
99
+ # In the block form, yields two arguments `master_io, slave_file` and the value
100
+ # of the block is returned from `open`.
101
+ #
102
+ # The IO and File are both closed after the block completes if they haven't been
103
+ # already closed.
104
+ #
105
+ # PTY.open {|master, slave|
106
+ # p master #=> #<IO:masterpty:/dev/pts/1>
107
+ # p slave #=> #<File:/dev/pts/1>
108
+ # p slave.path #=> "/dev/pts/1"
109
+ # }
110
+ #
111
+ # In the non-block form, returns a two element array, `[master_io, slave_file]`.
112
+ #
113
+ # master, slave = PTY.open
114
+ # # do something with master for IO, or the slave file
115
+ #
116
+ # The arguments in both forms are:
117
+ #
118
+ # `master_io`
119
+ # : the master of the pty, as an IO.
120
+ # `slave_file`
121
+ # : the slave of the pty, as a File. The path to the terminal device is
122
+ # available via `slave_file.path`
123
+ #
124
+ #
125
+ # IO#raw! is usable to disable newline conversions:
126
+ #
127
+ # require 'io/console'
128
+ # PTY.open {|m, s|
129
+ # s.raw!
130
+ # ...
131
+ # }
132
+ def self.open: () -> [ IO, File ]
133
+ | () { ([ IO , File ]) -> untyped } -> untyped
134
+
135
+ # Spawns the specified command on a newly allocated pty. You can also use the
136
+ # alias ::getpty.
137
+ #
138
+ # The command's controlling tty is set to the slave device of the pty and its
139
+ # standard input/output/error is redirected to the slave device.
140
+ #
141
+ # `command` and `command_line` are the full commands to run, given a String. Any
142
+ # additional `arguments` will be passed to the command.
143
+ #
144
+ # ### Return values
145
+ #
146
+ # In the non-block form this returns an array of size three, `[r, w, pid]`.
147
+ #
148
+ # In the block form these same values will be yielded to the block:
149
+ #
150
+ # `r`
151
+ # : A readable IO that contains the command's standard output and standard
152
+ # error
153
+ # `w`
154
+ # : A writable IO that is the command's standard input
155
+ # `pid`
156
+ # : The process identifier for the command.
157
+ def self.spawn: (*String command) -> [ IO, IO, Integer ]
158
+ | (*String command) {([ IO , IO , Integer ]) -> untyped } -> untyped
159
+ end
@@ -0,0 +1,392 @@
1
+ # This module provides access to the [zlib library](http://zlib.net). Zlib is
2
+ # designed to be a portable, free, general-purpose, legally unencumbered -- that
3
+ # is, not covered by any patents -- lossless data-compression library for use on
4
+ # virtually any computer hardware and operating system.
5
+ #
6
+ # The zlib compression library provides in-memory compression and decompression
7
+ # functions, including integrity checks of the uncompressed data.
8
+ #
9
+ # The zlib compressed data format is described in RFC 1950, which is a wrapper
10
+ # around a deflate stream which is described in RFC 1951.
11
+ #
12
+ # The library also supports reading and writing files in gzip (.gz) format with
13
+ # an interface similar to that of IO. The gzip format is described in RFC 1952
14
+ # which is also a wrapper around a deflate stream.
15
+ #
16
+ # The zlib format was designed to be compact and fast for use in memory and on
17
+ # communications channels. The gzip format was designed for single-file
18
+ # compression on file systems, has a larger header than zlib to maintain
19
+ # directory information, and uses a different, slower check method than zlib.
20
+ #
21
+ # See your system's zlib.h for further information about zlib
22
+ #
23
+ # ## Sample usage
24
+ #
25
+ # Using the wrapper to compress strings with default parameters is quite simple:
26
+ #
27
+ # require "zlib"
28
+ #
29
+ # data_to_compress = File.read("don_quixote.txt")
30
+ #
31
+ # puts "Input size: #{data_to_compress.size}"
32
+ # #=> Input size: 2347740
33
+ #
34
+ # data_compressed = Zlib::Deflate.deflate(data_to_compress)
35
+ #
36
+ # puts "Compressed size: #{data_compressed.size}"
37
+ # #=> Compressed size: 887238
38
+ #
39
+ # uncompressed_data = Zlib::Inflate.inflate(data_compressed)
40
+ #
41
+ # puts "Uncompressed data is: #{uncompressed_data}"
42
+ # #=> Uncompressed data is: The Project Gutenberg EBook of Don Quixote...
43
+ #
44
+ # ## Class tree
45
+ #
46
+ # * Zlib::Deflate
47
+ # * Zlib::Inflate
48
+ # * Zlib::ZStream
49
+ # * Zlib::Error
50
+ # * Zlib::StreamEnd
51
+ # * Zlib::NeedDict
52
+ # * Zlib::DataError
53
+ # * Zlib::StreamError
54
+ # * Zlib::MemError
55
+ # * Zlib::BufError
56
+ # * Zlib::VersionError
57
+ #
58
+ #
59
+ #
60
+ # (if you have GZIP_SUPPORT)
61
+ # * Zlib::GzipReader
62
+ # * Zlib::GzipWriter
63
+ # * Zlib::GzipFile
64
+ # * Zlib::GzipFile::Error
65
+ # * Zlib::GzipFile::LengthError
66
+ # * Zlib::GzipFile::CRCError
67
+ # * Zlib::GzipFile::NoFooter
68
+ #
69
+ #
70
+ #
71
+ module Zlib
72
+ # Calculates Adler-32 checksum for `string`, and returns updated value of
73
+ # `adler`. If `string` is omitted, it returns the Adler-32 initial value. If
74
+ # `adler` is omitted, it assumes that the initial value is given to `adler`.
75
+ #
76
+ # Example usage:
77
+ #
78
+ # require "zlib"
79
+ #
80
+ # data = "foo"
81
+ # puts "Adler32 checksum: #{Zlib.adler32(data).to_s(16)}"
82
+ # #=> Adler32 checksum: 2820145
83
+ #
84
+ def self.adler32: () -> Integer
85
+ | (String) -> Integer
86
+ | (String, Integer) -> Integer
87
+
88
+ # Combine two Adler-32 check values in to one. `alder1` is the first Adler-32
89
+ # value, `adler2` is the second Adler-32 value. `len2` is the length of the
90
+ # string used to generate `adler2`.
91
+ #
92
+ def self.adler32_combine: (Integer, Integer, Integer) -> Integer
93
+
94
+ # Calculates CRC checksum for `string`, and returns updated value of `crc`. If
95
+ # `string` is omitted, it returns the CRC initial value. If `crc` is omitted, it
96
+ # assumes that the initial value is given to `crc`.
97
+ #
98
+ # FIXME: expression.
99
+ #
100
+ def self.crc32: () -> Integer
101
+ | (String) -> Integer
102
+ | (String, Integer) -> Integer
103
+
104
+ # Combine two CRC-32 check values in to one. `crc1` is the first CRC-32 value,
105
+ # `crc2` is the second CRC-32 value. `len2` is the length of the string used to
106
+ # generate `crc2`.
107
+ #
108
+ def self.crc32_combine: (Integer, Integer, Integer) -> Integer
109
+
110
+ # Returns the table for calculating CRC checksum as an array.
111
+ #
112
+ def self.crc_table: () -> Array[Integer]
113
+
114
+ # Compresses the given `string`. Valid values of level are Zlib::NO_COMPRESSION,
115
+ # Zlib::BEST_SPEED, Zlib::BEST_COMPRESSION, Zlib::DEFAULT_COMPRESSION, or an
116
+ # integer from 0 to 9.
117
+ #
118
+ # This method is almost equivalent to the following code:
119
+ #
120
+ # def deflate(string, level)
121
+ # z = Zlib::Deflate.new(level)
122
+ # dst = z.deflate(string, Zlib::FINISH)
123
+ # z.close
124
+ # dst
125
+ # end
126
+ #
127
+ # See also Zlib.inflate
128
+ #
129
+ def self.deflate: (String) -> String
130
+ | (String, Integer) -> String
131
+ # Decode the given gzipped `string`.
132
+ #
133
+ # This method is almost equivalent to the following code:
134
+ #
135
+ # def gunzip(string)
136
+ # sio = StringIO.new(string)
137
+ # gz = Zlib::GzipReader.new(sio, encoding: Encoding::ASCII_8BIT)
138
+ # gz.read
139
+ # ensure
140
+ # gz&.close
141
+ # end
142
+ #
143
+ # See also Zlib.gzip
144
+ #
145
+ def self.gunzip: (String) -> String
146
+
147
+ # Gzip the given `string`. Valid values of level are Zlib::NO_COMPRESSION,
148
+ # Zlib::BEST_SPEED, Zlib::BEST_COMPRESSION, Zlib::DEFAULT_COMPRESSION (default),
149
+ # or an integer from 0 to 9.
150
+ #
151
+ # This method is almost equivalent to the following code:
152
+ #
153
+ # def gzip(string, level: nil, strategy: nil)
154
+ # sio = StringIO.new
155
+ # sio.binmode
156
+ # gz = Zlib::GzipWriter.new(sio, level, strategy)
157
+ # gz.write(string)
158
+ # gz.close
159
+ # sio.string
160
+ # end
161
+ #
162
+ # See also Zlib.gunzip
163
+ #
164
+ def self.gzip: (String) -> String
165
+ | (String, level: Integer) -> String
166
+ | (String, strategy: Integer) -> String
167
+ | (String, level: Integer, strategy: Integer) -> String
168
+ # Decompresses `string`. Raises a Zlib::NeedDict exception if a preset
169
+ # dictionary is needed for decompression.
170
+ #
171
+ # This method is almost equivalent to the following code:
172
+ #
173
+ # def inflate(string)
174
+ # zstream = Zlib::Inflate.new
175
+ # buf = zstream.inflate(string)
176
+ # zstream.finish
177
+ # zstream.close
178
+ # buf
179
+ # end
180
+ #
181
+ # See also Zlib.deflate
182
+ #
183
+ def self.inflate: (String) -> String
184
+
185
+ # Returns the string which represents the version of zlib library.
186
+ #
187
+ def self.zlib_version: () -> String
188
+ end
189
+
190
+ # Represents text data as guessed by deflate.
191
+ #
192
+ # NOTE: The underlying constant Z_ASCII was deprecated in favor of Z_TEXT in
193
+ # zlib 1.2.2. New applications should not use this constant.
194
+ #
195
+ # See Zlib::Deflate#data_type.
196
+ #
197
+ #
198
+ Zlib::ASCII: Integer
199
+
200
+ # Slowest compression level, but with the best space savings.
201
+ #
202
+ #
203
+ Zlib::BEST_COMPRESSION: Integer
204
+
205
+ # Fastest compression level, but with the lowest space savings.
206
+ #
207
+ #
208
+ Zlib::BEST_SPEED: Integer
209
+
210
+ # Represents binary data as guessed by deflate.
211
+ #
212
+ # See Zlib::Deflate#data_type.
213
+ #
214
+ #
215
+ Zlib::BINARY: Integer
216
+
217
+ # Default compression level which is a good trade-off between space and time
218
+ #
219
+ Zlib::DEFAULT_COMPRESSION: Integer
220
+
221
+ # Default deflate strategy which is used for normal data.
222
+ #
223
+ #
224
+ Zlib::DEFAULT_STRATEGY: Integer
225
+
226
+ # The default memory level for allocating zlib deflate compression state.
227
+ #
228
+ Zlib::DEF_MEM_LEVEL: Integer
229
+
230
+ # Deflate strategy for data produced by a filter (or predictor). The effect of
231
+ # FILTERED is to force more Huffman codes and less string matching; it is
232
+ # somewhat intermediate between DEFAULT_STRATEGY and HUFFMAN_ONLY. Filtered data
233
+ # consists mostly of small values with a somewhat random distribution.
234
+ #
235
+ Zlib::FILTERED: Integer
236
+
237
+ # Processes all pending input and flushes pending output.
238
+ #
239
+ #
240
+ Zlib::FINISH: Integer
241
+
242
+ # Deflate strategy which prevents the use of dynamic Huffman codes, allowing for
243
+ # a simpler decoder for specialized applications.
244
+ #
245
+ Zlib::FIXED: Integer
246
+
247
+ # Flushes all output as with SYNC_FLUSH, and the compression state is reset so
248
+ # that decompression can restart from this point if previous compressed data has
249
+ # been damaged or if random access is desired. Like SYNC_FLUSH, using FULL_FLUSH
250
+ # too often can seriously degrade compression.
251
+ #
252
+ Zlib::FULL_FLUSH: Integer
253
+
254
+ # Deflate strategy which uses Huffman codes only (no string matching).
255
+ #
256
+ #
257
+ Zlib::HUFFMAN_ONLY: Integer
258
+
259
+ # The maximum memory level for allocating zlib deflate compression state.
260
+ #
261
+ Zlib::MAX_MEM_LEVEL: Integer
262
+
263
+ # The maximum size of the zlib history buffer. Note that zlib allows larger
264
+ # values to enable different inflate modes. See Zlib::Inflate.new for details.
265
+ #
266
+ Zlib::MAX_WBITS: Integer
267
+
268
+ # No compression, passes through data untouched. Use this for appending
269
+ # pre-compressed data to a deflate stream.
270
+ #
271
+ Zlib::NO_COMPRESSION: Integer
272
+
273
+ # NO_FLUSH is the default flush method and allows deflate to decide how much
274
+ # data to accumulate before producing output in order to maximize compression.
275
+ #
276
+ Zlib::NO_FLUSH: Integer
277
+
278
+ # OS code for Amiga hosts
279
+ #
280
+ #
281
+ Zlib::OS_AMIGA: Integer
282
+
283
+ # OS code for Atari hosts
284
+ #
285
+ #
286
+ Zlib::OS_ATARI: Integer
287
+
288
+ # The OS code of current host
289
+ #
290
+ #
291
+ Zlib::OS_CODE: Integer
292
+
293
+ # OS code for CP/M hosts
294
+ #
295
+ #
296
+ Zlib::OS_CPM: Integer
297
+
298
+ # OS code for Mac OS hosts
299
+ #
300
+ #
301
+ Zlib::OS_MACOS: Integer
302
+
303
+ # OS code for MSDOS hosts
304
+ #
305
+ #
306
+ Zlib::OS_MSDOS: Integer
307
+
308
+ # OS code for OS2 hosts
309
+ #
310
+ #
311
+ Zlib::OS_OS2: Integer
312
+
313
+ # OS code for QDOS hosts
314
+ #
315
+ #
316
+ Zlib::OS_QDOS: Integer
317
+
318
+ # OS code for RISC OS hosts
319
+ #
320
+ #
321
+ Zlib::OS_RISCOS: Integer
322
+
323
+ # OS code for TOPS-20 hosts
324
+ #
325
+ #
326
+ Zlib::OS_TOPS20: Integer
327
+
328
+ # OS code for UNIX hosts
329
+ #
330
+ #
331
+ Zlib::OS_UNIX: Integer
332
+
333
+ # OS code for unknown hosts
334
+ #
335
+ #
336
+ Zlib::OS_UNKNOWN: Integer
337
+
338
+ # OS code for VM OS hosts
339
+ #
340
+ #
341
+ Zlib::OS_VMCMS: Integer
342
+
343
+ # OS code for VMS hosts
344
+ #
345
+ #
346
+ Zlib::OS_VMS: Integer
347
+
348
+ # OS code for Win32 hosts
349
+ #
350
+ #
351
+ Zlib::OS_WIN32: Integer
352
+
353
+ # OS code for Z-System hosts
354
+ #
355
+ #
356
+ Zlib::OS_ZSYSTEM: Integer
357
+
358
+ # Deflate compression strategy designed to be almost as fast as HUFFMAN_ONLY,
359
+ # but give better compression for PNG image data.
360
+ #
361
+ Zlib::RLE: Integer
362
+
363
+ # The SYNC_FLUSH method flushes all pending output to the output buffer and the
364
+ # output is aligned on a byte boundary. Flushing may degrade compression so it
365
+ # should be used only when necessary, such as at a request or response boundary
366
+ # for a network stream.
367
+ #
368
+ Zlib::SYNC_FLUSH: Integer
369
+
370
+ # Represents text data as guessed by deflate.
371
+ #
372
+ # See Zlib::Deflate#data_type.
373
+ #
374
+ #
375
+ Zlib::TEXT: Integer
376
+
377
+ # Represents an unknown data type as guessed by deflate.
378
+ #
379
+ # See Zlib::Deflate#data_type.
380
+ #
381
+ #
382
+ Zlib::UNKNOWN: Integer
383
+
384
+ # The Ruby/zlib version string.
385
+ #
386
+ #
387
+ Zlib::VERSION: String
388
+
389
+ # The string which represents the version of zlib.h
390
+ #
391
+ #
392
+ Zlib::ZLIB_VERSION: String