view_component 3.5.0 → 3.7.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: ce590ddce7011ae4362dde0733f78ba65992c31add6bac215555515d02ae1dc6
4
- data.tar.gz: df4867599a61d2757e2f226a3c6b187981772e2d225fc442f9184484c0423e64
3
+ metadata.gz: 47e62a0d72c8f9b594303a04d917565ea3766f30ee1335154643e311f92b6128
4
+ data.tar.gz: 412377cfaf624ddfb930d52dcf07a469666f57024d35712f71f752f454f507a5
5
5
  SHA512:
6
- metadata.gz: 0a39d71f089c0f4285dc1eecd324e44afc73f55565002a45c2d37292cc4fa8b05713f7237f04b530617ddc0bb2ccd08fab0c7d010400790dc00daf2d6c9c0546
7
- data.tar.gz: 252a63a4ed7eefd7db529dc93081d3ccfb78555ac1d051540f7a69829a41d4d22fd94557fa2fe9eb88c012bd8dccfd2ceb813aae2582877e387a2df347e2d915
6
+ metadata.gz: f55188297a16933853b95796a14686a29c1ba14eab0cf50d965c28ad8a18664cdafe8ebb12c700c5877f533b6ddb112cbba8dd498735d4a1f66a9b37647f33bd
7
+ data.tar.gz: 780c452ac9a0e33079ca50d49408c74a1c69f427836415c6c08bbdd82f0cb098a646859d26da8ecd93affe8724ab871ed08a210234a9fff71d68ba0ab7668fe8
data/docs/CHANGELOG.md CHANGED
@@ -10,6 +10,75 @@ nav_order: 5
10
10
 
11
11
  ## main
12
12
 
13
+ ## 3.7.0
14
+
15
+ * Support Rails 7.1 in CI.
16
+
17
+ *Reegan Viljoen*
18
+ *Cameron Dutro*
19
+
20
+ * Document the capture compatibility patch on the Known issues page.
21
+
22
+ *Simon Fish*
23
+
24
+ * Add Simundia to list of companies using ViewComponent.
25
+
26
+ *Alexandre Ignjatovic*
27
+
28
+ * Reduce UnboundMethod objects by memoizing initialize_parameters.
29
+
30
+ *Rainer Borene*
31
+
32
+ * Improve docs about inline templates interpolation.
33
+
34
+ *Hans Lemuet*
35
+
36
+ * Update generators.md to clarify the way of changing `config.view_component.view_component_path`.
37
+
38
+ *Shozo Hatta*
39
+
40
+ * Attempt to fix Ferrum timeout errors by creating driver with unique name.
41
+
42
+ *Cameron Dutro*
43
+
44
+ ## 3.6.0
45
+
46
+ * Refer to `helpers` in `NameError` message in development and test environments.
47
+
48
+ *Simon Fish*
49
+
50
+ * Fix API documentation and revert unnecessary change in `preview.rb`.
51
+
52
+ *Richard Macklin*
53
+
54
+ * Initialize ViewComponent::Config with defaults before framework load.
55
+
56
+ *Simon Fish*
57
+
58
+ * Add 3.2 to the list of Ruby CI versions
59
+
60
+ *Igor Drozdov*
61
+
62
+ * Stop running PVC's `docs:preview` rake task in CI, as the old docsite has been removed.
63
+
64
+ *Cameron Dutro*
65
+
66
+ * Minor testing documentation improvement.
67
+
68
+ *Travis Gaff*
69
+
70
+ * Add SearchApi to users list.
71
+
72
+ *Sebastjan Prachovskij*
73
+
74
+ * Fix `#with_request_url` to ensure `request.query_parameters` is an instance of ActiveSupport::HashWithIndifferentAccess.
75
+
76
+ *milk1000cc*
77
+
78
+ * Add PeopleForce to list of companies using ViewComponent.
79
+
80
+ *Volodymyr Khandiuk*
81
+
13
82
  ## 3.5.0
14
83
 
15
84
  * Add Skroutz to users list.
@@ -22,12 +22,8 @@ module ViewComponent
22
22
  #
23
23
  # @return [ActiveSupport::OrderedOptions]
24
24
  def config
25
- @config ||= ActiveSupport::OrderedOptions.new
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
@@ -542,6 +553,7 @@ module ViewComponent
542
553
  # @param parameter [Symbol] The parameter name used when rendering elements of a collection.
543
554
  def with_collection_parameter(parameter)
544
555
  @provided_collection_parameter = parameter
556
+ @initialize_parameters = nil
545
557
  end
546
558
 
547
559
  # Strips trailing whitespace from templates before compiling them.
@@ -637,7 +649,7 @@ module ViewComponent
637
649
  end
638
650
 
639
651
  def initialize_parameters
640
- instance_method(:initialize).parameters
652
+ @initialize_parameters ||= instance_method(:initialize).parameters
641
653
  end
642
654
 
643
655
  def provided_collection_parameter
@@ -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.defaults
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", Rack::Utils.parse_nested_query(query))
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
@@ -3,7 +3,7 @@
3
3
  module ViewComponent
4
4
  module VERSION
5
5
  MAJOR = 3
6
- MINOR = 5
6
+ MINOR = 7
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.5.0
4
+ version: 3.7.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-07-24 00:00:00.000000000 Z
11
+ date: 2023-10-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport