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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 88f41dda27814dde34bc2c802388e04ff4e96d02cd107b455406583d19fe93ee
4
- data.tar.gz: 4f968af602146f71ec2749455090c80db72099e0668f2961520cdf9918924ecd
3
+ metadata.gz: 64c3fe4a31a28a25a52afb5863267005dcdd45f01439b4b73ceeb2b239c5a4da
4
+ data.tar.gz: ee9d8b85da9d712137429b2a20195b3acb0743ede6966401eee1e277bcf924ef
5
5
  SHA512:
6
- metadata.gz: 5076c4abed4915eb568eb423918ce9a8c66af85f1290a7a1c6ec7858d82db515e6731f66b0135ad8208ae6cf7da5ca554b45faa12cad09487b1516cc25a09709
7
- data.tar.gz: a4d4040ae40657644b51971393b9ba0de2e4df7bfb47fbeb685f49fc1526d92bd15a2aa542be952b04aeb7b986d2b74a4568fc2cda9a3a82470cef6f1c05c947
6
+ metadata.gz: 75b5f118b1d2743025b696a1cde282414284ad0aa8c82f124a34c1dbb96abaada2b9cfd01c5bf2a3ede15ae020e0a037589c57dbf814bc6bdcfcbff3bd05e7b9
7
+ data.tar.gz: 00725e2e65ce61ec185a3a2a14025871388645efd221596da0270d82490f581006104f72ac1be59f09576f84b51614c31344aa316a2b4eddf7fb50e134873f6f
@@ -1,6 +1,6 @@
1
1
  name: Ruby on Rails
2
2
 
3
- on: [push]
3
+ on: [push, pull_request]
4
4
 
5
5
  jobs:
6
6
  build:
@@ -1,3 +1,9 @@
1
+ # v1.3.0
2
+
3
+ * Components are rendered with enough controller context to support rendering of partials and forms.
4
+
5
+ *Patrick Sinclair, Joel Hawksley, Aaron Patterson*
6
+
1
7
  # v1.2.1
2
8
 
3
9
  * `actionview-component` is now tested against Ruby 2.3/2.4 and Rails 5.0.0.
data/Gemfile CHANGED
@@ -3,6 +3,6 @@
3
3
  source "https://rubygems.org"
4
4
  gemspec
5
5
 
6
- rails_version = "#{ENV['RAILS_VERSION'] || '5.2.3'}"
6
+ rails_version = "#{ENV['RAILS_VERSION'] || '6.0.0'}"
7
7
 
8
8
  gem "rails", rails_version == "master" ? { github: "rails/rails" } : rails_version
@@ -6,48 +6,61 @@ PATH
6
6
  GEM
7
7
  remote: https://rubygems.org/
8
8
  specs:
9
- actioncable (5.2.3)
10
- actionpack (= 5.2.3)
9
+ actioncable (6.0.0)
10
+ actionpack (= 6.0.0)
11
11
  nio4r (~> 2.0)
12
12
  websocket-driver (>= 0.6.1)
13
- actionmailer (5.2.3)
14
- actionpack (= 5.2.3)
15
- actionview (= 5.2.3)
16
- activejob (= 5.2.3)
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 (5.2.3)
20
- actionview (= 5.2.3)
21
- activesupport (= 5.2.3)
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.2)
26
- actionview (5.2.3)
27
- activesupport (= 5.2.3)
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.0, >= 1.0.3)
32
- activejob (5.2.3)
33
- activesupport (= 5.2.3)
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 (5.2.3)
36
- activesupport (= 5.2.3)
37
- activerecord (5.2.3)
38
- activemodel (= 5.2.3)
39
- activesupport (= 5.2.3)
40
- arel (>= 9.0)
41
- activestorage (5.2.3)
42
- actionpack (= 5.2.3)
43
- activerecord (= 5.2.3)
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 (5.2.3)
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
- arel (9.0.0)
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.4.0)
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 (5.2.3)
86
- actioncable (= 5.2.3)
87
- actionmailer (= 5.2.3)
88
- actionpack (= 5.2.3)
89
- actionview (= 5.2.3)
90
- activejob (= 5.2.3)
91
- activemodel (= 5.2.3)
92
- activerecord (= 5.2.3)
93
- activestorage (= 5.2.3)
94
- activesupport (= 5.2.3)
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 (= 5.2.3)
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 (5.2.3)
104
- actionpack (= 5.2.3)
105
- activesupport (= 5.2.3)
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.19.0, < 2.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 (= 5.2.3)
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.2.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(ApplicationController.new.view_context.render(component, args, &block))
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.2.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-08-28 00:00:00.000000000 Z
11
+ date: 2019-09-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler