rbs 2.0.0 → 2.2.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.
Files changed (208) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/comments.yml +34 -0
  3. data/.github/workflows/ruby.yml +5 -0
  4. data/CHANGELOG.md +82 -0
  5. data/README.md +6 -1
  6. data/Rakefile +56 -21
  7. data/core/array.rbs +2866 -1086
  8. data/core/basic_object.rbs +150 -30
  9. data/core/binding.rbs +33 -0
  10. data/core/builtin.rbs +4 -4
  11. data/core/class.rbs +43 -5
  12. data/core/comparable.rbs +57 -0
  13. data/core/complex.rbs +170 -4
  14. data/core/constants.rbs +51 -0
  15. data/core/deprecated.rbs +7 -0
  16. data/core/dir.rbs +305 -20
  17. data/core/encoding.rbs +1214 -77
  18. data/core/enumerable.rbs +2173 -234
  19. data/core/enumerator.rbs +448 -182
  20. data/core/env.rbs +448 -1
  21. data/core/errno.rbs +1 -10
  22. data/core/errors.rbs +152 -2
  23. data/core/exception.rbs +201 -127
  24. data/core/false_class.rbs +27 -0
  25. data/core/fiber.rbs +118 -37
  26. data/core/fiber_error.rbs +8 -9
  27. data/core/file.rbs +1060 -142
  28. data/core/file_test.rbs +287 -32
  29. data/core/float.rbs +776 -300
  30. data/core/gc.rbs +185 -34
  31. data/core/global_variables.rbs +5 -1
  32. data/core/hash.rbs +1582 -649
  33. data/core/integer.rbs +974 -204
  34. data/core/io/buffer.rbs +710 -0
  35. data/core/io/wait.rbs +29 -8
  36. data/core/io.rbs +2438 -417
  37. data/core/kernel.rbs +2319 -318
  38. data/core/marshal.rbs +37 -2
  39. data/core/match_data.rbs +123 -6
  40. data/core/math.rbs +126 -6
  41. data/core/method.rbs +226 -102
  42. data/core/module.rbs +421 -45
  43. data/core/nil_class.rbs +64 -0
  44. data/core/numeric.rbs +620 -142
  45. data/core/object.rbs +453 -81
  46. data/core/object_space.rbs +92 -2
  47. data/core/proc.rbs +482 -285
  48. data/core/process.rbs +443 -34
  49. data/core/ractor.rbs +232 -9
  50. data/core/random.rbs +151 -52
  51. data/core/range.rbs +885 -160
  52. data/core/rational.rbs +122 -6
  53. data/core/rb_config.rbs +14 -4
  54. data/core/refinement.rbs +44 -0
  55. data/core/regexp.rbs +156 -14
  56. data/core/ruby_vm.rbs +42 -3
  57. data/core/signal.rbs +78 -39
  58. data/core/string.rbs +2123 -567
  59. data/core/string_io.rbs +204 -0
  60. data/core/struct.rbs +283 -28
  61. data/core/symbol.rbs +304 -30
  62. data/core/thread.rbs +1288 -688
  63. data/core/thread_group.rbs +66 -10
  64. data/core/time.rbs +643 -217
  65. data/core/trace_point.rbs +100 -12
  66. data/core/true_class.rbs +24 -0
  67. data/core/unbound_method.rbs +73 -7
  68. data/core/warning.rbs +37 -12
  69. data/docs/CONTRIBUTING.md +40 -34
  70. data/docs/stdlib.md +3 -102
  71. data/docs/syntax.md +54 -11
  72. data/ext/rbs_extension/extconf.rb +1 -0
  73. data/ext/rbs_extension/lexer.h +5 -0
  74. data/ext/rbs_extension/lexstate.c +6 -0
  75. data/ext/rbs_extension/parser.c +85 -10
  76. data/ext/rbs_extension/ruby_objs.c +4 -2
  77. data/ext/rbs_extension/ruby_objs.h +2 -2
  78. data/goodcheck.yml +0 -11
  79. data/lib/rbs/annotate/annotations.rb +197 -0
  80. data/lib/rbs/annotate/formatter.rb +80 -0
  81. data/lib/rbs/annotate/rdoc_annotator.rb +398 -0
  82. data/lib/rbs/annotate/rdoc_source.rb +120 -0
  83. data/lib/rbs/annotate.rb +6 -0
  84. data/lib/rbs/ast/members.rb +21 -13
  85. data/lib/rbs/buffer.rb +17 -11
  86. data/lib/rbs/cli.rb +48 -1
  87. data/lib/rbs/definition_builder/method_builder.rb +28 -16
  88. data/lib/rbs/definition_builder.rb +6 -2
  89. data/lib/rbs/environment.rb +8 -4
  90. data/lib/rbs/location_aux.rb +12 -0
  91. data/lib/rbs/namespace.rb +1 -1
  92. data/lib/rbs/prototype/rb.rb +12 -0
  93. data/lib/rbs/type_alias_regularity.rb +6 -4
  94. data/lib/rbs/type_name.rb +1 -1
  95. data/lib/rbs/types.rb +1 -1
  96. data/lib/rbs/validator.rb +6 -0
  97. data/lib/rbs/version.rb +1 -1
  98. data/lib/rbs/writer.rb +54 -4
  99. data/lib/rbs.rb +0 -2
  100. data/schema/typeParam.json +3 -3
  101. data/sig/annotate/annotations.rbs +102 -0
  102. data/sig/annotate/formatter.rbs +24 -0
  103. data/sig/annotate/rdoc_annotater.rbs +82 -0
  104. data/sig/annotate/rdoc_source.rbs +30 -0
  105. data/sig/buffer.rbs +6 -2
  106. data/sig/cli.rbs +2 -0
  107. data/sig/collection/{collections.rbs → sources.rbs} +0 -0
  108. data/sig/location.rbs +6 -0
  109. data/sig/members.rbs +24 -18
  110. data/sig/method_builder.rbs +5 -4
  111. data/sig/method_types.rbs +5 -1
  112. data/sig/polyfill.rbs +78 -0
  113. data/sig/validator.rbs +3 -1
  114. data/sig/writer.rbs +79 -2
  115. data/stdlib/abbrev/0/abbrev.rbs +6 -0
  116. data/stdlib/abbrev/0/array.rbs +26 -0
  117. data/stdlib/base64/0/base64.rbs +31 -0
  118. data/stdlib/benchmark/0/benchmark.rbs +74 -3
  119. data/stdlib/bigdecimal/0/big_decimal.rbs +614 -165
  120. data/stdlib/bigdecimal-math/0/big_math.rbs +41 -64
  121. data/stdlib/cgi/0/core.rbs +649 -21
  122. data/stdlib/coverage/0/coverage.rbs +164 -2
  123. data/stdlib/csv/0/csv.rbs +2862 -398
  124. data/stdlib/date/0/date.rbs +483 -25
  125. data/stdlib/date/0/date_time.rbs +187 -12
  126. data/stdlib/dbm/0/dbm.rbs +152 -17
  127. data/stdlib/digest/0/digest.rbs +146 -0
  128. data/stdlib/erb/0/erb.rbs +65 -245
  129. data/stdlib/fiber/0/fiber.rbs +73 -91
  130. data/stdlib/fileutils/0/fileutils.rbs +301 -1
  131. data/stdlib/find/0/find.rbs +9 -0
  132. data/stdlib/forwardable/0/forwardable.rbs +65 -1
  133. data/stdlib/io-console/0/io-console.rbs +227 -15
  134. data/stdlib/ipaddr/0/ipaddr.rbs +161 -0
  135. data/stdlib/json/0/json.rbs +1147 -145
  136. data/stdlib/logger/0/formatter.rbs +24 -0
  137. data/stdlib/logger/0/log_device.rbs +64 -0
  138. data/stdlib/logger/0/logger.rbs +165 -13
  139. data/stdlib/logger/0/period.rbs +10 -0
  140. data/stdlib/logger/0/severity.rbs +26 -0
  141. data/stdlib/monitor/0/monitor.rbs +163 -0
  142. data/stdlib/mutex_m/0/mutex_m.rbs +35 -6
  143. data/stdlib/net-http/0/manifest.yaml +1 -0
  144. data/stdlib/net-http/0/net-http.rbs +1513 -683
  145. data/stdlib/nkf/0/nkf.rbs +372 -0
  146. data/stdlib/objspace/0/objspace.rbs +149 -90
  147. data/stdlib/openssl/0/openssl.rbs +8108 -71
  148. data/stdlib/optparse/0/optparse.rbs +487 -19
  149. data/stdlib/pathname/0/pathname.rbs +425 -124
  150. data/stdlib/prettyprint/0/prettyprint.rbs +120 -99
  151. data/stdlib/prime/0/integer-extension.rbs +20 -2
  152. data/stdlib/prime/0/prime.rbs +88 -21
  153. data/stdlib/pstore/0/pstore.rbs +102 -0
  154. data/stdlib/pty/0/pty.rbs +64 -14
  155. data/stdlib/resolv/0/resolv.rbs +420 -31
  156. data/stdlib/rubygems/0/basic_specification.rbs +4 -1
  157. data/stdlib/rubygems/0/config_file.rbs +33 -1
  158. data/stdlib/rubygems/0/dependency_installer.rbs +4 -3
  159. data/stdlib/rubygems/0/installer.rbs +13 -1
  160. data/stdlib/rubygems/0/path_support.rbs +4 -1
  161. data/stdlib/rubygems/0/platform.rbs +5 -1
  162. data/stdlib/rubygems/0/request_set.rbs +44 -2
  163. data/stdlib/rubygems/0/requirement.rbs +65 -2
  164. data/stdlib/rubygems/0/rubygems.rbs +407 -0
  165. data/stdlib/rubygems/0/source_list.rbs +13 -0
  166. data/stdlib/rubygems/0/specification.rbs +21 -1
  167. data/stdlib/rubygems/0/stream_ui.rbs +3 -1
  168. data/stdlib/rubygems/0/uninstaller.rbs +8 -1
  169. data/stdlib/rubygems/0/version.rbs +60 -157
  170. data/stdlib/securerandom/0/securerandom.rbs +44 -0
  171. data/stdlib/set/0/set.rbs +423 -109
  172. data/stdlib/shellwords/0/shellwords.rbs +55 -77
  173. data/stdlib/singleton/0/singleton.rbs +20 -0
  174. data/stdlib/socket/0/addrinfo.rbs +210 -9
  175. data/stdlib/socket/0/basic_socket.rbs +103 -11
  176. data/stdlib/socket/0/ip_socket.rbs +31 -9
  177. data/stdlib/socket/0/socket.rbs +586 -38
  178. data/stdlib/socket/0/tcp_server.rbs +22 -2
  179. data/stdlib/socket/0/tcp_socket.rbs +12 -1
  180. data/stdlib/socket/0/udp_socket.rbs +25 -2
  181. data/stdlib/socket/0/unix_server.rbs +22 -2
  182. data/stdlib/socket/0/unix_socket.rbs +45 -5
  183. data/stdlib/strscan/0/string_scanner.rbs +210 -9
  184. data/stdlib/tempfile/0/tempfile.rbs +58 -10
  185. data/stdlib/time/0/time.rbs +208 -116
  186. data/stdlib/timeout/0/timeout.rbs +10 -0
  187. data/stdlib/tmpdir/0/tmpdir.rbs +13 -4
  188. data/stdlib/tsort/0/cyclic.rbs +1 -0
  189. data/stdlib/tsort/0/interfaces.rbs +1 -0
  190. data/stdlib/tsort/0/tsort.rbs +42 -0
  191. data/stdlib/uri/0/common.rbs +57 -8
  192. data/stdlib/uri/0/file.rbs +55 -109
  193. data/stdlib/uri/0/ftp.rbs +6 -3
  194. data/stdlib/uri/0/generic.rbs +558 -329
  195. data/stdlib/uri/0/http.rbs +60 -114
  196. data/stdlib/uri/0/https.rbs +8 -102
  197. data/stdlib/uri/0/ldap.rbs +143 -137
  198. data/stdlib/uri/0/ldaps.rbs +8 -102
  199. data/stdlib/uri/0/mailto.rbs +3 -0
  200. data/stdlib/uri/0/rfc2396_parser.rbs +66 -26
  201. data/stdlib/uri/0/ws.rbs +6 -3
  202. data/stdlib/uri/0/wss.rbs +5 -3
  203. data/stdlib/yaml/0/dbm.rbs +151 -87
  204. data/stdlib/yaml/0/store.rbs +6 -0
  205. data/stdlib/zlib/0/zlib.rbs +90 -31
  206. metadata +18 -6
  207. data/lib/rbs/location.rb +0 -221
  208. data/sig/char_scanner.rbs +0 -9
@@ -1,3 +1,4 @@
1
+ # <!-- rdoc-file=lib/cgi.rb -->
1
2
  # ## Overview
2
3
  #
3
4
  # The Common Gateway Interface (CGI) is a simple protocol for passing an HTTP
@@ -266,7 +267,17 @@
266
267
  # include CGI::Util
267
268
  # escapeHTML('Usage: foo "bar" <baz>')
268
269
  # h('Usage: foo "bar" <baz>') # alias
270
+ #
269
271
  class CGI
272
+ include CGI::Util
273
+
274
+ extend CGI::Util
275
+
276
+ # <!--
277
+ # rdoc-file=lib/cgi/core.rb
278
+ # - CGI.new(tag_maker) { block }
279
+ # - CGI.new(options_hash = {}) { block }
280
+ # -->
270
281
  # Create a new CGI instance.
271
282
  #
272
283
  # `tag_maker`
@@ -343,26 +354,42 @@ class CGI
343
354
  def initialize: (?String tag_maker) ?{ (String name, String value) -> void } -> void
344
355
  | (Hash[Symbol, untyped] options_hash) ?{ (String name, String value) -> void } -> void
345
356
 
346
- attr_reader accept_charset: String
347
-
357
+ # <!--
358
+ # rdoc-file=lib/cgi/core.rb
359
+ # - accept_charset()
360
+ # -->
348
361
  # Return the accept character set for all new CGI instances.
349
362
  #
350
363
  def self.accept_charset: () -> String
351
364
 
365
+ # <!--
366
+ # rdoc-file=lib/cgi/core.rb
367
+ # - accept_charset=(accept_charset)
368
+ # -->
352
369
  # Set the accept character set for all new CGI instances.
353
370
  #
354
371
  def self.accept_charset=: (String accept_charset) -> String
355
372
 
373
+ # <!--
374
+ # rdoc-file=lib/cgi/core.rb
375
+ # - parse(query)
376
+ # -->
356
377
  # Parse an HTTP query string into a hash of key=>value pairs.
357
378
  #
358
379
  # params = CGI.parse("query_string")
359
380
  # # {"name1" => ["value1", "value2", ...],
360
381
  # # "name2" => ["value1", "value2", ...], ... }
361
382
  #
362
- def self.parse: (String query) -> Hash[String, String | Array[String]]
383
+ def self.parse: (String query) -> Hash[String, Array[String]]
363
384
 
364
385
  public
365
386
 
387
+ # <!-- rdoc-file=lib/cgi/core.rb -->
388
+ # Return the accept character set for this CGI instance.
389
+ #
390
+ attr_reader accept_charset: String
391
+
392
+ # <!-- rdoc-file=lib/cgi/core.rb -->
366
393
  # This method is an alias for #http_header, when HTML5 tag maker is inactive.
367
394
  #
368
395
  # NOTE: use #http_header to create HTTP header blocks, this alias is only
@@ -372,6 +399,11 @@ class CGI
372
399
  #
373
400
  alias header http_header
374
401
 
402
+ # <!--
403
+ # rdoc-file=lib/cgi/core.rb
404
+ # - http_header(content_type_string="text/html")
405
+ # - http_header(headers_hash)
406
+ # -->
375
407
  # Create an HTTP header block as a string.
376
408
  #
377
409
  # Includes the empty line that ends the header block.
@@ -485,8 +517,13 @@ class CGI
485
517
  def http_header: (?String options) -> String
486
518
  | (?Hash[String | Symbol, untyped] header_hash) -> String
487
519
 
488
- def nph?: () -> boolish
520
+ def nph?: () -> untyped
489
521
 
522
+ # <!--
523
+ # rdoc-file=lib/cgi/core.rb
524
+ # - cgi.out(content_type_string='text/html')
525
+ # - cgi.out(headers_hash)
526
+ # -->
490
527
  # Print an HTTP header and body to $DEFAULT_OUTPUT ($>)
491
528
  #
492
529
  # `content_type_string`
@@ -551,6 +588,10 @@ class CGI
551
588
  def out: (?String content_type_string) { () -> String } -> void
552
589
  | (Hash[String | Symbol, untyped] headers_hash) { () -> String } -> void
553
590
 
591
+ # <!--
592
+ # rdoc-file=lib/cgi/core.rb
593
+ # - print(*options)
594
+ # -->
554
595
  # Print an argument or list of arguments to the default output stream
555
596
  #
556
597
  # cgi = CGI.new
@@ -560,36 +601,623 @@ class CGI
560
601
 
561
602
  private
562
603
 
604
+ # <!--
605
+ # rdoc-file=lib/cgi/core.rb
606
+ # - stdinput()
607
+ # -->
563
608
  # Synonym for $stdin.
564
609
  #
565
610
  def stdinput: () -> ::IO
566
611
 
612
+ # <!--
613
+ # rdoc-file=lib/cgi/core.rb
614
+ # - stdoutput()
615
+ # -->
567
616
  # Synonym for $stdout.
568
617
  #
569
618
  def stdoutput: () -> ::IO
570
- end
571
619
 
572
- # String for carriage return
573
- CGI::CR: String
620
+ # <!-- rdoc-file=lib/cgi/core.rb -->
621
+ # String for carriage return
622
+ #
623
+ CR: String
624
+
625
+ # <!-- rdoc-file=lib/cgi/core.rb -->
626
+ # Standard internet newline sequence
627
+ #
628
+ EOL: String
629
+
630
+ # <!-- rdoc-file=lib/cgi/core.rb -->
631
+ # HTTP status codes.
632
+ #
633
+ HTTP_STATUS: Hash[String, String]
634
+
635
+ # <!-- rdoc-file=lib/cgi/core.rb -->
636
+ # String for linefeed
637
+ #
638
+ LF: String
639
+
640
+ # <!-- rdoc-file=lib/cgi/core.rb -->
641
+ # Maximum number of request parameters when multipart
642
+ #
643
+ MAX_MULTIPART_COUNT: Integer
644
+
645
+ # <!-- rdoc-file=lib/cgi/core.rb -->
646
+ # Whether processing will be required in binary vs text
647
+ #
648
+ NEEDS_BINMODE: bool
649
+
650
+ # <!-- rdoc-file=lib/cgi/core.rb -->
651
+ # Path separators in different environments.
652
+ #
653
+ PATH_SEPARATOR: Hash[String, String]
654
+
655
+ REVISION: String
656
+
657
+ VERSION: String
658
+
659
+ # <!-- rdoc-file=lib/cgi/cookie.rb -->
660
+ # Class representing an HTTP cookie.
661
+ #
662
+ # In addition to its specific fields and methods, a Cookie instance is a
663
+ # delegator to the array of its values.
664
+ #
665
+ # See RFC 2965.
666
+ #
667
+ # ## Examples of use
668
+ # cookie1 = CGI::Cookie.new("name", "value1", "value2", ...)
669
+ # cookie1 = CGI::Cookie.new("name" => "name", "value" => "value")
670
+ # cookie1 = CGI::Cookie.new('name' => 'name',
671
+ # 'value' => ['value1', 'value2', ...],
672
+ # 'path' => 'path', # optional
673
+ # 'domain' => 'domain', # optional
674
+ # 'expires' => Time.now, # optional
675
+ # 'secure' => true, # optional
676
+ # 'httponly' => true # optional
677
+ # )
678
+ #
679
+ # cgi.out("cookie" => [cookie1, cookie2]) { "string" }
680
+ #
681
+ # name = cookie1.name
682
+ # values = cookie1.value
683
+ # path = cookie1.path
684
+ # domain = cookie1.domain
685
+ # expires = cookie1.expires
686
+ # secure = cookie1.secure
687
+ # httponly = cookie1.httponly
688
+ #
689
+ # cookie1.name = 'name'
690
+ # cookie1.value = ['value1', 'value2', ...]
691
+ # cookie1.path = 'path'
692
+ # cookie1.domain = 'domain'
693
+ # cookie1.expires = Time.now + 30
694
+ # cookie1.secure = true
695
+ # cookie1.httponly = true
696
+ #
697
+ class Cookie < Array[String]
698
+ # <!--
699
+ # rdoc-file=lib/cgi/cookie.rb
700
+ # - parse(raw_cookie)
701
+ # -->
702
+ # Parse a raw cookie string into a hash of cookie-name=>Cookie pairs.
703
+ #
704
+ # cookies = CGI::Cookie.parse("raw_cookie_string")
705
+ # # { "name1" => cookie1, "name2" => cookie2, ... }
706
+ #
707
+ def self.parse: (String raw_cookie) -> Hash[String, instance]
708
+
709
+ public
710
+
711
+ # <!-- rdoc-file=lib/cgi/cookie.rb -->
712
+ # Domain for which this cookie applies, as a `String`
713
+ #
714
+ def domain: () -> String?
715
+
716
+ # <!-- rdoc-file=lib/cgi/cookie.rb -->
717
+ # Domain for which this cookie applies, as a `String`
718
+ #
719
+ def domain=: (String domain) -> String
720
+
721
+ # <!-- rdoc-file=lib/cgi/cookie.rb -->
722
+ # Time at which this cookie expires, as a `Time`
723
+ #
724
+ def expires: () -> Time?
725
+
726
+ # <!-- rdoc-file=lib/cgi/cookie.rb -->
727
+ # Time at which this cookie expires, as a `Time`
728
+ #
729
+ def expires=: (Time time) -> Time
730
+
731
+ # <!-- rdoc-file=lib/cgi/cookie.rb -->
732
+ # True if this cookie is httponly; false otherwise
733
+ #
734
+ def httponly: () -> bool
735
+
736
+ # <!--
737
+ # rdoc-file=lib/cgi/cookie.rb
738
+ # - httponly=(val)
739
+ # -->
740
+ # Set whether the Cookie is a httponly cookie or not.
741
+ #
742
+ # `val` must be a boolean.
743
+ #
744
+ def httponly=: (boolish val) -> bool
745
+
746
+ # <!--
747
+ # rdoc-file=lib/cgi/cookie.rb
748
+ # - inspect()
749
+ # -->
750
+ # A summary of cookie string.
751
+ #
752
+ def inspect: () -> String
753
+
754
+ # <!-- rdoc-file=lib/cgi/cookie.rb -->
755
+ # Name of this cookie, as a `String`
756
+ #
757
+ def name: () -> String
758
+
759
+ # <!-- rdoc-file=lib/cgi/cookie.rb -->
760
+ # Name of this cookie, as a `String`
761
+ #
762
+ def name=: (String name) -> String
763
+
764
+ # <!-- rdoc-file=lib/cgi/cookie.rb -->
765
+ # Path for which this cookie applies, as a `String`
766
+ #
767
+ def path: () -> String?
768
+
769
+ # <!-- rdoc-file=lib/cgi/cookie.rb -->
770
+ # Path for which this cookie applies, as a `String`
771
+ #
772
+ def path=: (String path) -> String
773
+
774
+ # <!-- rdoc-file=lib/cgi/cookie.rb -->
775
+ # True if this cookie is secure; false otherwise
776
+ #
777
+ def secure: () -> bool
778
+
779
+ # <!--
780
+ # rdoc-file=lib/cgi/cookie.rb
781
+ # - secure=(val)
782
+ # -->
783
+ # Set whether the Cookie is a secure cookie or not.
784
+ #
785
+ # `val` must be a boolean.
786
+ #
787
+ def secure=: [A] (boolish val) -> A
788
+
789
+ # <!--
790
+ # rdoc-file=lib/cgi/cookie.rb
791
+ # - to_s()
792
+ # -->
793
+ # Convert the Cookie to its string representation.
794
+ #
795
+ def to_s: () -> String
796
+
797
+ # <!--
798
+ # rdoc-file=lib/cgi/cookie.rb
799
+ # - value()
800
+ # -->
801
+ # Returns the value or list of values for this cookie.
802
+ #
803
+ def value: () -> Array[String]
804
+
805
+ # <!--
806
+ # rdoc-file=lib/cgi/cookie.rb
807
+ # - value=(val)
808
+ # -->
809
+ # Replaces the value of this cookie with a new value or list of values.
810
+ #
811
+ def value=: (String val) -> String
812
+ | (Array[String] val) -> Array[String]
813
+
814
+ private
815
+
816
+ # <!--
817
+ # rdoc-file=lib/cgi/cookie.rb
818
+ # - Cookie.new(name_string,*value)
819
+ # - Cookie.new(options_hash)
820
+ # -->
821
+ # Create a new CGI::Cookie object.
822
+ #
823
+ # `name_string`
824
+ # : The name of the cookie; in this form, there is no #domain or #expiration.
825
+ # The #path is gleaned from the `SCRIPT_NAME` environment variable, and
826
+ # #secure is false.
827
+ # `*value`
828
+ # : value or list of values of the cookie
829
+ # `options_hash`
830
+ # : A Hash of options to initialize this Cookie. Possible options are:
831
+ #
832
+ # name
833
+ # : the name of the cookie. Required.
834
+ # value
835
+ # : the cookie's value or list of values.
836
+ # path
837
+ # : the path for which this cookie applies. Defaults to the value of the
838
+ # `SCRIPT_NAME` environment variable.
839
+ # domain
840
+ # : the domain for which this cookie applies.
841
+ # expires
842
+ # : the time at which this cookie expires, as a `Time` object.
843
+ # secure
844
+ # : whether this cookie is a secure cookie or not (default to false).
845
+ # Secure cookies are only transmitted to HTTPS servers.
846
+ # httponly
847
+ # : whether this cookie is a HttpOnly cookie or not (default to
848
+ #
849
+ # false). HttpOnly cookies are not available to javascript.
850
+ #
851
+ # These keywords correspond to attributes of the cookie object.
852
+ #
853
+ def initialize: (String name_string, *String value) -> void
854
+ | (Hash[String, untyped] options_hash) -> void
855
+ end
856
+
857
+ module Escape
858
+ public
859
+
860
+ # <!--
861
+ # rdoc-file=ext/cgi/escape/escape.c
862
+ # - CGI.escape(string) -> string
863
+ # -->
864
+ # Returns URL-escaped string.
865
+ #
866
+ def escape: (string str) -> String
867
+
868
+ # <!--
869
+ # rdoc-file=ext/cgi/escape/escape.c
870
+ # - CGI.escapeHTML(string) -> string
871
+ # -->
872
+ # Returns HTML-escaped string.
873
+ #
874
+ def escapeHTML: (string str) -> String
875
+
876
+ # <!--
877
+ # rdoc-file=ext/cgi/escape/escape.c
878
+ # - CGI.unescape(string, encoding=@@accept_charset) -> string
879
+ # -->
880
+ # Returns URL-unescaped string.
881
+ #
882
+ def unescape: (string str, ?encoding encoding) -> String
883
+
884
+ # <!--
885
+ # rdoc-file=ext/cgi/escape/escape.c
886
+ # - CGI.unescapeHTML(string) -> string
887
+ # -->
888
+ # Returns HTML-unescaped string.
889
+ #
890
+ def unescapeHTML: (string str) -> String
891
+ end
892
+
893
+ # <!-- rdoc-file=lib/cgi/core.rb -->
894
+ # Exception raised when there is an invalid encoding detected
895
+ #
896
+ class InvalidEncoding < Exception
897
+ end
898
+
899
+ # <!-- rdoc-file=lib/cgi/core.rb -->
900
+ # Mixin module that provides the following:
901
+ #
902
+ # 1. Access to the CGI environment variables as methods. See documentation to
903
+ # the CGI class for a list of these variables. The methods are exposed by
904
+ # removing the leading `HTTP_` (if it exists) and downcasing the name. For
905
+ # example, `auth_type` will return the environment variable `AUTH_TYPE`, and
906
+ # `accept` will return the value for `HTTP_ACCEPT`.
907
+ #
908
+ # 2. Access to cookies, including the cookies attribute.
909
+ #
910
+ # 3. Access to parameters, including the params attribute, and overloading #[]
911
+ # to perform parameter value lookup by key.
912
+ #
913
+ # 4. The initialize_query method, for initializing the above mechanisms,
914
+ # handling multipart forms, and allowing the class to be used in "offline"
915
+ # mode.
916
+ #
917
+ module QueryExtension
918
+ public
919
+
920
+ # <!--
921
+ # rdoc-file=lib/cgi/core.rb
922
+ # - [](key)
923
+ # -->
924
+ # Get the value for the parameter with a given key.
925
+ #
926
+ # If the parameter has multiple values, only the first will be retrieved; use
927
+ # #params to get the array of values.
928
+ #
929
+ def []: (String key) -> String?
930
+
931
+ def accept: () -> String?
932
+
933
+ def accept_charset: () -> String?
934
+
935
+ def accept_encoding: () -> String?
936
+
937
+ def accept_language: () -> String?
938
+
939
+ def auth_type: () -> String?
940
+
941
+ def cache_control: () -> String?
942
+
943
+ def content_length: () -> String?
944
+
945
+ def content_type: () -> String?
946
+
947
+ # <!-- rdoc-file=lib/cgi/core.rb -->
948
+ # Get the cookies as a hash of cookie-name=>Cookie pairs.
949
+ #
950
+ def cookies: () -> Hash[String, Cookie]
951
+
952
+ # <!-- rdoc-file=lib/cgi/core.rb -->
953
+ # Get the cookies as a hash of cookie-name=>Cookie pairs.
954
+ #
955
+ def cookies=: (Hash[String, Cookie] cookies) -> Hash[String, Cookie]
956
+
957
+ def create_body: (boolish is_large) -> (Tempfile | StringIO)
958
+
959
+ # <!-- rdoc-file=lib/cgi/core.rb -->
960
+ # Get the uploaded files as a hash of name=>values pairs
961
+ #
962
+ def files: () -> Hash[String, Tempfile | StringIO]
963
+
964
+ def from: () -> String?
965
+
966
+ def gateway_interface: () -> String?
967
+
968
+ # <!--
969
+ # rdoc-file=lib/cgi/core.rb
970
+ # - has_key?(*args)
971
+ # -->
972
+ # Returns true if a given query string parameter exists.
973
+ #
974
+ def has_key?: (String key) -> bool
975
+
976
+ def host: () -> String?
977
+
978
+ # <!--
979
+ # rdoc-file=lib/cgi/core.rb
980
+ # - include?(*args)
981
+ # -->
982
+ #
983
+ alias include? has_key?
984
+
985
+ # <!--
986
+ # rdoc-file=lib/cgi/core.rb
987
+ # - key?(*args)
988
+ # -->
989
+ #
990
+ alias key? has_key?
991
+
992
+ # <!--
993
+ # rdoc-file=lib/cgi/core.rb
994
+ # - keys(*args)
995
+ # -->
996
+ # Return all query parameter names as an array of String.
997
+ #
998
+ def keys: () -> Array[String]
999
+
1000
+ # <!--
1001
+ # rdoc-file=lib/cgi/core.rb
1002
+ # - multipart?()
1003
+ # -->
1004
+ # Returns whether the form contained multipart/form-data
1005
+ #
1006
+ def multipart?: () -> bool
1007
+
1008
+ def negotiate: () -> String?
1009
+
1010
+ # <!-- rdoc-file=lib/cgi/core.rb -->
1011
+ # Get the parameters as a hash of name=>values pairs, where values is an Array.
1012
+ #
1013
+ def params: () -> Hash[String, Array[String] | Tempfile | StringIO]
1014
+
1015
+ # <!--
1016
+ # rdoc-file=lib/cgi/core.rb
1017
+ # - params=(hash)
1018
+ # -->
1019
+ # Set all the parameters.
1020
+ #
1021
+ def params=: (Hash[String, Array[String] | Tempfile | StringIO] hash) -> Hash[String, Array[String] | Tempfile | StringIO]
1022
+
1023
+ def path_info: () -> String?
574
1024
 
575
- # Standard internet newline sequence
576
- CGI::EOL: String
1025
+ def path_translated: () -> String?
577
1026
 
578
- # HTTP status codes.
579
- CGI::HTTP_STATUS: Hash[String, String]
1027
+ def pragma: () -> String?
580
1028
 
581
- # String for linefeed
582
- CGI::LF: String
1029
+ def query_string: () -> String?
583
1030
 
584
- # Maximum number of request parameters when multipart
585
- CGI::MAX_MULTIPART_COUNT: Integer
1031
+ # <!--
1032
+ # rdoc-file=lib/cgi/core.rb
1033
+ # - raw_cookie()
1034
+ # -->
1035
+ # Get the raw cookies as a string.
1036
+ #
1037
+ def raw_cookie: () -> String?
586
1038
 
587
- # Whether processing will be required in binary vs text
588
- CGI::NEEDS_BINMODE: bool
1039
+ # <!--
1040
+ # rdoc-file=lib/cgi/core.rb
1041
+ # - raw_cookie2()
1042
+ # -->
1043
+ # Get the raw RFC2965 cookies as a string.
1044
+ #
1045
+ def raw_cookie2: () -> String?
589
1046
 
590
- # Path separators in different environments.
591
- CGI::PATH_SEPARATOR: Hash[String, String]
1047
+ def referer: () -> String?
592
1048
 
593
- CGI::REVISION: String
1049
+ def remote_addr: () -> String?
594
1050
 
595
- CGI::VERSION: String
1051
+ def remote_host: () -> String?
1052
+
1053
+ def remote_ident: () -> String?
1054
+
1055
+ def remote_user: () -> String?
1056
+
1057
+ def request_method: () -> String?
1058
+
1059
+ def script_name: () -> String?
1060
+
1061
+ def server_name: () -> String?
1062
+
1063
+ def server_port: () -> String?
1064
+
1065
+ def server_protocol: () -> String?
1066
+
1067
+ def server_software: () -> String?
1068
+
1069
+ def unescape_filename?: () -> bool
1070
+
1071
+ def user_agent: () -> String?
1072
+
1073
+ private
1074
+
1075
+ # <!--
1076
+ # rdoc-file=lib/cgi/core.rb
1077
+ # - initialize_query()
1078
+ # -->
1079
+ # A wrapper class to use a StringIO object as the body and switch to a TempFile
1080
+ # when the passed threshold is passed. Initialize the data from the query.
1081
+ #
1082
+ # Handles multipart forms (in particular, forms that involve file uploads).
1083
+ # Reads query parameters in the @params field, and cookies into @cookies.
1084
+ #
1085
+ def initialize_query: () -> void
1086
+
1087
+ # <!--
1088
+ # rdoc-file=lib/cgi/core.rb
1089
+ # - read_from_cmdline()
1090
+ # -->
1091
+ # offline mode. read name=value pairs on standard input.
1092
+ #
1093
+ def read_from_cmdline: () -> String
1094
+
1095
+ # <!--
1096
+ # rdoc-file=lib/cgi/core.rb
1097
+ # - read_multipart(boundary, content_length)
1098
+ # -->
1099
+ # Parses multipart form elements according to
1100
+ # http://www.w3.org/TR/html401/interact/forms.html#h-17.13.4.2
1101
+ #
1102
+ # Returns a hash of multipart form parameters with bodies of type StringIO or
1103
+ # Tempfile depending on whether the multipart form element exceeds 10 KB
1104
+ #
1105
+ # params[name => body]
1106
+ #
1107
+ def read_multipart: (String boundary, Integer content_length) -> (Tempfile | StringIO)
1108
+ end
1109
+
1110
+ module Util
1111
+ include CGI::Escape
1112
+
1113
+ public
1114
+
1115
+ # <!--
1116
+ # rdoc-file=lib/cgi/util.rb
1117
+ # - escapeElement(string, *elements)
1118
+ # -->
1119
+ # Escape only the tags of certain HTML elements in `string`.
1120
+ #
1121
+ # Takes an element or elements or array of elements. Each element is specified
1122
+ # by the name of the element, without angle brackets. This matches both the
1123
+ # start and the end tag of that element. The attribute list of the open tag will
1124
+ # also be escaped (for instance, the double-quotes surrounding attribute
1125
+ # values).
1126
+ #
1127
+ # print CGI.escapeElement('<BR><A HREF="url"></A>', "A", "IMG")
1128
+ # # "<BR>&lt;A HREF=&quot;url&quot;&gt;&lt;/A&gt"
1129
+ #
1130
+ # print CGI.escapeElement('<BR><A HREF="url"></A>', ["A", "IMG"])
1131
+ # # "<BR>&lt;A HREF=&quot;url&quot;&gt;&lt;/A&gt"
1132
+ #
1133
+ def escapeElement: (string string, *String | Array[String] elements) -> String
1134
+
1135
+ # <!-- rdoc-file=lib/cgi/util.rb -->
1136
+ # Synonym for CGI.escapeElement(str)
1137
+ #
1138
+ alias escape_element escapeElement
1139
+
1140
+ # <!-- rdoc-file=lib/cgi/util.rb -->
1141
+ # Synonym for CGI.escapeHTML(str)
1142
+ #
1143
+ alias escape_html escapeHTML
1144
+
1145
+ # <!--
1146
+ # rdoc-file=lib/cgi/util.rb
1147
+ # - h(string)
1148
+ # -->
1149
+ #
1150
+ alias h escapeHTML
1151
+
1152
+ # <!--
1153
+ # rdoc-file=lib/cgi/util.rb
1154
+ # - pretty(string, shift = " ")
1155
+ # -->
1156
+ # Prettify (indent) an HTML string.
1157
+ #
1158
+ # `string` is the HTML string to indent. `shift` is the indentation unit to
1159
+ # use; it defaults to two spaces.
1160
+ #
1161
+ # print CGI.pretty("<HTML><BODY></BODY></HTML>")
1162
+ # # <HTML>
1163
+ # # <BODY>
1164
+ # # </BODY>
1165
+ # # </HTML>
1166
+ #
1167
+ # print CGI.pretty("<HTML><BODY></BODY></HTML>", "\t")
1168
+ # # <HTML>
1169
+ # # <BODY>
1170
+ # # </BODY>
1171
+ # # </HTML>
1172
+ #
1173
+ def pretty: (string string, ?String shift) -> String
1174
+
1175
+ # <!--
1176
+ # rdoc-file=lib/cgi/util.rb
1177
+ # - rfc1123_date(time)
1178
+ # -->
1179
+ # Format a `Time` object as a String using the format specified by RFC 1123.
1180
+ #
1181
+ # CGI.rfc1123_date(Time.now)
1182
+ # # Sat, 01 Jan 2000 00:00:00 GMT
1183
+ #
1184
+ def rfc1123_date: (Time time) -> String
1185
+
1186
+ # <!--
1187
+ # rdoc-file=lib/cgi/util.rb
1188
+ # - unescapeElement(string, *elements)
1189
+ # -->
1190
+ # Undo escaping such as that done by CGI.escapeElement()
1191
+ #
1192
+ # print CGI.unescapeElement(
1193
+ # CGI.escapeHTML('<BR><A HREF="url"></A>'), "A", "IMG")
1194
+ # # "&lt;BR&gt;<A HREF="url"></A>"
1195
+ #
1196
+ # print CGI.unescapeElement(
1197
+ # CGI.escapeHTML('<BR><A HREF="url"></A>'), ["A", "IMG"])
1198
+ # # "&lt;BR&gt;<A HREF="url"></A>"
1199
+ #
1200
+ def unescapeElement: (string string, *String | Array[String] elements) -> String
1201
+
1202
+ # <!-- rdoc-file=lib/cgi/util.rb -->
1203
+ # Synonym for CGI.unescapeElement(str)
1204
+ #
1205
+ alias unescape_element unescapeElement
1206
+
1207
+ # <!-- rdoc-file=lib/cgi/util.rb -->
1208
+ # Synonym for CGI.unescapeHTML(str)
1209
+ #
1210
+ alias unescape_html unescapeHTML
1211
+
1212
+ # Abbreviated day-of-week names specified by RFC 822
1213
+ RFC822_DAYS: Array[String]
1214
+
1215
+ # Abbreviated month names specified by RFC 822
1216
+ RFC822_MONTHS: Array[String]
1217
+
1218
+ # <!-- rdoc-file=lib/cgi/util.rb -->
1219
+ # The set of special characters and their escaped values
1220
+ #
1221
+ TABLE_FOR_ESCAPE_HTML__: Hash[String, String]
1222
+ end
1223
+ end