view_component 2.45.0 → 2.46.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 +4 -4
- data/README.md +2 -1
- data/docs/CHANGELOG.md +22 -0
- data/lib/view_component/compile_cache.rb +4 -0
- data/lib/view_component/compiler.rb +45 -37
- data/lib/view_component/engine.rb +10 -3
- data/lib/view_component/version.rb +1 -1
- data/lib/view_component.rb +10 -3
- 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: b9b1ca38d53b64e55ff434c43f11839cf122d82d17768c2f064e2622ef88dc88
|
4
|
+
data.tar.gz: 7bc10806de04abbe6c7458305592d09ea6f4dfe9d86aff5d0cf0b9b9cfa9a620
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5c100fe77483f4b5f7227a47188f63428cbde65ebddf75cd0accf881d2140536150ea1d52f5c68b66126dd5087d9ac7fd7725f4c829a82d58c5cf86ef8abff2e
|
7
|
+
data.tar.gz: 19e3230c2b894651462dd6dbae44b4579267cc662c962e2bf9208e28cea299e01286427ae3c949d5622e8302cad4ba2b8f5e58a6aa6dabd3e872de367affb8bb
|
data/README.md
CHANGED
@@ -1,4 +1,5 @@
|
|
1
|
-
|
1
|
+
![ViewComponent logo](/docs/logo/readme-light.svg#gh-light-mode-only)
|
2
|
+
![ViewComponent logo](/docs/logo/readme-dark.svg#gh-dark-mode-only)
|
2
3
|
|
3
4
|
A framework for building reusable, testable & encapsulated view components in Ruby on Rails.
|
4
5
|
|
data/docs/CHANGELOG.md
CHANGED
@@ -7,6 +7,24 @@ title: Changelog
|
|
7
7
|
|
8
8
|
## main
|
9
9
|
|
10
|
+
## 2.46.0
|
11
|
+
|
12
|
+
* Add thread safety to the compiler.
|
13
|
+
|
14
|
+
*Horia Radu*
|
15
|
+
|
16
|
+
* Add theme-specific logo images to readme.
|
17
|
+
|
18
|
+
*Dylan Smith*
|
19
|
+
|
20
|
+
* Add Orbit to users list.
|
21
|
+
|
22
|
+
*Nicolas Goutay*
|
23
|
+
|
24
|
+
* Increase clarity around purpose and use of slots.
|
25
|
+
|
26
|
+
*Simon Fish*
|
27
|
+
|
10
28
|
## 2.45.0
|
11
29
|
|
12
30
|
* Remove internal APIs from API documentation, fix link to license.
|
@@ -45,6 +63,10 @@ title: Changelog
|
|
45
63
|
|
46
64
|
*Yoshiyuki Hirano*
|
47
65
|
|
66
|
+
* Deprecate engine loading manually.
|
67
|
+
|
68
|
+
*Yoshiyuki Hirano*
|
69
|
+
|
48
70
|
## 2.44.0
|
49
71
|
|
50
72
|
* Rename internal accessor to use private naming.
|
@@ -2,8 +2,12 @@
|
|
2
2
|
|
3
3
|
module ViewComponent
|
4
4
|
class Compiler
|
5
|
+
# Lock required to be obtained before compiling the component
|
6
|
+
attr_reader :__vc_compiler_lock
|
7
|
+
|
5
8
|
def initialize(component_class)
|
6
9
|
@component_class = component_class
|
10
|
+
@__vc_compiler_lock = Monitor.new
|
7
11
|
end
|
8
12
|
|
9
13
|
def compiled?
|
@@ -13,55 +17,59 @@ module ViewComponent
|
|
13
17
|
def compile(raise_errors: false)
|
14
18
|
return if compiled?
|
15
19
|
|
16
|
-
|
20
|
+
__vc_compiler_lock.synchronize do
|
21
|
+
CompileCache.invalidate_class!(component_class)
|
17
22
|
|
18
|
-
|
19
|
-
raise ViewComponent::ComponentError.new(
|
20
|
-
"#{component_class} implements a reserved method, `#with_content`.\n\n" \
|
21
|
-
"To fix this issue, change the name of the method."
|
22
|
-
)
|
23
|
-
end
|
23
|
+
subclass_instance_methods = component_class.instance_methods(false)
|
24
24
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
25
|
+
if subclass_instance_methods.include?(:with_content) && raise_errors
|
26
|
+
raise ViewComponent::ComponentError.new(
|
27
|
+
"#{component_class} implements a reserved method, `#with_content`.\n\n" \
|
28
|
+
"To fix this issue, change the name of the method."
|
29
|
+
)
|
30
|
+
end
|
30
31
|
|
31
|
-
|
32
|
-
|
33
|
-
"`#before_render_check` will be removed in v3.0.0.\n\n" \
|
34
|
-
"To fix this issue, use `#before_render` instead."
|
35
|
-
)
|
36
|
-
end
|
32
|
+
if template_errors.present?
|
33
|
+
raise ViewComponent::TemplateError.new(template_errors) if raise_errors
|
37
34
|
|
38
|
-
|
39
|
-
|
40
|
-
component_class.validate_collection_parameter!
|
41
|
-
end
|
35
|
+
return false
|
36
|
+
end
|
42
37
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
38
|
+
if subclass_instance_methods.include?(:before_render_check)
|
39
|
+
ActiveSupport::Deprecation.warn(
|
40
|
+
"`#before_render_check` will be removed in v3.0.0.\n\n" \
|
41
|
+
"To fix this issue, use `#before_render` instead."
|
42
|
+
)
|
43
|
+
end
|
47
44
|
|
48
|
-
if
|
49
|
-
component_class.
|
45
|
+
if raise_errors
|
46
|
+
component_class.validate_initialization_parameters!
|
47
|
+
component_class.validate_collection_parameter!
|
50
48
|
end
|
51
49
|
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
50
|
+
templates.each do |template|
|
51
|
+
# Remove existing compiled template methods,
|
52
|
+
# as Ruby warns when redefining a method.
|
53
|
+
method_name = call_method_name(template[:variant])
|
54
|
+
|
55
|
+
if component_class.instance_methods.include?(method_name.to_sym)
|
56
|
+
component_class.send(:undef_method, method_name.to_sym)
|
56
57
|
end
|
57
|
-
RUBY
|
58
|
-
end
|
59
58
|
|
60
|
-
|
59
|
+
component_class.class_eval <<-RUBY, template[:path], -1
|
60
|
+
def #{method_name}
|
61
|
+
@output_buffer = ActionView::OutputBuffer.new
|
62
|
+
#{compiled_template(template[:path])}
|
63
|
+
end
|
64
|
+
RUBY
|
65
|
+
end
|
66
|
+
|
67
|
+
define_render_template_for
|
61
68
|
|
62
|
-
|
69
|
+
component_class._after_compile
|
63
70
|
|
64
|
-
|
71
|
+
CompileCache.register(component_class)
|
72
|
+
end
|
65
73
|
end
|
66
74
|
|
67
75
|
private
|
@@ -145,6 +145,13 @@ module ViewComponent
|
|
145
145
|
end
|
146
146
|
end
|
147
147
|
|
148
|
-
#
|
149
|
-
|
150
|
-
|
148
|
+
# :nocov:
|
149
|
+
unless defined?(ViewComponent::Base)
|
150
|
+
ActiveSupport::Deprecation.warn(
|
151
|
+
"This manually engine loading is deprecated and will be removed in v3.0.0. " \
|
152
|
+
"Remove `require \"view_component/engine\"`."
|
153
|
+
)
|
154
|
+
|
155
|
+
require "view_component"
|
156
|
+
end
|
157
|
+
# :nocov:
|
data/lib/view_component.rb
CHANGED
@@ -19,6 +19,13 @@ module ViewComponent
|
|
19
19
|
autoload :Translatable
|
20
20
|
end
|
21
21
|
|
22
|
-
#
|
23
|
-
|
24
|
-
|
22
|
+
# :nocov:
|
23
|
+
if defined?(ViewComponent::Engine)
|
24
|
+
ActiveSupport::Deprecation.warn(
|
25
|
+
"This manually engine loading is deprecated and will be removed in v3.0.0. " \
|
26
|
+
"Remove `require \"view_component/engine\"`."
|
27
|
+
)
|
28
|
+
elsif defined?(Rails::Engine)
|
29
|
+
require "view_component/engine"
|
30
|
+
end
|
31
|
+
# :nocov:
|
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.
|
4
|
+
version: 2.46.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: 2021-
|
11
|
+
date: 2021-12-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|