phlexible 2.1.0 → 3.0.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.
- checksums.yaml +4 -4
- data/.rubocop.yml +5 -7
- data/.ruby-version +1 -0
- data/Appraisals +11 -0
- data/Gemfile +2 -1
- data/Gemfile.lock +134 -42
- data/README.md +46 -1
- data/config/render_helper.rb +27 -0
- data/config/sus.rb +1 -1
- data/fixtures/rails_helper.rb +1 -0
- data/gemfiles/.bundle/config +2 -0
- data/gemfiles/phlex_1.gemfile +14 -0
- data/gemfiles/phlex_1.gemfile.lock +253 -0
- data/gemfiles/phlex_2.gemfile +14 -0
- data/gemfiles/phlex_2.gemfile.lock +254 -0
- data/lib/phlexible/callbacks.rb +44 -0
- data/lib/phlexible/rails/a_element.rb +7 -1
- data/lib/phlexible/rails/button_to.rb +0 -113
- data/lib/phlexible/rails/button_to_concerns.rb +140 -0
- data/lib/phlexible/rails/controller_variables.rb +23 -18
- data/lib/phlexible/rails/meta_tags_component.rb +3 -1
- data/lib/phlexible/rails/view_assigns.rb +17 -0
- data/lib/phlexible/version.rb +1 -1
- data/lib/phlexible.rb +6 -4
- data/phlexible.gemspec +4 -2
- metadata +57 -11
- data/config/view_helper.rb +0 -16
- data/lib/phlexible/rails.rb +0 -20
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: af9a39dba0e25b8381fc0f513111e488e27e6fa6d31d3d41ec7d7b7d4aa07cd1
|
4
|
+
data.tar.gz: b1e271a6e412e7e05aabed4b8c4f3a35157a04c6a7e0723ee70b9414beb65565
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 27635a6f6135a15af61920b630269372199777701ec92b216f6e7309880fd46d93705890ef8545fb7d47101d295ad0744406cc1cd9beddfdf81fe03c3b849f71
|
7
|
+
data.tar.gz: c22b9d2d997f94ee86ee3c3c854ec631e2864f549c76d3ffc10138de0df0e2eeafbb2c7c5d9f6e15f2cea4fa1bb1a2982ed38e784878f433edef563f1d6bf8f6
|
data/.rubocop.yml
CHANGED
@@ -2,6 +2,9 @@ AllCops:
|
|
2
2
|
TargetRubyVersion: 3.3.0
|
3
3
|
SuggestExtensions: false
|
4
4
|
NewCops: enable
|
5
|
+
Exclude:
|
6
|
+
- "vendor/**/*"
|
7
|
+
- gemfiles/**/*
|
5
8
|
|
6
9
|
Lint/ConstantDefinitionInBlock:
|
7
10
|
Exclude:
|
@@ -13,10 +16,5 @@ Style/ClassAndModuleChildren:
|
|
13
16
|
Exclude:
|
14
17
|
- fixtures/**/*
|
15
18
|
|
16
|
-
Metrics
|
17
|
-
|
18
|
-
- test/**/*
|
19
|
-
Metrics/MethodLength:
|
20
|
-
Max: 20
|
21
|
-
Metrics/CyclomaticComplexity:
|
22
|
-
Max: 8
|
19
|
+
Metrics:
|
20
|
+
Enabled: false
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
3.3.6
|
data/Appraisals
ADDED
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,16 +1,38 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
phlexible (
|
5
|
-
phlex (>= 1.10.0, <
|
6
|
-
phlex-rails (>= 1.2.
|
4
|
+
phlexible (3.0.0)
|
5
|
+
phlex (>= 1.10.0, < 3.0.0)
|
6
|
+
phlex-rails (>= 1.2.0, < 3.0.0)
|
7
|
+
rails (>= 7.2.0, < 9.0.0)
|
8
|
+
zeitwerk (~> 2.7.2)
|
7
9
|
|
8
10
|
GEM
|
9
11
|
remote: https://rubygems.org/
|
10
12
|
specs:
|
11
|
-
|
12
|
-
|
13
|
-
activesupport (= 8.0.
|
13
|
+
actioncable (8.0.2)
|
14
|
+
actionpack (= 8.0.2)
|
15
|
+
activesupport (= 8.0.2)
|
16
|
+
nio4r (~> 2.0)
|
17
|
+
websocket-driver (>= 0.6.1)
|
18
|
+
zeitwerk (~> 2.6)
|
19
|
+
actionmailbox (8.0.2)
|
20
|
+
actionpack (= 8.0.2)
|
21
|
+
activejob (= 8.0.2)
|
22
|
+
activerecord (= 8.0.2)
|
23
|
+
activestorage (= 8.0.2)
|
24
|
+
activesupport (= 8.0.2)
|
25
|
+
mail (>= 2.8.0)
|
26
|
+
actionmailer (8.0.2)
|
27
|
+
actionpack (= 8.0.2)
|
28
|
+
actionview (= 8.0.2)
|
29
|
+
activejob (= 8.0.2)
|
30
|
+
activesupport (= 8.0.2)
|
31
|
+
mail (>= 2.8.0)
|
32
|
+
rails-dom-testing (~> 2.2)
|
33
|
+
actionpack (8.0.2)
|
34
|
+
actionview (= 8.0.2)
|
35
|
+
activesupport (= 8.0.2)
|
14
36
|
nokogiri (>= 1.8.5)
|
15
37
|
rack (>= 2.2.4)
|
16
38
|
rack-session (>= 1.0.1)
|
@@ -18,13 +40,35 @@ GEM
|
|
18
40
|
rails-dom-testing (~> 2.2)
|
19
41
|
rails-html-sanitizer (~> 1.6)
|
20
42
|
useragent (~> 0.16)
|
21
|
-
|
22
|
-
|
43
|
+
actiontext (8.0.2)
|
44
|
+
actionpack (= 8.0.2)
|
45
|
+
activerecord (= 8.0.2)
|
46
|
+
activestorage (= 8.0.2)
|
47
|
+
activesupport (= 8.0.2)
|
48
|
+
globalid (>= 0.6.0)
|
49
|
+
nokogiri (>= 1.8.5)
|
50
|
+
actionview (8.0.2)
|
51
|
+
activesupport (= 8.0.2)
|
23
52
|
builder (~> 3.1)
|
24
53
|
erubi (~> 1.11)
|
25
54
|
rails-dom-testing (~> 2.2)
|
26
55
|
rails-html-sanitizer (~> 1.6)
|
27
|
-
|
56
|
+
activejob (8.0.2)
|
57
|
+
activesupport (= 8.0.2)
|
58
|
+
globalid (>= 0.3.6)
|
59
|
+
activemodel (8.0.2)
|
60
|
+
activesupport (= 8.0.2)
|
61
|
+
activerecord (8.0.2)
|
62
|
+
activemodel (= 8.0.2)
|
63
|
+
activesupport (= 8.0.2)
|
64
|
+
timeout (>= 0.4.0)
|
65
|
+
activestorage (8.0.2)
|
66
|
+
actionpack (= 8.0.2)
|
67
|
+
activejob (= 8.0.2)
|
68
|
+
activerecord (= 8.0.2)
|
69
|
+
activesupport (= 8.0.2)
|
70
|
+
marcel (~> 1.0)
|
71
|
+
activesupport (8.0.2)
|
28
72
|
base64
|
29
73
|
benchmark (>= 0.3)
|
30
74
|
bigdecimal
|
@@ -37,7 +81,11 @@ GEM
|
|
37
81
|
securerandom (>= 0.3)
|
38
82
|
tzinfo (~> 2.0, >= 2.0.5)
|
39
83
|
uri (>= 0.13.1)
|
40
|
-
|
84
|
+
appraisal (2.5.0)
|
85
|
+
bundler
|
86
|
+
rake
|
87
|
+
thor (>= 0.14.0)
|
88
|
+
ast (2.4.3)
|
41
89
|
base64 (0.2.0)
|
42
90
|
benchmark (0.4.0)
|
43
91
|
bigdecimal (3.1.9)
|
@@ -47,50 +95,72 @@ GEM
|
|
47
95
|
railties (>= 3.0.0)
|
48
96
|
thor (>= 0.14.6)
|
49
97
|
concurrent-ruby (1.3.5)
|
50
|
-
connection_pool (2.5.
|
98
|
+
connection_pool (2.5.1)
|
51
99
|
crass (1.0.6)
|
52
100
|
date (3.4.1)
|
101
|
+
debug (1.10.0)
|
102
|
+
irb (~> 1.10)
|
103
|
+
reline (>= 0.3.8)
|
53
104
|
drb (2.2.1)
|
54
105
|
erubi (1.13.1)
|
106
|
+
globalid (1.2.1)
|
107
|
+
activesupport (>= 6.1)
|
55
108
|
i18n (1.14.7)
|
56
109
|
concurrent-ruby (~> 1.0)
|
57
110
|
io-console (0.8.0)
|
58
|
-
irb (1.15.
|
111
|
+
irb (1.15.2)
|
59
112
|
pp (>= 0.6.0)
|
60
113
|
rdoc (>= 4.0.0)
|
61
114
|
reline (>= 0.4.2)
|
62
|
-
json (2.
|
115
|
+
json (2.10.2)
|
63
116
|
language_server-protocol (3.17.0.4)
|
64
|
-
|
117
|
+
lint_roller (1.1.0)
|
118
|
+
logger (1.7.0)
|
65
119
|
loofah (2.24.0)
|
66
120
|
crass (~> 1.0.2)
|
67
121
|
nokogiri (>= 1.12.0)
|
68
|
-
|
69
|
-
|
122
|
+
mail (2.8.1)
|
123
|
+
mini_mime (>= 0.1.1)
|
124
|
+
net-imap
|
125
|
+
net-pop
|
126
|
+
net-smtp
|
127
|
+
marcel (1.0.4)
|
128
|
+
mini_mime (1.1.5)
|
129
|
+
minitest (5.25.5)
|
130
|
+
net-imap (0.5.7)
|
131
|
+
date
|
132
|
+
net-protocol
|
133
|
+
net-pop (0.1.2)
|
134
|
+
net-protocol
|
135
|
+
net-protocol (0.2.2)
|
136
|
+
timeout
|
137
|
+
net-smtp (0.5.1)
|
138
|
+
net-protocol
|
139
|
+
nio4r (2.7.4)
|
140
|
+
nokogiri (1.18.8-arm64-darwin)
|
70
141
|
racc (~> 1.4)
|
71
|
-
nokogiri (1.18.
|
142
|
+
nokogiri (1.18.8-x86_64-darwin)
|
72
143
|
racc (~> 1.4)
|
73
|
-
nokogiri (1.18.
|
144
|
+
nokogiri (1.18.8-x86_64-linux-gnu)
|
74
145
|
racc (~> 1.4)
|
75
|
-
parallel (1.
|
76
|
-
parser (3.3.
|
146
|
+
parallel (1.27.0)
|
147
|
+
parser (3.3.8.0)
|
77
148
|
ast (~> 2.4.1)
|
78
149
|
racc
|
79
|
-
phlex (
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
nokogiri (~> 1.13)
|
85
|
-
phlex (>= 0.5)
|
150
|
+
phlex (2.2.1)
|
151
|
+
zeitwerk (~> 2.7)
|
152
|
+
phlex-rails (2.2.0)
|
153
|
+
phlex (~> 2.2.1)
|
154
|
+
railties (>= 7.1, < 9)
|
86
155
|
pp (0.6.2)
|
87
156
|
prettyprint
|
88
157
|
prettyprint (0.2.0)
|
158
|
+
prism (1.4.0)
|
89
159
|
psych (5.2.3)
|
90
160
|
date
|
91
161
|
stringio
|
92
162
|
racc (1.8.1)
|
93
|
-
rack (3.1.
|
163
|
+
rack (3.1.13)
|
94
164
|
rack-session (2.1.0)
|
95
165
|
base64 (>= 0.1.0)
|
96
166
|
rack (>= 3.0.0)
|
@@ -98,6 +168,20 @@ GEM
|
|
98
168
|
rack (>= 1.3)
|
99
169
|
rackup (2.2.1)
|
100
170
|
rack (>= 3)
|
171
|
+
rails (8.0.2)
|
172
|
+
actioncable (= 8.0.2)
|
173
|
+
actionmailbox (= 8.0.2)
|
174
|
+
actionmailer (= 8.0.2)
|
175
|
+
actionpack (= 8.0.2)
|
176
|
+
actiontext (= 8.0.2)
|
177
|
+
actionview (= 8.0.2)
|
178
|
+
activejob (= 8.0.2)
|
179
|
+
activemodel (= 8.0.2)
|
180
|
+
activerecord (= 8.0.2)
|
181
|
+
activestorage (= 8.0.2)
|
182
|
+
activesupport (= 8.0.2)
|
183
|
+
bundler (>= 1.15.0)
|
184
|
+
railties (= 8.0.2)
|
101
185
|
rails-dom-testing (2.2.0)
|
102
186
|
activesupport (>= 5.0.0)
|
103
187
|
minitest
|
@@ -105,9 +189,9 @@ GEM
|
|
105
189
|
rails-html-sanitizer (1.6.2)
|
106
190
|
loofah (~> 2.21)
|
107
191
|
nokogiri (>= 1.15.7, != 1.16.7, != 1.16.6, != 1.16.5, != 1.16.4, != 1.16.3, != 1.16.2, != 1.16.1, != 1.16.0.rc1, != 1.16.0)
|
108
|
-
railties (8.0.
|
109
|
-
actionpack (= 8.0.
|
110
|
-
activesupport (= 8.0.
|
192
|
+
railties (8.0.2)
|
193
|
+
actionpack (= 8.0.2)
|
194
|
+
activesupport (= 8.0.2)
|
111
195
|
irb (~> 1.13)
|
112
196
|
rackup (>= 1.0.0)
|
113
197
|
rake (>= 12.2)
|
@@ -115,36 +199,43 @@ GEM
|
|
115
199
|
zeitwerk (~> 2.6)
|
116
200
|
rainbow (3.1.1)
|
117
201
|
rake (13.2.1)
|
118
|
-
rdoc (6.
|
202
|
+
rdoc (6.13.1)
|
119
203
|
psych (>= 4.0.0)
|
120
204
|
regexp_parser (2.10.0)
|
121
|
-
reline (0.6.
|
205
|
+
reline (0.6.1)
|
122
206
|
io-console (~> 0.5)
|
123
|
-
rubocop (1.
|
207
|
+
rubocop (1.75.3)
|
124
208
|
json (~> 2.3)
|
125
|
-
language_server-protocol (
|
209
|
+
language_server-protocol (~> 3.17.0.2)
|
210
|
+
lint_roller (~> 1.1.0)
|
126
211
|
parallel (~> 1.10)
|
127
212
|
parser (>= 3.3.0.2)
|
128
213
|
rainbow (>= 2.2.2, < 4.0)
|
129
214
|
regexp_parser (>= 2.9.3, < 3.0)
|
130
|
-
rubocop-ast (>= 1.
|
215
|
+
rubocop-ast (>= 1.44.0, < 2.0)
|
131
216
|
ruby-progressbar (~> 1.7)
|
132
217
|
unicode-display_width (>= 2.4.0, < 4.0)
|
133
|
-
rubocop-ast (1.
|
134
|
-
parser (>= 3.3.
|
218
|
+
rubocop-ast (1.44.1)
|
219
|
+
parser (>= 3.3.7.2)
|
220
|
+
prism (~> 1.4)
|
135
221
|
ruby-progressbar (1.13.0)
|
136
222
|
securerandom (0.4.1)
|
137
|
-
stringio (3.1.
|
223
|
+
stringio (3.1.7)
|
138
224
|
sus (0.32.0)
|
139
225
|
thor (1.3.2)
|
226
|
+
timeout (0.4.3)
|
140
227
|
tzinfo (2.0.6)
|
141
228
|
concurrent-ruby (~> 1.0)
|
142
229
|
unicode-display_width (3.1.4)
|
143
230
|
unicode-emoji (~> 4.0, >= 4.0.4)
|
144
231
|
unicode-emoji (4.0.4)
|
145
|
-
uri (1.0.
|
232
|
+
uri (1.0.3)
|
146
233
|
useragent (0.16.11)
|
147
|
-
|
234
|
+
websocket-driver (0.7.7)
|
235
|
+
base64
|
236
|
+
websocket-extensions (>= 0.1.0)
|
237
|
+
websocket-extensions (0.1.5)
|
238
|
+
zeitwerk (2.7.2)
|
148
239
|
|
149
240
|
PLATFORMS
|
150
241
|
arm64-darwin-22
|
@@ -154,8 +245,9 @@ PLATFORMS
|
|
154
245
|
x86_64-linux
|
155
246
|
|
156
247
|
DEPENDENCIES
|
248
|
+
appraisal
|
157
249
|
combustion
|
158
|
-
|
250
|
+
debug
|
159
251
|
phlexible!
|
160
252
|
rake (~> 13.0)
|
161
253
|
rubocop (~> 1.55)
|
data/README.md
CHANGED
@@ -36,6 +36,32 @@ class UsersController
|
|
36
36
|
end
|
37
37
|
```
|
38
38
|
|
39
|
+
#### `Callbacks`
|
40
|
+
|
41
|
+
While Phlex does have `before_template`, `after_template`, and `around_template` hooks, they must be defined as regular Ruby methods, meaning you have to always remember to call `super` when redefining any hook method.
|
42
|
+
|
43
|
+
This module provides a more Rails-like interface for defining callbacks in your Phlex views, using `ActiveSupport::Callbacks`. It implements the same `before_template`, `after_template`, and `around_template` hooks as callbacks.
|
44
|
+
|
45
|
+
```ruby
|
46
|
+
class Views::Users::Index < Views::Base
|
47
|
+
include Phlexible::Callbacks
|
48
|
+
|
49
|
+
before_template :set_title
|
50
|
+
|
51
|
+
def view_template
|
52
|
+
h1 { @title }
|
53
|
+
end
|
54
|
+
|
55
|
+
private
|
56
|
+
|
57
|
+
def set_title
|
58
|
+
@title = 'Users'
|
59
|
+
end
|
60
|
+
end
|
61
|
+
```
|
62
|
+
|
63
|
+
You can still use the regular `before_template`, `after_template`, and `around_template` hooks as well, but I recommend that if you include this module, that you use callbacks instead.
|
64
|
+
|
39
65
|
#### `ControllerVariables`
|
40
66
|
|
41
67
|
> Available in **>= 1.0.0**
|
@@ -237,7 +263,26 @@ Then call the `page_title` method in the `<head>` of your page.
|
|
237
263
|
|
238
264
|
## Development
|
239
265
|
|
240
|
-
After checking out the repo,
|
266
|
+
After checking out the repo, install dependencies with:
|
267
|
+
|
268
|
+
```bash
|
269
|
+
bin/setup
|
270
|
+
```
|
271
|
+
|
272
|
+
This gem supports varios major Phlex versions, as defined in the `Appraisal` file.
|
273
|
+
|
274
|
+
To run tests for all supported Phlex versions:
|
275
|
+
|
276
|
+
```
|
277
|
+
bundle exec appraisal sus
|
278
|
+
```
|
279
|
+
|
280
|
+
To run tests for a specific Phlex versions, call:
|
281
|
+
|
282
|
+
```bash
|
283
|
+
bundle exec appraisal phlex-1 sus
|
284
|
+
bundle exec appraisal phlex-2 sus
|
285
|
+
```
|
241
286
|
|
242
287
|
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
243
288
|
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RenderHelper
|
4
|
+
def render_to_html(component)
|
5
|
+
view_context.render(component)
|
6
|
+
end
|
7
|
+
|
8
|
+
def render_to_nokogiri_fragment(...)
|
9
|
+
html = render_to_html(...)
|
10
|
+
Nokogiri::HTML5.fragment(html)
|
11
|
+
end
|
12
|
+
|
13
|
+
def render_to_nokogiri_document(...)
|
14
|
+
html = render_to_html(...)
|
15
|
+
Nokogiri::HTML5(html)
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
def view_context
|
21
|
+
controller.view_context
|
22
|
+
end
|
23
|
+
|
24
|
+
def controller
|
25
|
+
@controller ||= ActionView::TestCase::TestController.new
|
26
|
+
end
|
27
|
+
end
|
data/config/sus.rb
CHANGED
data/fixtures/rails_helper.rb
CHANGED
@@ -0,0 +1,14 @@
|
|
1
|
+
# This file was generated by Appraisal
|
2
|
+
|
3
|
+
source "https://rubygems.org"
|
4
|
+
|
5
|
+
gem "appraisal"
|
6
|
+
gem "combustion"
|
7
|
+
gem "debug"
|
8
|
+
gem "rake", "~> 13.0"
|
9
|
+
gem "rubocop", "~> 1.55"
|
10
|
+
gem "sus"
|
11
|
+
gem "phlex", ">= 1.10.0", "< 2.0.0"
|
12
|
+
gem "phlex-rails", ">= 1.2.1", "< 2.0.0"
|
13
|
+
|
14
|
+
gemspec path: "../"
|