rbs 4.0.0.dev.4 → 4.0.0.dev.5

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 (223) hide show
  1. checksums.yaml +4 -4
  2. data/.github/dependabot.yml +14 -14
  3. data/.github/workflows/bundle-update.yml +60 -0
  4. data/.github/workflows/c-check.yml +11 -8
  5. data/.github/workflows/comments.yml +3 -3
  6. data/.github/workflows/dependabot.yml +1 -1
  7. data/.github/workflows/ruby.yml +17 -34
  8. data/.github/workflows/typecheck.yml +2 -2
  9. data/.github/workflows/valgrind.yml +42 -0
  10. data/.github/workflows/windows.yml +2 -2
  11. data/.rubocop.yml +1 -1
  12. data/README.md +1 -1
  13. data/Rakefile +32 -5
  14. data/config.yml +46 -0
  15. data/core/array.rbs +96 -46
  16. data/core/binding.rbs +0 -2
  17. data/core/builtin.rbs +2 -2
  18. data/core/comparable.rbs +13 -6
  19. data/core/complex.rbs +55 -41
  20. data/core/dir.rbs +4 -4
  21. data/core/encoding.rbs +7 -10
  22. data/core/enumerable.rbs +90 -3
  23. data/core/enumerator/arithmetic_sequence.rbs +70 -0
  24. data/core/enumerator.rbs +63 -1
  25. data/core/errno.rbs +8 -0
  26. data/core/errors.rbs +28 -1
  27. data/core/exception.rbs +2 -2
  28. data/core/fiber.rbs +40 -20
  29. data/core/file.rbs +108 -78
  30. data/core/file_test.rbs +1 -1
  31. data/core/float.rbs +225 -69
  32. data/core/gc.rbs +417 -281
  33. data/core/hash.rbs +1023 -727
  34. data/core/integer.rbs +104 -110
  35. data/core/io/buffer.rbs +21 -10
  36. data/core/io/wait.rbs +11 -33
  37. data/core/io.rbs +82 -19
  38. data/core/kernel.rbs +70 -59
  39. data/core/marshal.rbs +1 -1
  40. data/core/match_data.rbs +1 -1
  41. data/core/math.rbs +42 -3
  42. data/core/method.rbs +63 -27
  43. data/core/module.rbs +103 -26
  44. data/core/nil_class.rbs +3 -3
  45. data/core/numeric.rbs +43 -35
  46. data/core/object.rbs +3 -3
  47. data/core/object_space.rbs +21 -15
  48. data/core/pathname.rbs +1272 -0
  49. data/core/proc.rbs +30 -25
  50. data/core/process.rbs +4 -2
  51. data/core/ractor.rbs +361 -509
  52. data/core/random.rbs +17 -0
  53. data/core/range.rbs +113 -16
  54. data/core/rational.rbs +56 -85
  55. data/core/rbs/unnamed/argf.rbs +2 -2
  56. data/core/rbs/unnamed/env_class.rbs +1 -1
  57. data/core/rbs/unnamed/random.rbs +4 -113
  58. data/core/regexp.rbs +25 -20
  59. data/core/ruby.rbs +53 -0
  60. data/core/ruby_vm.rbs +6 -4
  61. data/core/rubygems/errors.rbs +3 -70
  62. data/core/rubygems/rubygems.rbs +11 -79
  63. data/core/rubygems/version.rbs +2 -3
  64. data/core/set.rbs +488 -359
  65. data/core/signal.rbs +24 -14
  66. data/core/string.rbs +3171 -1241
  67. data/core/struct.rbs +1 -1
  68. data/core/symbol.rbs +17 -11
  69. data/core/thread.rbs +95 -33
  70. data/core/time.rbs +35 -9
  71. data/core/trace_point.rbs +7 -4
  72. data/core/unbound_method.rbs +14 -6
  73. data/docs/aliases.md +79 -0
  74. data/docs/collection.md +2 -2
  75. data/docs/encoding.md +56 -0
  76. data/docs/gem.md +0 -1
  77. data/docs/inline.md +470 -0
  78. data/docs/sigs.md +3 -3
  79. data/docs/syntax.md +33 -4
  80. data/docs/type_fingerprint.md +21 -0
  81. data/exe/rbs +1 -1
  82. data/ext/rbs_extension/ast_translation.c +77 -3
  83. data/ext/rbs_extension/ast_translation.h +3 -0
  84. data/ext/rbs_extension/class_constants.c +8 -2
  85. data/ext/rbs_extension/class_constants.h +4 -0
  86. data/ext/rbs_extension/extconf.rb +5 -1
  87. data/ext/rbs_extension/legacy_location.c +5 -5
  88. data/ext/rbs_extension/main.c +37 -20
  89. data/include/rbs/ast.h +85 -38
  90. data/include/rbs/defines.h +27 -0
  91. data/include/rbs/lexer.h +30 -11
  92. data/include/rbs/parser.h +6 -6
  93. data/include/rbs/string.h +0 -2
  94. data/include/rbs/util/rbs_allocator.h +34 -13
  95. data/include/rbs/util/rbs_assert.h +12 -1
  96. data/include/rbs/util/rbs_encoding.h +2 -0
  97. data/include/rbs/util/rbs_unescape.h +2 -1
  98. data/lib/rbs/ast/annotation.rb +1 -1
  99. data/lib/rbs/ast/comment.rb +1 -1
  100. data/lib/rbs/ast/declarations.rb +10 -10
  101. data/lib/rbs/ast/members.rb +14 -14
  102. data/lib/rbs/ast/ruby/annotations.rb +137 -0
  103. data/lib/rbs/ast/ruby/comment_block.rb +24 -0
  104. data/lib/rbs/ast/ruby/declarations.rb +198 -3
  105. data/lib/rbs/ast/ruby/helpers/constant_helper.rb +4 -0
  106. data/lib/rbs/ast/ruby/members.rb +159 -1
  107. data/lib/rbs/ast/type_param.rb +24 -4
  108. data/lib/rbs/buffer.rb +20 -15
  109. data/lib/rbs/cli/diff.rb +16 -15
  110. data/lib/rbs/cli/validate.rb +38 -51
  111. data/lib/rbs/cli.rb +52 -19
  112. data/lib/rbs/collection/config/lockfile_generator.rb +8 -0
  113. data/lib/rbs/collection/sources/git.rb +1 -0
  114. data/lib/rbs/definition.rb +1 -1
  115. data/lib/rbs/definition_builder/ancestor_builder.rb +62 -9
  116. data/lib/rbs/definition_builder/method_builder.rb +20 -0
  117. data/lib/rbs/definition_builder.rb +91 -2
  118. data/lib/rbs/diff.rb +7 -1
  119. data/lib/rbs/environment.rb +227 -74
  120. data/lib/rbs/environment_loader.rb +0 -6
  121. data/lib/rbs/errors.rb +27 -7
  122. data/lib/rbs/inline_parser.rb +341 -5
  123. data/lib/rbs/location_aux.rb +1 -1
  124. data/lib/rbs/locator.rb +5 -1
  125. data/lib/rbs/method_type.rb +5 -3
  126. data/lib/rbs/parser_aux.rb +2 -2
  127. data/lib/rbs/prototype/rb.rb +2 -2
  128. data/lib/rbs/prototype/rbi.rb +2 -0
  129. data/lib/rbs/prototype/runtime.rb +8 -0
  130. data/lib/rbs/resolver/constant_resolver.rb +2 -2
  131. data/lib/rbs/resolver/type_name_resolver.rb +116 -38
  132. data/lib/rbs/subtractor.rb +3 -1
  133. data/lib/rbs/test/type_check.rb +16 -2
  134. data/lib/rbs/type_name.rb +1 -1
  135. data/lib/rbs/types.rb +27 -27
  136. data/lib/rbs/validator.rb +2 -2
  137. data/lib/rbs/version.rb +1 -1
  138. data/lib/rbs.rb +1 -1
  139. data/lib/rdoc/discover.rb +1 -1
  140. data/lib/rdoc_plugin/parser.rb +1 -1
  141. data/rbs.gemspec +3 -2
  142. data/schema/typeParam.json +17 -1
  143. data/sig/ast/ruby/annotations.rbs +124 -0
  144. data/sig/ast/ruby/comment_block.rbs +8 -0
  145. data/sig/ast/ruby/declarations.rbs +102 -4
  146. data/sig/ast/ruby/members.rbs +87 -1
  147. data/sig/cli/diff.rbs +5 -11
  148. data/sig/cli/validate.rbs +13 -4
  149. data/sig/cli.rbs +18 -18
  150. data/sig/definition.rbs +6 -1
  151. data/sig/environment.rbs +70 -12
  152. data/sig/errors.rbs +13 -6
  153. data/sig/inline_parser.rbs +39 -2
  154. data/sig/locator.rbs +0 -2
  155. data/sig/manifest.yaml +0 -1
  156. data/sig/method_builder.rbs +3 -1
  157. data/sig/method_types.rbs +1 -1
  158. data/sig/parser.rbs +16 -2
  159. data/sig/resolver/type_name_resolver.rbs +35 -7
  160. data/sig/source.rbs +3 -3
  161. data/sig/type_param.rbs +13 -8
  162. data/sig/types.rbs +4 -4
  163. data/src/ast.c +80 -1
  164. data/src/lexer.c +1392 -1313
  165. data/src/lexer.re +3 -0
  166. data/src/lexstate.c +58 -37
  167. data/src/location.c +4 -4
  168. data/src/parser.c +412 -145
  169. data/src/string.c +0 -48
  170. data/src/util/rbs_allocator.c +89 -71
  171. data/src/util/rbs_assert.c +1 -1
  172. data/src/util/rbs_buffer.c +2 -2
  173. data/src/util/rbs_constant_pool.c +10 -10
  174. data/src/util/rbs_encoding.c +4 -8
  175. data/src/util/rbs_unescape.c +56 -20
  176. data/stdlib/bigdecimal/0/big_decimal.rbs +100 -82
  177. data/stdlib/bigdecimal-math/0/big_math.rbs +169 -8
  178. data/stdlib/cgi/0/core.rbs +9 -393
  179. data/stdlib/cgi/0/manifest.yaml +1 -0
  180. data/stdlib/cgi-escape/0/escape.rbs +171 -0
  181. data/stdlib/coverage/0/coverage.rbs +3 -1
  182. data/stdlib/date/0/date.rbs +67 -59
  183. data/stdlib/date/0/date_time.rbs +1 -1
  184. data/stdlib/delegate/0/delegator.rbs +10 -7
  185. data/stdlib/digest/0/digest.rbs +110 -0
  186. data/stdlib/erb/0/erb.rbs +737 -347
  187. data/stdlib/fileutils/0/fileutils.rbs +20 -14
  188. data/stdlib/forwardable/0/forwardable.rbs +3 -0
  189. data/stdlib/json/0/json.rbs +82 -28
  190. data/stdlib/net-http/0/net-http.rbs +3 -0
  191. data/stdlib/objspace/0/objspace.rbs +9 -27
  192. data/stdlib/open-uri/0/open-uri.rbs +40 -0
  193. data/stdlib/open3/0/open3.rbs +459 -1
  194. data/stdlib/openssl/0/openssl.rbs +331 -228
  195. data/stdlib/optparse/0/optparse.rbs +8 -3
  196. data/stdlib/pathname/0/pathname.rbs +9 -1379
  197. data/stdlib/psych/0/psych.rbs +4 -4
  198. data/stdlib/random-formatter/0/random-formatter.rbs +277 -0
  199. data/stdlib/rdoc/0/code_object.rbs +2 -1
  200. data/stdlib/rdoc/0/parser.rbs +1 -1
  201. data/stdlib/rdoc/0/rdoc.rbs +1 -1
  202. data/stdlib/rdoc/0/store.rbs +1 -1
  203. data/stdlib/resolv/0/resolv.rbs +25 -68
  204. data/stdlib/ripper/0/ripper.rbs +2 -2
  205. data/stdlib/securerandom/0/manifest.yaml +2 -0
  206. data/stdlib/securerandom/0/securerandom.rbs +6 -19
  207. data/stdlib/singleton/0/singleton.rbs +3 -0
  208. data/stdlib/socket/0/socket.rbs +13 -1
  209. data/stdlib/socket/0/tcp_socket.rbs +10 -2
  210. data/stdlib/stringio/0/stringio.rbs +1176 -85
  211. data/stdlib/strscan/0/string_scanner.rbs +31 -31
  212. data/stdlib/tempfile/0/tempfile.rbs +3 -3
  213. data/stdlib/time/0/time.rbs +1 -1
  214. data/stdlib/timeout/0/timeout.rbs +63 -7
  215. data/stdlib/tsort/0/cyclic.rbs +3 -0
  216. data/stdlib/uri/0/common.rbs +16 -2
  217. data/stdlib/uri/0/file.rbs +1 -1
  218. data/stdlib/uri/0/generic.rbs +24 -16
  219. data/stdlib/uri/0/rfc2396_parser.rbs +6 -7
  220. data/stdlib/zlib/0/gzip_reader.rbs +2 -2
  221. data/stdlib/zlib/0/gzip_writer.rbs +1 -1
  222. data/stdlib/zlib/0/zstream.rbs +1 -0
  223. metadata +30 -4
@@ -1,274 +1,15 @@
1
- # <!-- rdoc-file=lib/cgi.rb -->
2
- # ## Overview
1
+ # <!-- rdoc-file=lib/cgi/escape.rb -->
2
+ # Since Ruby 4.0, CGI is a small holder for various escaping methods, included
3
+ # from CGI::Escape
3
4
  #
4
- # The Common Gateway Interface (CGI) is a simple protocol for passing an HTTP
5
- # request from a web server to a standalone program, and returning the output to
6
- # the web browser. Basically, a CGI program is called with the parameters of
7
- # the request passed in either in the environment (GET) or via $stdin (POST),
8
- # and everything it prints to $stdout is returned to the client.
5
+ # require 'cgi/escape'
9
6
  #
10
- # This file holds the CGI class. This class provides functionality for
11
- # retrieving HTTP request parameters, managing cookies, and generating HTML
12
- # output.
7
+ # CGI.escape("Ruby programming language")
8
+ # #=> "Ruby+programming+language"
9
+ # CGI.escapeURIComponent("Ruby programming language")
10
+ # #=> "Ruby%20programming%20language"
13
11
  #
14
- # The file CGI::Session provides session management functionality; see that
15
- # class for more details.
16
- #
17
- # See http://www.w3.org/CGI/ for more information on the CGI protocol.
18
- #
19
- # ## Introduction
20
- #
21
- # CGI is a large class, providing several categories of methods, many of which
22
- # are mixed in from other modules. Some of the documentation is in this class,
23
- # some in the modules CGI::QueryExtension and CGI::HtmlExtension. See
24
- # CGI::Cookie for specific information on handling cookies, and cgi/session.rb
25
- # (CGI::Session) for information on sessions.
26
- #
27
- # For queries, CGI provides methods to get at environmental variables,
28
- # parameters, cookies, and multipart request data. For responses, CGI provides
29
- # methods for writing output and generating HTML.
30
- #
31
- # Read on for more details. Examples are provided at the bottom.
32
- #
33
- # ## Queries
34
- #
35
- # The CGI class dynamically mixes in parameter and cookie-parsing functionality,
36
- # environmental variable access, and support for parsing multipart requests
37
- # (including uploaded files) from the CGI::QueryExtension module.
38
- #
39
- # ### Environmental Variables
40
- #
41
- # The standard CGI environmental variables are available as read-only attributes
42
- # of a CGI object. The following is a list of these variables:
43
- #
44
- # AUTH_TYPE HTTP_HOST REMOTE_IDENT
45
- # CONTENT_LENGTH HTTP_NEGOTIATE REMOTE_USER
46
- # CONTENT_TYPE HTTP_PRAGMA REQUEST_METHOD
47
- # GATEWAY_INTERFACE HTTP_REFERER SCRIPT_NAME
48
- # HTTP_ACCEPT HTTP_USER_AGENT SERVER_NAME
49
- # HTTP_ACCEPT_CHARSET PATH_INFO SERVER_PORT
50
- # HTTP_ACCEPT_ENCODING PATH_TRANSLATED SERVER_PROTOCOL
51
- # HTTP_ACCEPT_LANGUAGE QUERY_STRING SERVER_SOFTWARE
52
- # HTTP_CACHE_CONTROL REMOTE_ADDR
53
- # HTTP_FROM REMOTE_HOST
54
- #
55
- # For each of these variables, there is a corresponding attribute with the same
56
- # name, except all lower case and without a preceding HTTP_. `content_length`
57
- # and `server_port` are integers; the rest are strings.
58
- #
59
- # ### Parameters
60
- #
61
- # The method #params() returns a hash of all parameters in the request as
62
- # name/value-list pairs, where the value-list is an Array of one or more values.
63
- # The CGI object itself also behaves as a hash of parameter names to values,
64
- # but only returns a single value (as a String) for each parameter name.
65
- #
66
- # For instance, suppose the request contains the parameter "favourite_colours"
67
- # with the multiple values "blue" and "green". The following behavior would
68
- # occur:
69
- #
70
- # cgi.params["favourite_colours"] # => ["blue", "green"]
71
- # cgi["favourite_colours"] # => "blue"
72
- #
73
- # If a parameter does not exist, the former method will return an empty array,
74
- # the latter an empty string. The simplest way to test for existence of a
75
- # parameter is by the #has_key? method.
76
- #
77
- # ### Cookies
78
- #
79
- # HTTP Cookies are automatically parsed from the request. They are available
80
- # from the #cookies() accessor, which returns a hash from cookie name to
81
- # CGI::Cookie object.
82
- #
83
- # ### Multipart requests
84
- #
85
- # If a request's method is POST and its content type is multipart/form-data,
86
- # then it may contain uploaded files. These are stored by the QueryExtension
87
- # module in the parameters of the request. The parameter name is the name
88
- # attribute of the file input field, as usual. However, the value is not a
89
- # string, but an IO object, either an IOString for small files, or a Tempfile
90
- # for larger ones. This object also has the additional singleton methods:
91
- #
92
- # #local_path()
93
- # : the path of the uploaded file on the local filesystem
94
- #
95
- # #original_filename()
96
- # : the name of the file on the client computer
97
- #
98
- # #content_type()
99
- # : the content type of the file
100
- #
101
- #
102
- # ## Responses
103
- #
104
- # The CGI class provides methods for sending header and content output to the
105
- # HTTP client, and mixes in methods for programmatic HTML generation from
106
- # CGI::HtmlExtension and CGI::TagMaker modules. The precise version of HTML to
107
- # use for HTML generation is specified at object creation time.
108
- #
109
- # ### Writing output
110
- #
111
- # The simplest way to send output to the HTTP client is using the #out() method.
112
- # This takes the HTTP headers as a hash parameter, and the body content via a
113
- # block. The headers can be generated as a string using the #http_header()
114
- # method. The output stream can be written directly to using the #print()
115
- # method.
116
- #
117
- # ### Generating HTML
118
- #
119
- # Each HTML element has a corresponding method for generating that element as a
120
- # String. The name of this method is the same as that of the element, all
121
- # lowercase. The attributes of the element are passed in as a hash, and the
122
- # body as a no-argument block that evaluates to a String. The HTML generation
123
- # module knows which elements are always empty, and silently drops any passed-in
124
- # body. It also knows which elements require matching closing tags and which
125
- # don't. However, it does not know what attributes are legal for which
126
- # elements.
127
- #
128
- # There are also some additional HTML generation methods mixed in from the
129
- # CGI::HtmlExtension module. These include individual methods for the different
130
- # types of form inputs, and methods for elements that commonly take particular
131
- # attributes where the attributes can be directly specified as arguments, rather
132
- # than via a hash.
133
- #
134
- # ### Utility HTML escape and other methods like a function.
135
- #
136
- # There are some utility tool defined in cgi/util.rb . And when include, you can
137
- # use utility methods like a function.
138
- #
139
- # ## Examples of use
140
- #
141
- # ### Get form values
142
- #
143
- # require "cgi"
144
- # cgi = CGI.new
145
- # value = cgi['field_name'] # <== value string for 'field_name'
146
- # # if not 'field_name' included, then return "".
147
- # fields = cgi.keys # <== array of field names
148
- #
149
- # # returns true if form has 'field_name'
150
- # cgi.has_key?('field_name')
151
- # cgi.has_key?('field_name')
152
- # cgi.include?('field_name')
153
- #
154
- # CAUTION! `cgi['field_name']` returned an Array with the old cgi.rb(included in
155
- # Ruby 1.6)
156
- #
157
- # ### Get form values as hash
158
- #
159
- # require "cgi"
160
- # cgi = CGI.new
161
- # params = cgi.params
162
- #
163
- # cgi.params is a hash.
164
- #
165
- # cgi.params['new_field_name'] = ["value"] # add new param
166
- # cgi.params['field_name'] = ["new_value"] # change value
167
- # cgi.params.delete('field_name') # delete param
168
- # cgi.params.clear # delete all params
169
- #
170
- # ### Save form values to file
171
- #
172
- # require "pstore"
173
- # db = PStore.new("query.db")
174
- # db.transaction do
175
- # db["params"] = cgi.params
176
- # end
177
- #
178
- # ### Restore form values from file
179
- #
180
- # require "pstore"
181
- # db = PStore.new("query.db")
182
- # db.transaction do
183
- # cgi.params = db["params"]
184
- # end
185
- #
186
- # ### Get multipart form values
187
- #
188
- # require "cgi"
189
- # cgi = CGI.new
190
- # value = cgi['field_name'] # <== value string for 'field_name'
191
- # value.read # <== body of value
192
- # value.local_path # <== path to local file of value
193
- # value.original_filename # <== original filename of value
194
- # value.content_type # <== content_type of value
195
- #
196
- # and value has StringIO or Tempfile class methods.
197
- #
198
- # ### Get cookie values
199
- #
200
- # require "cgi"
201
- # cgi = CGI.new
202
- # values = cgi.cookies['name'] # <== array of 'name'
203
- # # if not 'name' included, then return [].
204
- # names = cgi.cookies.keys # <== array of cookie names
205
- #
206
- # and cgi.cookies is a hash.
207
- #
208
- # ### Get cookie objects
209
- #
210
- # require "cgi"
211
- # cgi = CGI.new
212
- # for name, cookie in cgi.cookies
213
- # cookie.expires = Time.now + 30
214
- # end
215
- # cgi.out("cookie" => cgi.cookies) {"string"}
216
- #
217
- # cgi.cookies # { "name1" => cookie1, "name2" => cookie2, ... }
218
- #
219
- # require "cgi"
220
- # cgi = CGI.new
221
- # cgi.cookies['name'].expires = Time.now + 30
222
- # cgi.out("cookie" => cgi.cookies['name']) {"string"}
223
- #
224
- # ### Print http header and html string to $DEFAULT_OUTPUT ($>)
225
- #
226
- # require "cgi"
227
- # cgi = CGI.new("html4") # add HTML generation methods
228
- # cgi.out do
229
- # cgi.html do
230
- # cgi.head do
231
- # cgi.title { "TITLE" }
232
- # end +
233
- # cgi.body do
234
- # cgi.form("ACTION" => "uri") do
235
- # cgi.p do
236
- # cgi.textarea("get_text") +
237
- # cgi.br +
238
- # cgi.submit
239
- # end
240
- # end +
241
- # cgi.pre do
242
- # CGI.escapeHTML(
243
- # "params: #{cgi.params.inspect}\n" +
244
- # "cookies: #{cgi.cookies.inspect}\n" +
245
- # ENV.collect do |key, value|
246
- # "#{key} --> #{value}\n"
247
- # end.join("")
248
- # )
249
- # end
250
- # end
251
- # end
252
- # end
253
- #
254
- # # add HTML generation methods
255
- # CGI.new("html3") # html3.2
256
- # CGI.new("html4") # html4.01 (Strict)
257
- # CGI.new("html4Tr") # html4.01 Transitional
258
- # CGI.new("html4Fr") # html4.01 Frameset
259
- # CGI.new("html5") # html5
260
- #
261
- # ### Some utility methods
262
- #
263
- # require 'cgi/util'
264
- # CGI.escapeHTML('Usage: foo "bar" <baz>')
265
- #
266
- # ### Some utility methods like a function
267
- #
268
- # require 'cgi/util'
269
- # include CGI::Util
270
- # escapeHTML('Usage: foo "bar" <baz>')
271
- # h('Usage: foo "bar" <baz>') # alias
12
+ # See CGI::Escape module for methods list and their description.
272
13
  #
273
14
  class CGI
274
15
  include CGI::Util
@@ -906,66 +647,6 @@ class CGI
906
647
  | (Hash[String, untyped] options_hash) -> void
907
648
  end
908
649
 
909
- module Escape
910
- # <!--
911
- # rdoc-file=ext/cgi/escape/escape.c
912
- # - CGI.escape(string) -> string
913
- # -->
914
- # Returns URL-escaped string (`application/x-www-form-urlencoded`).
915
- #
916
- def escape: (string str) -> String
917
-
918
- # <!--
919
- # rdoc-file=ext/cgi/escape/escape.c
920
- # - CGI.escapeHTML(string) -> string
921
- # -->
922
- # Returns HTML-escaped string.
923
- #
924
- def escapeHTML: (string str) -> String
925
-
926
- # <!--
927
- # rdoc-file=ext/cgi/escape/escape.c
928
- # - CGI.escapeURIComponent(string) -> string
929
- # -->
930
- # Returns URL-escaped string following RFC 3986.
931
- #
932
- def escapeURIComponent: (string) -> String
933
-
934
- # <!-- rdoc-file=ext/cgi/escape/escape.c -->
935
- # Returns URL-escaped string following RFC 3986.
936
- #
937
- alias escape_uri_component escapeURIComponent
938
-
939
- # <!--
940
- # rdoc-file=ext/cgi/escape/escape.c
941
- # - CGI.unescape(string, encoding=@@accept_charset) -> string
942
- # -->
943
- # Returns URL-unescaped string (`application/x-www-form-urlencoded`).
944
- #
945
- def unescape: (string str, ?encoding encoding) -> String
946
-
947
- # <!--
948
- # rdoc-file=ext/cgi/escape/escape.c
949
- # - CGI.unescapeHTML(string) -> string
950
- # -->
951
- # Returns HTML-unescaped string.
952
- #
953
- def unescapeHTML: (string str) -> String
954
-
955
- # <!--
956
- # rdoc-file=ext/cgi/escape/escape.c
957
- # - CGI.unescapeURIComponent(string, encoding=@@accept_charset) -> string
958
- # -->
959
- # Returns URL-unescaped string following RFC 3986.
960
- #
961
- def unescapeURIComponent: (string) -> String
962
-
963
- # <!-- rdoc-file=ext/cgi/escape/escape.c -->
964
- # Returns URL-unescaped string following RFC 3986.
965
- #
966
- alias unescape_uri_component unescapeURIComponent
967
- end
968
-
969
650
  # <!-- rdoc-file=lib/cgi/core.rb -->
970
651
  # Exception raised when there is an invalid encoding detected
971
652
  #
@@ -1182,45 +863,6 @@ class CGI
1182
863
  end
1183
864
 
1184
865
  module Util
1185
- include CGI::Escape
1186
-
1187
- # <!--
1188
- # rdoc-file=lib/cgi/util.rb
1189
- # - escapeElement(string, *elements)
1190
- # -->
1191
- # Escape only the tags of certain HTML elements in `string`.
1192
- #
1193
- # Takes an element or elements or array of elements. Each element is specified
1194
- # by the name of the element, without angle brackets. This matches both the
1195
- # start and the end tag of that element. The attribute list of the open tag will
1196
- # also be escaped (for instance, the double-quotes surrounding attribute
1197
- # values).
1198
- #
1199
- # print CGI.escapeElement('<BR><A HREF="url"></A>', "A", "IMG")
1200
- # # "<BR>&lt;A HREF=&quot;url&quot;&gt;&lt;/A&gt"
1201
- #
1202
- # print CGI.escapeElement('<BR><A HREF="url"></A>', ["A", "IMG"])
1203
- # # "<BR>&lt;A HREF=&quot;url&quot;&gt;&lt;/A&gt"
1204
- #
1205
- def escapeElement: (string string, *String | Array[String] elements) -> String
1206
-
1207
- # <!-- rdoc-file=lib/cgi/util.rb -->
1208
- # Synonym for CGI.escapeElement(str)
1209
- #
1210
- alias escape_element escapeElement
1211
-
1212
- # <!-- rdoc-file=lib/cgi/util.rb -->
1213
- # Synonym for CGI.escapeHTML(str)
1214
- #
1215
- alias escape_html escapeHTML
1216
-
1217
- # <!--
1218
- # rdoc-file=lib/cgi/util.rb
1219
- # - h(string)
1220
- # -->
1221
- #
1222
- alias h escapeHTML
1223
-
1224
866
  # <!--
1225
867
  # rdoc-file=lib/cgi/util.rb
1226
868
  # - pretty(string, shift = " ")
@@ -1255,32 +897,6 @@ class CGI
1255
897
  #
1256
898
  def rfc1123_date: (Time time) -> String
1257
899
 
1258
- # <!--
1259
- # rdoc-file=lib/cgi/util.rb
1260
- # - unescapeElement(string, *elements)
1261
- # -->
1262
- # Undo escaping such as that done by CGI.escapeElement()
1263
- #
1264
- # print CGI.unescapeElement(
1265
- # CGI.escapeHTML('<BR><A HREF="url"></A>'), "A", "IMG")
1266
- # # "&lt;BR&gt;<A HREF="url"></A>"
1267
- #
1268
- # print CGI.unescapeElement(
1269
- # CGI.escapeHTML('<BR><A HREF="url"></A>'), ["A", "IMG"])
1270
- # # "&lt;BR&gt;<A HREF="url"></A>"
1271
- #
1272
- def unescapeElement: (string string, *String | Array[String] elements) -> String
1273
-
1274
- # <!-- rdoc-file=lib/cgi/util.rb -->
1275
- # Synonym for CGI.unescapeElement(str)
1276
- #
1277
- alias unescape_element unescapeElement
1278
-
1279
- # <!-- rdoc-file=lib/cgi/util.rb -->
1280
- # Synonym for CGI.unescapeHTML(str)
1281
- #
1282
- alias unescape_html unescapeHTML
1283
-
1284
900
  # Abbreviated day-of-week names specified by RFC 822
1285
901
  RFC822_DAYS: Array[String]
1286
902
 
@@ -1,3 +1,4 @@
1
1
  dependencies:
2
2
  - name: tempfile
3
3
  - name: stringio
4
+ - name: cgi-escape
@@ -0,0 +1,171 @@
1
+ # <!-- rdoc-file=lib/cgi/escape.rb -->
2
+ # Since Ruby 4.0, CGI is a small holder for various escaping methods, included
3
+ # from CGI::Escape
4
+ #
5
+ # require 'cgi/escape'
6
+ #
7
+ # CGI.escape("Ruby programming language")
8
+ # #=> "Ruby+programming+language"
9
+ # CGI.escapeURIComponent("Ruby programming language")
10
+ # #=> "Ruby%20programming%20language"
11
+ #
12
+ # See CGI::Escape module for methods list and their description.
13
+ #
14
+ class CGI
15
+ include Escape
16
+
17
+ extend Escape
18
+
19
+ # <!-- rdoc-file=lib/cgi/escape.rb -->
20
+ # Web-related escape/unescape functionality.
21
+ #
22
+ module Escape
23
+ # <!--
24
+ # rdoc-file=lib/cgi/escape.rb
25
+ # - escape(string)
26
+ # -->
27
+ # URL-encode a string into application/x-www-form-urlencoded. Space characters
28
+ # (`" "`) are encoded with plus signs (`"+"`)
29
+ # url_encoded_string = CGI.escape("'Stop!' said Fred")
30
+ # # => "%27Stop%21%27+said+Fred"
31
+ #
32
+ def escape: (string str) -> String
33
+
34
+ # <!--
35
+ # rdoc-file=lib/cgi/escape.rb
36
+ # - escapeElement(string, *elements)
37
+ # -->
38
+ # Escape only the tags of certain HTML elements in `string`.
39
+ #
40
+ # Takes an element or elements or array of elements. Each element is specified
41
+ # by the name of the element, without angle brackets. This matches both the
42
+ # start and the end tag of that element. The attribute list of the open tag will
43
+ # also be escaped (for instance, the double-quotes surrounding attribute
44
+ # values).
45
+ #
46
+ # print CGI.escapeElement('<BR><A HREF="url"></A>', "A", "IMG")
47
+ # # "<BR>&lt;A HREF=&quot;url&quot;&gt;&lt;/A&gt"
48
+ #
49
+ # print CGI.escapeElement('<BR><A HREF="url"></A>', ["A", "IMG"])
50
+ # # "<BR>&lt;A HREF=&quot;url&quot;&gt;&lt;/A&gt"
51
+ #
52
+ def escapeElement: (string string, *String | Array[String] elements) -> String
53
+
54
+ # <!--
55
+ # rdoc-file=lib/cgi/escape.rb
56
+ # - escapeHTML(string)
57
+ # -->
58
+ # Escape special characters in HTML, namely `'&\"<>`
59
+ # CGI.escapeHTML('Usage: foo "bar" <baz>')
60
+ # # => "Usage: foo &quot;bar&quot; &lt;baz&gt;"
61
+ #
62
+ def escapeHTML: (string str) -> String
63
+
64
+ # <!--
65
+ # rdoc-file=lib/cgi/escape.rb
66
+ # - escapeURIComponent(string)
67
+ # -->
68
+ # URL-encode a string following RFC 3986 Space characters (`" "`) are encoded
69
+ # with (`"%20"`)
70
+ # url_encoded_string = CGI.escapeURIComponent("'Stop!' said Fred")
71
+ # # => "%27Stop%21%27%20said%20Fred"
72
+ #
73
+ def escapeURIComponent: (string) -> String
74
+
75
+ # <!--
76
+ # rdoc-file=lib/cgi/escape.rb
77
+ # - escape_element(string, *elements)
78
+ # -->
79
+ #
80
+ alias escape_element escapeElement
81
+
82
+ # <!--
83
+ # rdoc-file=lib/cgi/escape.rb
84
+ # - escape_html(string)
85
+ # -->
86
+ #
87
+ alias escape_html escapeHTML
88
+
89
+ # <!--
90
+ # rdoc-file=lib/cgi/escape.rb
91
+ # - escape_uri_component(string)
92
+ # -->
93
+ #
94
+ alias escape_uri_component escapeURIComponent
95
+
96
+ # <!--
97
+ # rdoc-file=lib/cgi/escape.rb
98
+ # - h(string)
99
+ # -->
100
+ #
101
+ alias h escapeHTML
102
+
103
+ # <!--
104
+ # rdoc-file=lib/cgi/escape.rb
105
+ # - unescape(string, encoding = @@accept_charset)
106
+ # -->
107
+ # URL-decode an application/x-www-form-urlencoded string with
108
+ # encoding(optional).
109
+ # string = CGI.unescape("%27Stop%21%27+said+Fred")
110
+ # # => "'Stop!' said Fred"
111
+ #
112
+ def unescape: (string str, ?encoding encoding) -> String
113
+
114
+ # <!--
115
+ # rdoc-file=lib/cgi/escape.rb
116
+ # - unescapeElement(string, *elements)
117
+ # -->
118
+ # Undo escaping such as that done by CGI.escapeElement
119
+ #
120
+ # print CGI.unescapeElement(
121
+ # CGI.escapeHTML('<BR><A HREF="url"></A>'), "A", "IMG")
122
+ # # "&lt;BR&gt;<A HREF="url"></A>"
123
+ #
124
+ # print CGI.unescapeElement(
125
+ # CGI.escapeHTML('<BR><A HREF="url"></A>'), ["A", "IMG"])
126
+ # # "&lt;BR&gt;<A HREF="url"></A>"
127
+ #
128
+ def unescapeElement: (string string, *String | Array[String] elements) -> String
129
+
130
+ # <!--
131
+ # rdoc-file=lib/cgi/escape.rb
132
+ # - unescapeHTML(string)
133
+ # -->
134
+ # Unescape a string that has been HTML-escaped
135
+ # CGI.unescapeHTML("Usage: foo &quot;bar&quot; &lt;baz&gt;")
136
+ # # => "Usage: foo \"bar\" <baz>"
137
+ #
138
+ def unescapeHTML: (string str) -> String
139
+
140
+ # <!--
141
+ # rdoc-file=lib/cgi/escape.rb
142
+ # - unescapeURIComponent(string, encoding = @@accept_charset)
143
+ # -->
144
+ # URL-decode a string following RFC 3986 with encoding(optional).
145
+ # string = CGI.unescapeURIComponent("%27Stop%21%27+said%20Fred")
146
+ # # => "'Stop!'+said Fred"
147
+ #
148
+ def unescapeURIComponent: (string) -> String
149
+
150
+ # <!--
151
+ # rdoc-file=lib/cgi/escape.rb
152
+ # - unescape_element(string, *elements)
153
+ # -->
154
+ #
155
+ alias unescape_element unescapeElement
156
+
157
+ # <!--
158
+ # rdoc-file=lib/cgi/escape.rb
159
+ # - unescape_html(string)
160
+ # -->
161
+ #
162
+ alias unescape_html unescapeHTML
163
+
164
+ # <!--
165
+ # rdoc-file=lib/cgi/escape.rb
166
+ # - unescape_uri_component(string, encoding = @@accept_charset)
167
+ # -->
168
+ #
169
+ alias unescape_uri_component unescapeURIComponent
170
+ end
171
+ end
@@ -147,8 +147,10 @@
147
147
  module Coverage
148
148
  # <!--
149
149
  # rdoc-file=ext/coverage/lib/coverage.rb
150
- # - line_stub(file)
150
+ # - line_stub(file) -> array
151
151
  # -->
152
+ # A simple helper function that creates the "stub" of line coverage from a given
153
+ # source code.
152
154
  #
153
155
  def self.line_stub: (String) -> Array[Integer?]
154
156