view_component 3.5.0 → 3.6.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.
Potentially problematic release.
This version of view_component might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/docs/CHANGELOG.md +38 -0
- data/lib/view_component/base.rb +16 -5
- data/lib/view_component/config.rb +8 -0
- data/lib/view_component/engine.rb +4 -3
- data/lib/view_component/test_helpers.rb +2 -1
- data/lib/view_component/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e24f482306b48f037310ce13c9fd25a35ad809a1b3cc536f5b496cf4f4e17ebc
|
4
|
+
data.tar.gz: b403755a43c062e591b2b6cce09422a7148a22d263ff15ca0f2395086df965b2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8cac599cdbad5dfaf4bdf9e02cc3ca34bf45be4fd8832745fe00bd3487127f360e144cc746f5a975a55f1beded97193a3d5abaa42ce161c8d88535e4547fb21b
|
7
|
+
data.tar.gz: d7e4d742329eec00ac562e5cd02ca7a1cd206af87dd4544649ab8790697511fb400a2175d70c6fff39fbed9124810a97db8e4e4d92ec8f6a7735247042140417
|
data/docs/CHANGELOG.md
CHANGED
@@ -10,6 +10,44 @@ nav_order: 5
|
|
10
10
|
|
11
11
|
## main
|
12
12
|
|
13
|
+
## 3.6.0
|
14
|
+
|
15
|
+
* Refer to `helpers` in `NameError` message in development and test environments.
|
16
|
+
|
17
|
+
*Simon Fish*
|
18
|
+
|
19
|
+
* Fix API documentation and revert unnecessary change in `preview.rb`.
|
20
|
+
|
21
|
+
*Richard Macklin*
|
22
|
+
|
23
|
+
* Initialize ViewComponent::Config with defaults before framework load.
|
24
|
+
|
25
|
+
*Simon Fish*
|
26
|
+
|
27
|
+
* Add 3.2 to the list of Ruby CI versions
|
28
|
+
|
29
|
+
*Igor Drozdov*
|
30
|
+
|
31
|
+
* Stop running PVC's `docs:preview` rake task in CI, as the old docsite has been removed.
|
32
|
+
|
33
|
+
*Cameron Dutro*
|
34
|
+
|
35
|
+
* Minor testing documentation improvement.
|
36
|
+
|
37
|
+
*Travis Gaff*
|
38
|
+
|
39
|
+
* Add SearchApi to users list.
|
40
|
+
|
41
|
+
*Sebastjan Prachovskij*
|
42
|
+
|
43
|
+
* Fix `#with_request_url` to ensure `request.query_parameters` is an instance of ActiveSupport::HashWithIndifferentAccess.
|
44
|
+
|
45
|
+
*milk1000cc*
|
46
|
+
|
47
|
+
* Add PeopleForce to list of companies using ViewComponent.
|
48
|
+
|
49
|
+
*Volodymyr Khandiuk*
|
50
|
+
|
13
51
|
## 3.5.0
|
14
52
|
|
15
53
|
* Add Skroutz to users list.
|
data/lib/view_component/base.rb
CHANGED
@@ -22,12 +22,8 @@ module ViewComponent
|
|
22
22
|
#
|
23
23
|
# @return [ActiveSupport::OrderedOptions]
|
24
24
|
def config
|
25
|
-
|
25
|
+
ViewComponent::Config.current
|
26
26
|
end
|
27
|
-
|
28
|
-
# Replaces the entire config. You shouldn't need to use this directly
|
29
|
-
# unless you're building a `ViewComponent::Config` elsewhere.
|
30
|
-
attr_writer :config
|
31
27
|
end
|
32
28
|
|
33
29
|
include ViewComponent::InlineTemplate
|
@@ -223,6 +219,21 @@ module ViewComponent
|
|
223
219
|
@__vc_helpers ||= __vc_original_view_context || controller.view_context
|
224
220
|
end
|
225
221
|
|
222
|
+
if Rails.env.development? || Rails.env.test?
|
223
|
+
def method_missing(method_name, *args) # rubocop:disable Style/MissingRespondToMissing
|
224
|
+
super
|
225
|
+
rescue => e # rubocop:disable Style/RescueStandardError
|
226
|
+
e.set_backtrace e.backtrace.tap(&:shift)
|
227
|
+
raise e, <<~MESSAGE.chomp if view_context && e.is_a?(NameError) && helpers.respond_to?(method_name)
|
228
|
+
#{e.message}
|
229
|
+
|
230
|
+
You may be trying to call a method provided as a view helper. Did you mean `helpers.#{method_name}'?
|
231
|
+
MESSAGE
|
232
|
+
|
233
|
+
raise
|
234
|
+
end
|
235
|
+
end
|
236
|
+
|
226
237
|
# Exposes .virtual_path as an instance method
|
227
238
|
#
|
228
239
|
# @private
|
@@ -167,6 +167,14 @@ module ViewComponent
|
|
167
167
|
end
|
168
168
|
end
|
169
169
|
|
170
|
+
# @!attribute current
|
171
|
+
# @return [ViewComponent::Config]
|
172
|
+
# Returns the current ViewComponent::Config. This is persisted against this
|
173
|
+
# class so that config options remain accessible before the rest of
|
174
|
+
# ViewComponent has loaded. Defaults to an instance of ViewComponent::Config
|
175
|
+
# with all other documented defaults set.
|
176
|
+
class_attribute :current, default: defaults, instance_predicate: false
|
177
|
+
|
170
178
|
def initialize
|
171
179
|
@config = self.class.defaults
|
172
180
|
end
|
@@ -6,7 +6,7 @@ require "view_component/deprecation"
|
|
6
6
|
|
7
7
|
module ViewComponent
|
8
8
|
class Engine < Rails::Engine # :nodoc:
|
9
|
-
config.view_component = ViewComponent::Config.
|
9
|
+
config.view_component = ViewComponent::Config.current
|
10
10
|
|
11
11
|
rake_tasks do
|
12
12
|
load "view_component/rails/tasks/view_component.rake"
|
@@ -15,6 +15,9 @@ module ViewComponent
|
|
15
15
|
initializer "view_component.set_configs" do |app|
|
16
16
|
options = app.config.view_component
|
17
17
|
|
18
|
+
%i[generate preview_controller preview_route show_previews_source].each do |config_option|
|
19
|
+
options[config_option] ||= ViewComponent::Base.public_send(config_option)
|
20
|
+
end
|
18
21
|
options.instrumentation_enabled = false if options.instrumentation_enabled.nil?
|
19
22
|
options.render_monkey_patch_enabled = true if options.render_monkey_patch_enabled.nil?
|
20
23
|
options.show_previews = (Rails.env.development? || Rails.env.test?) if options.show_previews.nil?
|
@@ -37,8 +40,6 @@ module ViewComponent
|
|
37
40
|
|
38
41
|
initializer "view_component.enable_instrumentation" do |app|
|
39
42
|
ActiveSupport.on_load(:view_component) do
|
40
|
-
Base.config = app.config.view_component
|
41
|
-
|
42
43
|
if app.config.view_component.instrumentation_enabled.present?
|
43
44
|
# :nocov: Re-executing the below in tests duplicates initializers and causes order-dependent failures.
|
44
45
|
ViewComponent::Base.prepend(ViewComponent::Instrumentation)
|
@@ -177,7 +177,8 @@ module ViewComponent
|
|
177
177
|
vc_test_request.host = host if host
|
178
178
|
vc_test_request.path_info = path
|
179
179
|
vc_test_request.path_parameters = Rails.application.routes.recognize_path_with_request(vc_test_request, path, {})
|
180
|
-
vc_test_request.set_header("action_dispatch.request.query_parameters",
|
180
|
+
vc_test_request.set_header("action_dispatch.request.query_parameters",
|
181
|
+
Rack::Utils.parse_nested_query(query).with_indifferent_access)
|
181
182
|
vc_test_request.set_header(Rack::QUERY_STRING, query)
|
182
183
|
yield
|
183
184
|
ensure
|
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.
|
4
|
+
version: 3.6.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: 2023-
|
11
|
+
date: 2023-09-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|