sorbet-result 1.2.0 → 1.3.0
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.
- checksums.yaml +4 -4
- data/.ruby-version +1 -1
- data/CHANGELOG.md +6 -0
- data/Gemfile.lock +73 -51
- data/README.md +1 -1
- data/lib/typed/no_payload_on_failure_error.rb +8 -3
- data/lib/typed/result.rb +1 -1
- data/sorbet/rbi/gems/{ast@2.4.2.rbi → ast@2.4.3.rbi} +3 -3
- data/sorbet/rbi/gems/benchmark@0.4.1.rbi +619 -0
- data/sorbet/rbi/gems/cgi@0.5.0.rbi +2961 -0
- data/sorbet/rbi/gems/date@3.4.1.rbi +75 -0
- data/sorbet/rbi/gems/erb@4.0.4.rbi +910 -0
- data/sorbet/rbi/gems/{erubi@1.13.0.rbi → erubi@1.13.1.rbi} +14 -9
- data/sorbet/rbi/gems/{json@2.7.5.rbi → json@2.12.2.rbi} +654 -232
- data/sorbet/rbi/gems/{language_server-protocol@3.17.0.3.rbi → language_server-protocol@3.17.0.5.rbi} +11 -5
- data/sorbet/rbi/gems/logger@1.7.0.rbi +963 -0
- data/sorbet/rbi/gems/{minitest@5.25.1.rbi → minitest@5.25.5.rbi} +227 -220
- data/sorbet/rbi/gems/{parser@3.3.5.1.rbi → parser@3.3.8.0.rbi} +215 -199
- data/sorbet/rbi/gems/pp@0.6.2.rbi +368 -0
- data/sorbet/rbi/gems/prettyprint@0.2.0.rbi +477 -0
- data/sorbet/rbi/gems/{prism@1.2.0.rbi → prism@1.4.0.rbi} +6569 -3922
- data/sorbet/rbi/gems/{psych@5.1.2.rbi → psych@5.2.6.rbi} +973 -236
- data/sorbet/rbi/gems/{rake@13.2.1.rbi → rake@13.3.0.rbi} +15 -12
- data/sorbet/rbi/gems/{rbi@0.2.1.rbi → rbi@0.3.6.rbi} +3340 -982
- data/sorbet/rbi/gems/rbs@3.9.4.rbi +6976 -0
- data/sorbet/rbi/gems/{regexp_parser@2.9.2.rbi → regexp_parser@2.10.0.rbi} +193 -170
- data/sorbet/rbi/gems/{rubocop-ast@1.33.1.rbi → rubocop-ast@1.45.1.rbi} +1069 -826
- data/sorbet/rbi/gems/{rubocop@1.66.1.rbi → rubocop@1.75.8.rbi} +7880 -4054
- data/sorbet/rbi/gems/{spoom@1.5.0.rbi → spoom@1.6.1.rbi} +3315 -973
- data/sorbet/rbi/gems/{standard@1.41.1.rbi → standard@1.50.0.rbi} +68 -59
- data/sorbet/rbi/gems/{tapioca@0.16.3.rbi → tapioca@0.16.11.rbi} +273 -248
- data/sorbet/rbi/gems/unicode-display_width@3.1.4.rbi +132 -0
- data/sorbet/rbi/gems/unicode-emoji@4.0.4.rbi +251 -0
- metadata +41 -33
- data/.tool-versions +0 -1
- data/sorbet/rbi/gems/unicode-display_width@2.6.0.rbi +0 -66
- /data/sorbet/rbi/gems/{io-console@0.7.2.rbi → io-console@0.8.0.rbi} +0 -0
- /data/sorbet/rbi/gems/{parallel@1.26.3.rbi → parallel@1.27.0.rbi} +0 -0
- /data/sorbet/rbi/gems/{reline@0.5.10.rbi → reline@0.6.1.rbi} +0 -0
- /data/sorbet/rbi/gems/{rubocop-performance@1.22.1.rbi → rubocop-performance@1.25.0.rbi} +0 -0
- /data/sorbet/rbi/gems/{rubocop-sorbet@0.7.8.rbi → rubocop-sorbet@0.9.0.rbi} +0 -0
- /data/sorbet/rbi/gems/{standard-performance@1.5.0.rbi → standard-performance@1.8.0.rbi} +0 -0
- /data/sorbet/rbi/gems/{standard-sorbet@0.0.2.rbi → standard-sorbet@0.0.3.rbi} +0 -0
- /data/sorbet/rbi/gems/{stringio@3.1.1.rbi → stringio@3.1.7.rbi} +0 -0
@@ -0,0 +1,910 @@
|
|
1
|
+
# typed: false
|
2
|
+
|
3
|
+
# DO NOT EDIT MANUALLY
|
4
|
+
# This is an autogenerated file for types exported from the `erb` gem.
|
5
|
+
# Please instead update this file by running `bin/tapioca gem erb`.
|
6
|
+
|
7
|
+
|
8
|
+
# = ERB -- Ruby Templating
|
9
|
+
#
|
10
|
+
# == Introduction
|
11
|
+
#
|
12
|
+
# ERB provides an easy to use but powerful templating system for Ruby. Using
|
13
|
+
# ERB, actual Ruby code can be added to any plain text document for the
|
14
|
+
# purposes of generating document information details and/or flow control.
|
15
|
+
#
|
16
|
+
# A very simple example is this:
|
17
|
+
#
|
18
|
+
# require 'erb'
|
19
|
+
#
|
20
|
+
# x = 42
|
21
|
+
# template = ERB.new <<-EOF
|
22
|
+
# The value of x is: <%= x %>
|
23
|
+
# EOF
|
24
|
+
# puts template.result(binding)
|
25
|
+
#
|
26
|
+
# <em>Prints:</em> The value of x is: 42
|
27
|
+
#
|
28
|
+
# More complex examples are given below.
|
29
|
+
#
|
30
|
+
#
|
31
|
+
# == Recognized Tags
|
32
|
+
#
|
33
|
+
# ERB recognizes certain tags in the provided template and converts them based
|
34
|
+
# on the rules below:
|
35
|
+
#
|
36
|
+
# <% Ruby code -- inline with output %>
|
37
|
+
# <%= Ruby expression -- replace with result %>
|
38
|
+
# <%# comment -- ignored -- useful in testing %> (`<% #` doesn't work. Don't use Ruby comments.)
|
39
|
+
# % a line of Ruby code -- treated as <% line %> (optional -- see ERB.new)
|
40
|
+
# %% replaced with % if first thing on a line and % processing is used
|
41
|
+
# <%% or %%> -- replace with <% or %> respectively
|
42
|
+
#
|
43
|
+
# All other text is passed through ERB filtering unchanged.
|
44
|
+
#
|
45
|
+
#
|
46
|
+
# == Options
|
47
|
+
#
|
48
|
+
# There are several settings you can change when you use ERB:
|
49
|
+
# * the nature of the tags that are recognized;
|
50
|
+
# * the binding used to resolve local variables in the template.
|
51
|
+
#
|
52
|
+
# See the ERB.new and ERB#result methods for more detail.
|
53
|
+
#
|
54
|
+
# == Character encodings
|
55
|
+
#
|
56
|
+
# ERB (or Ruby code generated by ERB) returns a string in the same
|
57
|
+
# character encoding as the input string. When the input string has
|
58
|
+
# a magic comment, however, it returns a string in the encoding specified
|
59
|
+
# by the magic comment.
|
60
|
+
#
|
61
|
+
# # -*- coding: utf-8 -*-
|
62
|
+
# require 'erb'
|
63
|
+
#
|
64
|
+
# template = ERB.new <<EOF
|
65
|
+
# <%#-*- coding: Big5 -*-%>
|
66
|
+
# \_\_ENCODING\_\_ is <%= \_\_ENCODING\_\_ %>.
|
67
|
+
# EOF
|
68
|
+
# puts template.result
|
69
|
+
#
|
70
|
+
# <em>Prints:</em> \_\_ENCODING\_\_ is Big5.
|
71
|
+
#
|
72
|
+
#
|
73
|
+
# == Examples
|
74
|
+
#
|
75
|
+
# === Plain Text
|
76
|
+
#
|
77
|
+
# ERB is useful for any generic templating situation. Note that in this example, we use the
|
78
|
+
# convenient "% at start of line" tag, and we quote the template literally with
|
79
|
+
# <tt>%q{...}</tt> to avoid trouble with the backslash.
|
80
|
+
#
|
81
|
+
# require "erb"
|
82
|
+
#
|
83
|
+
# # Create template.
|
84
|
+
# template = %q{
|
85
|
+
# From: James Edward Gray II <james@grayproductions.net>
|
86
|
+
# To: <%= to %>
|
87
|
+
# Subject: Addressing Needs
|
88
|
+
#
|
89
|
+
# <%= to[/\w+/] %>:
|
90
|
+
#
|
91
|
+
# Just wanted to send a quick note assuring that your needs are being
|
92
|
+
# addressed.
|
93
|
+
#
|
94
|
+
# I want you to know that my team will keep working on the issues,
|
95
|
+
# especially:
|
96
|
+
#
|
97
|
+
# <%# ignore numerous minor requests -- focus on priorities %>
|
98
|
+
# % priorities.each do |priority|
|
99
|
+
# * <%= priority %>
|
100
|
+
# % end
|
101
|
+
#
|
102
|
+
# Thanks for your patience.
|
103
|
+
#
|
104
|
+
# James Edward Gray II
|
105
|
+
# }.gsub(/^ /, '')
|
106
|
+
#
|
107
|
+
# message = ERB.new(template, trim_mode: "%<>")
|
108
|
+
#
|
109
|
+
# # Set up template data.
|
110
|
+
# to = "Community Spokesman <spokesman@ruby_community.org>"
|
111
|
+
# priorities = [ "Run Ruby Quiz",
|
112
|
+
# "Document Modules",
|
113
|
+
# "Answer Questions on Ruby Talk" ]
|
114
|
+
#
|
115
|
+
# # Produce result.
|
116
|
+
# email = message.result
|
117
|
+
# puts email
|
118
|
+
#
|
119
|
+
# <i>Generates:</i>
|
120
|
+
#
|
121
|
+
# From: James Edward Gray II <james@grayproductions.net>
|
122
|
+
# To: Community Spokesman <spokesman@ruby_community.org>
|
123
|
+
# Subject: Addressing Needs
|
124
|
+
#
|
125
|
+
# Community:
|
126
|
+
#
|
127
|
+
# Just wanted to send a quick note assuring that your needs are being addressed.
|
128
|
+
#
|
129
|
+
# I want you to know that my team will keep working on the issues, especially:
|
130
|
+
#
|
131
|
+
# * Run Ruby Quiz
|
132
|
+
# * Document Modules
|
133
|
+
# * Answer Questions on Ruby Talk
|
134
|
+
#
|
135
|
+
# Thanks for your patience.
|
136
|
+
#
|
137
|
+
# James Edward Gray II
|
138
|
+
#
|
139
|
+
# === Ruby in HTML
|
140
|
+
#
|
141
|
+
# ERB is often used in <tt>.rhtml</tt> files (HTML with embedded Ruby). Notice the need in
|
142
|
+
# this example to provide a special binding when the template is run, so that the instance
|
143
|
+
# variables in the Product object can be resolved.
|
144
|
+
#
|
145
|
+
# require "erb"
|
146
|
+
#
|
147
|
+
# # Build template data class.
|
148
|
+
# class Product
|
149
|
+
# def initialize( code, name, desc, cost )
|
150
|
+
# @code = code
|
151
|
+
# @name = name
|
152
|
+
# @desc = desc
|
153
|
+
# @cost = cost
|
154
|
+
#
|
155
|
+
# @features = [ ]
|
156
|
+
# end
|
157
|
+
#
|
158
|
+
# def add_feature( feature )
|
159
|
+
# @features << feature
|
160
|
+
# end
|
161
|
+
#
|
162
|
+
# # Support templating of member data.
|
163
|
+
# def get_binding
|
164
|
+
# binding
|
165
|
+
# end
|
166
|
+
#
|
167
|
+
# # ...
|
168
|
+
# end
|
169
|
+
#
|
170
|
+
# # Create template.
|
171
|
+
# template = %{
|
172
|
+
# <html>
|
173
|
+
# <head><title>Ruby Toys -- <%= @name %></title></head>
|
174
|
+
# <body>
|
175
|
+
#
|
176
|
+
# <h1><%= @name %> (<%= @code %>)</h1>
|
177
|
+
# <p><%= @desc %></p>
|
178
|
+
#
|
179
|
+
# <ul>
|
180
|
+
# <% @features.each do |f| %>
|
181
|
+
# <li><b><%= f %></b></li>
|
182
|
+
# <% end %>
|
183
|
+
# </ul>
|
184
|
+
#
|
185
|
+
# <p>
|
186
|
+
# <% if @cost < 10 %>
|
187
|
+
# <b>Only <%= @cost %>!!!</b>
|
188
|
+
# <% else %>
|
189
|
+
# Call for a price, today!
|
190
|
+
# <% end %>
|
191
|
+
# </p>
|
192
|
+
#
|
193
|
+
# </body>
|
194
|
+
# </html>
|
195
|
+
# }.gsub(/^ /, '')
|
196
|
+
#
|
197
|
+
# rhtml = ERB.new(template)
|
198
|
+
#
|
199
|
+
# # Set up template data.
|
200
|
+
# toy = Product.new( "TZ-1002",
|
201
|
+
# "Rubysapien",
|
202
|
+
# "Geek's Best Friend! Responds to Ruby commands...",
|
203
|
+
# 999.95 )
|
204
|
+
# toy.add_feature("Listens for verbal commands in the Ruby language!")
|
205
|
+
# toy.add_feature("Ignores Perl, Java, and all C variants.")
|
206
|
+
# toy.add_feature("Karate-Chop Action!!!")
|
207
|
+
# toy.add_feature("Matz signature on left leg.")
|
208
|
+
# toy.add_feature("Gem studded eyes... Rubies, of course!")
|
209
|
+
#
|
210
|
+
# # Produce result.
|
211
|
+
# rhtml.run(toy.get_binding)
|
212
|
+
#
|
213
|
+
# <i>Generates (some blank lines removed):</i>
|
214
|
+
#
|
215
|
+
# <html>
|
216
|
+
# <head><title>Ruby Toys -- Rubysapien</title></head>
|
217
|
+
# <body>
|
218
|
+
#
|
219
|
+
# <h1>Rubysapien (TZ-1002)</h1>
|
220
|
+
# <p>Geek's Best Friend! Responds to Ruby commands...</p>
|
221
|
+
#
|
222
|
+
# <ul>
|
223
|
+
# <li><b>Listens for verbal commands in the Ruby language!</b></li>
|
224
|
+
# <li><b>Ignores Perl, Java, and all C variants.</b></li>
|
225
|
+
# <li><b>Karate-Chop Action!!!</b></li>
|
226
|
+
# <li><b>Matz signature on left leg.</b></li>
|
227
|
+
# <li><b>Gem studded eyes... Rubies, of course!</b></li>
|
228
|
+
# </ul>
|
229
|
+
#
|
230
|
+
# <p>
|
231
|
+
# Call for a price, today!
|
232
|
+
# </p>
|
233
|
+
#
|
234
|
+
# </body>
|
235
|
+
# </html>
|
236
|
+
#
|
237
|
+
#
|
238
|
+
# == Notes
|
239
|
+
#
|
240
|
+
# There are a variety of templating solutions available in various Ruby projects.
|
241
|
+
# For example, RDoc, distributed with Ruby, uses its own template engine, which
|
242
|
+
# can be reused elsewhere.
|
243
|
+
#
|
244
|
+
# Other popular engines could be found in the corresponding
|
245
|
+
# {Category}[https://www.ruby-toolbox.com/categories/template_engines] of
|
246
|
+
# The Ruby Toolbox.
|
247
|
+
#
|
248
|
+
# source://erb//lib/erb/version.rb#2
|
249
|
+
class ERB
|
250
|
+
# Constructs a new ERB object with the template specified in _str_.
|
251
|
+
#
|
252
|
+
# An ERB object works by building a chunk of Ruby code that will output
|
253
|
+
# the completed template when run.
|
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
|
264
|
+
# its output in. This is useful when you need to run multiple ERB
|
265
|
+
# templates through the same binding and/or when you want to control where
|
266
|
+
# output ends up. Pass 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', trim_mode: "", eoutvar: "@product").result b
|
289
|
+
# <%= PRODUCT[:name] %>
|
290
|
+
# <%= PRODUCT[:desc] %>
|
291
|
+
# END_PRODUCT
|
292
|
+
# ERB.new(<<~'END_PRICE', 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
|
+
# @return [ERB] a new instance of ERB
|
314
|
+
#
|
315
|
+
# source://erb//lib/erb.rb#335
|
316
|
+
def initialize(str, safe_level = T.unsafe(nil), legacy_trim_mode = T.unsafe(nil), legacy_eoutvar = T.unsafe(nil), trim_mode: T.unsafe(nil), eoutvar: T.unsafe(nil)); end
|
317
|
+
|
318
|
+
# Define unnamed class which has _methodname_ as instance method, and return it.
|
319
|
+
#
|
320
|
+
# example:
|
321
|
+
# class MyClass_
|
322
|
+
# def initialize(arg1, arg2)
|
323
|
+
# @arg1 = arg1; @arg2 = arg2
|
324
|
+
# end
|
325
|
+
# end
|
326
|
+
# filename = 'example.rhtml' # @arg1 and @arg2 are used in example.rhtml
|
327
|
+
# erb = ERB.new(File.read(filename))
|
328
|
+
# erb.filename = filename
|
329
|
+
# MyClass = erb.def_class(MyClass_, 'render()')
|
330
|
+
# print MyClass.new('foo', 123).render()
|
331
|
+
#
|
332
|
+
# source://erb//lib/erb.rb#501
|
333
|
+
def def_class(superklass = T.unsafe(nil), methodname = T.unsafe(nil)); end
|
334
|
+
|
335
|
+
# Define _methodname_ as instance method of _mod_ from compiled Ruby source.
|
336
|
+
#
|
337
|
+
# example:
|
338
|
+
# filename = 'example.rhtml' # 'arg1' and 'arg2' are used in example.rhtml
|
339
|
+
# erb = ERB.new(File.read(filename))
|
340
|
+
# erb.def_method(MyClass, 'render(arg1, arg2)', filename)
|
341
|
+
# print MyClass.new.render('foo', 123)
|
342
|
+
#
|
343
|
+
# source://erb//lib/erb.rb#465
|
344
|
+
def def_method(mod, methodname, fname = T.unsafe(nil)); end
|
345
|
+
|
346
|
+
# Create unnamed module, define _methodname_ as instance method of it, and return it.
|
347
|
+
#
|
348
|
+
# example:
|
349
|
+
# filename = 'example.rhtml' # 'arg1' and 'arg2' are used in example.rhtml
|
350
|
+
# erb = ERB.new(File.read(filename))
|
351
|
+
# erb.filename = filename
|
352
|
+
# MyModule = erb.def_module('render(arg1, arg2)')
|
353
|
+
# class MyClass
|
354
|
+
# include MyModule
|
355
|
+
# end
|
356
|
+
#
|
357
|
+
# source://erb//lib/erb.rb#482
|
358
|
+
def def_module(methodname = T.unsafe(nil)); end
|
359
|
+
|
360
|
+
# The encoding to eval
|
361
|
+
#
|
362
|
+
# source://erb//lib/erb.rb#370
|
363
|
+
def encoding; end
|
364
|
+
|
365
|
+
# The optional _filename_ argument passed to Kernel#eval when the ERB code
|
366
|
+
# is run
|
367
|
+
#
|
368
|
+
# source://erb//lib/erb.rb#374
|
369
|
+
def filename; end
|
370
|
+
|
371
|
+
# The optional _filename_ argument passed to Kernel#eval when the ERB code
|
372
|
+
# is run
|
373
|
+
#
|
374
|
+
# source://erb//lib/erb.rb#374
|
375
|
+
def filename=(_arg0); end
|
376
|
+
|
377
|
+
# The optional _lineno_ argument passed to Kernel#eval when the ERB code
|
378
|
+
# is run
|
379
|
+
#
|
380
|
+
# source://erb//lib/erb.rb#378
|
381
|
+
def lineno; end
|
382
|
+
|
383
|
+
# The optional _lineno_ argument passed to Kernel#eval when the ERB code
|
384
|
+
# is run
|
385
|
+
#
|
386
|
+
# source://erb//lib/erb.rb#378
|
387
|
+
def lineno=(_arg0); end
|
388
|
+
|
389
|
+
# Sets optional filename and line number that will be used in ERB code
|
390
|
+
# evaluation and error reporting. See also #filename= and #lineno=
|
391
|
+
#
|
392
|
+
# erb = ERB.new('<%= some_x %>')
|
393
|
+
# erb.render
|
394
|
+
# # undefined local variable or method `some_x'
|
395
|
+
# # from (erb):1
|
396
|
+
#
|
397
|
+
# erb.location = ['file.erb', 3]
|
398
|
+
# # All subsequent error reporting would use new location
|
399
|
+
# erb.render
|
400
|
+
# # undefined local variable or method `some_x'
|
401
|
+
# # from file.erb:4
|
402
|
+
#
|
403
|
+
# source://erb//lib/erb.rb#395
|
404
|
+
def location=(_arg0); end
|
405
|
+
|
406
|
+
# Creates a new compiler for ERB. See ERB::Compiler.new for details
|
407
|
+
#
|
408
|
+
# source://erb//lib/erb.rb#362
|
409
|
+
def make_compiler(trim_mode); end
|
410
|
+
|
411
|
+
# Executes the generated ERB code to produce a completed template, returning
|
412
|
+
# the results of that code. (See ERB::new for details on how this process
|
413
|
+
# can be affected by _safe_level_.)
|
414
|
+
#
|
415
|
+
# _b_ accepts a Binding object which is used to set the context of
|
416
|
+
# code evaluation.
|
417
|
+
#
|
418
|
+
# source://erb//lib/erb.rb#425
|
419
|
+
def result(b = T.unsafe(nil)); end
|
420
|
+
|
421
|
+
# Render a template on a new toplevel binding with local variables specified
|
422
|
+
# by a Hash object.
|
423
|
+
#
|
424
|
+
# source://erb//lib/erb.rb#434
|
425
|
+
def result_with_hash(hash); end
|
426
|
+
|
427
|
+
# Generate results and print them. (see ERB#result)
|
428
|
+
#
|
429
|
+
# source://erb//lib/erb.rb#413
|
430
|
+
def run(b = T.unsafe(nil)); end
|
431
|
+
|
432
|
+
# Can be used to set _eoutvar_ as described in ERB::new. It's probably
|
433
|
+
# easier to just use the constructor though, since calling this method
|
434
|
+
# requires the setup of an ERB _compiler_ object.
|
435
|
+
#
|
436
|
+
# source://erb//lib/erb.rb#405
|
437
|
+
def set_eoutvar(compiler, eoutvar = T.unsafe(nil)); end
|
438
|
+
|
439
|
+
# The Ruby code generated by ERB
|
440
|
+
#
|
441
|
+
# source://erb//lib/erb.rb#367
|
442
|
+
def src; end
|
443
|
+
|
444
|
+
private
|
445
|
+
|
446
|
+
# Returns a new binding each time *near* TOPLEVEL_BINDING for runs that do
|
447
|
+
# not specify a binding.
|
448
|
+
#
|
449
|
+
# source://erb//lib/erb.rb#446
|
450
|
+
def new_toplevel(vars = T.unsafe(nil)); end
|
451
|
+
|
452
|
+
class << self
|
453
|
+
# Returns revision information for the erb.rb module.
|
454
|
+
#
|
455
|
+
# source://erb//lib/erb.rb#267
|
456
|
+
def version; end
|
457
|
+
end
|
458
|
+
end
|
459
|
+
|
460
|
+
# --
|
461
|
+
# ERB::Compiler
|
462
|
+
#
|
463
|
+
# Compiles ERB templates into Ruby code; the compiled code produces the
|
464
|
+
# template result when evaluated. ERB::Compiler provides hooks to define how
|
465
|
+
# generated output is handled.
|
466
|
+
#
|
467
|
+
# Internally ERB does something like this to generate the code returned by
|
468
|
+
# ERB#src:
|
469
|
+
#
|
470
|
+
# compiler = ERB::Compiler.new('<>')
|
471
|
+
# compiler.pre_cmd = ["_erbout=+''"]
|
472
|
+
# compiler.put_cmd = "_erbout.<<"
|
473
|
+
# compiler.insert_cmd = "_erbout.<<"
|
474
|
+
# compiler.post_cmd = ["_erbout"]
|
475
|
+
#
|
476
|
+
# code, enc = compiler.compile("Got <%= obj %>!\n")
|
477
|
+
# puts code
|
478
|
+
#
|
479
|
+
# <i>Generates</i>:
|
480
|
+
#
|
481
|
+
# #coding:UTF-8
|
482
|
+
# _erbout=+''; _erbout.<< "Got ".freeze; _erbout.<<(( obj ).to_s); _erbout.<< "!\n".freeze; _erbout
|
483
|
+
#
|
484
|
+
# By default the output is sent to the print method. For example:
|
485
|
+
#
|
486
|
+
# compiler = ERB::Compiler.new('<>')
|
487
|
+
# code, enc = compiler.compile("Got <%= obj %>!\n")
|
488
|
+
# puts code
|
489
|
+
#
|
490
|
+
# <i>Generates</i>:
|
491
|
+
#
|
492
|
+
# #coding:UTF-8
|
493
|
+
# print "Got ".freeze; print(( obj ).to_s); print "!\n".freeze
|
494
|
+
#
|
495
|
+
# == Evaluation
|
496
|
+
#
|
497
|
+
# The compiled code can be used in any context where the names in the code
|
498
|
+
# correctly resolve. Using the last example, each of these print 'Got It!'
|
499
|
+
#
|
500
|
+
# Evaluate using a variable:
|
501
|
+
#
|
502
|
+
# obj = 'It'
|
503
|
+
# eval code
|
504
|
+
#
|
505
|
+
# Evaluate using an input:
|
506
|
+
#
|
507
|
+
# mod = Module.new
|
508
|
+
# mod.module_eval %{
|
509
|
+
# def get(obj)
|
510
|
+
# #{code}
|
511
|
+
# end
|
512
|
+
# }
|
513
|
+
# extend mod
|
514
|
+
# get('It')
|
515
|
+
#
|
516
|
+
# Evaluate using an accessor:
|
517
|
+
#
|
518
|
+
# klass = Class.new Object
|
519
|
+
# klass.class_eval %{
|
520
|
+
# attr_accessor :obj
|
521
|
+
# def initialize(obj)
|
522
|
+
# @obj = obj
|
523
|
+
# end
|
524
|
+
# def get_it
|
525
|
+
# #{code}
|
526
|
+
# end
|
527
|
+
# }
|
528
|
+
# klass.new('It').get_it
|
529
|
+
#
|
530
|
+
# Good! See also ERB#def_method, ERB#def_module, and ERB#def_class.
|
531
|
+
#
|
532
|
+
# source://erb//lib/erb/compiler.rb#73
|
533
|
+
class ERB::Compiler
|
534
|
+
# Construct a new compiler using the trim_mode. See ERB::new for available
|
535
|
+
# trim modes.
|
536
|
+
#
|
537
|
+
# @return [Compiler] a new instance of Compiler
|
538
|
+
#
|
539
|
+
# source://erb//lib/erb/compiler.rb#427
|
540
|
+
def initialize(trim_mode); end
|
541
|
+
|
542
|
+
# source://erb//lib/erb/compiler.rb#309
|
543
|
+
def add_insert_cmd(out, content); end
|
544
|
+
|
545
|
+
# source://erb//lib/erb/compiler.rb#305
|
546
|
+
def add_put_cmd(out, content); end
|
547
|
+
|
548
|
+
# Compiles an ERB template into Ruby code. Returns an array of the code
|
549
|
+
# and encoding like ["code", Encoding].
|
550
|
+
#
|
551
|
+
# @raise [ArgumentError]
|
552
|
+
#
|
553
|
+
# source://erb//lib/erb/compiler.rb#315
|
554
|
+
def compile(s); end
|
555
|
+
|
556
|
+
# source://erb//lib/erb/compiler.rb#375
|
557
|
+
def compile_content(stag, out); end
|
558
|
+
|
559
|
+
# source://erb//lib/erb/compiler.rb#362
|
560
|
+
def compile_etag(etag, out, scanner); end
|
561
|
+
|
562
|
+
# source://erb//lib/erb/compiler.rb#338
|
563
|
+
def compile_stag(stag, out, scanner); end
|
564
|
+
|
565
|
+
# The command to handle text that is inserted prior to a newline
|
566
|
+
#
|
567
|
+
# source://erb//lib/erb/compiler.rb#440
|
568
|
+
def insert_cmd; end
|
569
|
+
|
570
|
+
# The command to handle text that is inserted prior to a newline
|
571
|
+
#
|
572
|
+
# source://erb//lib/erb/compiler.rb#440
|
573
|
+
def insert_cmd=(_arg0); end
|
574
|
+
|
575
|
+
# source://erb//lib/erb/compiler.rb#421
|
576
|
+
def make_scanner(src); end
|
577
|
+
|
578
|
+
# Returns the value of attribute percent.
|
579
|
+
#
|
580
|
+
# source://erb//lib/erb/compiler.rb#434
|
581
|
+
def percent; end
|
582
|
+
|
583
|
+
# An array of commands appended to compiled code
|
584
|
+
#
|
585
|
+
# source://erb//lib/erb/compiler.rb#446
|
586
|
+
def post_cmd; end
|
587
|
+
|
588
|
+
# An array of commands appended to compiled code
|
589
|
+
#
|
590
|
+
# source://erb//lib/erb/compiler.rb#446
|
591
|
+
def post_cmd=(_arg0); end
|
592
|
+
|
593
|
+
# An array of commands prepended to compiled code
|
594
|
+
#
|
595
|
+
# source://erb//lib/erb/compiler.rb#443
|
596
|
+
def pre_cmd; end
|
597
|
+
|
598
|
+
# An array of commands prepended to compiled code
|
599
|
+
#
|
600
|
+
# source://erb//lib/erb/compiler.rb#443
|
601
|
+
def pre_cmd=(_arg0); end
|
602
|
+
|
603
|
+
# source://erb//lib/erb/compiler.rb#392
|
604
|
+
def prepare_trim_mode(mode); end
|
605
|
+
|
606
|
+
# The command to handle text that ends with a newline
|
607
|
+
#
|
608
|
+
# source://erb//lib/erb/compiler.rb#437
|
609
|
+
def put_cmd; end
|
610
|
+
|
611
|
+
# The command to handle text that ends with a newline
|
612
|
+
#
|
613
|
+
# source://erb//lib/erb/compiler.rb#437
|
614
|
+
def put_cmd=(_arg0); end
|
615
|
+
|
616
|
+
# Returns the value of attribute trim_mode.
|
617
|
+
#
|
618
|
+
# source://erb//lib/erb/compiler.rb#434
|
619
|
+
def trim_mode; end
|
620
|
+
|
621
|
+
private
|
622
|
+
|
623
|
+
# A buffered text in #compile
|
624
|
+
#
|
625
|
+
# source://erb//lib/erb/compiler.rb#451
|
626
|
+
def content; end
|
627
|
+
|
628
|
+
# A buffered text in #compile
|
629
|
+
#
|
630
|
+
# source://erb//lib/erb/compiler.rb#451
|
631
|
+
def content=(_arg0); end
|
632
|
+
|
633
|
+
# source://erb//lib/erb/compiler.rb#453
|
634
|
+
def detect_magic_comment(s, enc = T.unsafe(nil)); end
|
635
|
+
|
636
|
+
# source://erb//lib/erb/compiler.rb#469
|
637
|
+
def warn_invalid_trim_mode(mode, uplevel:); end
|
638
|
+
end
|
639
|
+
|
640
|
+
# source://erb//lib/erb/compiler.rb#272
|
641
|
+
class ERB::Compiler::Buffer
|
642
|
+
# @return [Buffer] a new instance of Buffer
|
643
|
+
#
|
644
|
+
# source://erb//lib/erb/compiler.rb#273
|
645
|
+
def initialize(compiler, enc = T.unsafe(nil), frozen = T.unsafe(nil)); end
|
646
|
+
|
647
|
+
# source://erb//lib/erb/compiler.rb#295
|
648
|
+
def close; end
|
649
|
+
|
650
|
+
# source://erb//lib/erb/compiler.rb#289
|
651
|
+
def cr; end
|
652
|
+
|
653
|
+
# source://erb//lib/erb/compiler.rb#285
|
654
|
+
def push(cmd); end
|
655
|
+
|
656
|
+
# Returns the value of attribute script.
|
657
|
+
#
|
658
|
+
# source://erb//lib/erb/compiler.rb#283
|
659
|
+
def script; end
|
660
|
+
end
|
661
|
+
|
662
|
+
# source://erb//lib/erb/compiler.rb#248
|
663
|
+
class ERB::Compiler::ExplicitScanner < ::ERB::Compiler::Scanner
|
664
|
+
# source://erb//lib/erb/compiler.rb#249
|
665
|
+
def scan; end
|
666
|
+
end
|
667
|
+
|
668
|
+
# source://erb//lib/erb/compiler.rb#74
|
669
|
+
class ERB::Compiler::PercentLine
|
670
|
+
# @return [PercentLine] a new instance of PercentLine
|
671
|
+
#
|
672
|
+
# source://erb//lib/erb/compiler.rb#75
|
673
|
+
def initialize(str); end
|
674
|
+
|
675
|
+
# Returns the value of attribute value.
|
676
|
+
#
|
677
|
+
# source://erb//lib/erb/compiler.rb#78
|
678
|
+
def to_s; end
|
679
|
+
|
680
|
+
# Returns the value of attribute value.
|
681
|
+
#
|
682
|
+
# source://erb//lib/erb/compiler.rb#78
|
683
|
+
def value; end
|
684
|
+
end
|
685
|
+
|
686
|
+
# source://erb//lib/erb/compiler.rb#82
|
687
|
+
class ERB::Compiler::Scanner
|
688
|
+
# @return [Scanner] a new instance of Scanner
|
689
|
+
#
|
690
|
+
# source://erb//lib/erb/compiler.rb#102
|
691
|
+
def initialize(src, trim_mode, percent); end
|
692
|
+
|
693
|
+
# Returns the value of attribute etags.
|
694
|
+
#
|
695
|
+
# source://erb//lib/erb/compiler.rb#109
|
696
|
+
def etags; end
|
697
|
+
|
698
|
+
# source://erb//lib/erb/compiler.rb#111
|
699
|
+
def scan; end
|
700
|
+
|
701
|
+
# Returns the value of attribute stag.
|
702
|
+
#
|
703
|
+
# source://erb//lib/erb/compiler.rb#108
|
704
|
+
def stag; end
|
705
|
+
|
706
|
+
# Sets the attribute stag
|
707
|
+
#
|
708
|
+
# @param value the value to set the attribute stag to.
|
709
|
+
#
|
710
|
+
# source://erb//lib/erb/compiler.rb#108
|
711
|
+
def stag=(_arg0); end
|
712
|
+
|
713
|
+
# Returns the value of attribute stags.
|
714
|
+
#
|
715
|
+
# source://erb//lib/erb/compiler.rb#109
|
716
|
+
def stags; end
|
717
|
+
|
718
|
+
class << self
|
719
|
+
# source://erb//lib/erb/compiler.rb#91
|
720
|
+
def default_scanner=(klass); end
|
721
|
+
|
722
|
+
# source://erb//lib/erb/compiler.rb#95
|
723
|
+
def make_scanner(src, trim_mode, percent); end
|
724
|
+
|
725
|
+
# source://erb//lib/erb/compiler.rb#85
|
726
|
+
def regist_scanner(klass, trim_mode, percent); end
|
727
|
+
|
728
|
+
# source://erb//lib/erb/compiler.rb#85
|
729
|
+
def register_scanner(klass, trim_mode, percent); end
|
730
|
+
end
|
731
|
+
end
|
732
|
+
|
733
|
+
# source://erb//lib/erb/compiler.rb#101
|
734
|
+
ERB::Compiler::Scanner::DEFAULT_ETAGS = T.let(T.unsafe(nil), Array)
|
735
|
+
|
736
|
+
# source://erb//lib/erb/compiler.rb#100
|
737
|
+
ERB::Compiler::Scanner::DEFAULT_STAGS = T.let(T.unsafe(nil), Array)
|
738
|
+
|
739
|
+
# source://erb//lib/erb/compiler.rb#234
|
740
|
+
class ERB::Compiler::SimpleScanner < ::ERB::Compiler::Scanner
|
741
|
+
# source://erb//lib/erb/compiler.rb#235
|
742
|
+
def scan; end
|
743
|
+
end
|
744
|
+
|
745
|
+
# source://erb//lib/erb/compiler.rb#114
|
746
|
+
class ERB::Compiler::TrimScanner < ::ERB::Compiler::Scanner
|
747
|
+
# @return [TrimScanner] a new instance of TrimScanner
|
748
|
+
#
|
749
|
+
# source://erb//lib/erb/compiler.rb#115
|
750
|
+
def initialize(src, trim_mode, percent); end
|
751
|
+
|
752
|
+
# source://erb//lib/erb/compiler.rb#204
|
753
|
+
def explicit_trim_line(line); end
|
754
|
+
|
755
|
+
# @return [Boolean]
|
756
|
+
#
|
757
|
+
# source://erb//lib/erb/compiler.rb#223
|
758
|
+
def is_erb_stag?(s); end
|
759
|
+
|
760
|
+
# source://erb//lib/erb/compiler.rb#146
|
761
|
+
def percent_line(line, &block); end
|
762
|
+
|
763
|
+
# source://erb//lib/erb/compiler.rb#134
|
764
|
+
def scan(&block); end
|
765
|
+
|
766
|
+
# source://erb//lib/erb/compiler.rb#159
|
767
|
+
def scan_line(line); end
|
768
|
+
|
769
|
+
# source://erb//lib/erb/compiler.rb#168
|
770
|
+
def trim_line1(line); end
|
771
|
+
|
772
|
+
# source://erb//lib/erb/compiler.rb#182
|
773
|
+
def trim_line2(line); end
|
774
|
+
end
|
775
|
+
|
776
|
+
# --
|
777
|
+
# ERB::DefMethod
|
778
|
+
#
|
779
|
+
# Utility module to define eRuby script as instance method.
|
780
|
+
#
|
781
|
+
# === Example
|
782
|
+
#
|
783
|
+
# example.rhtml:
|
784
|
+
# <% for item in @items %>
|
785
|
+
# <b><%= item %></b>
|
786
|
+
# <% end %>
|
787
|
+
#
|
788
|
+
# example.rb:
|
789
|
+
# require 'erb'
|
790
|
+
# class MyClass
|
791
|
+
# extend ERB::DefMethod
|
792
|
+
# def_erb_method('render()', 'example.rhtml')
|
793
|
+
# def initialize(items)
|
794
|
+
# @items = items
|
795
|
+
# end
|
796
|
+
# end
|
797
|
+
# print MyClass.new([10,20,30]).render()
|
798
|
+
#
|
799
|
+
# result:
|
800
|
+
#
|
801
|
+
# <b>10</b>
|
802
|
+
#
|
803
|
+
# <b>20</b>
|
804
|
+
#
|
805
|
+
# <b>30</b>
|
806
|
+
#
|
807
|
+
# source://erb//lib/erb/def_method.rb#33
|
808
|
+
module ERB::DefMethod
|
809
|
+
private
|
810
|
+
|
811
|
+
# define _methodname_ as instance method of current module, using ERB
|
812
|
+
# object or eRuby file
|
813
|
+
#
|
814
|
+
# source://erb//lib/erb/def_method.rb#36
|
815
|
+
def def_erb_method(methodname, erb_or_fname); end
|
816
|
+
|
817
|
+
class << self
|
818
|
+
# define _methodname_ as instance method of current module, using ERB
|
819
|
+
# object or eRuby file
|
820
|
+
#
|
821
|
+
# source://erb//lib/erb/def_method.rb#36
|
822
|
+
def def_erb_method(methodname, erb_or_fname); end
|
823
|
+
end
|
824
|
+
end
|
825
|
+
|
826
|
+
module ERB::Escape
|
827
|
+
private
|
828
|
+
|
829
|
+
def html_escape(_arg0); end
|
830
|
+
|
831
|
+
class << self
|
832
|
+
def html_escape(_arg0); end
|
833
|
+
end
|
834
|
+
end
|
835
|
+
|
836
|
+
# source://erb//lib/erb.rb#356
|
837
|
+
ERB::NOT_GIVEN = T.let(T.unsafe(nil), Object)
|
838
|
+
|
839
|
+
# --
|
840
|
+
# ERB::Util
|
841
|
+
#
|
842
|
+
# A utility module for conversion routines, often handy in HTML generation.
|
843
|
+
#
|
844
|
+
# source://erb//lib/erb/util.rb#27
|
845
|
+
module ERB::Util
|
846
|
+
include ::ERB::Escape
|
847
|
+
|
848
|
+
private
|
849
|
+
|
850
|
+
# A utility method for encoding the String _s_ as a URL.
|
851
|
+
#
|
852
|
+
# require "erb"
|
853
|
+
# include ERB::Util
|
854
|
+
#
|
855
|
+
# puts url_encode("Programming Ruby: The Pragmatic Programmer's Guide")
|
856
|
+
#
|
857
|
+
# _Generates_
|
858
|
+
#
|
859
|
+
# Programming%20Ruby%3A%20%20The%20Pragmatic%20Programmer%27s%20Guide
|
860
|
+
#
|
861
|
+
# source://erb//lib/erb/util.rb#57
|
862
|
+
def u(s); end
|
863
|
+
|
864
|
+
# A utility method for encoding the String _s_ as a URL.
|
865
|
+
#
|
866
|
+
# require "erb"
|
867
|
+
# include ERB::Util
|
868
|
+
#
|
869
|
+
# puts url_encode("Programming Ruby: The Pragmatic Programmer's Guide")
|
870
|
+
#
|
871
|
+
# _Generates_
|
872
|
+
#
|
873
|
+
# Programming%20Ruby%3A%20%20The%20Pragmatic%20Programmer%27s%20Guide
|
874
|
+
#
|
875
|
+
# source://erb//lib/erb/util.rb#57
|
876
|
+
def url_encode(s); end
|
877
|
+
|
878
|
+
class << self
|
879
|
+
# A utility method for encoding the String _s_ as a URL.
|
880
|
+
#
|
881
|
+
# require "erb"
|
882
|
+
# include ERB::Util
|
883
|
+
#
|
884
|
+
# puts url_encode("Programming Ruby: The Pragmatic Programmer's Guide")
|
885
|
+
#
|
886
|
+
# _Generates_
|
887
|
+
#
|
888
|
+
# Programming%20Ruby%3A%20%20The%20Pragmatic%20Programmer%27s%20Guide
|
889
|
+
#
|
890
|
+
# source://erb//lib/erb/util.rb#57
|
891
|
+
def u(s); end
|
892
|
+
|
893
|
+
# A utility method for encoding the String _s_ as a URL.
|
894
|
+
#
|
895
|
+
# require "erb"
|
896
|
+
# include ERB::Util
|
897
|
+
#
|
898
|
+
# puts url_encode("Programming Ruby: The Pragmatic Programmer's Guide")
|
899
|
+
#
|
900
|
+
# _Generates_
|
901
|
+
#
|
902
|
+
# Programming%20Ruby%3A%20%20The%20Pragmatic%20Programmer%27s%20Guide
|
903
|
+
#
|
904
|
+
# source://erb//lib/erb/util.rb#57
|
905
|
+
def url_encode(s); end
|
906
|
+
end
|
907
|
+
end
|
908
|
+
|
909
|
+
# source://erb//lib/erb/version.rb#3
|
910
|
+
ERB::VERSION = T.let(T.unsafe(nil), String)
|