rbs 3.10.0 → 4.0.0.dev.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (202) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/comments.yml +3 -3
  3. data/.github/workflows/ruby.yml +24 -35
  4. data/.github/workflows/typecheck.yml +3 -1
  5. data/.github/workflows/windows.yml +2 -2
  6. data/.gitignore +0 -4
  7. data/CHANGELOG.md +0 -88
  8. data/README.md +1 -38
  9. data/Rakefile +20 -142
  10. data/Steepfile +1 -0
  11. data/config.yml +43 -1
  12. data/core/array.rbs +46 -100
  13. data/core/complex.rbs +21 -32
  14. data/core/dir.rbs +2 -2
  15. data/core/encoding.rbs +9 -6
  16. data/core/enumerable.rbs +3 -90
  17. data/core/enumerator.rbs +1 -18
  18. data/core/errno.rbs +0 -8
  19. data/core/errors.rbs +1 -28
  20. data/core/exception.rbs +2 -2
  21. data/core/fiber.rbs +4 -5
  22. data/core/file.rbs +12 -27
  23. data/core/file_test.rbs +1 -1
  24. data/core/float.rbs +22 -209
  25. data/core/gc.rbs +281 -417
  26. data/core/hash.rbs +727 -1024
  27. data/core/integer.rbs +38 -78
  28. data/core/io/buffer.rbs +7 -18
  29. data/core/io/wait.rbs +33 -11
  30. data/core/io.rbs +12 -14
  31. data/core/kernel.rbs +51 -57
  32. data/core/marshal.rbs +1 -1
  33. data/core/match_data.rbs +1 -1
  34. data/core/math.rbs +3 -42
  35. data/core/method.rbs +6 -14
  36. data/core/module.rbs +17 -88
  37. data/core/nil_class.rbs +3 -3
  38. data/core/numeric.rbs +16 -16
  39. data/core/object.rbs +3 -3
  40. data/core/object_space.rbs +15 -21
  41. data/core/proc.rbs +8 -15
  42. data/core/process.rbs +2 -2
  43. data/core/ractor.rbs +437 -278
  44. data/core/range.rbs +8 -7
  45. data/core/rational.rbs +24 -37
  46. data/core/rbs/unnamed/argf.rbs +2 -2
  47. data/core/rbs/unnamed/env_class.rbs +1 -1
  48. data/core/rbs/unnamed/random.rbs +2 -4
  49. data/core/regexp.rbs +20 -25
  50. data/core/ruby_vm.rbs +4 -6
  51. data/core/rubygems/errors.rbs +70 -3
  52. data/core/rubygems/rubygems.rbs +79 -11
  53. data/core/rubygems/version.rbs +3 -2
  54. data/core/set.rbs +359 -488
  55. data/core/string.rbs +1228 -3153
  56. data/core/struct.rbs +1 -1
  57. data/core/symbol.rbs +4 -4
  58. data/core/thread.rbs +29 -92
  59. data/core/time.rbs +9 -35
  60. data/core/trace_point.rbs +4 -7
  61. data/core/unbound_method.rbs +6 -14
  62. data/docs/collection.md +2 -2
  63. data/docs/gem.md +1 -0
  64. data/docs/sigs.md +3 -3
  65. data/ext/rbs_extension/ast_translation.c +1077 -944
  66. data/ext/rbs_extension/ast_translation.h +0 -7
  67. data/ext/rbs_extension/class_constants.c +83 -71
  68. data/ext/rbs_extension/class_constants.h +7 -4
  69. data/ext/rbs_extension/extconf.rb +2 -24
  70. data/ext/rbs_extension/legacy_location.c +172 -173
  71. data/ext/rbs_extension/legacy_location.h +3 -8
  72. data/ext/rbs_extension/main.c +289 -239
  73. data/ext/rbs_extension/rbs_extension.h +0 -3
  74. data/ext/rbs_extension/rbs_string_bridging.h +0 -4
  75. data/include/rbs/ast.h +98 -37
  76. data/include/rbs/defines.h +12 -38
  77. data/include/rbs/lexer.h +114 -126
  78. data/include/rbs/location.h +14 -14
  79. data/include/rbs/parser.h +37 -21
  80. data/include/rbs/string.h +5 -3
  81. data/include/rbs/util/rbs_allocator.h +19 -40
  82. data/include/rbs/util/rbs_assert.h +1 -12
  83. data/include/rbs/util/rbs_constant_pool.h +3 -3
  84. data/include/rbs/util/rbs_encoding.h +1 -3
  85. data/include/rbs/util/rbs_unescape.h +1 -2
  86. data/lib/rbs/ast/ruby/annotations.rb +119 -0
  87. data/lib/rbs/ast/ruby/comment_block.rb +221 -0
  88. data/lib/rbs/ast/ruby/declarations.rb +86 -0
  89. data/lib/rbs/ast/ruby/helpers/constant_helper.rb +24 -0
  90. data/lib/rbs/ast/ruby/helpers/location_helper.rb +15 -0
  91. data/lib/rbs/ast/ruby/members.rb +213 -0
  92. data/lib/rbs/buffer.rb +104 -24
  93. data/lib/rbs/cli/validate.rb +40 -35
  94. data/lib/rbs/cli.rb +5 -6
  95. data/lib/rbs/collection/config/lockfile_generator.rb +0 -1
  96. data/lib/rbs/collection.rb +0 -1
  97. data/lib/rbs/definition.rb +6 -1
  98. data/lib/rbs/definition_builder/ancestor_builder.rb +65 -62
  99. data/lib/rbs/definition_builder/method_builder.rb +45 -30
  100. data/lib/rbs/definition_builder.rb +44 -9
  101. data/lib/rbs/environment/class_entry.rb +69 -0
  102. data/lib/rbs/environment/module_entry.rb +66 -0
  103. data/lib/rbs/environment.rb +244 -218
  104. data/lib/rbs/environment_loader.rb +3 -3
  105. data/lib/rbs/errors.rb +5 -4
  106. data/lib/rbs/inline_parser/comment_association.rb +117 -0
  107. data/lib/rbs/inline_parser.rb +206 -0
  108. data/lib/rbs/location_aux.rb +35 -3
  109. data/lib/rbs/parser_aux.rb +11 -6
  110. data/lib/rbs/prototype/runtime.rb +2 -2
  111. data/lib/rbs/resolver/constant_resolver.rb +2 -2
  112. data/lib/rbs/resolver/type_name_resolver.rb +38 -124
  113. data/lib/rbs/source.rb +99 -0
  114. data/lib/rbs/subtractor.rb +4 -3
  115. data/lib/rbs/test/type_check.rb +0 -14
  116. data/lib/rbs/types.rb +1 -3
  117. data/lib/rbs/version.rb +1 -1
  118. data/lib/rbs.rb +13 -1
  119. data/lib/rdoc/discover.rb +1 -1
  120. data/lib/rdoc_plugin/parser.rb +1 -1
  121. data/rbs.gemspec +1 -0
  122. data/sig/ancestor_builder.rbs +1 -1
  123. data/sig/ast/ruby/annotations.rbs +110 -0
  124. data/sig/ast/ruby/comment_block.rbs +119 -0
  125. data/sig/ast/ruby/declarations.rbs +60 -0
  126. data/sig/ast/ruby/helpers/constant_helper.rbs +11 -0
  127. data/sig/ast/ruby/helpers/location_helper.rbs +15 -0
  128. data/sig/ast/ruby/members.rbs +72 -0
  129. data/sig/buffer.rbs +63 -5
  130. data/sig/definition.rbs +1 -0
  131. data/sig/definition_builder.rbs +1 -1
  132. data/sig/environment/class_entry.rbs +50 -0
  133. data/sig/environment/module_entry.rbs +50 -0
  134. data/sig/environment.rbs +28 -133
  135. data/sig/errors.rbs +13 -6
  136. data/sig/inline_parser/comment_association.rbs +71 -0
  137. data/sig/inline_parser.rbs +87 -0
  138. data/sig/location.rbs +32 -7
  139. data/sig/manifest.yaml +1 -0
  140. data/sig/method_builder.rbs +7 -4
  141. data/sig/parser.rbs +16 -20
  142. data/sig/resolver/type_name_resolver.rbs +7 -38
  143. data/sig/source.rbs +48 -0
  144. data/sig/types.rbs +1 -4
  145. data/src/ast.c +290 -201
  146. data/src/lexer.c +2813 -2902
  147. data/src/lexer.re +4 -0
  148. data/src/lexstate.c +155 -169
  149. data/src/location.c +40 -40
  150. data/src/parser.c +2665 -2433
  151. data/src/string.c +48 -0
  152. data/src/util/rbs_allocator.c +77 -80
  153. data/src/util/rbs_assert.c +10 -10
  154. data/src/util/rbs_buffer.c +2 -2
  155. data/src/util/rbs_constant_pool.c +15 -13
  156. data/src/util/rbs_encoding.c +4062 -20097
  157. data/src/util/rbs_unescape.c +48 -85
  158. data/stdlib/bigdecimal/0/big_decimal.rbs +82 -100
  159. data/stdlib/bigdecimal-math/0/big_math.rbs +8 -169
  160. data/stdlib/cgi/0/core.rbs +396 -2
  161. data/stdlib/cgi/0/manifest.yaml +0 -1
  162. data/stdlib/coverage/0/coverage.rbs +1 -3
  163. data/stdlib/date/0/date.rbs +59 -67
  164. data/stdlib/date/0/date_time.rbs +1 -1
  165. data/stdlib/delegate/0/delegator.rbs +7 -10
  166. data/stdlib/erb/0/erb.rbs +347 -737
  167. data/stdlib/fileutils/0/fileutils.rbs +13 -18
  168. data/stdlib/forwardable/0/forwardable.rbs +0 -3
  169. data/stdlib/json/0/json.rbs +48 -68
  170. data/stdlib/net-http/0/net-http.rbs +0 -3
  171. data/stdlib/objspace/0/objspace.rbs +4 -9
  172. data/stdlib/open-uri/0/open-uri.rbs +0 -40
  173. data/stdlib/openssl/0/openssl.rbs +228 -331
  174. data/stdlib/optparse/0/optparse.rbs +3 -3
  175. data/{core → stdlib/pathname/0}/pathname.rbs +355 -255
  176. data/stdlib/psych/0/psych.rbs +3 -3
  177. data/stdlib/rdoc/0/rdoc.rbs +1 -1
  178. data/stdlib/resolv/0/resolv.rbs +68 -25
  179. data/stdlib/ripper/0/ripper.rbs +2 -5
  180. data/stdlib/singleton/0/singleton.rbs +0 -3
  181. data/stdlib/socket/0/socket.rbs +1 -13
  182. data/stdlib/socket/0/tcp_socket.rbs +2 -10
  183. data/stdlib/stringio/0/stringio.rbs +85 -1176
  184. data/stdlib/strscan/0/string_scanner.rbs +31 -31
  185. data/stdlib/tempfile/0/tempfile.rbs +3 -3
  186. data/stdlib/time/0/time.rbs +1 -1
  187. data/stdlib/timeout/0/timeout.rbs +7 -63
  188. data/stdlib/tsort/0/cyclic.rbs +0 -3
  189. data/stdlib/uri/0/common.rbs +2 -11
  190. data/stdlib/uri/0/file.rbs +1 -1
  191. data/stdlib/uri/0/generic.rbs +16 -17
  192. data/stdlib/uri/0/rfc2396_parser.rbs +7 -6
  193. data/stdlib/zlib/0/zstream.rbs +0 -1
  194. metadata +40 -12
  195. data/.clang-format +0 -74
  196. data/.clangd +0 -2
  197. data/.github/workflows/c-check.yml +0 -54
  198. data/core/ruby.rbs +0 -53
  199. data/docs/aliases.md +0 -79
  200. data/docs/encoding.md +0 -56
  201. data/ext/rbs_extension/compat.h +0 -10
  202. data/stdlib/cgi-escape/0/escape.rbs +0 -153
data/.clang-format DELETED
@@ -1,74 +0,0 @@
1
- ---
2
- Language: Cpp
3
-
4
- # Indentation
5
- UseTab: Never
6
- IndentWidth: 4
7
- BreakBeforeBraces: Attach
8
- IndentCaseLabels: false
9
- NamespaceIndentation: None
10
- ContinuationIndentWidth: 4
11
- IndentPPDirectives: None
12
- IndentWrappedFunctionNames: false
13
- AccessModifierOffset: -2
14
-
15
- # Alignment
16
- AlignAfterOpenBracket: BlockIndent
17
- AlignConsecutiveAssignments: false
18
- AlignConsecutiveDeclarations: false
19
- AlignConsecutiveMacros: false
20
- AlignEscapedNewlines: Left
21
- AlignOperands: false
22
- AlignTrailingComments: true
23
- DerivePointerAlignment: false
24
- PointerAlignment: Right
25
-
26
- # Function calls formatting
27
- BinPackArguments: false
28
- BinPackParameters: false
29
- AllowAllArgumentsOnNextLine: false
30
- ExperimentalAutoDetectBinPacking: false
31
- PenaltyBreakBeforeFirstCallParameter: 1
32
- AlwaysBreakAfterDefinitionReturnType: None
33
-
34
- # Wrapping and Breaking
35
- ColumnLimit: 0
36
- AllowShortBlocksOnASingleLine: Never
37
- AllowShortCaseLabelsOnASingleLine: false
38
- AllowShortFunctionsOnASingleLine: All
39
- AllowShortIfStatementsOnASingleLine: Always
40
- AllowShortLoopsOnASingleLine: false
41
- AlwaysBreakAfterReturnType: None
42
- AlwaysBreakBeforeMultilineStrings: false
43
- AlwaysBreakTemplateDeclarations: No
44
- BreakBeforeBinaryOperators: None
45
- BreakBeforeTernaryOperators: false
46
- BreakConstructorInitializers: BeforeColon
47
- BreakInheritanceList: BeforeColon
48
- BreakStringLiterals: false
49
- CompactNamespaces: false
50
- ConstructorInitializerAllOnOneLineOrOnePerLine: false
51
- Cpp11BracedListStyle: false
52
- ReflowComments: false
53
- SortIncludes: Never
54
-
55
- # Spaces
56
- SpaceAfterCStyleCast: true
57
- SpaceAfterLogicalNot: false
58
- SpaceAfterTemplateKeyword: true
59
- SpaceBeforeAssignmentOperators: true
60
- SpaceBeforeCpp11BracedList: true
61
- SpaceBeforeCtorInitializerColon: true
62
- SpaceBeforeInheritanceColon: true
63
- SpaceBeforeParens: ControlStatements
64
- SpaceBeforeRangeBasedForLoopColon: true
65
- SpaceBeforeSquareBrackets: false
66
- SpaceInEmptyBlock: false
67
- SpaceInEmptyParentheses: false
68
- SpacesBeforeTrailingComments: 1
69
- SpacesInAngles: false
70
- SpacesInCStyleCastParentheses: false
71
- SpacesInConditionalStatement: false
72
- SpacesInContainerLiterals: true
73
- SpacesInParentheses: false
74
- SpacesInSquareBrackets: false
data/.clangd DELETED
@@ -1,2 +0,0 @@
1
- CompileFlags:
2
- CompilationDatabase: ext/rbs_extension
@@ -1,54 +0,0 @@
1
- name: C Code Generation and Formatting Check
2
-
3
- on:
4
- push:
5
- pull_request: {}
6
- merge_group: {}
7
-
8
- jobs:
9
- format-check:
10
- runs-on: ubuntu-latest
11
- steps:
12
- - uses: actions/checkout@v4
13
- - uses: ruby/setup-ruby@v1
14
- with:
15
- ruby-version: "4.0.0-preview3"
16
- bundler-cache: none
17
- - name: Set working directory as safe
18
- run: git config --global --add safe.directory $(pwd)
19
- - name: Install dependencies
20
- run: |
21
- sudo apt-get update
22
- sudo apt-get install -y libdb-dev curl autoconf automake m4 libtool
23
- - name: Install clang-format from LLVM
24
- run: |
25
- wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -
26
- sudo apt-add-repository "deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-20 main"
27
- sudo apt-get update
28
- sudo apt-get install -y clang-format-20
29
- sudo ln -sf /usr/bin/clang-format-20 /usr/local/bin/clang-format
30
- clang-format --version
31
- - name: Count processors
32
- run: nproc
33
- - name: Install Re2c
34
- run: |
35
- cd /tmp
36
- curl -L https://github.com/skvadrik/re2c/archive/refs/tags/4.3.tar.gz > re2c-4.3.tar.gz
37
- tar xf re2c-4.3.tar.gz
38
- cd re2c-4.3
39
- autoreconf -i -W all
40
- ./configure
41
- make -j"$(nproc)" -l"$(nproc)"
42
- sudo make install
43
- - name: Update rubygems & bundler
44
- run: |
45
- ruby -v
46
- gem update --system
47
- - name: bin/setup
48
- run: |
49
- bin/setup
50
- - name: Check C code generation and formatting
51
- run: |
52
- clang-format --version
53
- bundle exec rake lexer templates compile confirm_lexer confirm_templates
54
- bundle exec rake format:c_check
data/core/ruby.rbs DELETED
@@ -1,53 +0,0 @@
1
- # <!-- rdoc-file=version.c -->
2
- # The [Ruby](rdoc-ref:Ruby) module that contains portable information among
3
- # implementations.
4
- #
5
- # The constants defined here are aliased in the toplevel with `RUBY_` prefix.
6
- #
7
- module Ruby
8
- # <!-- rdoc-file=version.c -->
9
- # The copyright string for ruby
10
- #
11
- COPYRIGHT: ::String
12
-
13
- # <!-- rdoc-file=version.c -->
14
- # The full ruby version string, like `ruby -v` prints
15
- #
16
- DESCRIPTION: ::String
17
-
18
- # <!-- rdoc-file=version.c -->
19
- # The engine or interpreter this ruby uses.
20
- #
21
- ENGINE: ::String
22
-
23
- # <!-- rdoc-file=version.c -->
24
- # The version of the engine or interpreter this ruby uses.
25
- #
26
- ENGINE_VERSION: ::String
27
-
28
- # <!-- rdoc-file=version.c -->
29
- # The patchlevel for this ruby. If this is a development build of ruby the
30
- # patchlevel will be -1
31
- #
32
- PATCHLEVEL: ::Integer
33
-
34
- # <!-- rdoc-file=version.c -->
35
- # The platform for this ruby
36
- #
37
- PLATFORM: ::String
38
-
39
- # <!-- rdoc-file=version.c -->
40
- # The date this ruby was released
41
- #
42
- RELEASE_DATE: ::String
43
-
44
- # <!-- rdoc-file=version.c -->
45
- # The GIT commit hash for this ruby.
46
- #
47
- REVISION: ::String
48
-
49
- # <!-- rdoc-file=version.c -->
50
- # The running version of ruby
51
- #
52
- VERSION: ::String
53
- end
data/docs/aliases.md DELETED
@@ -1,79 +0,0 @@
1
- # Aliases
2
-
3
- This document explains module/class aliases and type aliases.
4
-
5
- ## Module/class alias
6
-
7
- Module/class aliases give another name to a module/class.
8
- This is useful for some syntaxes that has lexical constraints.
9
-
10
- ```rbs
11
- class C
12
- end
13
-
14
- class D = C # ::D is an alias for ::C
15
-
16
- class E < D # ::E inherits from ::D, which is actually ::C
17
- end
18
- ```
19
-
20
- Note that module/class aliases cannot be recursive.
21
-
22
- So, we can define a *normalization* of aliased module/class names.
23
- Normalization follows the chain of alias definitions and resolves them to the original module/class defined with `module`/`class` syntax.
24
-
25
- ```rbs
26
- class C
27
- end
28
-
29
- class D = C
30
- class E = D
31
- ```
32
-
33
- `::E` is defined as an alias, and it can be normalized to `::C`.
34
-
35
- ## Type alias
36
-
37
- The biggest difference from module/class alias is that type alias can be recursive.
38
-
39
- ```rbs
40
- # cons_cell type is defined recursively
41
- type cons_cell = nil
42
- | [Integer, cons_cell]
43
- ```
44
-
45
- This means type aliases *cannot be* normalized generally.
46
- So, we provide another operation for type alias, `DefinitionBuilder#expand_alias` and its family.
47
- It substitutes with the immediate right hand side of a type alias.
48
-
49
- ```
50
- cons_cell ===> nil | [Integer, cons_cell] (expand 1 step)
51
- ===> nil | [Integer, nil | [Integer, cons_cell]] (expand 2 steps)
52
- ===> ... (expand will go infinitely)
53
- ```
54
-
55
- Note that the namespace of a type alias *can be* normalized, because they are module names.
56
-
57
- ```rbs
58
- module M
59
- type t = String
60
- end
61
-
62
- module N = M
63
- ```
64
-
65
- With the type definition above, a type `::N::t` can be normalized to `::M::t`.
66
- And then it can be expanded to `::String`.
67
-
68
- > [!NOTE]
69
- > This is something like an *unfold* operation in type theory.
70
-
71
- ## Type name resolution
72
-
73
- Type name resolution in RBS usually rewrites *relative* type names to *absolute* type names.
74
- `Environment#resolve_type_names` converts all type names in the RBS type definitions, and returns a new `Environment` object.
75
-
76
- It also *normalizes* modules names in type names.
77
-
78
- - If the type name can be resolved and normalized successfully, the AST has *absolute* type names.
79
- - If the type name resolution/normalization fails, the AST has *relative* type names.
data/docs/encoding.md DELETED
@@ -1,56 +0,0 @@
1
- # RBS File Encoding
2
-
3
- ## Best Practice
4
-
5
- **Use UTF-8** for both file encoding and your system locale.
6
-
7
- ## Supported Encodings
8
-
9
- RBS parser supports ASCII-compatible encodings (similar to Ruby's script encoding support).
10
-
11
- **Examples**: UTF-8, US-ASCII, Shift JIS, EUC-JP, ...
12
-
13
- ## Unicode Codepoint Symbols
14
-
15
- String literal types in RBS can contain Unicode codepoint escape sequences (`\uXXXX`).
16
-
17
- When the file encoding is UTF-8, the parser translates Unicode codepoint symbols:
18
-
19
- ```rbs
20
- # In UTF-8 encoded files
21
-
22
- type t = "\u0123" # Translated to the actual Unicode character ģ
23
- type s = "\u3042" # Translated to the actual Unicode character あ
24
- ```
25
-
26
- When the file encoding is not UTF-8, Unicode escape sequences are interpreted literally as the string `\uXXXX`:
27
-
28
- ```rbs
29
- # In non-UTF-8 encoded files
30
-
31
- type t = "\u0123" # Remains as the literal string "\u0123"
32
- ```
33
-
34
- ## Implementation
35
-
36
- RBS gem currently doesn't do anything for file encoding. It relies on Ruby's encoding handling, specifically `Encoding.default_external` and `Encoding.default_internal`.
37
-
38
- `Encoding.default_external` is the encoding Ruby assumes when it reads external resources like files. The Ruby interpreter sets it based on the locale. `Encoding.default_internal` is the encoding Ruby converts the external resources to. The default is `nil` (no conversion.)
39
-
40
- When your locale is set to use `UTF-8` encoding, `default_external` is `Encoding::UTF_8`. So the RBS file content read from the disk will have UTF-8 encoding.
41
-
42
- ### Parsing non UTF-8 RBS source text
43
-
44
- If you want to work with another encoding, ensure the source string has ASCII compatible encoding.
45
-
46
- ```ruby
47
- source = '"日本語"'
48
- RBS::Parser.parse_type(source.encode(Encoding::EUC_JP)) # => Parses successfully
49
- RBS::Parser.parse_type(source.encode(Encoding::UTF_32)) # => Returns `nil` since UTF-32 is not ASCII compatible
50
- ```
51
-
52
- ### Specifying file encoding
53
-
54
- Currently, RBS doesn't support specifying file encoding directly.
55
-
56
- You can use `Encoding.default_external` while the gem loads RBS files from the storage.
@@ -1,10 +0,0 @@
1
- #ifdef __clang__
2
- #define SUPPRESS_RUBY_HEADER_DIAGNOSTICS_BEGIN \
3
- _Pragma("clang diagnostic push") \
4
- _Pragma("clang diagnostic ignored \"-Wc2x-extensions\"")
5
- #define SUPPRESS_RUBY_HEADER_DIAGNOSTICS_END \
6
- _Pragma("clang diagnostic pop")
7
- #else
8
- #define SUPPRESS_RUBY_HEADER_DIAGNOSTICS_BEGIN
9
- #define SUPPRESS_RUBY_HEADER_DIAGNOSTICS_END
10
- #endif
@@ -1,153 +0,0 @@
1
- # <!-- rdoc-file=lib/cgi/escape.rb -->
2
- # :stopdoc
3
- #
4
- class CGI
5
- include Escape
6
-
7
- extend Escape
8
-
9
- # <!-- rdoc-file=lib/cgi/escape.rb -->
10
- # Escape/unescape for CGI, HTML, URI.
11
- #
12
- module Escape
13
- # <!--
14
- # rdoc-file=lib/cgi/escape.rb
15
- # - escape(string)
16
- # -->
17
- # URL-encode a string into application/x-www-form-urlencoded. Space characters
18
- # (+" "+) are encoded with plus signs (+"+"+)
19
- # url_encoded_string = CGI.escape("'Stop!' said Fred")
20
- # # => "%27Stop%21%27+said+Fred"
21
- #
22
- def escape: (string str) -> String
23
-
24
- # <!--
25
- # rdoc-file=lib/cgi/escape.rb
26
- # - escapeElement(string, *elements)
27
- # -->
28
- # Escape only the tags of certain HTML elements in `string`.
29
- #
30
- # Takes an element or elements or array of elements. Each element is specified
31
- # by the name of the element, without angle brackets. This matches both the
32
- # start and the end tag of that element. The attribute list of the open tag will
33
- # also be escaped (for instance, the double-quotes surrounding attribute
34
- # values).
35
- #
36
- # print CGI.escapeElement('<BR><A HREF="url"></A>', "A", "IMG")
37
- # # "<BR>&lt;A HREF=&quot;url&quot;&gt;&lt;/A&gt"
38
- #
39
- # print CGI.escapeElement('<BR><A HREF="url"></A>', ["A", "IMG"])
40
- # # "<BR>&lt;A HREF=&quot;url&quot;&gt;&lt;/A&gt"
41
- #
42
- def escapeElement: (string string, *String | Array[String] elements) -> String
43
-
44
- # <!--
45
- # rdoc-file=lib/cgi/escape.rb
46
- # - escapeHTML(string)
47
- # -->
48
- # Escape special characters in HTML, namely '&"<>
49
- # CGI.escapeHTML('Usage: foo "bar" <baz>')
50
- # # => "Usage: foo &quot;bar&quot; &lt;baz&gt;"
51
- #
52
- def escapeHTML: (string str) -> String
53
-
54
- # <!--
55
- # rdoc-file=lib/cgi/escape.rb
56
- # - escapeURIComponent(string)
57
- # -->
58
- # URL-encode a string following RFC 3986 Space characters (+" "+) are encoded
59
- # with (+"%20"+)
60
- # url_encoded_string = CGI.escapeURIComponent("'Stop!' said Fred")
61
- # # => "%27Stop%21%27%20said%20Fred"
62
- #
63
- def escapeURIComponent: (string) -> String
64
-
65
- # <!-- rdoc-file=lib/cgi/escape.rb -->
66
- # Synonym for CGI.escapeElement(str)
67
- #
68
- alias escape_element escapeElement
69
-
70
- # <!-- rdoc-file=lib/cgi/escape.rb -->
71
- # Synonym for CGI.escapeHTML(str)
72
- #
73
- alias escape_html escapeHTML
74
-
75
- # <!--
76
- # rdoc-file=lib/cgi/escape.rb
77
- # - escape_uri_component(string)
78
- # -->
79
- #
80
- alias escape_uri_component escapeURIComponent
81
-
82
- # <!--
83
- # rdoc-file=lib/cgi/escape.rb
84
- # - h(string)
85
- # -->
86
- #
87
- alias h escapeHTML
88
-
89
- # <!--
90
- # rdoc-file=lib/cgi/escape.rb
91
- # - unescape(string, encoding = @@accept_charset)
92
- # -->
93
- # URL-decode an application/x-www-form-urlencoded string with
94
- # encoding(optional).
95
- # string = CGI.unescape("%27Stop%21%27+said+Fred")
96
- # # => "'Stop!' said Fred"
97
- #
98
- def unescape: (string str, ?encoding encoding) -> String
99
-
100
- # <!--
101
- # rdoc-file=lib/cgi/escape.rb
102
- # - unescapeElement(string, *elements)
103
- # -->
104
- # Undo escaping such as that done by CGI.escapeElement()
105
- #
106
- # print CGI.unescapeElement(
107
- # CGI.escapeHTML('<BR><A HREF="url"></A>'), "A", "IMG")
108
- # # "&lt;BR&gt;<A HREF="url"></A>"
109
- #
110
- # print CGI.unescapeElement(
111
- # CGI.escapeHTML('<BR><A HREF="url"></A>'), ["A", "IMG"])
112
- # # "&lt;BR&gt;<A HREF="url"></A>"
113
- #
114
- def unescapeElement: (string string, *String | Array[String] elements) -> String
115
-
116
- # <!--
117
- # rdoc-file=lib/cgi/escape.rb
118
- # - unescapeHTML(string)
119
- # -->
120
- # Unescape a string that has been HTML-escaped
121
- # CGI.unescapeHTML("Usage: foo &quot;bar&quot; &lt;baz&gt;")
122
- # # => "Usage: foo \"bar\" <baz>"
123
- #
124
- def unescapeHTML: (string str) -> String
125
-
126
- # <!--
127
- # rdoc-file=lib/cgi/escape.rb
128
- # - unescapeURIComponent(string, encoding = @@accept_charset)
129
- # -->
130
- # URL-decode a string following RFC 3986 with encoding(optional).
131
- # string = CGI.unescapeURIComponent("%27Stop%21%27+said%20Fred")
132
- # # => "'Stop!'+said Fred"
133
- #
134
- def unescapeURIComponent: (string) -> String
135
-
136
- # <!-- rdoc-file=lib/cgi/escape.rb -->
137
- # Synonym for CGI.unescapeElement(str)
138
- #
139
- alias unescape_element unescapeElement
140
-
141
- # <!-- rdoc-file=lib/cgi/escape.rb -->
142
- # Synonym for CGI.unescapeHTML(str)
143
- #
144
- alias unescape_html unescapeHTML
145
-
146
- # <!--
147
- # rdoc-file=lib/cgi/escape.rb
148
- # - unescape_uri_component(string, encoding = @@accept_charset)
149
- # -->
150
- #
151
- alias unescape_uri_component unescapeURIComponent
152
- end
153
- end