rbs 3.7.0 → 3.8.0.pre.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/comments.yml +3 -3
- data/.github/workflows/ruby.yml +7 -7
- data/CHANGELOG.md +52 -0
- data/core/array.rbs +1743 -1580
- data/core/basic_object.rbs +38 -35
- data/core/comparable.rbs +1 -1
- data/core/complex.rbs +165 -93
- data/core/data.rbs +1 -1
- data/core/dir.rbs +1 -17
- data/core/encoding.rbs +12 -6
- data/core/enumerable.rbs +270 -266
- data/core/enumerator.rbs +0 -2
- data/core/env.rbs +1 -1
- data/core/errno.rbs +33 -16
- data/core/errors.rbs +2 -2
- data/core/exception.rbs +236 -170
- data/core/fiber.rbs +3 -2
- data/core/file.rbs +32 -74
- data/core/float.rbs +125 -72
- data/core/gc.rbs +138 -40
- data/core/hash.rbs +120 -141
- data/core/integer.rbs +79 -50
- data/core/io/buffer.rbs +49 -43
- data/core/io.rbs +97 -144
- data/core/kernel.rbs +290 -200
- data/core/match_data.rbs +76 -2
- data/core/math.rbs +0 -36
- data/core/module.rbs +28 -23
- data/core/nil_class.rbs +0 -3
- data/core/numeric.rbs +100 -103
- data/core/object.rbs +0 -4
- data/core/object_space/weak_key_map.rbs +3 -4
- data/core/object_space.rbs +3 -3
- data/core/proc.rbs +0 -2
- data/core/process.rbs +109 -57
- data/core/ractor.rbs +37 -4
- data/core/range.rbs +114 -87
- data/core/rational.rbs +0 -2
- data/core/rbs/unnamed/argf.rbs +234 -33
- data/core/rbs/unnamed/env_class.rbs +35 -53
- data/core/rbs/unnamed/random.rbs +1 -2
- data/core/regexp.rbs +4 -52
- data/core/ruby_vm.rbs +88 -9
- data/core/rubygems/config_file.rbs +3 -0
- data/core/rubygems/errors.rbs +0 -5
- data/core/rubygems/platform.rbs +0 -9
- data/core/rubygems/rubygems.rbs +0 -5
- data/core/rubygems/version.rbs +6 -6
- data/core/set.rbs +3 -15
- data/core/string.rbs +130 -136
- data/core/struct.rbs +6 -18
- data/core/symbol.rbs +14 -21
- data/core/thread.rbs +32 -35
- data/core/time.rbs +127 -50
- data/core/trace_point.rbs +16 -0
- data/core/true_class.rbs +0 -1
- data/core/warning.rbs +9 -2
- data/docs/architecture.md +1 -1
- data/docs/syntax.md +1 -1
- data/ext/rbs_extension/location.c +29 -19
- data/ext/rbs_extension/parser.c +267 -292
- data/ext/rbs_extension/parserstate.c +56 -22
- data/lib/rbs/annotate/annotations.rb +3 -3
- data/lib/rbs/annotate/rdoc_source.rb +2 -2
- data/lib/rbs/cli/diff.rb +3 -3
- data/lib/rbs/cli/validate.rb +1 -1
- data/lib/rbs/cli.rb +13 -13
- data/lib/rbs/collection/config.rb +3 -1
- data/lib/rbs/definition_builder/ancestor_builder.rb +3 -3
- data/lib/rbs/environment_loader.rb +1 -1
- data/lib/rbs/namespace.rb +1 -0
- data/lib/rbs/parser_aux.rb +2 -2
- data/lib/rbs/prototype/rb.rb +11 -8
- data/lib/rbs/prototype/rbi.rb +9 -5
- data/lib/rbs/prototype/runtime/value_object_generator.rb +7 -5
- data/lib/rbs/prototype/runtime.rb +4 -5
- data/lib/rbs/type_name.rb +14 -9
- data/lib/rbs/unit_test/type_assertions.rb +2 -2
- data/lib/rbs/validator.rb +3 -1
- data/lib/rbs/version.rb +1 -1
- data/lib/rdoc_plugin/parser.rb +2 -2
- data/rbs.gemspec +4 -0
- data/sig/ancestor_graph.rbs +4 -4
- data/sig/namespace.rbs +2 -3
- data/sig/resolver/constant_resolver.rbs +2 -2
- data/sig/resolver/context.rbs +1 -1
- data/sig/type_alias_regularity.rbs +5 -5
- data/sig/typename.rbs +8 -5
- data/sig/use_map.rbs +1 -1
- data/sig/validator.rbs +2 -2
- data/stdlib/base64/0/base64.rbs +0 -9
- data/stdlib/benchmark/0/benchmark.rbs +11 -2
- data/stdlib/bigdecimal/0/big_decimal.rbs +26 -182
- data/stdlib/cgi/0/core.rbs +47 -0
- data/stdlib/coverage/0/coverage.rbs +0 -3
- data/stdlib/csv/0/csv.rbs +18 -58
- data/stdlib/date/0/date.rbs +4 -19
- data/stdlib/did_you_mean/0/did_you_mean.rbs +0 -5
- data/stdlib/digest/0/digest.rbs +25 -2
- data/stdlib/erb/0/erb.rbs +0 -1
- data/stdlib/etc/0/etc.rbs +51 -34
- data/stdlib/fileutils/0/fileutils.rbs +3 -44
- data/stdlib/io-console/0/io-console.rbs +69 -15
- data/stdlib/ipaddr/0/ipaddr.rbs +8 -4
- data/stdlib/json/0/json.rbs +56 -71
- data/stdlib/logger/0/log_device.rbs +1 -1
- data/stdlib/logger/0/logger.rbs +3 -18
- data/stdlib/net-http/0/net-http.rbs +19 -77
- data/stdlib/nkf/0/nkf.rbs +30 -0
- data/stdlib/objspace/0/objspace.rbs +1 -2
- data/stdlib/observable/0/observable.rbs +1 -1
- data/stdlib/open-uri/0/open-uri.rbs +52 -0
- data/stdlib/open3/0/open3.rbs +0 -8
- data/stdlib/openssl/0/openssl.rbs +136 -69
- data/stdlib/optparse/0/optparse.rbs +58 -18
- data/stdlib/pathname/0/pathname.rbs +2 -8
- data/stdlib/pp/0/pp.rbs +3 -1
- data/stdlib/prettyprint/0/prettyprint.rbs +0 -4
- data/stdlib/pstore/0/pstore.rbs +0 -6
- data/stdlib/psych/0/psych.rbs +15 -4
- data/stdlib/pty/0/pty.rbs +46 -4
- data/stdlib/rdoc/0/code_object.rbs +0 -4
- data/stdlib/rdoc/0/markup.rbs +10 -12
- data/stdlib/rdoc/0/rdoc.rbs +1 -2
- data/stdlib/resolv/0/resolv.rbs +8 -3
- data/stdlib/ripper/0/ripper.rbs +0 -2
- data/stdlib/securerandom/0/securerandom.rbs +0 -2
- data/stdlib/shellwords/0/shellwords.rbs +11 -12
- data/stdlib/singleton/0/singleton.rbs +0 -1
- data/stdlib/socket/0/addrinfo.rbs +0 -1
- data/stdlib/socket/0/basic_socket.rbs +0 -5
- data/stdlib/socket/0/socket.rbs +49 -25
- data/stdlib/socket/0/tcp_server.rbs +0 -3
- data/stdlib/socket/0/tcp_socket.rbs +58 -3
- data/stdlib/socket/0/udp_socket.rbs +0 -1
- data/stdlib/socket/0/unix_server.rbs +0 -3
- data/stdlib/strscan/0/string_scanner.rbs +1265 -422
- data/stdlib/tempfile/0/tempfile.rbs +135 -28
- data/stdlib/time/0/time.rbs +48 -35
- data/stdlib/timeout/0/timeout.rbs +11 -8
- data/stdlib/tmpdir/0/tmpdir.rbs +8 -1
- data/stdlib/tsort/0/tsort.rbs +0 -4
- data/stdlib/uri/0/common.rbs +11 -30
- data/stdlib/uri/0/ftp.rbs +1 -1
- data/stdlib/uri/0/generic.rbs +22 -18
- data/stdlib/uri/0/http.rbs +2 -2
- data/stdlib/uri/0/rfc2396_parser.rbs +3 -0
- data/stdlib/zlib/0/buf_error.rbs +1 -70
- data/stdlib/zlib/0/data_error.rbs +1 -70
- data/stdlib/zlib/0/deflate.rbs +8 -72
- data/stdlib/zlib/0/error.rbs +1 -70
- data/stdlib/zlib/0/gzip_file/crc_error.rbs +2 -105
- data/stdlib/zlib/0/gzip_file/error.rbs +2 -105
- data/stdlib/zlib/0/gzip_file/length_error.rbs +2 -105
- data/stdlib/zlib/0/gzip_file/no_footer.rbs +2 -105
- data/stdlib/zlib/0/gzip_file.rbs +1 -71
- data/stdlib/zlib/0/gzip_reader.rbs +3 -74
- data/stdlib/zlib/0/gzip_writer.rbs +1 -70
- data/stdlib/zlib/0/inflate.rbs +4 -71
- data/stdlib/zlib/0/mem_error.rbs +1 -70
- data/stdlib/zlib/0/need_dict.rbs +1 -70
- data/stdlib/zlib/0/stream_end.rbs +1 -70
- data/stdlib/zlib/0/stream_error.rbs +1 -70
- data/stdlib/zlib/0/version_error.rbs +1 -70
- data/stdlib/zlib/0/zlib.rbs +0 -2
- data/stdlib/zlib/0/zstream.rbs +4 -72
- metadata +4 -6
data/stdlib/cgi/0/core.rbs
CHANGED
@@ -91,8 +91,10 @@
|
|
91
91
|
#
|
92
92
|
# #local_path()
|
93
93
|
# : the path of the uploaded file on the local filesystem
|
94
|
+
#
|
94
95
|
# #original_filename()
|
95
96
|
# : the name of the file on the client computer
|
97
|
+
#
|
96
98
|
# #content_type()
|
97
99
|
# : the content type of the file
|
98
100
|
#
|
@@ -285,6 +287,7 @@ class CGI
|
|
285
287
|
# :tag_maker => tag_maker }` Note that it is recommended to use the
|
286
288
|
# `options_hash` form, since it also allows you specify the charset you will
|
287
289
|
# accept.
|
290
|
+
#
|
288
291
|
# `options_hash`
|
289
292
|
# : A Hash that recognizes three options:
|
290
293
|
#
|
@@ -303,6 +306,7 @@ class CGI
|
|
303
306
|
#
|
304
307
|
# cgi=CGI.new(:accept_charset => "EUC-JP") # => "EUC-JP"
|
305
308
|
#
|
309
|
+
#
|
306
310
|
# `:tag_maker`
|
307
311
|
# : String that specifies which version of the HTML generation methods to
|
308
312
|
# use. If not specified, no HTML generation methods will be loaded.
|
@@ -311,16 +315,21 @@ class CGI
|
|
311
315
|
#
|
312
316
|
# "html3"
|
313
317
|
# : HTML 3.x
|
318
|
+
#
|
314
319
|
# "html4"
|
315
320
|
# : HTML 4.0
|
321
|
+
#
|
316
322
|
# "html4Tr"
|
317
323
|
# : HTML 4.0 Transitional
|
324
|
+
#
|
318
325
|
# "html4Fr"
|
319
326
|
# : HTML 4.0 with Framesets
|
327
|
+
#
|
320
328
|
# "html5"
|
321
329
|
# : HTML 5
|
322
330
|
#
|
323
331
|
#
|
332
|
+
#
|
324
333
|
# `:max_multipart_length`
|
325
334
|
# : Specifies maximum length of multipart data. Can be an Integer scalar
|
326
335
|
# or a lambda, that will be evaluated when the request is parsed. This
|
@@ -334,6 +343,7 @@ class CGI
|
|
334
343
|
# cgi=CGI.new(:max_multipart_length => -> {check_filesystem}) # lambda
|
335
344
|
#
|
336
345
|
#
|
346
|
+
#
|
337
347
|
# `block`
|
338
348
|
# : If provided, the block is called when an invalid encoding is encountered.
|
339
349
|
# For example:
|
@@ -408,72 +418,99 @@ class CGI
|
|
408
418
|
#
|
409
419
|
# `content_type_string`
|
410
420
|
# : If this form is used, this string is the `Content-Type`
|
421
|
+
#
|
411
422
|
# `headers_hash`
|
412
423
|
# : A Hash of header values. The following header keys are recognized:
|
413
424
|
#
|
414
425
|
# type
|
415
426
|
# : The Content-Type header. Defaults to "text/html"
|
427
|
+
#
|
416
428
|
# charset
|
417
429
|
# : The charset of the body, appended to the Content-Type header.
|
430
|
+
#
|
418
431
|
# nph
|
419
432
|
# : A boolean value. If true, prepend protocol string and status code,
|
420
433
|
# and date; and sets default values for "server" and "connection" if not
|
421
434
|
# explicitly set.
|
435
|
+
#
|
422
436
|
# status
|
423
437
|
# : The HTTP status code as a String, returned as the Status header. The
|
424
438
|
# values are:
|
425
439
|
#
|
426
440
|
# OK
|
427
441
|
# : 200 OK
|
442
|
+
#
|
428
443
|
# PARTIAL_CONTENT
|
429
444
|
# : 206 Partial Content
|
445
|
+
#
|
430
446
|
# MULTIPLE_CHOICES
|
431
447
|
# : 300 Multiple Choices
|
448
|
+
#
|
432
449
|
# MOVED
|
433
450
|
# : 301 Moved Permanently
|
451
|
+
#
|
434
452
|
# REDIRECT
|
435
453
|
# : 302 Found
|
454
|
+
#
|
436
455
|
# NOT_MODIFIED
|
437
456
|
# : 304 Not Modified
|
457
|
+
#
|
438
458
|
# BAD_REQUEST
|
439
459
|
# : 400 Bad Request
|
460
|
+
#
|
440
461
|
# AUTH_REQUIRED
|
441
462
|
# : 401 Authorization Required
|
463
|
+
#
|
442
464
|
# FORBIDDEN
|
443
465
|
# : 403 Forbidden
|
466
|
+
#
|
444
467
|
# NOT_FOUND
|
445
468
|
# : 404 Not Found
|
469
|
+
#
|
446
470
|
# METHOD_NOT_ALLOWED
|
447
471
|
# : 405 Method Not Allowed
|
472
|
+
#
|
448
473
|
# NOT_ACCEPTABLE
|
449
474
|
# : 406 Not Acceptable
|
475
|
+
#
|
450
476
|
# LENGTH_REQUIRED
|
451
477
|
# : 411 Length Required
|
478
|
+
#
|
452
479
|
# PRECONDITION_FAILED
|
453
480
|
# : 412 Precondition Failed
|
481
|
+
#
|
454
482
|
# SERVER_ERROR
|
455
483
|
# : 500 Internal Server Error
|
484
|
+
#
|
456
485
|
# NOT_IMPLEMENTED
|
457
486
|
# : 501 Method Not Implemented
|
487
|
+
#
|
458
488
|
# BAD_GATEWAY
|
459
489
|
# : 502 Bad Gateway
|
490
|
+
#
|
460
491
|
# VARIANT_ALSO_VARIES
|
461
492
|
# : 506 Variant Also Negotiates
|
462
493
|
#
|
463
494
|
#
|
495
|
+
#
|
464
496
|
# server
|
465
497
|
# : The server software, returned as the Server header.
|
498
|
+
#
|
466
499
|
# connection
|
467
500
|
# : The connection type, returned as the Connection header (for instance,
|
468
501
|
# "close".
|
502
|
+
#
|
469
503
|
# length
|
470
504
|
# : The length of the content that will be sent, returned as the
|
471
505
|
# Content-Length header.
|
506
|
+
#
|
472
507
|
# language
|
473
508
|
# : The language of the content, returned as the Content-Language header.
|
509
|
+
#
|
474
510
|
# expires
|
475
511
|
# : The time on which the current content expires, as a `Time` object,
|
476
512
|
# returned as the Expires header.
|
513
|
+
#
|
477
514
|
# cookie
|
478
515
|
# : A cookie or cookies, returned as one or more Set-Cookie headers. The
|
479
516
|
# value can be the literal string of the cookie; a CGI::Cookie object;
|
@@ -526,8 +563,10 @@ class CGI
|
|
526
563
|
#
|
527
564
|
# `content_type_string`
|
528
565
|
# : If a string is passed, it is assumed to be the content type.
|
566
|
+
#
|
529
567
|
# `headers_hash`
|
530
568
|
# : This is a Hash of headers, similar to that used by #http_header.
|
569
|
+
#
|
531
570
|
# `block`
|
532
571
|
# : A block is required and should evaluate to the body of the response.
|
533
572
|
#
|
@@ -829,25 +868,33 @@ class CGI
|
|
829
868
|
# : The name of the cookie; in this form, there is no #domain or #expiration.
|
830
869
|
# The #path is gleaned from the `SCRIPT_NAME` environment variable, and
|
831
870
|
# #secure is false.
|
871
|
+
#
|
832
872
|
# `*value`
|
833
873
|
# : value or list of values of the cookie
|
874
|
+
#
|
834
875
|
# `options_hash`
|
835
876
|
# : A Hash of options to initialize this Cookie. Possible options are:
|
836
877
|
#
|
837
878
|
# name
|
838
879
|
# : the name of the cookie. Required.
|
880
|
+
#
|
839
881
|
# value
|
840
882
|
# : the cookie's value or list of values.
|
883
|
+
#
|
841
884
|
# path
|
842
885
|
# : the path for which this cookie applies. Defaults to the value of the
|
843
886
|
# `SCRIPT_NAME` environment variable.
|
887
|
+
#
|
844
888
|
# domain
|
845
889
|
# : the domain for which this cookie applies.
|
890
|
+
#
|
846
891
|
# expires
|
847
892
|
# : the time at which this cookie expires, as a `Time` object.
|
893
|
+
#
|
848
894
|
# secure
|
849
895
|
# : whether this cookie is a secure cookie or not (default to false).
|
850
896
|
# Secure cookies are only transmitted to HTTPS servers.
|
897
|
+
#
|
851
898
|
# httponly
|
852
899
|
# : whether this cookie is a HttpOnly cookie or not (default to
|
853
900
|
#
|
@@ -15,7 +15,6 @@
|
|
15
15
|
# of line execution by the interpreter. A `nil` value means coverage is
|
16
16
|
# disabled for this line (lines like `else` and `end`).
|
17
17
|
#
|
18
|
-
#
|
19
18
|
# # Examples
|
20
19
|
#
|
21
20
|
# [foo.rb]
|
@@ -95,7 +94,6 @@
|
|
95
94
|
# 5. The ending line number it appears on in the file.
|
96
95
|
# 6. The ending column number it appears on in the file.
|
97
96
|
#
|
98
|
-
#
|
99
97
|
# ## Methods Coverage
|
100
98
|
#
|
101
99
|
# Methods coverage reports how many times each method was executed.
|
@@ -134,7 +132,6 @@
|
|
134
132
|
# 5. The ending line number the method appears on in the file.
|
135
133
|
# 6. The ending column number the method appears on in the file.
|
136
134
|
#
|
137
|
-
#
|
138
135
|
# ## All Coverage Modes
|
139
136
|
#
|
140
137
|
# You can also run all modes of coverage simultaneously with this shortcut. Note
|
data/stdlib/csv/0/csv.rbs
CHANGED
@@ -9,7 +9,6 @@
|
|
9
9
|
# * A *column* *separator* delimits fields in a row. A common column separator
|
10
10
|
# is the comma character `","`.
|
11
11
|
#
|
12
|
-
#
|
13
12
|
# This CSV String, with row separator `"\n"` and column separator `","`, has
|
14
13
|
# three rows and two columns:
|
15
14
|
# "foo,0\nbar,1\nbaz,2\n"
|
@@ -28,7 +27,6 @@
|
|
28
27
|
# IO object.
|
29
28
|
# * Generating CSV data to a String object.
|
30
29
|
#
|
31
|
-
#
|
32
30
|
# To make CSV available:
|
33
31
|
# require 'csv'
|
34
32
|
#
|
@@ -51,11 +49,9 @@
|
|
51
49
|
# * The outer Array is the entire "table".
|
52
50
|
# * Each inner Array is a row.
|
53
51
|
# * Each String is a field.
|
54
|
-
#
|
55
52
|
# * A CSV::Table object. For details, see [\CSV with
|
56
53
|
# Headers](#class-CSV-label-CSV+with+Headers).
|
57
54
|
#
|
58
|
-
#
|
59
55
|
# #### Parsing a String
|
60
56
|
#
|
61
57
|
# The input to be parsed can be a string:
|
@@ -168,7 +164,6 @@
|
|
168
164
|
# * Method CSV.instance returns a new or cached CSV object.
|
169
165
|
# * Method CSV() also returns a new or cached CSV object.
|
170
166
|
#
|
171
|
-
#
|
172
167
|
# ### Instance Methods
|
173
168
|
#
|
174
169
|
# CSV has three groups of instance methods:
|
@@ -176,7 +171,6 @@
|
|
176
171
|
# * Methods included by module Enumerable.
|
177
172
|
# * Methods delegated to class IO. See below.
|
178
173
|
#
|
179
|
-
#
|
180
174
|
# #### Delegated Methods
|
181
175
|
#
|
182
176
|
# For convenience, a CSV object will delegate to many methods in class IO. (A
|
@@ -215,7 +209,6 @@
|
|
215
209
|
# * IO#truncate
|
216
210
|
# * IO#tty?
|
217
211
|
#
|
218
|
-
#
|
219
212
|
# ### Options
|
220
213
|
#
|
221
214
|
# The default values for options are:
|
@@ -274,7 +267,6 @@
|
|
274
267
|
# * `empty_value`: Specifies the object that is to be substituted for each
|
275
268
|
# empty field.
|
276
269
|
#
|
277
|
-
#
|
278
270
|
# ###### Option `row_sep`
|
279
271
|
#
|
280
272
|
# Specifies the row separator, a String or the Symbol `:auto` (see below), to be
|
@@ -365,7 +357,6 @@
|
|
365
357
|
# * Data is `ARGF`, `STDIN`, `STDOUT`, or `STDERR`.
|
366
358
|
# * The stream is only available for output.
|
367
359
|
#
|
368
|
-
#
|
369
360
|
# Obviously, discovery takes a little time. Set manually if speed is important.
|
370
361
|
# Also note that IO objects should be opened in binary mode on Windows if this
|
371
362
|
# feature will be used as the line-ending translation can cause problems with
|
@@ -684,7 +675,6 @@
|
|
684
675
|
# * The converters apply only to the header row.
|
685
676
|
# * The built-in header converters are `:downcase` and `:symbol`.
|
686
677
|
#
|
687
|
-
#
|
688
678
|
# This section assumes prior execution of:
|
689
679
|
# str = <<-EOT
|
690
680
|
# Name,Value
|
@@ -756,7 +746,6 @@
|
|
756
746
|
# * If a String, converts it to a Regexp, ignores lines that match it.
|
757
747
|
# * If `nil`, no lines are considered to be comments.
|
758
748
|
#
|
759
|
-
#
|
760
749
|
# Default value:
|
761
750
|
# CSV::DEFAULT_OPTIONS.fetch(:skip_lines) # => nil
|
762
751
|
#
|
@@ -885,7 +874,6 @@
|
|
885
874
|
# * `write_empty_value`: Specifies the object that is to be substituted for
|
886
875
|
# each empty field.
|
887
876
|
#
|
888
|
-
#
|
889
877
|
# ###### Option `row_sep`
|
890
878
|
#
|
891
879
|
# Specifies the row separator, a String or the Symbol `:auto` (see below), to be
|
@@ -976,7 +964,6 @@
|
|
976
964
|
# * Data is `ARGF`, `STDIN`, `STDOUT`, or `STDERR`.
|
977
965
|
# * The stream is only available for output.
|
978
966
|
#
|
979
|
-
#
|
980
967
|
# Obviously, discovery takes a little time. Set manually if speed is important.
|
981
968
|
# Also note that IO objects should be opened in binary mode on Windows if this
|
982
969
|
# feature will be used as the line-ending translation can cause problems with
|
@@ -1231,12 +1218,10 @@
|
|
1231
1218
|
# * See [Field Converters](#class-CSV-label-Field+Converters).
|
1232
1219
|
# * See [Header Converters](#class-CSV-label-Header+Converters).
|
1233
1220
|
#
|
1234
|
-
#
|
1235
1221
|
# Also by default, each value to be written during generation is written
|
1236
1222
|
# 'as-is'. You can use a *write* *converter* to modify values before writing.
|
1237
1223
|
# * See [Write Converters](#class-CSV-label-Write+Converters).
|
1238
1224
|
#
|
1239
|
-
#
|
1240
1225
|
# #### Specifying Converters
|
1241
1226
|
#
|
1242
1227
|
# You can specify converters for parsing or generating in the `options` argument
|
@@ -1245,14 +1230,12 @@
|
|
1245
1230
|
# * Option `header_converters` for converting parsed header values.
|
1246
1231
|
# * Option `write_converters` for converting values to be written (generated).
|
1247
1232
|
#
|
1248
|
-
#
|
1249
1233
|
# There are three forms for specifying converters:
|
1250
1234
|
# * A converter proc: executable code to be used for conversion.
|
1251
1235
|
# * A converter name: the name of a stored converter.
|
1252
1236
|
# * A converter list: an array of converter procs, converter names, and
|
1253
1237
|
# converter lists.
|
1254
1238
|
#
|
1255
|
-
#
|
1256
1239
|
# ##### Converter Procs
|
1257
1240
|
#
|
1258
1241
|
# This converter proc, `strip_converter`, accepts a value `field` and returns
|
@@ -1263,7 +1246,6 @@
|
|
1263
1246
|
# string_converter` specifies that:
|
1264
1247
|
# * Proc `string_converter` is to be called for each parsed field.
|
1265
1248
|
# * The converter's return value is to replace the `field` value.
|
1266
|
-
#
|
1267
1249
|
# Example:
|
1268
1250
|
# string = " foo , 0 \n bar , 1 \n baz , 2 \n"
|
1269
1251
|
# array = CSV.parse(string, converters: strip_converter)
|
@@ -1293,7 +1275,6 @@
|
|
1293
1275
|
# * The 1-based line index.
|
1294
1276
|
# * The field header, if any.
|
1295
1277
|
#
|
1296
|
-
#
|
1297
1278
|
# ##### Stored Converters
|
1298
1279
|
#
|
1299
1280
|
# A converter may be given a name and stored in a structure where the parsing
|
@@ -1305,7 +1286,6 @@
|
|
1305
1286
|
# * `:float`: converts each String-embedded float into a true Float.
|
1306
1287
|
# * `:date`: converts each String-embedded date into a true Date.
|
1307
1288
|
# * `:date_time`: converts each String-embedded date-time into a true DateTime
|
1308
|
-
#
|
1309
1289
|
# . This example creates a converter proc, then stores it:
|
1310
1290
|
# strip_converter = proc {|field| field.strip }
|
1311
1291
|
# CSV::Converters[:strip] = strip_converter
|
@@ -1320,7 +1300,6 @@
|
|
1320
1300
|
# * `:downcase`: Downcases each header.
|
1321
1301
|
# * `:symbol`: Converts each header to a Symbol.
|
1322
1302
|
#
|
1323
|
-
#
|
1324
1303
|
# There is no such storage structure for write headers.
|
1325
1304
|
#
|
1326
1305
|
# In order for the parsing methods to access stored converters in
|
@@ -1338,7 +1317,6 @@
|
|
1338
1317
|
# * Names of stored converters.
|
1339
1318
|
# * Nested converter lists.
|
1340
1319
|
#
|
1341
|
-
#
|
1342
1320
|
# Examples:
|
1343
1321
|
# numeric_converters = [:integer, :float]
|
1344
1322
|
# date_converters = [:date, :date_time]
|
@@ -1387,7 +1365,6 @@
|
|
1387
1365
|
# csv.converters # => [:integer]
|
1388
1366
|
# csv.read # => [["foo", 0], ["bar", 1], ["baz", 2]]
|
1389
1367
|
#
|
1390
|
-
#
|
1391
1368
|
# Installing a field converter does not affect already-read rows:
|
1392
1369
|
# csv = CSV.new(string)
|
1393
1370
|
# csv.shift # => ["foo", "0"]
|
@@ -1407,8 +1384,6 @@
|
|
1407
1384
|
# * A Proc field converter.
|
1408
1385
|
# * An Array of field converter names.
|
1409
1386
|
#
|
1410
|
-
#
|
1411
|
-
#
|
1412
1387
|
# Display:
|
1413
1388
|
# CSV::Converters.each_pair do |name, value|
|
1414
1389
|
# if value.kind_of?(Proc)
|
@@ -1522,7 +1497,6 @@
|
|
1522
1497
|
# tbl = CSV.parse(string, headers: true)
|
1523
1498
|
# tbl.headers # => ["Name", "Count"]
|
1524
1499
|
#
|
1525
|
-
#
|
1526
1500
|
# ##### Built-In Header Converters
|
1527
1501
|
#
|
1528
1502
|
# The built-in header converters are in Hash CSV::HeaderConverters. The keys
|
@@ -1547,7 +1521,6 @@
|
|
1547
1521
|
# * Removes non-word characters.
|
1548
1522
|
# * Makes the string into a Symbol.
|
1549
1523
|
#
|
1550
|
-
#
|
1551
1524
|
# ##### Custom Header Converters
|
1552
1525
|
#
|
1553
1526
|
# You can define a custom header converter:
|
@@ -1744,15 +1717,12 @@ class CSV < Object
|
|
1744
1717
|
# * Positioned at the beginning. To position at the end, for appending,
|
1745
1718
|
# use method CSV.generate. For any other positioning, pass a preset
|
1746
1719
|
# StringIO object instead.
|
1747
|
-
#
|
1748
1720
|
# * Argument `options`: See:
|
1749
1721
|
# * [Options for Parsing](#class-CSV-label-Options+for+Parsing)
|
1750
1722
|
# * [Options for Generating](#class-CSV-label-Options+for+Generating)
|
1751
|
-
#
|
1752
1723
|
# For performance reasons, the options cannot be overridden in a CSV object,
|
1753
1724
|
# so those specified here will endure.
|
1754
1725
|
#
|
1755
|
-
#
|
1756
1726
|
# In addition to the CSV instance methods, several IO methods are delegated. See
|
1757
1727
|
# [Delegated Methods](#class-CSV-label-Delegated+Methods).
|
1758
1728
|
#
|
@@ -1793,11 +1763,9 @@ class CSV < Object
|
|
1793
1763
|
# * Positioned at the beginning. To position at the end, for appending,
|
1794
1764
|
# use method CSV.generate. For any other positioning, pass a preset
|
1795
1765
|
# StringIO object instead.
|
1796
|
-
#
|
1797
1766
|
# * Argument `options`: see [Options for
|
1798
1767
|
# Parsing](#class-CSV-label-Options+for+Parsing)
|
1799
1768
|
#
|
1800
|
-
#
|
1801
1769
|
# ###### Without Option `headers`
|
1802
1770
|
#
|
1803
1771
|
# Without {option `headers`[}](#class-CSV-label-Option+headers) case.
|
@@ -1916,11 +1884,9 @@ class CSV < Object
|
|
1916
1884
|
# * Positioned at the beginning. To position at the end, for appending,
|
1917
1885
|
# use method CSV.generate. For any other positioning, pass a preset
|
1918
1886
|
# StringIO object instead.
|
1919
|
-
#
|
1920
1887
|
# * Argument `options`: see [Options for
|
1921
1888
|
# Parsing](#class-CSV-label-Options+for+Parsing)
|
1922
1889
|
#
|
1923
|
-
#
|
1924
1890
|
# ###### Without Option `headers`
|
1925
1891
|
#
|
1926
1892
|
# Without option `headers`, returns the first row as a new Array.
|
@@ -1975,7 +1941,6 @@ class CSV < Object
|
|
1975
1941
|
# * A CSV::Table object, if headers are in use.
|
1976
1942
|
# * An Array of Arrays, otherwise.
|
1977
1943
|
#
|
1978
|
-
#
|
1979
1944
|
# The data source must be opened for reading.
|
1980
1945
|
#
|
1981
1946
|
# Without headers:
|
@@ -2043,7 +2008,6 @@ class CSV < Object
|
|
2043
2008
|
# * Argument `row` must be an Array object or a CSV::Row object.
|
2044
2009
|
# * The output stream must be open for writing.
|
2045
2010
|
#
|
2046
|
-
#
|
2047
2011
|
# ---
|
2048
2012
|
#
|
2049
2013
|
# Append Arrays:
|
@@ -2099,7 +2063,6 @@ class CSV < Object
|
|
2099
2063
|
# * Arguments `options`, if given, should be generating options. See [Options
|
2100
2064
|
# for Generating](#class-CSV-label-Options+for+Generating).
|
2101
2065
|
#
|
2102
|
-
#
|
2103
2066
|
# ---
|
2104
2067
|
#
|
2105
2068
|
# Creates a new CSV object via `CSV.new(csv_string, **options)`; calls the block
|
@@ -2227,7 +2190,6 @@ CSV::VERSION: String
|
|
2227
2190
|
# * Fields: each is an object, not necessarily a String.
|
2228
2191
|
# * Headers: each serves a key, and also need not be a String.
|
2229
2192
|
#
|
2230
|
-
#
|
2231
2193
|
# ### Instance Methods
|
2232
2194
|
#
|
2233
2195
|
# CSV::Row has three groups of instance methods:
|
@@ -2238,8 +2200,6 @@ CSV::VERSION: String
|
|
2238
2200
|
# * Array#length
|
2239
2201
|
# * Array#size
|
2240
2202
|
#
|
2241
|
-
#
|
2242
|
-
#
|
2243
2203
|
# ## Creating a CSV::Row Instance
|
2244
2204
|
#
|
2245
2205
|
# Commonly, a new CSV::Row instance is created by parsing CSV source that has
|
@@ -2658,7 +2618,6 @@ class CSV::Row < Object
|
|
2658
2618
|
# * Header.
|
2659
2619
|
# * Range of headers.
|
2660
2620
|
#
|
2661
|
-
#
|
2662
2621
|
# For `specifier` in one of the first four cases above, returns the result of
|
2663
2622
|
# `self.field(specifier)`; see #field.
|
2664
2623
|
#
|
@@ -2765,7 +2724,6 @@ class CSV::Row < Object
|
|
2765
2724
|
# Returns an ASCII-compatible String showing:
|
2766
2725
|
# * Class CSV::Row.
|
2767
2726
|
# * Header-value pairs.
|
2768
|
-
#
|
2769
2727
|
# Example:
|
2770
2728
|
# source = "Name,Value\nfoo,0\nbar,1\nbaz,2\n"
|
2771
2729
|
# table = CSV.parse(source, headers: true)
|
@@ -2875,7 +2833,6 @@ end
|
|
2875
2833
|
# * Rows: each is a Table::Row object.
|
2876
2834
|
# * Headers: names for the columns.
|
2877
2835
|
#
|
2878
|
-
#
|
2879
2836
|
# ### Instance Methods
|
2880
2837
|
#
|
2881
2838
|
# CSV::Table has three groups of instance methods:
|
@@ -2886,8 +2843,6 @@ end
|
|
2886
2843
|
# * Array#length
|
2887
2844
|
# * Array#size
|
2888
2845
|
#
|
2889
|
-
#
|
2890
|
-
#
|
2891
2846
|
# ## Creating a CSV::Table Instance
|
2892
2847
|
#
|
2893
2848
|
# Commonly, a new CSV::Table instance is created by parsing CSV source using
|
@@ -2921,7 +2876,6 @@ end
|
|
2921
2876
|
# * Column mode.
|
2922
2877
|
# * Mixed mode (the default for a new table).
|
2923
2878
|
#
|
2924
|
-
#
|
2925
2879
|
# The access mode for aCSV::Table instance affects the behavior of some of its
|
2926
2880
|
# instance methods:
|
2927
2881
|
# * #[]
|
@@ -2931,7 +2885,6 @@ end
|
|
2931
2885
|
# * #each
|
2932
2886
|
# * #values_at
|
2933
2887
|
#
|
2934
|
-
#
|
2935
2888
|
# ### Row Mode
|
2936
2889
|
#
|
2937
2890
|
# Set a table to row mode with method #by_row!:
|
@@ -2984,7 +2937,6 @@ end
|
|
2984
2937
|
# * A Range index refers to multiple rows.
|
2985
2938
|
# * A String index refers to a column.
|
2986
2939
|
#
|
2987
|
-
#
|
2988
2940
|
# Set a table to mixed mode with method #by_col_or_row!:
|
2989
2941
|
# source = "Name,Value\nfoo,0\nbar,1\nbaz,2\n"
|
2990
2942
|
# table = CSV.parse(source, headers: true)
|
@@ -3025,7 +2977,6 @@ class CSV::Table[out Elem] < Object
|
|
3025
2977
|
# * Argument `array_of_rows` must be an Array of CSV::Row objects.
|
3026
2978
|
# * Argument `headers`, if given, may be an Array of Strings.
|
3027
2979
|
#
|
3028
|
-
#
|
3029
2980
|
# ---
|
3030
2981
|
#
|
3031
2982
|
# Create an empty CSV::Table object:
|
@@ -3135,7 +3086,6 @@ class CSV::Table[out Elem] < Object
|
|
3135
3086
|
# * Access mode: `:row` or `:col_or_row`.
|
3136
3087
|
# * Return value: *nth* row of the table, if that row exists; otherwise `nil`.
|
3137
3088
|
#
|
3138
|
-
#
|
3139
3089
|
# Returns the *nth* row of the table if that row exists:
|
3140
3090
|
# source = "Name,Value\nfoo,0\nbar,1\nbaz,2\n"
|
3141
3091
|
# table = CSV.parse(source, headers: true)
|
@@ -3166,7 +3116,6 @@ class CSV::Table[out Elem] < Object
|
|
3166
3116
|
# * Return value: *nth* column of the table, if that column exists; otherwise
|
3167
3117
|
# an Array of `nil` fields of length `self.size`.
|
3168
3118
|
#
|
3169
|
-
#
|
3170
3119
|
# Returns the *nth* column of the table if that column exists:
|
3171
3120
|
# source = "Name,Value\nfoo,0\nbar,1\nbaz,2\n"
|
3172
3121
|
# table = CSV.parse(source, headers: true)
|
@@ -3190,7 +3139,6 @@ class CSV::Table[out Elem] < Object
|
|
3190
3139
|
# * Return value: rows from the table, beginning at row `range.start`, if
|
3191
3140
|
# those rows exists.
|
3192
3141
|
#
|
3193
|
-
#
|
3194
3142
|
# Returns rows from the table, beginning at row `range.first`, if those rows
|
3195
3143
|
# exist:
|
3196
3144
|
# source = "Name,Value\nfoo,0\nbar,1\nbaz,2\n"
|
@@ -3230,7 +3178,6 @@ class CSV::Table[out Elem] < Object
|
|
3230
3178
|
# * Return value: column data from the table, beginning at column
|
3231
3179
|
# `range.start`, if those columns exist.
|
3232
3180
|
#
|
3233
|
-
#
|
3234
3181
|
# Returns column values from the table, if the column exists; the values are
|
3235
3182
|
# arranged by row:
|
3236
3183
|
# source = "Name,Value\nfoo,0\nbar,1\nbaz,2\n"
|
@@ -3261,7 +3208,6 @@ class CSV::Table[out Elem] < Object
|
|
3261
3208
|
# * Access mode: `:col` or `:col_or_row`
|
3262
3209
|
# * Return value: column data from the table, if that `header` exists.
|
3263
3210
|
#
|
3264
|
-
#
|
3265
3211
|
# Returns column values from the table, if the column exists:
|
3266
3212
|
# source = "Name,Value\nfoo,0\nbar,1\nbaz,2\n"
|
3267
3213
|
# table = CSV.parse(source, headers: true)
|
@@ -3299,7 +3245,6 @@ class CSV::Table[out Elem] < Object
|
|
3299
3245
|
# * Access mode: `:row` or `:col_or_row`.
|
3300
3246
|
# * Return value: `row`.
|
3301
3247
|
#
|
3302
|
-
#
|
3303
3248
|
# If the row exists, it is replaced:
|
3304
3249
|
# source = "Name,Value\nfoo,0\nbar,1\nbaz,2\n"
|
3305
3250
|
# table = CSV.parse(source, headers: true)
|
@@ -3341,7 +3286,6 @@ class CSV::Table[out Elem] < Object
|
|
3341
3286
|
# * Access mode: `:col`.
|
3342
3287
|
# * Return value: `array_of_fields`.
|
3343
3288
|
#
|
3344
|
-
#
|
3345
3289
|
# If the column exists, it is replaced:
|
3346
3290
|
# source = "Name,Value\nfoo,0\nbar,1\nbaz,2\n"
|
3347
3291
|
# table = CSV.parse(source, headers: true)
|
@@ -3380,7 +3324,6 @@ class CSV::Table[out Elem] < Object
|
|
3380
3324
|
# * Access mode: `:col` or `:col_or_row`.
|
3381
3325
|
# * Return value: `field_or_array_of_fields`.
|
3382
3326
|
#
|
3383
|
-
#
|
3384
3327
|
# If the column exists, it is replaced:
|
3385
3328
|
# source = "Name,Value\nfoo,0\nbar,1\nbaz,2\n"
|
3386
3329
|
# table = CSV.parse(source, headers: true)
|
@@ -3684,7 +3627,6 @@ class CSV::Table[out Elem] < Object
|
|
3684
3627
|
# * Access mode: `:row`, `:col`, or `:col_or_row`.
|
3685
3628
|
# * Size: Row count, including the header row.
|
3686
3629
|
#
|
3687
|
-
#
|
3688
3630
|
# Example:
|
3689
3631
|
# source = "Name,Value\nfoo,0\nbar,1\nbaz,2\n"
|
3690
3632
|
# table = CSV.parse(source, headers: true)
|
@@ -3814,3 +3756,21 @@ class CSV::Table[out Elem] < Object
|
|
3814
3756
|
#
|
3815
3757
|
def values_at: (*untyped indices_or_headers) -> untyped
|
3816
3758
|
end
|
3759
|
+
|
3760
|
+
%a{annotate:rdoc:skip}
|
3761
|
+
class Array[unchecked out Elem] < Object
|
3762
|
+
# Equivalent to CSV::generate_line(self, options)
|
3763
|
+
#
|
3764
|
+
# ["CSV", "data"].to_csv
|
3765
|
+
# #=> "CSV,data\n"
|
3766
|
+
def to_csv: (**untyped options) -> String
|
3767
|
+
end
|
3768
|
+
|
3769
|
+
%a{annotate:rdoc:skip}
|
3770
|
+
class String
|
3771
|
+
# Equivalent to CSV::parse_line(self, options)
|
3772
|
+
#
|
3773
|
+
# "CSV,data".parse_csv
|
3774
|
+
# #=> ["CSV", "data"]
|
3775
|
+
def parse_csv: (**untyped options) -> ::Array[String?]?
|
3776
|
+
end
|