phlex 1.3.2 → 1.5.1
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of phlex might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/.rubocop.yml +2 -24
- data/Gemfile +0 -2
- data/README.md +12 -0
- data/fixtures/view_helper.rb +6 -0
- data/lib/phlex/black_hole.rb +15 -9
- data/lib/phlex/callable.rb +3 -5
- data/lib/phlex/deferred_render.rb +2 -4
- data/lib/phlex/element_clobbering_guard.rb +13 -0
- data/lib/phlex/elements.rb +64 -54
- data/lib/phlex/helpers.rb +9 -2
- data/lib/phlex/html/standard_elements.rb +0 -14
- data/lib/phlex/html.rb +19 -297
- data/lib/{overrides → phlex/overrides}/symbol/name.rb +1 -1
- data/lib/phlex/sgml.rb +313 -0
- data/lib/phlex/svg/standard_elements.rb +389 -0
- data/lib/phlex/svg.rb +14 -0
- data/lib/phlex/testing/view_helper.rb +10 -12
- data/lib/phlex/unbuffered.rb +34 -36
- data/lib/phlex/version.rb +1 -1
- data/lib/phlex.rb +5 -1
- metadata +21 -4
- data/lib/phlex/buffered.rb +0 -19
@@ -0,0 +1,389 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Phlex::SVG::StandardElements
|
4
|
+
extend Phlex::Elements
|
5
|
+
|
6
|
+
# @!method a(**attributes, &content)
|
7
|
+
# Outputs an <code>a</code> tag
|
8
|
+
# @return [nil]
|
9
|
+
# @see https://developer.mozilla.org/docs/Web/SVG/Element/a
|
10
|
+
register_element :a, tag: "a"
|
11
|
+
|
12
|
+
# @!method animate(**attributes, &content)
|
13
|
+
# Outputs an <code>animate</code> tag
|
14
|
+
# @return [nil]
|
15
|
+
# @see https://developer.mozilla.org/docs/Web/SVG/Element/animate
|
16
|
+
register_element :animate, tag: "animate"
|
17
|
+
|
18
|
+
# @!method animateMotion(**attributes, &content)
|
19
|
+
# Outputs an <code>animateMotion</code> tag
|
20
|
+
# @return [nil]
|
21
|
+
# @see https://developer.mozilla.org/docs/Web/SVG/Element/animateMotion
|
22
|
+
register_element :animateMotion, tag: "animateMotion"
|
23
|
+
|
24
|
+
# @!method animateTransform(**attributes, &content)
|
25
|
+
# Outputs an <code>animateTransform</code> tag
|
26
|
+
# @return [nil]
|
27
|
+
# @see https://developer.mozilla.org/docs/Web/SVG/Element/animateTransform
|
28
|
+
register_element :animateTransform, tag: "animateTransform"
|
29
|
+
|
30
|
+
# @!method circle(**attributes, &content)
|
31
|
+
# Outputs an <code>circle</code> tag
|
32
|
+
# @return [nil]
|
33
|
+
# @see https://developer.mozilla.org/docs/Web/SVG/Element/circle
|
34
|
+
register_element :circle, tag: "circle"
|
35
|
+
|
36
|
+
# @!method clipPath(**attributes, &content)
|
37
|
+
# Outputs an <code>clipPath</code> tag
|
38
|
+
# @return [nil]
|
39
|
+
# @see https://developer.mozilla.org/docs/Web/SVG/Element/clipPath
|
40
|
+
register_element :clipPath, tag: "clipPath"
|
41
|
+
|
42
|
+
# @!method defs(**attributes, &content)
|
43
|
+
# Outputs an <code>defs</code> tag
|
44
|
+
# @return [nil]
|
45
|
+
# @see https://developer.mozilla.org/docs/Web/SVG/Element/defs
|
46
|
+
register_element :defs, tag: "defs"
|
47
|
+
|
48
|
+
# @!method desc(**attributes, &content)
|
49
|
+
# Outputs an <code>desc</code> tag
|
50
|
+
# @return [nil]
|
51
|
+
# @see https://developer.mozilla.org/docs/Web/SVG/Element/desc
|
52
|
+
register_element :desc, tag: "desc"
|
53
|
+
|
54
|
+
# @!method discard(**attributes, &content)
|
55
|
+
# Outputs an <code>discard</code> tag
|
56
|
+
# @return [nil]
|
57
|
+
# @see https://developer.mozilla.org/docs/Web/SVG/Element/discard
|
58
|
+
register_element :discard, tag: "discard"
|
59
|
+
|
60
|
+
# @!method ellipse(**attributes, &content)
|
61
|
+
# Outputs an <code>ellipse</code> tag
|
62
|
+
# @return [nil]
|
63
|
+
# @see https://developer.mozilla.org/docs/Web/SVG/Element/ellipse
|
64
|
+
register_element :ellipse, tag: "ellipse"
|
65
|
+
|
66
|
+
# @!method feBlend(**attributes, &content)
|
67
|
+
# Outputs an <code>feBlend</code> tag
|
68
|
+
# @return [nil]
|
69
|
+
# @see https://developer.mozilla.org/docs/Web/SVG/Element/feBlend
|
70
|
+
register_element :feBlend, tag: "feBlend"
|
71
|
+
|
72
|
+
# @!method feColorMatrix(**attributes, &content)
|
73
|
+
# Outputs an <code>feColorMatrix</code> tag
|
74
|
+
# @return [nil]
|
75
|
+
# @see https://developer.mozilla.org/docs/Web/SVG/Element/feColorMatrix
|
76
|
+
register_element :feColorMatrix, tag: "feColorMatrix"
|
77
|
+
|
78
|
+
# @!method feComponentTransfer(**attributes, &content)
|
79
|
+
# Outputs an <code>feComponentTransfer</code> tag
|
80
|
+
# @return [nil]
|
81
|
+
# @see https://developer.mozilla.org/docs/Web/SVG/Element/feComponentTransfer
|
82
|
+
register_element :feComponentTransfer, tag: "feComponentTransfer"
|
83
|
+
|
84
|
+
# @!method feComposite(**attributes, &content)
|
85
|
+
# Outputs an <code>feComposite</code> tag
|
86
|
+
# @return [nil]
|
87
|
+
# @see https://developer.mozilla.org/docs/Web/SVG/Element/feComposite
|
88
|
+
register_element :feComposite, tag: "feComposite"
|
89
|
+
|
90
|
+
# @!method feConvolveMatrix(**attributes, &content)
|
91
|
+
# Outputs an <code>feConvolveMatrix</code> tag
|
92
|
+
# @return [nil]
|
93
|
+
# @see https://developer.mozilla.org/docs/Web/SVG/Element/feConvolveMatrix
|
94
|
+
register_element :feConvolveMatrix, tag: "feConvolveMatrix"
|
95
|
+
|
96
|
+
# @!method feDiffuseLighting(**attributes, &content)
|
97
|
+
# Outputs an <code>feDiffuseLighting</code> tag
|
98
|
+
# @return [nil]
|
99
|
+
# @see https://developer.mozilla.org/docs/Web/SVG/Element/feDiffuseLighting
|
100
|
+
register_element :feDiffuseLighting, tag: "feDiffuseLighting"
|
101
|
+
|
102
|
+
# @!method feDisplacementMap(**attributes, &content)
|
103
|
+
# Outputs an <code>feDisplacementMap</code> tag
|
104
|
+
# @return [nil]
|
105
|
+
# @see https://developer.mozilla.org/docs/Web/SVG/Element/feDisplacementMap
|
106
|
+
register_element :feDisplacementMap, tag: "feDisplacementMap"
|
107
|
+
|
108
|
+
# @!method feDistantLight(**attributes, &content)
|
109
|
+
# Outputs an <code>feDistantLight</code> tag
|
110
|
+
# @return [nil]
|
111
|
+
# @see https://developer.mozilla.org/docs/Web/SVG/Element/feDistantLight
|
112
|
+
register_element :feDistantLight, tag: "feDistantLight"
|
113
|
+
|
114
|
+
# @!method feDropShadow(**attributes, &content)
|
115
|
+
# Outputs an <code>feDropShadow</code> tag
|
116
|
+
# @return [nil]
|
117
|
+
# @see https://developer.mozilla.org/docs/Web/SVG/Element/feDropShadow
|
118
|
+
register_element :feDropShadow, tag: "feDropShadow"
|
119
|
+
|
120
|
+
# @!method feFlood(**attributes, &content)
|
121
|
+
# Outputs an <code>feFlood</code> tag
|
122
|
+
# @return [nil]
|
123
|
+
# @see https://developer.mozilla.org/docs/Web/SVG/Element/feFlood
|
124
|
+
register_element :feFlood, tag: "feFlood"
|
125
|
+
|
126
|
+
# @!method feFuncA(**attributes, &content)
|
127
|
+
# Outputs an <code>feFuncA</code> tag
|
128
|
+
# @return [nil]
|
129
|
+
# @see https://developer.mozilla.org/docs/Web/SVG/Element/feFuncA
|
130
|
+
register_element :feFuncA, tag: "feFuncA"
|
131
|
+
|
132
|
+
# @!method feFuncB(**attributes, &content)
|
133
|
+
# Outputs an <code>feFuncB</code> tag
|
134
|
+
# @return [nil]
|
135
|
+
# @see https://developer.mozilla.org/docs/Web/SVG/Element/feFuncB
|
136
|
+
register_element :feFuncB, tag: "feFuncB"
|
137
|
+
|
138
|
+
# @!method feFuncG(**attributes, &content)
|
139
|
+
# Outputs an <code>feFuncG</code> tag
|
140
|
+
# @return [nil]
|
141
|
+
# @see https://developer.mozilla.org/docs/Web/SVG/Element/feFuncG
|
142
|
+
register_element :feFuncG, tag: "feFuncG"
|
143
|
+
|
144
|
+
# @!method feFuncR(**attributes, &content)
|
145
|
+
# Outputs an <code>feFuncR</code> tag
|
146
|
+
# @return [nil]
|
147
|
+
# @see https://developer.mozilla.org/docs/Web/SVG/Element/feFuncR
|
148
|
+
register_element :feFuncR, tag: "feFuncR"
|
149
|
+
|
150
|
+
# @!method feGaussianBlur(**attributes, &content)
|
151
|
+
# Outputs an <code>feGaussianBlur</code> tag
|
152
|
+
# @return [nil]
|
153
|
+
# @see https://developer.mozilla.org/docs/Web/SVG/Element/feGaussianBlur
|
154
|
+
register_element :feGaussianBlur, tag: "feGaussianBlur"
|
155
|
+
|
156
|
+
# @!method feImage(**attributes, &content)
|
157
|
+
# Outputs an <code>feImage</code> tag
|
158
|
+
# @return [nil]
|
159
|
+
# @see https://developer.mozilla.org/docs/Web/SVG/Element/feImage
|
160
|
+
register_element :feImage, tag: "feImage"
|
161
|
+
|
162
|
+
# @!method feMerge(**attributes, &content)
|
163
|
+
# Outputs an <code>feMerge</code> tag
|
164
|
+
# @return [nil]
|
165
|
+
# @see https://developer.mozilla.org/docs/Web/SVG/Element/feMerge
|
166
|
+
register_element :feMerge, tag: "feMerge"
|
167
|
+
|
168
|
+
# @!method feMergeNode(**attributes, &content)
|
169
|
+
# Outputs an <code>feMergeNode</code> tag
|
170
|
+
# @return [nil]
|
171
|
+
# @see https://developer.mozilla.org/docs/Web/SVG/Element/feMergeNode
|
172
|
+
register_element :feMergeNode, tag: "feMergeNode"
|
173
|
+
|
174
|
+
# @!method feMorphology(**attributes, &content)
|
175
|
+
# Outputs an <code>feMorphology</code> tag
|
176
|
+
# @return [nil]
|
177
|
+
# @see https://developer.mozilla.org/docs/Web/SVG/Element/feMorphology
|
178
|
+
register_element :feMorphology, tag: "feMorphology"
|
179
|
+
|
180
|
+
# @!method feOffset(**attributes, &content)
|
181
|
+
# Outputs an <code>feOffset</code> tag
|
182
|
+
# @return [nil]
|
183
|
+
# @see https://developer.mozilla.org/docs/Web/SVG/Element/feOffset
|
184
|
+
register_element :feOffset, tag: "feOffset"
|
185
|
+
|
186
|
+
# @!method fePointLight(**attributes, &content)
|
187
|
+
# Outputs an <code>fePointLight</code> tag
|
188
|
+
# @return [nil]
|
189
|
+
# @see https://developer.mozilla.org/docs/Web/SVG/Element/fePointLight
|
190
|
+
register_element :fePointLight, tag: "fePointLight"
|
191
|
+
|
192
|
+
# @!method feSpecularLighting(**attributes, &content)
|
193
|
+
# Outputs an <code>feSpecularLighting</code> tag
|
194
|
+
# @return [nil]
|
195
|
+
# @see https://developer.mozilla.org/docs/Web/SVG/Element/feSpecularLighting
|
196
|
+
register_element :feSpecularLighting, tag: "feSpecularLighting"
|
197
|
+
|
198
|
+
# @!method feSpotLight(**attributes, &content)
|
199
|
+
# Outputs an <code>feSpotLight</code> tag
|
200
|
+
# @return [nil]
|
201
|
+
# @see https://developer.mozilla.org/docs/Web/SVG/Element/feSpotLight
|
202
|
+
register_element :feSpotLight, tag: "feSpotLight"
|
203
|
+
|
204
|
+
# @!method feTile(**attributes, &content)
|
205
|
+
# Outputs an <code>feTile</code> tag
|
206
|
+
# @return [nil]
|
207
|
+
# @see https://developer.mozilla.org/docs/Web/SVG/Element/feTile
|
208
|
+
register_element :feTile, tag: "feTile"
|
209
|
+
|
210
|
+
# @!method feTurbulence(**attributes, &content)
|
211
|
+
# Outputs an <code>feTurbulence</code> tag
|
212
|
+
# @return [nil]
|
213
|
+
# @see https://developer.mozilla.org/docs/Web/SVG/Element/feTurbulence
|
214
|
+
register_element :feTurbulence, tag: "feTurbulence"
|
215
|
+
|
216
|
+
# @!method filter(**attributes, &content)
|
217
|
+
# Outputs an <code>filter</code> tag
|
218
|
+
# @return [nil]
|
219
|
+
# @see https://developer.mozilla.org/docs/Web/SVG/Element/filter
|
220
|
+
register_element :filter, tag: "filter"
|
221
|
+
|
222
|
+
# @!method foreignObject(**attributes, &content)
|
223
|
+
# Outputs an <code>foreignObject</code> tag
|
224
|
+
# @return [nil]
|
225
|
+
# @see https://developer.mozilla.org/docs/Web/SVG/Element/foreignObject
|
226
|
+
register_element :foreignObject, tag: "foreignObject"
|
227
|
+
|
228
|
+
# @!method g(**attributes, &content)
|
229
|
+
# Outputs an <code>g</code> tag
|
230
|
+
# @return [nil]
|
231
|
+
# @see https://developer.mozilla.org/docs/Web/SVG/Element/g
|
232
|
+
register_element :g, tag: "g"
|
233
|
+
|
234
|
+
# @!method image(**attributes, &content)
|
235
|
+
# Outputs an <code>image</code> tag
|
236
|
+
# @return [nil]
|
237
|
+
# @see https://developer.mozilla.org/docs/Web/SVG/Element/image
|
238
|
+
register_element :image, tag: "image"
|
239
|
+
|
240
|
+
# @!method line(**attributes, &content)
|
241
|
+
# Outputs an <code>line</code> tag
|
242
|
+
# @return [nil]
|
243
|
+
# @see https://developer.mozilla.org/docs/Web/SVG/Element/line
|
244
|
+
register_element :line, tag: "line"
|
245
|
+
|
246
|
+
# @!method linearGradient(**attributes, &content)
|
247
|
+
# Outputs an <code>linearGradient</code> tag
|
248
|
+
# @return [nil]
|
249
|
+
# @see https://developer.mozilla.org/docs/Web/SVG/Element/linearGradient
|
250
|
+
register_element :linearGradient, tag: "linearGradient"
|
251
|
+
|
252
|
+
# @!method marker(**attributes, &content)
|
253
|
+
# Outputs an <code>marker</code> tag
|
254
|
+
# @return [nil]
|
255
|
+
# @see https://developer.mozilla.org/docs/Web/SVG/Element/marker
|
256
|
+
register_element :marker, tag: "marker"
|
257
|
+
|
258
|
+
# @!method mask(**attributes, &content)
|
259
|
+
# Outputs an <code>mask</code> tag
|
260
|
+
# @return [nil]
|
261
|
+
# @see https://developer.mozilla.org/docs/Web/SVG/Element/mask
|
262
|
+
register_element :mask, tag: "mask"
|
263
|
+
|
264
|
+
# @!method metadata(**attributes, &content)
|
265
|
+
# Outputs an <code>metadata</code> tag
|
266
|
+
# @return [nil]
|
267
|
+
# @see https://developer.mozilla.org/docs/Web/SVG/Element/metadata
|
268
|
+
register_element :metadata, tag: "metadata"
|
269
|
+
|
270
|
+
# @!method mpath(**attributes, &content)
|
271
|
+
# Outputs an <code>mpath</code> tag
|
272
|
+
# @return [nil]
|
273
|
+
# @see https://developer.mozilla.org/docs/Web/SVG/Element/mpath
|
274
|
+
register_element :mpath, tag: "mpath"
|
275
|
+
|
276
|
+
# @!method path(**attributes, &content)
|
277
|
+
# Outputs an <code>path</code> tag
|
278
|
+
# @return [nil]
|
279
|
+
# @see https://developer.mozilla.org/docs/Web/SVG/Element/path
|
280
|
+
register_element :path, tag: "path"
|
281
|
+
|
282
|
+
# @!method pattern(**attributes, &content)
|
283
|
+
# Outputs an <code>pattern</code> tag
|
284
|
+
# @return [nil]
|
285
|
+
# @see https://developer.mozilla.org/docs/Web/SVG/Element/pattern
|
286
|
+
register_element :pattern, tag: "pattern"
|
287
|
+
|
288
|
+
# @!method polygon(**attributes, &content)
|
289
|
+
# Outputs an <code>polygon</code> tag
|
290
|
+
# @return [nil]
|
291
|
+
# @see https://developer.mozilla.org/docs/Web/SVG/Element/polygon
|
292
|
+
register_element :polygon, tag: "polygon"
|
293
|
+
|
294
|
+
# @!method polyline(**attributes, &content)
|
295
|
+
# Outputs an <code>polyline</code> tag
|
296
|
+
# @return [nil]
|
297
|
+
# @see https://developer.mozilla.org/docs/Web/SVG/Element/polyline
|
298
|
+
register_element :polyline, tag: "polyline"
|
299
|
+
|
300
|
+
# @!method radialGradient(**attributes, &content)
|
301
|
+
# Outputs an <code>radialGradient</code> tag
|
302
|
+
# @return [nil]
|
303
|
+
# @see https://developer.mozilla.org/docs/Web/SVG/Element/radialGradient
|
304
|
+
register_element :radialGradient, tag: "radialGradient"
|
305
|
+
|
306
|
+
# @!method rect(**attributes, &content)
|
307
|
+
# Outputs an <code>rect</code> tag
|
308
|
+
# @return [nil]
|
309
|
+
# @see https://developer.mozilla.org/docs/Web/SVG/Element/rect
|
310
|
+
register_element :rect, tag: "rect"
|
311
|
+
|
312
|
+
# @!method script(**attributes, &content)
|
313
|
+
# Outputs an <code>script</code> tag
|
314
|
+
# @return [nil]
|
315
|
+
# @see https://developer.mozilla.org/docs/Web/SVG/Element/script
|
316
|
+
register_element :script, tag: "script"
|
317
|
+
|
318
|
+
# @!method set(**attributes, &content)
|
319
|
+
# Outputs an <code>set</code> tag
|
320
|
+
# @return [nil]
|
321
|
+
# @see https://developer.mozilla.org/docs/Web/SVG/Element/set
|
322
|
+
register_element :set, tag: "set"
|
323
|
+
|
324
|
+
# @!method stop(**attributes, &content)
|
325
|
+
# Outputs an <code>stop</code> tag
|
326
|
+
# @return [nil]
|
327
|
+
# @see https://developer.mozilla.org/docs/Web/SVG/Element/stop
|
328
|
+
register_element :stop, tag: "stop"
|
329
|
+
|
330
|
+
# @!method style(**attributes, &content)
|
331
|
+
# Outputs an <code>style</code> tag
|
332
|
+
# @return [nil]
|
333
|
+
# @see https://developer.mozilla.org/docs/Web/SVG/Element/style
|
334
|
+
register_element :style, tag: "style"
|
335
|
+
|
336
|
+
# @!method svg(**attributes, &content)
|
337
|
+
# Outputs an <code>svg</code> tag
|
338
|
+
# @return [nil]
|
339
|
+
# @see https://developer.mozilla.org/docs/Web/SVG/Element/svg
|
340
|
+
register_element :svg, tag: "svg"
|
341
|
+
|
342
|
+
# @!method switch(**attributes, &content)
|
343
|
+
# Outputs an <code>switch</code> tag
|
344
|
+
# @return [nil]
|
345
|
+
# @see https://developer.mozilla.org/docs/Web/SVG/Element/switch
|
346
|
+
register_element :switch, tag: "switch"
|
347
|
+
|
348
|
+
# @!method symbol(**attributes, &content)
|
349
|
+
# Outputs an <code>symbol</code> tag
|
350
|
+
# @return [nil]
|
351
|
+
# @see https://developer.mozilla.org/docs/Web/SVG/Element/symbol
|
352
|
+
register_element :symbol, tag: "symbol"
|
353
|
+
|
354
|
+
# @!method text(**attributes, &content)
|
355
|
+
# Outputs an <code>text</code> tag
|
356
|
+
# @return [nil]
|
357
|
+
# @see https://developer.mozilla.org/docs/Web/SVG/Element/text
|
358
|
+
register_element :text, tag: "text"
|
359
|
+
|
360
|
+
# @!method textPath(**attributes, &content)
|
361
|
+
# Outputs an <code>textPath</code> tag
|
362
|
+
# @return [nil]
|
363
|
+
# @see https://developer.mozilla.org/docs/Web/SVG/Element/textPath
|
364
|
+
register_element :textPath, tag: "textPath"
|
365
|
+
|
366
|
+
# @!method title(**attributes, &content)
|
367
|
+
# Outputs an <code>title</code> tag
|
368
|
+
# @return [nil]
|
369
|
+
# @see https://developer.mozilla.org/docs/Web/SVG/Element/title
|
370
|
+
register_element :title, tag: "title"
|
371
|
+
|
372
|
+
# @!method tspan(**attributes, &content)
|
373
|
+
# Outputs an <code>tspan</code> tag
|
374
|
+
# @return [nil]
|
375
|
+
# @see https://developer.mozilla.org/docs/Web/SVG/Element/tspan
|
376
|
+
register_element :tspan, tag: "tspan"
|
377
|
+
|
378
|
+
# @!method use(**attributes, &content)
|
379
|
+
# Outputs an <code>use</code> tag
|
380
|
+
# @return [nil]
|
381
|
+
# @see https://developer.mozilla.org/docs/Web/SVG/Element/use
|
382
|
+
register_element :use, tag: "use"
|
383
|
+
|
384
|
+
# @!method view(**attributes, &content)
|
385
|
+
# Outputs an <code>view</code> tag
|
386
|
+
# @return [nil]
|
387
|
+
# @see https://developer.mozilla.org/docs/Web/SVG/Element/view
|
388
|
+
register_element :view, tag: "view"
|
389
|
+
end
|
data/lib/phlex/svg.rb
ADDED
@@ -1,19 +1,17 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
module Phlex
|
4
|
-
module
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
view = view.new
|
9
|
-
end
|
10
|
-
|
11
|
-
view.call(view_context: view_context, &block)
|
3
|
+
module Phlex::Testing
|
4
|
+
module ViewHelper
|
5
|
+
def render(view, &block)
|
6
|
+
if view.is_a?(Class) && view < Phlex::SGML
|
7
|
+
view = view.new
|
12
8
|
end
|
13
9
|
|
14
|
-
|
15
|
-
|
16
|
-
|
10
|
+
view.call(view_context: view_context, &block)
|
11
|
+
end
|
12
|
+
|
13
|
+
def view_context
|
14
|
+
nil
|
17
15
|
end
|
18
16
|
end
|
19
17
|
end
|
data/lib/phlex/unbuffered.rb
CHANGED
@@ -1,51 +1,49 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
end
|
8
|
-
|
9
|
-
def inspect
|
10
|
-
"Unbuffered(#{@object.class.name})[object: #{@object.inspect}]"
|
11
|
-
end
|
3
|
+
class Phlex::Unbuffered < BasicObject
|
4
|
+
def initialize(object)
|
5
|
+
@object = object
|
6
|
+
end
|
12
7
|
|
13
|
-
|
14
|
-
|
15
|
-
|
8
|
+
def inspect
|
9
|
+
"Unbuffered(#{@object.class.name})[object: #{@object.inspect}]"
|
10
|
+
end
|
16
11
|
|
17
|
-
|
18
|
-
|
12
|
+
# Borrow some important methods from Object
|
13
|
+
define_method :__class__,
|
14
|
+
::Object.instance_method(:class)
|
19
15
|
|
20
|
-
|
21
|
-
|
22
|
-
end
|
16
|
+
define_method :__public_send__,
|
17
|
+
::Object.instance_method(:public_send)
|
23
18
|
|
24
|
-
|
25
|
-
|
19
|
+
def respond_to_missing?(...)
|
20
|
+
@object.respond_to?(...)
|
21
|
+
end
|
26
22
|
|
27
|
-
|
28
|
-
|
29
|
-
end
|
23
|
+
def method_missing(name, *args, **kwargs, &block)
|
24
|
+
if @object.respond_to?(name)
|
30
25
|
|
31
|
-
|
32
|
-
|
33
|
-
else
|
34
|
-
super
|
26
|
+
__class__.define_method(name) do |*a, **k, &b|
|
27
|
+
@object.capture { @object.public_send(name, *a, **k, &b) }
|
35
28
|
end
|
36
|
-
end
|
37
29
|
|
38
|
-
|
39
|
-
|
40
|
-
|
30
|
+
# Now we've defined this missing method, we can call it.
|
31
|
+
__public_send__(name, *args, **kwargs, &block)
|
32
|
+
else
|
33
|
+
super
|
41
34
|
end
|
35
|
+
end
|
42
36
|
|
43
|
-
|
44
|
-
|
45
|
-
|
37
|
+
# Forward some methods to the original underlying method
|
38
|
+
def call(...)
|
39
|
+
@object.call(...)
|
40
|
+
end
|
46
41
|
|
47
|
-
|
48
|
-
|
49
|
-
|
42
|
+
def send(...)
|
43
|
+
@object.send(...)
|
44
|
+
end
|
45
|
+
|
46
|
+
def public_send(...)
|
47
|
+
@object.public_send(...)
|
50
48
|
end
|
51
49
|
end
|
data/lib/phlex/version.rb
CHANGED
data/lib/phlex.rb
CHANGED
@@ -6,7 +6,11 @@ require "concurrent"
|
|
6
6
|
|
7
7
|
module Phlex
|
8
8
|
Loader = Zeitwerk::Loader.for_gem(warn_on_extra_files: false).tap do |loader|
|
9
|
-
loader.inflector.inflect(
|
9
|
+
loader.inflector.inflect(
|
10
|
+
"html" => "HTML",
|
11
|
+
"svg" => "SVG",
|
12
|
+
"sgml" => "SGML"
|
13
|
+
)
|
10
14
|
loader.ignore("#{__dir__}/phlex/testing")
|
11
15
|
loader.setup
|
12
16
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: phlex
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.5.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joel Drapper
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-03-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: concurrent-ruby
|
@@ -24,6 +24,20 @@ dependencies:
|
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '1.2'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: erb
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '4'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '4'
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: zeitwerk
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -59,17 +73,20 @@ files:
|
|
59
73
|
- fixtures/layout.rb
|
60
74
|
- fixtures/page.rb
|
61
75
|
- fixtures/view_helper.rb
|
62
|
-
- lib/overrides/symbol/name.rb
|
63
76
|
- lib/phlex.rb
|
64
77
|
- lib/phlex/black_hole.rb
|
65
|
-
- lib/phlex/buffered.rb
|
66
78
|
- lib/phlex/callable.rb
|
67
79
|
- lib/phlex/deferred_render.rb
|
80
|
+
- lib/phlex/element_clobbering_guard.rb
|
68
81
|
- lib/phlex/elements.rb
|
69
82
|
- lib/phlex/helpers.rb
|
70
83
|
- lib/phlex/html.rb
|
71
84
|
- lib/phlex/html/standard_elements.rb
|
72
85
|
- lib/phlex/html/void_elements.rb
|
86
|
+
- lib/phlex/overrides/symbol/name.rb
|
87
|
+
- lib/phlex/sgml.rb
|
88
|
+
- lib/phlex/svg.rb
|
89
|
+
- lib/phlex/svg/standard_elements.rb
|
73
90
|
- lib/phlex/testing/view_helper.rb
|
74
91
|
- lib/phlex/unbuffered.rb
|
75
92
|
- lib/phlex/version.rb
|
data/lib/phlex/buffered.rb
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "delegate"
|
4
|
-
|
5
|
-
module Phlex
|
6
|
-
class Buffered < SimpleDelegator
|
7
|
-
def initialize(object, buffer:)
|
8
|
-
super(object)
|
9
|
-
@buffer = buffer
|
10
|
-
end
|
11
|
-
|
12
|
-
# Alias output methods to this
|
13
|
-
def __output_method__(...)
|
14
|
-
output = __getobj__.public_send(__callee__, ...)
|
15
|
-
@buffer << output if output.is_a? String
|
16
|
-
nil
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|