view_component 2.48.0 → 2.49.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of view_component might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3abce9e08dcb71614178ed68b9c8443211ff78790911057752d8fda6fbb194b7
4
- data.tar.gz: 3ac0a8ff1d7cafd2eb12e04a24f1d8f3362675833e4fda780bc238b8fc5ed41f
3
+ metadata.gz: 8feda954b97fc366da967bee72554a1975a40f50aef0cbd1cde6f83f97547d49
4
+ data.tar.gz: 92312db0824d58d24ee8f74f56c3a14e961f03fc71bb1669b1a529fedfb225f3
5
5
  SHA512:
6
- metadata.gz: dba31d0d37e73b7a1e26863d167f5d1eaefb8c5f53d9f542e47667090802b5f53b5c6b9c4b0a9188bf76f42d375c5d7a2cd3024065620aa9ff40b15911706cb8
7
- data.tar.gz: f329872b25f36fe8fa0d018c2a5847ed0b6e47b095d16a27e89d2b0c7180f938d09730d0868405483a8e7c4fe4075afed56927a018b7a273ac4c94950d174fac
6
+ metadata.gz: 1ff56022e2212300d6ae5f8ea8700364fc5675354476b1830e05885c6f4beff3f7b75d6733531eea10aa1b0830917e025686bf17af89606ed2e457aaf1004f73
7
+ data.tar.gz: 5d8dddd267a4a627af6ba0a07507d9d0c2dd2ae38da92f542a690e2fa3052bdc56aa37488e1fde440c9a064b825f0ef1db3ec838f06eba4a4598b4e8c95e315f
data/docs/CHANGELOG.md CHANGED
@@ -7,6 +7,36 @@ title: Changelog
7
7
 
8
8
  ## main
9
9
 
10
+ ## 2.49.0
11
+
12
+ * Fix path handling for evaluated view components that broke in Ruby 3.1.
13
+
14
+ *Adam Hess*
15
+
16
+ * Fix support for the `default:` option for a global translation.
17
+
18
+ *Elia Schito*
19
+
20
+ * Ensure i18n scope is a symbol to protect lookups.
21
+
22
+ *Simon Fish*
23
+
24
+ * Small update to preview docs to include rspec mention.
25
+
26
+ *Leigh Halliday*
27
+
28
+ * Small improvements to collection iteration docs.
29
+
30
+ *Brian O'Rourke*
31
+
32
+ * Add good and bad examples to `ViewComponents in practice`.
33
+
34
+ *Joel Hawksley*
35
+
36
+ * Add Ruby 3.1 and Rails 7.0 to CI
37
+
38
+ *Peter Goldstein*
39
+
10
40
  ## 2.48.0
11
41
 
12
42
  * Correct path in example test command in Contributing docs.
@@ -401,7 +401,7 @@ module ViewComponent
401
401
  # Derive the source location of the component Ruby file from the call stack.
402
402
  # We need to ignore `inherited` frames here as they indicate that `inherited`
403
403
  # has been re-defined by the consuming application, likely in ApplicationComponent.
404
- child.source_location = caller_locations(1, 10).reject { |l| l.label == "inherited" }[0].absolute_path
404
+ child.source_location = caller_locations(1, 10).reject { |l| l.label == "inherited" }[0].path
405
405
 
406
406
  # Removes the first part of the path and the extension.
407
407
  child.virtual_path = child.source_location.gsub(
@@ -5,14 +5,16 @@ require "active_support/notifications"
5
5
  module ViewComponent # :nodoc:
6
6
  module Instrumentation
7
7
  def self.included(mod)
8
- mod.prepend(self)
8
+ mod.prepend(self) unless ancestors.include?(ViewComponent::Instrumentation)
9
9
  end
10
10
 
11
11
  def render_in(view_context, &block)
12
12
  ActiveSupport::Notifications.instrument(
13
13
  "!render.view_component",
14
- name: self.class.name,
15
- identifier: self.class.identifier
14
+ {
15
+ name: self.class.name,
16
+ identifier: self.class.identifier
17
+ }
16
18
  ) do
17
19
  super(view_context, &block)
18
20
  end
@@ -41,7 +41,7 @@ module ViewComponent
41
41
  EMPTY_HASH = {}.freeze
42
42
 
43
43
  def initialize(i18n_scope:, load_paths:)
44
- @i18n_scope = i18n_scope.split(".")
44
+ @i18n_scope = i18n_scope.split(".").map(&:to_sym)
45
45
  @load_paths = load_paths
46
46
  end
47
47
 
@@ -70,21 +70,25 @@ module ViewComponent
70
70
  key = key&.to_s unless key.is_a?(String)
71
71
  key = "#{i18n_scope}#{key}" if key.start_with?(".")
72
72
 
73
- translated =
74
- catch(:exception) do
75
- i18n_backend.translate(locale, key, options)
73
+ if key.start_with?(i18n_scope + ".")
74
+ translated =
75
+ catch(:exception) do
76
+ i18n_backend.translate(locale, key, options)
77
+ end
78
+
79
+ # Fallback to the global translations
80
+ if translated.is_a? ::I18n::MissingTranslation
81
+ return super(key, locale: locale, **options)
76
82
  end
77
83
 
78
- # Fallback to the global translations
79
- if translated.is_a? ::I18n::MissingTranslation
80
- return super(key, locale: locale, **options)
81
- end
84
+ if HTML_SAFE_TRANSLATION_KEY.match?(key)
85
+ translated = translated.html_safe # rubocop:disable Rails/OutputSafety
86
+ end
82
87
 
83
- if HTML_SAFE_TRANSLATION_KEY.match?(key)
84
- translated = translated.html_safe # rubocop:disable Rails/OutputSafety
88
+ translated
89
+ else
90
+ super(key, locale: locale, **options)
85
91
  end
86
-
87
- translated
88
92
  end
89
93
  alias :t :translate
90
94
 
@@ -3,7 +3,7 @@
3
3
  module ViewComponent
4
4
  module VERSION
5
5
  MAJOR = 2
6
- MINOR = 48
6
+ MINOR = 49
7
7
  PATCH = 0
8
8
 
9
9
  STRING = [MAJOR, MINOR, PATCH].join(".")
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: 2.48.0
4
+ version: 2.49.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - GitHub Open Source
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-01-14 00:00:00.000000000 Z
11
+ date: 2022-02-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -373,7 +373,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
373
373
  - !ruby/object:Gem::Version
374
374
  version: '0'
375
375
  requirements: []
376
- rubygems_version: 3.1.4
376
+ rubygems_version: 3.3.3
377
377
  signing_key:
378
378
  specification_version: 4
379
379
  summary: View components for Rails