view_component 3.9.0 → 3.11.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7d167b54bcd09ae6e5a8ace98cdb2cfac7386a29029cd8b4b34d1e5aa00093fd
4
- data.tar.gz: 5ea5073913c8c6026dbf5d5e6d04671bc28a42564a9788988dfe0ee18d03af9d
3
+ metadata.gz: dad3e67f83aa23cac53f816d751a652b229a1cbee327e753dbcdb9814549cf03
4
+ data.tar.gz: 15e2fdafbb4132567a3b81bfeb7723704ffc5824aa82eb8083f2f79f48505ad3
5
5
  SHA512:
6
- metadata.gz: 2232e4237c3d851577dc10cb9054c03a7614113761e2f6b2b33e3005ad05e665dd1031d29c84f10fcc7bef1a72fa3529866d11082c4ddbc9dd395e415ae5b2b9
7
- data.tar.gz: 67d9aa02848b03e68b5eb56c2bb37d27b39d757d53b4a30b466c9f7e73db29fe5771f2732f6447a135a3d1a120abc387350451b8d875923ce3dae6db06f5ce24
6
+ metadata.gz: 9fc84bada7187832e5cf4dba96b864e177260f6db88d9b9af78bee95b11ce7a3197d59d1f1171a9b4f473c62230e385b5b922b0536084c86ee73b80e6b9d293d
7
+ data.tar.gz: 100e6e5e8f7d06848790906ee5b6ecc106a53d3c018c7bccfd303097ec2c126ee4511b409ff42513ae3b98ac7441cf6c0ecd1f0d0404b936529c78e8fdebef88
data/docs/CHANGELOG.md CHANGED
@@ -10,6 +10,54 @@ nav_order: 5
10
10
 
11
11
  ## main
12
12
 
13
+ ## 3.11.0
14
+
15
+ * Fix running non-integration tests under Rails main.
16
+
17
+ *Cameron Dutro*
18
+
19
+ * Better name and link for Avo.
20
+
21
+ *Adrian Marin*
22
+
23
+ * Document using rack-mini-profiler with ViewComponent.
24
+
25
+ *Thomas Carr*
26
+
27
+ * Move dependencies to gemspec.
28
+
29
+ *Joel Hawksley*
30
+
31
+ * Include ViewComponent::UseHelpers by default.
32
+
33
+ *Reegan Viljoen*
34
+
35
+ * Bump `puma` in Gemfile.lock.
36
+
37
+ *Cameron Dutro*
38
+
39
+ * Add Keenly to users list.
40
+
41
+ *Vinoth*
42
+
43
+ ## 3.10.0
44
+
45
+ * Fix html escaping in `#call` for non-strings.
46
+
47
+ *Reegan Viljoen, Cameron Dutro*
48
+
49
+ * Add `output_preamble` to match `output_postamble`, using the same safety checks.
50
+
51
+ *Kali Donovan, Michael Daross*
52
+
53
+ * Exclude html escaping of I18n reserved keys with `I18n::RESERVED_KEYS` rather than `I18n.reserved_keys_pattern`.
54
+
55
+ *Nick Coyne*
56
+
57
+ * Update CI configuration to use `Appraisal`.
58
+
59
+ *Hans Lemuet, Simon Fish*
60
+
13
61
  ## 3.9.0
14
62
 
15
63
  * Don’t break `rails stats` if ViewComponent path is missing.
@@ -22,7 +70,7 @@ nav_order: 5
22
70
 
23
71
  * Add support for Ruby 3.3.
24
72
 
25
- *Reegan Viljoen*
73
+ *Reegan Viljoen*
26
74
 
27
75
  * Allow translations to be inherited and overridden in subclasses.
28
76
 
@@ -28,6 +28,7 @@ module ViewComponent
28
28
  end
29
29
 
30
30
  include ViewComponent::InlineTemplate
31
+ include ViewComponent::UseHelpers
31
32
  include ViewComponent::Slotable
32
33
  include ViewComponent::Translatable
33
34
  include ViewComponent::WithContentHelper
@@ -104,11 +105,13 @@ module ViewComponent
104
105
  before_render
105
106
 
106
107
  if render?
107
- # Avoid allocating new string when output_postamble is blank
108
- if output_postamble.blank?
109
- safe_render_template_for(@__vc_variant).to_s
108
+ # Avoid allocating new string when output_preamble and output_postamble are blank
109
+ rendered_template = safe_render_template_for(@__vc_variant).to_s
110
+
111
+ if output_preamble.blank? && output_postamble.blank?
112
+ rendered_template
110
113
  else
111
- safe_render_template_for(@__vc_variant).to_s + safe_output_postamble
114
+ safe_output_preamble + rendered_template + safe_output_postamble
112
115
  end
113
116
  else
114
117
  ""
@@ -156,6 +159,13 @@ module ViewComponent
156
159
  end
157
160
  end
158
161
 
162
+ # Optional content to be returned before the rendered template.
163
+ #
164
+ # @return [String]
165
+ def output_preamble
166
+ @@default_output_preamble ||= "".html_safe
167
+ end
168
+
159
169
  # Optional content to be returned after the rendered template.
160
170
  #
161
171
  # @return [String]
@@ -309,7 +319,7 @@ module ViewComponent
309
319
 
310
320
  def maybe_escape_html(text)
311
321
  return text if request && !request.format.html?
312
- return text if text.nil? || text.empty?
322
+ return text if text.blank?
313
323
 
314
324
  if text.html_safe?
315
325
  text
@@ -329,6 +339,12 @@ module ViewComponent
329
339
  end
330
340
  end
331
341
 
342
+ def safe_output_preamble
343
+ maybe_escape_html(output_preamble) do
344
+ Kernel.warn("WARNING: The #{self.class} component was provided an HTML-unsafe preamble. The preamble will be automatically escaped, but you may want to investigate.")
345
+ end
346
+ end
347
+
332
348
  def safe_output_postamble
333
349
  maybe_escape_html(output_postamble) do
334
350
  Kernel.warn("WARNING: The #{self.class} component was provided an HTML-unsafe postamble. The postamble will be automatically escaped, but you may want to investigate.")
@@ -238,6 +238,8 @@ module ViewComponent
238
238
  #
239
239
  # @return [ActionDispatch::TestRequest]
240
240
  def vc_test_request
241
+ require "action_controller/test_case"
242
+
241
243
  @vc_test_request ||=
242
244
  begin
243
245
  out = ActionDispatch::TestRequest.create
@@ -255,9 +257,11 @@ module ViewComponent
255
257
 
256
258
  def __vc_test_helpers_preview_class
257
259
  result = if respond_to?(:described_class)
260
+ # :nocov:
258
261
  raise "`render_preview` expected a described_class, but it is nil." if described_class.nil?
259
262
 
260
263
  "#{described_class}Preview"
264
+ # :nocov:
261
265
  else
262
266
  self.class.name.gsub("Test", "Preview")
263
267
  end
@@ -265,5 +269,6 @@ module ViewComponent
265
269
  rescue NameError
266
270
  raise NameError, "`render_preview` expected to find #{result}, but it does not exist."
267
271
  end
272
+ # :nocov:
268
273
  end
269
274
  end
@@ -138,8 +138,7 @@ module ViewComponent
138
138
  end
139
139
 
140
140
  def html_escape_translation_options!(options)
141
- options.each do |name, value|
142
- next if ::I18n.reserved_keys_pattern.match?(name)
141
+ options.except(*::I18n::RESERVED_KEYS).each do |name, value|
143
142
  next if name == :count && value.is_a?(Numeric)
144
143
 
145
144
  options[name] = ERB::Util.html_escape(value.to_s)
@@ -3,7 +3,7 @@
3
3
  module ViewComponent
4
4
  module VERSION
5
5
  MAJOR = 3
6
- MINOR = 9
6
+ MINOR = 11
7
7
  PATCH = 0
8
8
  PRE = nil
9
9
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: view_component
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.9.0
4
+ version: 3.11.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - ViewComponent Team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-01-04 00:00:00.000000000 Z
11
+ date: 2024-02-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -114,6 +114,48 @@ dependencies:
114
114
  - - "~>"
115
115
  - !ruby/object:Gem::Version
116
116
  version: '2'
117
+ - !ruby/object:Gem::Dependency
118
+ name: capybara
119
+ requirement: !ruby/object:Gem::Requirement
120
+ requirements:
121
+ - - "~>"
122
+ - !ruby/object:Gem::Version
123
+ version: '3'
124
+ type: :development
125
+ prerelease: false
126
+ version_requirements: !ruby/object:Gem::Requirement
127
+ requirements:
128
+ - - "~>"
129
+ - !ruby/object:Gem::Version
130
+ version: '3'
131
+ - !ruby/object:Gem::Dependency
132
+ name: cuprite
133
+ requirement: !ruby/object:Gem::Requirement
134
+ requirements:
135
+ - - "~>"
136
+ - !ruby/object:Gem::Version
137
+ version: '0.15'
138
+ type: :development
139
+ prerelease: false
140
+ version_requirements: !ruby/object:Gem::Requirement
141
+ requirements:
142
+ - - "~>"
143
+ - !ruby/object:Gem::Version
144
+ version: '0.15'
145
+ - !ruby/object:Gem::Dependency
146
+ name: debug
147
+ requirement: !ruby/object:Gem::Requirement
148
+ requirements:
149
+ - - ">="
150
+ - !ruby/object:Gem::Version
151
+ version: '0'
152
+ type: :development
153
+ prerelease: false
154
+ version_requirements: !ruby/object:Gem::Requirement
155
+ requirements:
156
+ - - ">="
157
+ - !ruby/object:Gem::Version
158
+ version: '0'
117
159
  - !ruby/object:Gem::Dependency
118
160
  name: erb_lint
119
161
  requirement: !ruby/object:Gem::Requirement
@@ -198,6 +240,20 @@ dependencies:
198
240
  - - "~>"
199
241
  - !ruby/object:Gem::Version
200
242
  version: '0.13'
243
+ - !ruby/object:Gem::Dependency
244
+ name: puma
245
+ requirement: !ruby/object:Gem::Requirement
246
+ requirements:
247
+ - - "~>"
248
+ - !ruby/object:Gem::Version
249
+ version: '6'
250
+ type: :development
251
+ prerelease: false
252
+ version_requirements: !ruby/object:Gem::Requirement
253
+ requirements:
254
+ - - "~>"
255
+ - !ruby/object:Gem::Version
256
+ version: '6'
201
257
  - !ruby/object:Gem::Dependency
202
258
  name: rake
203
259
  requirement: !ruby/object:Gem::Requirement
@@ -212,6 +268,20 @@ dependencies:
212
268
  - - "~>"
213
269
  - !ruby/object:Gem::Version
214
270
  version: '13.0'
271
+ - !ruby/object:Gem::Dependency
272
+ name: rspec-rails
273
+ requirement: !ruby/object:Gem::Requirement
274
+ requirements:
275
+ - - "~>"
276
+ - !ruby/object:Gem::Version
277
+ version: '5'
278
+ type: :development
279
+ prerelease: false
280
+ version_requirements: !ruby/object:Gem::Requirement
281
+ requirements:
282
+ - - "~>"
283
+ - !ruby/object:Gem::Version
284
+ version: '5'
215
285
  - !ruby/object:Gem::Dependency
216
286
  name: rubocop-md
217
287
  requirement: !ruby/object:Gem::Requirement
@@ -226,6 +296,20 @@ dependencies:
226
296
  - - "~>"
227
297
  - !ruby/object:Gem::Version
228
298
  version: '1'
299
+ - !ruby/object:Gem::Dependency
300
+ name: selenium-webdriver
301
+ requirement: !ruby/object:Gem::Requirement
302
+ requirements:
303
+ - - '='
304
+ - !ruby/object:Gem::Version
305
+ version: 4.9.0
306
+ type: :development
307
+ prerelease: false
308
+ version_requirements: !ruby/object:Gem::Requirement
309
+ requirements:
310
+ - - '='
311
+ - !ruby/object:Gem::Version
312
+ version: 4.9.0
229
313
  - !ruby/object:Gem::Dependency
230
314
  name: standard
231
315
  requirement: !ruby/object:Gem::Requirement
@@ -296,6 +380,20 @@ dependencies:
296
380
  - - "~>"
297
381
  - !ruby/object:Gem::Version
298
382
  version: 3.4.2
383
+ - !ruby/object:Gem::Dependency
384
+ name: warning
385
+ requirement: !ruby/object:Gem::Requirement
386
+ requirements:
387
+ - - ">="
388
+ - !ruby/object:Gem::Version
389
+ version: '0'
390
+ type: :development
391
+ prerelease: false
392
+ version_requirements: !ruby/object:Gem::Requirement
393
+ requirements:
394
+ - - ">="
395
+ - !ruby/object:Gem::Version
396
+ version: '0'
299
397
  - !ruby/object:Gem::Dependency
300
398
  name: yard
301
399
  requirement: !ruby/object:Gem::Requirement
@@ -324,6 +422,48 @@ dependencies:
324
422
  - - "~>"
325
423
  - !ruby/object:Gem::Version
326
424
  version: 0.0.1
425
+ - !ruby/object:Gem::Dependency
426
+ name: net-imap
427
+ requirement: !ruby/object:Gem::Requirement
428
+ requirements:
429
+ - - ">="
430
+ - !ruby/object:Gem::Version
431
+ version: '0'
432
+ type: :development
433
+ prerelease: false
434
+ version_requirements: !ruby/object:Gem::Requirement
435
+ requirements:
436
+ - - ">="
437
+ - !ruby/object:Gem::Version
438
+ version: '0'
439
+ - !ruby/object:Gem::Dependency
440
+ name: net-pop
441
+ requirement: !ruby/object:Gem::Requirement
442
+ requirements:
443
+ - - ">="
444
+ - !ruby/object:Gem::Version
445
+ version: '0'
446
+ type: :development
447
+ prerelease: false
448
+ version_requirements: !ruby/object:Gem::Requirement
449
+ requirements:
450
+ - - ">="
451
+ - !ruby/object:Gem::Version
452
+ version: '0'
453
+ - !ruby/object:Gem::Dependency
454
+ name: net-smtp
455
+ requirement: !ruby/object:Gem::Requirement
456
+ requirements:
457
+ - - ">="
458
+ - !ruby/object:Gem::Version
459
+ version: '0'
460
+ type: :development
461
+ prerelease: false
462
+ version_requirements: !ruby/object:Gem::Requirement
463
+ requirements:
464
+ - - ">="
465
+ - !ruby/object:Gem::Version
466
+ version: '0'
327
467
  description:
328
468
  email:
329
469
  executables: []