actionview-component 1.2.1 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ruby_on_rails.yml +1 -1
- data/CHANGELOG.md +6 -0
- data/Gemfile +1 -1
- data/Gemfile.lock +59 -43
- data/README.md +4 -0
- data/actionview-component.gemspec +1 -1
- data/lib/action_view/component/base.rb +11 -1
- data/lib/action_view/component/test_helpers.rb +5 -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: 64c3fe4a31a28a25a52afb5863267005dcdd45f01439b4b73ceeb2b239c5a4da
|
4
|
+
data.tar.gz: ee9d8b85da9d712137429b2a20195b3acb0743ede6966401eee1e277bcf924ef
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 75b5f118b1d2743025b696a1cde282414284ad0aa8c82f124a34c1dbb96abaada2b9cfd01c5bf2a3ede15ae020e0a037589c57dbf814bc6bdcfcbff3bd05e7b9
|
7
|
+
data.tar.gz: 00725e2e65ce61ec185a3a2a14025871388645efd221596da0270d82490f581006104f72ac1be59f09576f84b51614c31344aa316a2b4eddf7fb50e134873f6f
|
data/CHANGELOG.md
CHANGED
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -6,48 +6,61 @@ PATH
|
|
6
6
|
GEM
|
7
7
|
remote: https://rubygems.org/
|
8
8
|
specs:
|
9
|
-
actioncable (
|
10
|
-
actionpack (=
|
9
|
+
actioncable (6.0.0)
|
10
|
+
actionpack (= 6.0.0)
|
11
11
|
nio4r (~> 2.0)
|
12
12
|
websocket-driver (>= 0.6.1)
|
13
|
-
|
14
|
-
actionpack (=
|
15
|
-
|
16
|
-
|
13
|
+
actionmailbox (6.0.0)
|
14
|
+
actionpack (= 6.0.0)
|
15
|
+
activejob (= 6.0.0)
|
16
|
+
activerecord (= 6.0.0)
|
17
|
+
activestorage (= 6.0.0)
|
18
|
+
activesupport (= 6.0.0)
|
19
|
+
mail (>= 2.7.1)
|
20
|
+
actionmailer (6.0.0)
|
21
|
+
actionpack (= 6.0.0)
|
22
|
+
actionview (= 6.0.0)
|
23
|
+
activejob (= 6.0.0)
|
17
24
|
mail (~> 2.5, >= 2.5.4)
|
18
25
|
rails-dom-testing (~> 2.0)
|
19
|
-
actionpack (
|
20
|
-
actionview (=
|
21
|
-
activesupport (=
|
26
|
+
actionpack (6.0.0)
|
27
|
+
actionview (= 6.0.0)
|
28
|
+
activesupport (= 6.0.0)
|
22
29
|
rack (~> 2.0)
|
23
30
|
rack-test (>= 0.6.3)
|
24
31
|
rails-dom-testing (~> 2.0)
|
25
|
-
rails-html-sanitizer (~> 1.0, >= 1.0
|
26
|
-
|
27
|
-
|
32
|
+
rails-html-sanitizer (~> 1.0, >= 1.2.0)
|
33
|
+
actiontext (6.0.0)
|
34
|
+
actionpack (= 6.0.0)
|
35
|
+
activerecord (= 6.0.0)
|
36
|
+
activestorage (= 6.0.0)
|
37
|
+
activesupport (= 6.0.0)
|
38
|
+
nokogiri (>= 1.8.5)
|
39
|
+
actionview (6.0.0)
|
40
|
+
activesupport (= 6.0.0)
|
28
41
|
builder (~> 3.1)
|
29
42
|
erubi (~> 1.4)
|
30
43
|
rails-dom-testing (~> 2.0)
|
31
|
-
rails-html-sanitizer (~> 1.
|
32
|
-
activejob (
|
33
|
-
activesupport (=
|
44
|
+
rails-html-sanitizer (~> 1.1, >= 1.2.0)
|
45
|
+
activejob (6.0.0)
|
46
|
+
activesupport (= 6.0.0)
|
34
47
|
globalid (>= 0.3.6)
|
35
|
-
activemodel (
|
36
|
-
activesupport (=
|
37
|
-
activerecord (
|
38
|
-
activemodel (=
|
39
|
-
activesupport (=
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
activerecord (=
|
48
|
+
activemodel (6.0.0)
|
49
|
+
activesupport (= 6.0.0)
|
50
|
+
activerecord (6.0.0)
|
51
|
+
activemodel (= 6.0.0)
|
52
|
+
activesupport (= 6.0.0)
|
53
|
+
activestorage (6.0.0)
|
54
|
+
actionpack (= 6.0.0)
|
55
|
+
activejob (= 6.0.0)
|
56
|
+
activerecord (= 6.0.0)
|
44
57
|
marcel (~> 0.3.1)
|
45
|
-
activesupport (
|
58
|
+
activesupport (6.0.0)
|
46
59
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
47
60
|
i18n (>= 0.7, < 2)
|
48
61
|
minitest (~> 5.1)
|
49
62
|
tzinfo (~> 1.1)
|
50
|
-
|
63
|
+
zeitwerk (~> 2.1, >= 2.1.8)
|
51
64
|
ast (2.4.0)
|
52
65
|
builder (3.2.3)
|
53
66
|
concurrent-ruby (1.1.5)
|
@@ -73,7 +86,7 @@ GEM
|
|
73
86
|
mini_mime (1.0.2)
|
74
87
|
mini_portile2 (2.4.0)
|
75
88
|
minitest (5.1.0)
|
76
|
-
nio4r (2.
|
89
|
+
nio4r (2.5.2)
|
77
90
|
nokogiri (1.10.4)
|
78
91
|
mini_portile2 (~> 2.4.0)
|
79
92
|
parallel (1.17.0)
|
@@ -82,30 +95,32 @@ GEM
|
|
82
95
|
rack (2.0.7)
|
83
96
|
rack-test (1.1.0)
|
84
97
|
rack (>= 1.0, < 3)
|
85
|
-
rails (
|
86
|
-
actioncable (=
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
98
|
+
rails (6.0.0)
|
99
|
+
actioncable (= 6.0.0)
|
100
|
+
actionmailbox (= 6.0.0)
|
101
|
+
actionmailer (= 6.0.0)
|
102
|
+
actionpack (= 6.0.0)
|
103
|
+
actiontext (= 6.0.0)
|
104
|
+
actionview (= 6.0.0)
|
105
|
+
activejob (= 6.0.0)
|
106
|
+
activemodel (= 6.0.0)
|
107
|
+
activerecord (= 6.0.0)
|
108
|
+
activestorage (= 6.0.0)
|
109
|
+
activesupport (= 6.0.0)
|
95
110
|
bundler (>= 1.3.0)
|
96
|
-
railties (=
|
111
|
+
railties (= 6.0.0)
|
97
112
|
sprockets-rails (>= 2.0.0)
|
98
113
|
rails-dom-testing (2.0.3)
|
99
114
|
activesupport (>= 4.2.0)
|
100
115
|
nokogiri (>= 1.6)
|
101
116
|
rails-html-sanitizer (1.2.0)
|
102
117
|
loofah (~> 2.2, >= 2.2.2)
|
103
|
-
railties (
|
104
|
-
actionpack (=
|
105
|
-
activesupport (=
|
118
|
+
railties (6.0.0)
|
119
|
+
actionpack (= 6.0.0)
|
120
|
+
activesupport (= 6.0.0)
|
106
121
|
method_source
|
107
122
|
rake (>= 0.8.7)
|
108
|
-
thor (>= 0.
|
123
|
+
thor (>= 0.20.3, < 2.0)
|
109
124
|
rainbow (3.0.0)
|
110
125
|
rake (10.5.0)
|
111
126
|
rubocop (0.74.0)
|
@@ -141,6 +156,7 @@ GEM
|
|
141
156
|
websocket-driver (0.7.1)
|
142
157
|
websocket-extensions (>= 0.1.0)
|
143
158
|
websocket-extensions (0.1.4)
|
159
|
+
zeitwerk (2.1.10)
|
144
160
|
|
145
161
|
PLATFORMS
|
146
162
|
ruby
|
@@ -150,7 +166,7 @@ DEPENDENCIES
|
|
150
166
|
bundler (>= 1.14)
|
151
167
|
haml (~> 5)
|
152
168
|
minitest (= 5.1.0)
|
153
|
-
rails (=
|
169
|
+
rails (= 6.0.0)
|
154
170
|
rake (~> 10.0)
|
155
171
|
rubocop (~> 0.59)
|
156
172
|
rubocop-github (~> 0.13.0)
|
data/README.md
CHANGED
@@ -9,6 +9,10 @@ This gem is meant to serve as a precursor to upstreaming the `ActionView::Compon
|
|
9
9
|
|
10
10
|
Preliminary support for rendering components was merged into Rails `6.1.0.alpha` in https://github.com/rails/rails/pull/36388. Assuming `ActionView::Component` makes it into Rails `6.1`, this gem will then exist to serve as a backport.
|
11
11
|
|
12
|
+
## Design philosophy
|
13
|
+
|
14
|
+
As the goal of this gem is to be upstreamed into Rails, it is designed to integrate as seamlessly as possible, with the [least surprise](https://www.artima.com/intv/ruby4.html).
|
15
|
+
|
12
16
|
## Compatibility
|
13
17
|
|
14
18
|
`actionview-component` is tested for compatibility with combinations of Ruby `2.3`/`2.4`/`2.5`/`2.6` and Rails `5.0.0`/`5.2.3`/`6.0.0`/`6.1.0.alpha`.
|
@@ -6,7 +6,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
6
6
|
|
7
7
|
Gem::Specification.new do |spec|
|
8
8
|
spec.name = "actionview-component"
|
9
|
-
spec.version = "1.
|
9
|
+
spec.version = "1.3.0"
|
10
10
|
spec.authors = ["GitHub Open Source"]
|
11
11
|
spec.email = ["opensource+actionview-component@github.com"]
|
12
12
|
|
@@ -30,6 +30,10 @@ module ActionView
|
|
30
30
|
module Component
|
31
31
|
class Base < ActionView::Base
|
32
32
|
include ActiveModel::Validations
|
33
|
+
include ActiveSupport::Configurable
|
34
|
+
include ActionController::RequestForgeryProtection
|
35
|
+
|
36
|
+
delegate :render, to: :view_context
|
33
37
|
|
34
38
|
# Entrypoint for rendering components. Called by ActionView::Base#render.
|
35
39
|
#
|
@@ -58,6 +62,12 @@ module ActionView
|
|
58
62
|
#
|
59
63
|
def render_in(view_context, *args, &block)
|
60
64
|
self.class.compile
|
65
|
+
self.controller = view_context.controller
|
66
|
+
@view_context = view_context
|
67
|
+
@view_renderer ||= view_context.view_renderer
|
68
|
+
@lookup_context ||= view_context.lookup_context
|
69
|
+
@view_flow ||= view_context.view_flow
|
70
|
+
|
61
71
|
@content = view_context.capture(&block) if block_given?
|
62
72
|
validate!
|
63
73
|
call
|
@@ -136,7 +146,7 @@ module ActionView
|
|
136
146
|
|
137
147
|
private
|
138
148
|
|
139
|
-
attr_reader :content
|
149
|
+
attr_reader :content, :view_context
|
140
150
|
end
|
141
151
|
end
|
142
152
|
end
|
@@ -4,7 +4,11 @@ module ActionView
|
|
4
4
|
module Component
|
5
5
|
module TestHelpers
|
6
6
|
def render_inline(component, **args, &block)
|
7
|
-
Nokogiri::HTML(
|
7
|
+
Nokogiri::HTML(controller.view_context.render(component, args, &block))
|
8
|
+
end
|
9
|
+
|
10
|
+
def controller
|
11
|
+
@controller ||= ApplicationController.new.tap { |c| c.request = ActionDispatch::TestRequest.create }
|
8
12
|
end
|
9
13
|
|
10
14
|
def render_component(component, **args, &block)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: actionview-component
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- GitHub Open Source
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-09-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|