steep 0.14.0 → 0.15.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (190) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +5 -0
  3. data/exe/rbs +1 -1
  4. data/lib/steep/annotation_parser.rb +4 -4
  5. data/lib/steep/ast/buffer.rb +11 -7
  6. data/lib/steep/ast/builtin.rb +8 -0
  7. data/lib/steep/ast/types/factory.rb +55 -55
  8. data/lib/steep/drivers/check.rb +20 -4
  9. data/lib/steep/drivers/langserver.rb +6 -1
  10. data/lib/steep/drivers/vendor.rb +2 -2
  11. data/lib/steep/project/completion_provider.rb +5 -11
  12. data/lib/steep/project/dsl.rb +14 -0
  13. data/lib/steep/project/file.rb +42 -46
  14. data/lib/steep/project/hover_content.rb +11 -5
  15. data/lib/steep/project/options.rb +25 -3
  16. data/lib/steep/project/target.rb +10 -4
  17. data/lib/steep/signature/errors.rb +1 -1
  18. data/lib/steep/signature/validator.rb +8 -8
  19. data/lib/steep/source.rb +1 -1
  20. data/lib/steep/type_construction.rb +987 -711
  21. data/lib/steep/type_inference/constant_env.rb +1 -1
  22. data/lib/steep/type_inference/context.rb +7 -3
  23. data/lib/steep/type_inference/context_array.rb +111 -0
  24. data/lib/steep/type_inference/local_variable_type_env.rb +226 -0
  25. data/lib/steep/type_inference/logic.rb +130 -0
  26. data/lib/steep/type_inference/type_env.rb +5 -69
  27. data/lib/steep/typing.rb +79 -22
  28. data/lib/steep/version.rb +1 -1
  29. data/lib/steep.rb +6 -1
  30. data/smoke/alias/Steepfile +1 -0
  31. data/smoke/and/Steepfile +1 -0
  32. data/smoke/array/Steepfile +1 -0
  33. data/smoke/array/b.rb +0 -2
  34. data/smoke/block/Steepfile +1 -0
  35. data/smoke/case/Steepfile +1 -0
  36. data/smoke/class/Steepfile +1 -0
  37. data/smoke/const/Steepfile +1 -0
  38. data/smoke/dstr/Steepfile +1 -0
  39. data/smoke/ensure/Steepfile +1 -0
  40. data/smoke/enumerator/Steepfile +1 -0
  41. data/smoke/extension/Steepfile +1 -0
  42. data/smoke/extension/c.rb +1 -0
  43. data/smoke/hash/Steepfile +1 -0
  44. data/smoke/hello/Steepfile +1 -0
  45. data/smoke/if/Steepfile +1 -0
  46. data/smoke/if/a.rb +1 -1
  47. data/smoke/implements/Steepfile +1 -0
  48. data/smoke/initialize/Steepfile +1 -0
  49. data/smoke/integer/Steepfile +1 -0
  50. data/smoke/interface/Steepfile +1 -0
  51. data/smoke/kwbegin/Steepfile +1 -0
  52. data/smoke/lambda/Steepfile +1 -0
  53. data/smoke/literal/Steepfile +1 -0
  54. data/smoke/map/Steepfile +1 -0
  55. data/smoke/method/Steepfile +1 -0
  56. data/smoke/module/Steepfile +1 -0
  57. data/smoke/regexp/Steepfile +1 -0
  58. data/smoke/regression/Steepfile +1 -0
  59. data/smoke/rescue/Steepfile +1 -0
  60. data/smoke/rescue/a.rb +1 -1
  61. data/smoke/self/Steepfile +1 -0
  62. data/smoke/skip/Steepfile +1 -0
  63. data/smoke/stdout/Steepfile +1 -0
  64. data/smoke/super/Steepfile +1 -0
  65. data/smoke/type_case/Steepfile +1 -0
  66. data/smoke/yield/Steepfile +1 -0
  67. data/steep.gemspec +1 -1
  68. data/vendor/ruby-signature/.gitignore +2 -2
  69. data/vendor/ruby-signature/README.md +2 -2
  70. data/vendor/ruby-signature/Rakefile +2 -2
  71. data/vendor/ruby-signature/bin/annotate-with-rdoc +14 -13
  72. data/vendor/ruby-signature/bin/console +1 -1
  73. data/vendor/ruby-signature/bin/sort +7 -6
  74. data/vendor/ruby-signature/bin/test_runner.rb +0 -1
  75. data/vendor/ruby-signature/docs/CONTRIBUTING.md +1 -1
  76. data/vendor/ruby-signature/docs/sigs.md +3 -3
  77. data/vendor/ruby-signature/docs/stdlib.md +1 -1
  78. data/vendor/ruby-signature/docs/syntax.md +9 -9
  79. data/vendor/ruby-signature/exe/rbs +5 -1
  80. data/vendor/ruby-signature/lib/rbs/ast/annotation.rb +27 -0
  81. data/vendor/ruby-signature/lib/rbs/ast/comment.rb +27 -0
  82. data/vendor/ruby-signature/lib/rbs/ast/declarations.rb +395 -0
  83. data/vendor/ruby-signature/lib/rbs/ast/members.rb +362 -0
  84. data/vendor/ruby-signature/lib/rbs/buffer.rb +50 -0
  85. data/vendor/ruby-signature/lib/rbs/builtin_names.rb +55 -0
  86. data/vendor/ruby-signature/lib/rbs/cli.rb +558 -0
  87. data/vendor/ruby-signature/lib/rbs/constant.rb +26 -0
  88. data/vendor/ruby-signature/lib/rbs/constant_table.rb +150 -0
  89. data/vendor/ruby-signature/lib/rbs/definition.rb +170 -0
  90. data/vendor/ruby-signature/lib/rbs/definition_builder.rb +919 -0
  91. data/vendor/ruby-signature/lib/rbs/environment.rb +281 -0
  92. data/vendor/ruby-signature/lib/rbs/environment_loader.rb +136 -0
  93. data/vendor/ruby-signature/lib/rbs/environment_walker.rb +124 -0
  94. data/vendor/ruby-signature/lib/rbs/errors.rb +187 -0
  95. data/vendor/ruby-signature/lib/rbs/location.rb +102 -0
  96. data/vendor/ruby-signature/lib/rbs/method_type.rb +123 -0
  97. data/vendor/ruby-signature/lib/rbs/namespace.rb +91 -0
  98. data/vendor/ruby-signature/lib/{ruby/signature → rbs}/parser.rb +21 -23
  99. data/vendor/ruby-signature/lib/{ruby/signature → rbs}/parser.y +18 -18
  100. data/vendor/ruby-signature/lib/rbs/prototype/rb.rb +553 -0
  101. data/vendor/ruby-signature/lib/rbs/prototype/rbi.rb +587 -0
  102. data/vendor/ruby-signature/lib/rbs/prototype/runtime.rb +381 -0
  103. data/vendor/ruby-signature/lib/rbs/substitution.rb +46 -0
  104. data/vendor/ruby-signature/lib/rbs/test/errors.rb +61 -0
  105. data/vendor/ruby-signature/lib/rbs/test/hook.rb +294 -0
  106. data/vendor/ruby-signature/lib/{ruby/signature → rbs}/test/setup.rb +7 -7
  107. data/vendor/ruby-signature/lib/rbs/test/spy.rb +325 -0
  108. data/vendor/ruby-signature/lib/rbs/test/test_helper.rb +183 -0
  109. data/vendor/ruby-signature/lib/rbs/test/type_check.rb +254 -0
  110. data/vendor/ruby-signature/lib/rbs/test.rb +26 -0
  111. data/vendor/ruby-signature/lib/rbs/type_name.rb +70 -0
  112. data/vendor/ruby-signature/lib/rbs/types.rb +936 -0
  113. data/vendor/ruby-signature/lib/rbs/variance_calculator.rb +138 -0
  114. data/vendor/ruby-signature/lib/rbs/vendorer.rb +47 -0
  115. data/vendor/ruby-signature/lib/rbs/version.rb +3 -0
  116. data/vendor/ruby-signature/lib/rbs/writer.rb +269 -0
  117. data/vendor/ruby-signature/lib/rbs.rb +64 -0
  118. data/vendor/ruby-signature/lib/ruby/signature.rb +4 -61
  119. data/vendor/ruby-signature/{ruby-signature.gemspec → rbs.gemspec} +4 -4
  120. data/vendor/ruby-signature/stdlib/abbrev/abbrev.rbs +58 -1
  121. data/vendor/ruby-signature/stdlib/base64/base64.rbs +69 -13
  122. data/vendor/ruby-signature/stdlib/benchmark/benchmark.rbs +372 -0
  123. data/vendor/ruby-signature/stdlib/builtin/builtin.rbs +9 -0
  124. data/vendor/ruby-signature/stdlib/builtin/dir.rbs +1 -7
  125. data/vendor/ruby-signature/stdlib/builtin/encoding.rbs +2 -1
  126. data/vendor/ruby-signature/stdlib/builtin/exception.rbs +3 -2
  127. data/vendor/ruby-signature/stdlib/builtin/file.rbs +902 -302
  128. data/vendor/ruby-signature/stdlib/builtin/gc.rbs +190 -68
  129. data/vendor/ruby-signature/stdlib/builtin/integer.rbs +3 -6
  130. data/vendor/ruby-signature/stdlib/builtin/kernel.rbs +6 -4
  131. data/vendor/ruby-signature/stdlib/builtin/marshal.rbs +146 -120
  132. data/vendor/ruby-signature/stdlib/builtin/math.rbs +310 -7
  133. data/vendor/ruby-signature/stdlib/builtin/method.rbs +11 -8
  134. data/vendor/ruby-signature/stdlib/builtin/module.rbs +959 -103
  135. data/vendor/ruby-signature/stdlib/builtin/proc.rbs +3 -0
  136. data/vendor/ruby-signature/stdlib/builtin/process.rbs +981 -108
  137. data/vendor/ruby-signature/stdlib/builtin/random.rbs +215 -41
  138. data/vendor/ruby-signature/stdlib/builtin/rb_config.rbs +47 -0
  139. data/vendor/ruby-signature/stdlib/builtin/string.rbs +9 -2
  140. data/vendor/ruby-signature/stdlib/builtin/string_io.rbs +282 -11
  141. data/vendor/ruby-signature/stdlib/builtin/symbol.rbs +11 -13
  142. data/vendor/ruby-signature/stdlib/builtin/thread.rbs +25 -29
  143. data/vendor/ruby-signature/stdlib/builtin/thread_group.rbs +1 -1
  144. data/vendor/ruby-signature/stdlib/builtin/time.rbs +875 -567
  145. data/vendor/ruby-signature/stdlib/builtin/trace_point.rbs +243 -44
  146. data/vendor/ruby-signature/stdlib/builtin/unbound_method.rbs +103 -109
  147. data/vendor/ruby-signature/stdlib/coverage/coverage.rbs +62 -0
  148. data/vendor/ruby-signature/stdlib/csv/csv.rbs +773 -0
  149. data/vendor/ruby-signature/stdlib/erb/erb.rbs +375 -1
  150. data/vendor/ruby-signature/stdlib/find/find.rbs +0 -4
  151. data/vendor/ruby-signature/stdlib/ipaddr/ipaddr.rbs +247 -0
  152. data/vendor/ruby-signature/stdlib/pathname/pathname.rbs +1088 -16
  153. data/vendor/ruby-signature/stdlib/set/set.rbs +251 -27
  154. metadata +49 -44
  155. data/exe/ruby-signature +0 -3
  156. data/vendor/ruby-signature/exe/ruby-signature +0 -7
  157. data/vendor/ruby-signature/lib/ruby/signature/ast/annotation.rb +0 -29
  158. data/vendor/ruby-signature/lib/ruby/signature/ast/comment.rb +0 -29
  159. data/vendor/ruby-signature/lib/ruby/signature/ast/declarations.rb +0 -391
  160. data/vendor/ruby-signature/lib/ruby/signature/ast/members.rb +0 -364
  161. data/vendor/ruby-signature/lib/ruby/signature/buffer.rb +0 -52
  162. data/vendor/ruby-signature/lib/ruby/signature/builtin_names.rb +0 -54
  163. data/vendor/ruby-signature/lib/ruby/signature/cli.rb +0 -555
  164. data/vendor/ruby-signature/lib/ruby/signature/constant.rb +0 -28
  165. data/vendor/ruby-signature/lib/ruby/signature/constant_table.rb +0 -152
  166. data/vendor/ruby-signature/lib/ruby/signature/definition.rb +0 -172
  167. data/vendor/ruby-signature/lib/ruby/signature/definition_builder.rb +0 -921
  168. data/vendor/ruby-signature/lib/ruby/signature/environment.rb +0 -283
  169. data/vendor/ruby-signature/lib/ruby/signature/environment_loader.rb +0 -138
  170. data/vendor/ruby-signature/lib/ruby/signature/environment_walker.rb +0 -126
  171. data/vendor/ruby-signature/lib/ruby/signature/errors.rb +0 -189
  172. data/vendor/ruby-signature/lib/ruby/signature/location.rb +0 -104
  173. data/vendor/ruby-signature/lib/ruby/signature/method_type.rb +0 -125
  174. data/vendor/ruby-signature/lib/ruby/signature/namespace.rb +0 -93
  175. data/vendor/ruby-signature/lib/ruby/signature/prototype/rb.rb +0 -444
  176. data/vendor/ruby-signature/lib/ruby/signature/prototype/rbi.rb +0 -579
  177. data/vendor/ruby-signature/lib/ruby/signature/prototype/runtime.rb +0 -383
  178. data/vendor/ruby-signature/lib/ruby/signature/substitution.rb +0 -48
  179. data/vendor/ruby-signature/lib/ruby/signature/test/errors.rb +0 -63
  180. data/vendor/ruby-signature/lib/ruby/signature/test/hook.rb +0 -290
  181. data/vendor/ruby-signature/lib/ruby/signature/test/spy.rb +0 -327
  182. data/vendor/ruby-signature/lib/ruby/signature/test/test_helper.rb +0 -185
  183. data/vendor/ruby-signature/lib/ruby/signature/test/type_check.rb +0 -256
  184. data/vendor/ruby-signature/lib/ruby/signature/test.rb +0 -28
  185. data/vendor/ruby-signature/lib/ruby/signature/type_name.rb +0 -72
  186. data/vendor/ruby-signature/lib/ruby/signature/types.rb +0 -932
  187. data/vendor/ruby-signature/lib/ruby/signature/variance_calculator.rb +0 -140
  188. data/vendor/ruby-signature/lib/ruby/signature/vendorer.rb +0 -49
  189. data/vendor/ruby-signature/lib/ruby/signature/version.rb +0 -5
  190. data/vendor/ruby-signature/lib/ruby/signature/writer.rb +0 -271
@@ -1,18 +1,392 @@
1
+ # # ERB -- Ruby Templating
2
+ #
3
+ # ## Introduction
4
+ #
5
+ # ERB provides an easy to use but powerful templating system for Ruby. Using
6
+ # ERB, actual Ruby code can be added to any plain text document for the purposes
7
+ # of generating document information details and/or flow control.
8
+ #
9
+ # A very simple example is this:
10
+ #
11
+ # require 'erb'
12
+ #
13
+ # x = 42
14
+ # template = ERB.new <<-EOF
15
+ # The value of x is: <%= x %>
16
+ # EOF
17
+ # puts template.result(binding)
18
+ #
19
+ # *Prints:* The value of x is: 42
20
+ #
21
+ # More complex examples are given below.
22
+ #
23
+ # ## Recognized Tags
24
+ #
25
+ # ERB recognizes certain tags in the provided template and converts them based
26
+ # on the rules below:
27
+ #
28
+ # <% Ruby code -- inline with output %>
29
+ # <%= Ruby expression -- replace with result %>
30
+ # <%# comment -- ignored -- useful in testing %>
31
+ # % a line of Ruby code -- treated as <% line %> (optional -- see ERB.new)
32
+ # %% replaced with % if first thing on a line and % processing is used
33
+ # <%% or %%> -- replace with <% or %> respectively
34
+ #
35
+ # All other text is passed through ERB filtering unchanged.
36
+ #
37
+ # ## Options
38
+ #
39
+ # There are several settings you can change when you use ERB:
40
+ # * the nature of the tags that are recognized;
41
+ # * the value of `$SAFE` under which the template is run;
42
+ # * the binding used to resolve local variables in the template.
43
+ #
44
+ #
45
+ # See the ERB.new and ERB#result methods for more detail.
46
+ #
47
+ # ## Character encodings
48
+ #
49
+ # ERB (or Ruby code generated by ERB) returns a string in the same character
50
+ # encoding as the input string. When the input string has a magic comment,
51
+ # however, it returns a string in the encoding specified by the magic comment.
52
+ #
53
+ # # -*- coding: utf-8 -*-
54
+ # require 'erb'
55
+ #
56
+ # template = ERB.new <<EOF
57
+ # <%#-*- coding: Big5 -*-%>
58
+ # \_\_ENCODING\_\_ is <%= \_\_ENCODING\_\_ %>.
59
+ # EOF
60
+ # puts template.result
61
+ #
62
+ # *Prints:* _*ENCODING*_ is Big5.
63
+ #
64
+ # ## Examples
65
+ #
66
+ # ### Plain Text
67
+ #
68
+ # ERB is useful for any generic templating situation. Note that in this
69
+ # example, we use the convenient "% at start of line" tag, and we quote the
70
+ # template literally with `%q{...}` to avoid trouble with the backslash.
71
+ #
72
+ # require "erb"
73
+ #
74
+ # # Create template.
75
+ # template = %q{
76
+ # From: James Edward Gray II <james@grayproductions.net>
77
+ # To: <%= to %>
78
+ # Subject: Addressing Needs
79
+ #
80
+ # <%= to[/\w+/] %>:
81
+ #
82
+ # Just wanted to send a quick note assuring that your needs are being
83
+ # addressed.
84
+ #
85
+ # I want you to know that my team will keep working on the issues,
86
+ # especially:
87
+ #
88
+ # <%# ignore numerous minor requests -- focus on priorities %>
89
+ # % priorities.each do |priority|
90
+ # * <%= priority %>
91
+ # % end
92
+ #
93
+ # Thanks for your patience.
94
+ #
95
+ # James Edward Gray II
96
+ # }.gsub(/^ /, '')
97
+ #
98
+ # message = ERB.new(template, trim_mode: "%<>")
99
+ #
100
+ # # Set up template data.
101
+ # to = "Community Spokesman <spokesman@ruby_community.org>"
102
+ # priorities = [ "Run Ruby Quiz",
103
+ # "Document Modules",
104
+ # "Answer Questions on Ruby Talk" ]
105
+ #
106
+ # # Produce result.
107
+ # email = message.result
108
+ # puts email
109
+ #
110
+ # *Generates:*
111
+ #
112
+ # From: James Edward Gray II <james@grayproductions.net>
113
+ # To: Community Spokesman <spokesman@ruby_community.org>
114
+ # Subject: Addressing Needs
115
+ #
116
+ # Community:
117
+ #
118
+ # Just wanted to send a quick note assuring that your needs are being addressed.
119
+ #
120
+ # I want you to know that my team will keep working on the issues, especially:
121
+ #
122
+ # * Run Ruby Quiz
123
+ # * Document Modules
124
+ # * Answer Questions on Ruby Talk
125
+ #
126
+ # Thanks for your patience.
127
+ #
128
+ # James Edward Gray II
129
+ #
130
+ # ### Ruby in HTML
131
+ #
132
+ # ERB is often used in `.rhtml` files (HTML with embedded Ruby). Notice the
133
+ # need in this example to provide a special binding when the template is run, so
134
+ # that the instance variables in the Product object can be resolved.
135
+ #
136
+ # require "erb"
137
+ #
138
+ # # Build template data class.
139
+ # class Product
140
+ # def initialize( code, name, desc, cost )
141
+ # @code = code
142
+ # @name = name
143
+ # @desc = desc
144
+ # @cost = cost
145
+ #
146
+ # @features = [ ]
147
+ # end
148
+ #
149
+ # def add_feature( feature )
150
+ # @features << feature
151
+ # end
152
+ #
153
+ # # Support templating of member data.
154
+ # def get_binding
155
+ # binding
156
+ # end
157
+ #
158
+ # # ...
159
+ # end
160
+ #
161
+ # # Create template.
162
+ # template = %{
163
+ # <html>
164
+ # <head><title>Ruby Toys -- <%= @name %></title></head>
165
+ # <body>
166
+ #
167
+ # <h1><%= @name %> (<%= @code %>)</h1>
168
+ # <p><%= @desc %></p>
169
+ #
170
+ # <ul>
171
+ # <% @features.each do |f| %>
172
+ # <li><b><%= f %></b></li>
173
+ # <% end %>
174
+ # </ul>
175
+ #
176
+ # <p>
177
+ # <% if @cost < 10 %>
178
+ # <b>Only <%= @cost %>!!!</b>
179
+ # <% else %>
180
+ # Call for a price, today!
181
+ # <% end %>
182
+ # </p>
183
+ #
184
+ # </body>
185
+ # </html>
186
+ # }.gsub(/^ /, '')
187
+ #
188
+ # rhtml = ERB.new(template)
189
+ #
190
+ # # Set up template data.
191
+ # toy = Product.new( "TZ-1002",
192
+ # "Rubysapien",
193
+ # "Geek's Best Friend! Responds to Ruby commands...",
194
+ # 999.95 )
195
+ # toy.add_feature("Listens for verbal commands in the Ruby language!")
196
+ # toy.add_feature("Ignores Perl, Java, and all C variants.")
197
+ # toy.add_feature("Karate-Chop Action!!!")
198
+ # toy.add_feature("Matz signature on left leg.")
199
+ # toy.add_feature("Gem studded eyes... Rubies, of course!")
200
+ #
201
+ # # Produce result.
202
+ # rhtml.run(toy.get_binding)
203
+ #
204
+ # *Generates (some blank lines removed):*
205
+ #
206
+ # <html>
207
+ # <head><title>Ruby Toys -- Rubysapien</title></head>
208
+ # <body>
209
+ #
210
+ # <h1>Rubysapien (TZ-1002)</h1>
211
+ # <p>Geek's Best Friend! Responds to Ruby commands...</p>
212
+ #
213
+ # <ul>
214
+ # <li><b>Listens for verbal commands in the Ruby language!</b></li>
215
+ # <li><b>Ignores Perl, Java, and all C variants.</b></li>
216
+ # <li><b>Karate-Chop Action!!!</b></li>
217
+ # <li><b>Matz signature on left leg.</b></li>
218
+ # <li><b>Gem studded eyes... Rubies, of course!</b></li>
219
+ # </ul>
220
+ #
221
+ # <p>
222
+ # Call for a price, today!
223
+ # </p>
224
+ #
225
+ # </body>
226
+ # </html>
227
+ #
228
+ # ## Notes
229
+ #
230
+ # There are a variety of templating solutions available in various Ruby
231
+ # projects:
232
+ # * ERB's big brother, eRuby, works the same but is written in C for speed;
233
+ # * Amrita (smart at producing HTML/XML);
234
+ # * cs/Template (written in C for speed);
235
+ # * RDoc, distributed with Ruby, uses its own template engine, which can be
236
+ # reused elsewhere;
237
+ # * and others; search [RubyGems.org](https://rubygems.org/) or [The Ruby
238
+ # Toolbox](https://www.ruby-toolbox.com/).
239
+ #
240
+ #
241
+ # Rails, the web application framework, uses ERB to create views.
242
+ #
1
243
  class ERB
244
+ # Returns revision information for the erb.rb module.
245
+ #
2
246
  def self.version: () -> String
3
247
 
4
- def initialize: (String, ?trim_mode: Integer | String | NilClass, ?eoutvar: String) -> untyped
248
+ # Constructs a new ERB object with the template specified in *str*.
249
+ #
250
+ # An ERB object works by building a chunk of Ruby code that will output the
251
+ # completed template when run. If *safe_level* is set to a non-nil value, ERB
252
+ # code will be run in a separate thread with **$SAFE** set to the provided
253
+ # level.
254
+ #
255
+ # If *trim_mode* is passed a String containing one or more of the following
256
+ # modifiers, ERB will adjust its code generation as listed:
257
+ #
258
+ # % enables Ruby code processing for lines beginning with %
259
+ # <> omit newline for lines starting with <% and ending in %>
260
+ # > omit newline for lines ending in %>
261
+ # - omit blank lines ending in -%>
262
+ #
263
+ # *eoutvar* can be used to set the name of the variable ERB will build up its
264
+ # output in. This is useful when you need to run multiple ERB templates through
265
+ # the same binding and/or when you want to control where output ends up. Pass
266
+ # the name of the variable to be used inside a String.
267
+ #
268
+ # ### Example
269
+ #
270
+ # require "erb"
271
+ #
272
+ # # build data class
273
+ # class Listings
274
+ # PRODUCT = { :name => "Chicken Fried Steak",
275
+ # :desc => "A well messages pattie, breaded and fried.",
276
+ # :cost => 9.95 }
277
+ #
278
+ # attr_reader :product, :price
279
+ #
280
+ # def initialize( product = "", price = "" )
281
+ # @product = product
282
+ # @price = price
283
+ # end
284
+ #
285
+ # def build
286
+ # b = binding
287
+ # # create and run templates, filling member data variables
288
+ # ERB.new(<<-'END_PRODUCT'.gsub(/^\s+/, ""), trim_mode: "", eoutvar: "@product").result b
289
+ # <%= PRODUCT[:name] %>
290
+ # <%= PRODUCT[:desc] %>
291
+ # END_PRODUCT
292
+ # ERB.new(<<-'END_PRICE'.gsub(/^\s+/, ""), trim_mode: "", eoutvar: "@price").result b
293
+ # <%= PRODUCT[:name] %> -- <%= PRODUCT[:cost] %>
294
+ # <%= PRODUCT[:desc] %>
295
+ # END_PRICE
296
+ # end
297
+ # end
298
+ #
299
+ # # setup template data
300
+ # listings = Listings.new
301
+ # listings.build
302
+ #
303
+ # puts listings.product + "\n" + listings.price
304
+ #
305
+ # *Generates*
306
+ #
307
+ # Chicken Fried Steak
308
+ # A well messages pattie, breaded and fried.
309
+ #
310
+ # Chicken Fried Steak -- 9.95
311
+ # A well messages pattie, breaded and fried.
312
+ #
313
+ def initialize: (String, ?eoutvar: String, ?trim_mode: Integer | String | NilClass) -> untyped
314
+
315
+ # The Ruby code generated by ERB
316
+ #
5
317
  def src: () -> String
318
+
319
+ # The encoding to eval
320
+ #
6
321
  def encoding: () -> Encoding
322
+
323
+ # The optional *filename* argument passed to Kernel#eval when the ERB code is
324
+ # run
325
+ #
7
326
  def filename: () -> (String | NilClass)
8
327
  def filename=: (String | NilClass) -> untyped
328
+
329
+ # The optional *lineno* argument passed to Kernel#eval when the ERB code is run
330
+ #
9
331
  def lineno: () -> Integer
10
332
  def lineno=: (Integer) -> untyped
11
333
  def location=: (Array[String | Integer]) -> untyped
334
+
335
+ # Generate results and print them. (see ERB#result)
336
+ #
12
337
  def run: (?Binding) -> untyped
338
+
339
+ # Executes the generated ERB code to produce a completed template, returning the
340
+ # results of that code. (See ERB::new for details on how this process can be
341
+ # affected by *safe_level*.)
342
+ #
343
+ # *b* accepts a Binding object which is used to set the context of code
344
+ # evaluation.
345
+ #
13
346
  def result: (?Binding) -> String
347
+
348
+ # Render a template on a new toplevel binding with local variables specified by
349
+ # a Hash object.
350
+ #
14
351
  def result_with_hash: (Hash[untyped, untyped]) -> String
352
+
353
+ # Define *methodname* as instance method of *mod* from compiled Ruby source.
354
+ #
355
+ # example:
356
+ # filename = 'example.rhtml' # 'arg1' and 'arg2' are used in example.rhtml
357
+ # erb = ERB.new(File.read(filename))
358
+ # erb.def_method(MyClass, 'render(arg1, arg2)', filename)
359
+ # print MyClass.new.render('foo', 123)
360
+ #
15
361
  def def_method: (Module, String, ?String) -> untyped
362
+
363
+ # Create unnamed module, define *methodname* as instance method of it, and
364
+ # return it.
365
+ #
366
+ # example:
367
+ # filename = 'example.rhtml' # 'arg1' and 'arg2' are used in example.rhtml
368
+ # erb = ERB.new(File.read(filename))
369
+ # erb.filename = filename
370
+ # MyModule = erb.def_module('render(arg1, arg2)')
371
+ # class MyClass
372
+ # include MyModule
373
+ # end
374
+ #
16
375
  def def_module: (?String) -> Module
376
+
377
+ # Define unnamed class which has *methodname* as instance method, and return it.
378
+ #
379
+ # example:
380
+ # class MyClass_
381
+ # def initialize(arg1, arg2)
382
+ # @arg1 = arg1; @arg2 = arg2
383
+ # end
384
+ # end
385
+ # filename = 'example.rhtml' # @arg1 and @arg2 are used in example.rhtml
386
+ # erb = ERB.new(File.read(filename))
387
+ # erb.filename = filename
388
+ # MyClass = erb.def_class(MyClass_, 'render()')
389
+ # print MyClass.new('foo', 123).render()
390
+ #
17
391
  def def_class: (?Class, ?String) -> Class
18
392
  end
@@ -38,7 +38,3 @@ module Find
38
38
  #
39
39
  def self?.prune: () -> void
40
40
  end
41
-
42
- interface _ToPath
43
- def to_path: () -> String
44
- end
@@ -0,0 +1,247 @@
1
+ # IPAddr provides a set of methods to manipulate an IP address. Both IPv4 and
2
+ # IPv6 are supported.
3
+ #
4
+ # ## Example
5
+ #
6
+ # require 'ipaddr'
7
+ #
8
+ # ipaddr1 = IPAddr.new "3ffe:505:2::1"
9
+ #
10
+ # p ipaddr1 #=> #<IPAddr: IPv6:3ffe:0505:0002:0000:0000:0000:0000:0001/ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff>
11
+ #
12
+ # p ipaddr1.to_s #=> "3ffe:505:2::1"
13
+ #
14
+ # ipaddr2 = ipaddr1.mask(48) #=> #<IPAddr: IPv6:3ffe:0505:0002:0000:0000:0000:0000:0000/ffff:ffff:ffff:0000:0000:0000:0000:0000>
15
+ #
16
+ # p ipaddr2.to_s #=> "3ffe:505:2::"
17
+ #
18
+ # ipaddr3 = IPAddr.new "192.168.2.0/24"
19
+ #
20
+ # p ipaddr3 #=> #<IPAddr: IPv4:192.168.2.0/255.255.255.0>
21
+ #
22
+ class IPAddr
23
+ include Comparable
24
+
25
+ # Creates a new ipaddr containing the given network byte ordered string form of
26
+ # an IP address.
27
+ #
28
+ def self.new_ntoh: (String addr) -> IPAddr
29
+
30
+ # Convert a network byte ordered string form of an IP address into human
31
+ # readable form.
32
+ #
33
+ def self.ntop: (String addr) -> String
34
+
35
+ # Creates a new ipaddr object either from a human readable IP address
36
+ # representation in string, or from a packed in_addr value followed by an
37
+ # address family.
38
+ #
39
+ # In the former case, the following are the valid formats that will be
40
+ # recognized: "address", "address/prefixlen" and "address/mask", where IPv6
41
+ # address may be enclosed in square brackets (`[' and `]'). If a prefixlen or a
42
+ # mask is specified, it returns a masked IP address. Although the address
43
+ # family is determined automatically from a specified string, you can specify
44
+ # one explicitly by the optional second argument.
45
+ #
46
+ # Otherwise an IP address is generated from a packed in_addr value and an
47
+ # address family.
48
+ #
49
+ # The IPAddr class defines many methods and operators, and some of those, such
50
+ # as &, |, include? and ==, accept a string, or a packed in_addr value instead
51
+ # of an IPAddr object.
52
+ #
53
+ def initialize: (?String addr, ?untyped family) -> IPAddr
54
+
55
+ # Returns a new ipaddr built by bitwise AND.
56
+ #
57
+ def &: (untyped other) -> IPAddr
58
+
59
+ # Returns a new ipaddr built by bitwise left shift.
60
+ #
61
+ def <<: (Integer num) -> IPAddr
62
+
63
+ # Compares the ipaddr with another.
64
+ #
65
+ def <=>: (untyped other) -> Integer?
66
+
67
+ # Returns true if two ipaddrs are equal.
68
+ #
69
+ def ==: (untyped other) -> bool
70
+
71
+ alias === include?
72
+
73
+ # Returns a new ipaddr built by bitwise right-shift.
74
+ #
75
+ def >>: (Integer num) -> IPAddr
76
+
77
+ # Checks equality used by Hash.
78
+ #
79
+ def eql?: (untyped other) -> bool
80
+
81
+ # Returns the address family of this IP address.
82
+ #
83
+ attr_reader family: Integer
84
+
85
+ # Returns a hash value used by Hash, Set, and Array classes
86
+ #
87
+ def hash: () -> Integer
88
+
89
+ # Returns a network byte ordered string form of the IP address.
90
+ #
91
+ def hton: () -> String
92
+
93
+ # Returns true if the given ipaddr is in the range.
94
+ #
95
+ # e.g.:
96
+ # require 'ipaddr'
97
+ # net1 = IPAddr.new("192.168.2.0/24")
98
+ # net2 = IPAddr.new("192.168.2.100")
99
+ # net3 = IPAddr.new("192.168.3.0")
100
+ # p net1.include?(net2) #=> true
101
+ # p net1.include?(net3) #=> false
102
+ #
103
+ def include?: (untyped other) -> bool
104
+
105
+ # Returns a string containing a human-readable representation of the ipaddr.
106
+ # ("#<IPAddr: family:address/mask>")
107
+ #
108
+ def inspect: () -> String
109
+
110
+ # Returns a string for DNS reverse lookup compatible with RFC3172.
111
+ #
112
+ def ip6_arpa: () -> String
113
+
114
+ # Returns a string for DNS reverse lookup compatible with RFC1886.
115
+ #
116
+ def ip6_int: () -> String
117
+
118
+ # Returns true if the ipaddr is an IPv4 address.
119
+ #
120
+ def ipv4?: () -> bool
121
+
122
+ # Returns a new ipaddr built by converting the native IPv4 address into an
123
+ # IPv4-compatible IPv6 address.
124
+ #
125
+ def ipv4_compat: () -> IPAddr
126
+
127
+ # Returns true if the ipaddr is an IPv4-compatible IPv6 address.
128
+ #
129
+ def ipv4_compat?: () -> bool
130
+
131
+ # Returns a new ipaddr built by converting the native IPv4 address into an
132
+ # IPv4-mapped IPv6 address.
133
+ #
134
+ def ipv4_mapped: () -> IPAddr
135
+
136
+ # Returns true if the ipaddr is an IPv4-mapped IPv6 address.
137
+ #
138
+ def ipv4_mapped?: () -> bool
139
+
140
+ # Returns true if the ipaddr is an IPv6 address.
141
+ #
142
+ def ipv6?: () -> bool
143
+
144
+ # Returns true if the ipaddr is a link-local address. IPv4 addresses in
145
+ # 169.254.0.0/16 reserved by RFC 3927 and Link-Local IPv6 Unicast Addresses in
146
+ # fe80::/10 reserved by RFC 4291 are considered link-local.
147
+ #
148
+ def link_local?: () -> bool
149
+
150
+ # Returns true if the ipaddr is a loopback address.
151
+ #
152
+ def loopback?: () -> bool
153
+
154
+ # Returns a new ipaddr built by masking IP address with the given
155
+ # prefixlen/netmask. (e.g. 8, 64, "255.255.255.0", etc.)
156
+ #
157
+ def mask: (String | Integer prefixlen) -> IPAddr
158
+
159
+ # Returns a new ipaddr built by converting the IPv6 address into a native IPv4
160
+ # address. If the IP address is not an IPv4-mapped or IPv4-compatible IPv6
161
+ # address, returns self.
162
+ #
163
+ def native: () -> IPAddr
164
+
165
+ # Returns the prefix length in bits for the ipaddr.
166
+ #
167
+ def prefix: () -> Integer
168
+
169
+ # Sets the prefix length in bits
170
+ #
171
+ def prefix=: (Integer prefix) -> self
172
+
173
+ # Returns true if the ipaddr is a private address. IPv4 addresses in
174
+ # 10.0.0.0/8, 172.16.0.0/12 and 192.168.0.0/16 as defined in RFC 1918 and IPv6
175
+ # Unique Local Addresses in fc00::/7 as defined in RFC 4193 are considered
176
+ # private.
177
+ #
178
+ def private?: () -> bool
179
+
180
+ # Returns a string for DNS reverse lookup. It returns a string in RFC3172 form
181
+ # for an IPv6 address.
182
+ #
183
+ def reverse: () -> String
184
+
185
+ # Returns the successor to the ipaddr.
186
+ #
187
+ def succ: () -> IPAddr
188
+
189
+ # Returns the integer representation of the ipaddr.
190
+ #
191
+ def to_i: () -> Integer
192
+
193
+ # Creates a Range object for the network address.
194
+ #
195
+ def to_range: () -> Range[IPAddr]
196
+
197
+ # Returns a string containing the IP address representation.
198
+ #
199
+ def to_s: () -> String
200
+
201
+ # Returns a string containing the IP address representation in canonical form.
202
+ #
203
+ def to_string: () -> String
204
+
205
+ # Returns a new ipaddr built by bitwise OR.
206
+ #
207
+ def |: (untyped other) -> IPAddr
208
+
209
+ # Returns a new ipaddr built by bitwise negation.
210
+ #
211
+ def ~: () -> IPAddr
212
+ end
213
+
214
+ # Generic IPAddr related error. Exceptions raised in this class should inherit
215
+ # from Error.
216
+ #
217
+ class IPAddr::Error < ArgumentError
218
+ end
219
+
220
+ # Raised when the provided IP address is an invalid address.
221
+ #
222
+ class IPAddr::InvalidAddressError < IPAddr::Error
223
+ end
224
+
225
+ # Raised when the address family is invalid such as an address with an
226
+ # unsupported family, an address with an inconsistent family, or an address
227
+ # who's family cannot be determined.
228
+ #
229
+ class IPAddr::AddressFamilyError < IPAddr::Error
230
+ end
231
+
232
+ # Raised when the address is an invalid length.
233
+ #
234
+ class IPAddr::InvalidPrefixError < IPAddr::InvalidAddressError
235
+ end
236
+
237
+ # 32 bit mask for IPv4
238
+ #
239
+ IPAddr::IN4MASK: Integer
240
+
241
+ # Format string for IPv6
242
+ #
243
+ IPAddr::IN6FORMAT: String
244
+
245
+ # 128 bit mask for IPv6
246
+ #
247
+ IPAddr::IN6MASK: Integer