stimulus_reflex 3.2.2.pre0 → 3.3.0.pre1
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/CHANGELOG.md +92 -1
- data/Gemfile.lock +74 -69
- data/README.md +1 -1
- data/lib/generators/USAGE +1 -1
- data/lib/generators/stimulus_reflex_generator.rb +10 -21
- data/lib/generators/templates/{custom_controller.js → app/javascript/controllers/%file_name%_controller.js.tt} +20 -0
- data/lib/generators/templates/{application_controller.js → app/javascript/controllers/application_controller.js.tt} +0 -0
- data/lib/generators/templates/{custom_reflex.rb → app/reflexes/%file_name%_reflex.rb.tt} +6 -0
- data/lib/generators/templates/{application_reflex.rb → app/reflexes/application_reflex.rb.tt} +0 -0
- data/lib/stimulus_reflex.rb +5 -0
- data/lib/stimulus_reflex/broadcaster.rb +53 -0
- data/lib/stimulus_reflex/channel.rb +28 -71
- data/lib/stimulus_reflex/morph_mode.rb +19 -0
- data/lib/stimulus_reflex/morph_mode/nothing_morph_mode.rb +15 -0
- data/lib/stimulus_reflex/morph_mode/page_morph_mode.rb +15 -0
- data/lib/stimulus_reflex/morph_mode/selector_morph_mode.rb +15 -0
- data/lib/stimulus_reflex/reflex.rb +50 -3
- data/lib/stimulus_reflex/version.rb +1 -1
- data/lib/tasks/stimulus_reflex/install.rake +10 -5
- data/test/generators/stimulus_reflex_generator_test.rb +23 -0
- data/test/tmp/app/reflexes/demo_reflex.rb +1 -0
- metadata +14 -9
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: cb3ab10321ba245b37a1c1c930f48218146079db9b3448adf6ec86511a8eee27
|
|
4
|
+
data.tar.gz: f9e891d1775eca3787f9d95c3860d1cab43fec42895cb97a25f698636d7912e7
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 6bba44eda7278bf6b54fd3ce3ee511169d6a1170164bea35ec8cf0f3df0b2c55bedd4c4030ee37c650af35c52761e386192e2b1844bd9676244bb67206b2097d
|
|
7
|
+
data.tar.gz: 8887eb98ce990e7c70e508628850c0955dc81d8a03ec02c94d8e4150a65c708274e7450eb00f81bf7d4be7e8b9f4ca53a201791381a85700c3eec6d26f27de5d
|
data/CHANGELOG.md
CHANGED
|
@@ -2,7 +2,98 @@
|
|
|
2
2
|
|
|
3
3
|
## [Unreleased](https://github.com/hopsoft/stimulus_reflex/tree/HEAD)
|
|
4
4
|
|
|
5
|
-
[Full Changelog](https://github.com/hopsoft/stimulus_reflex/compare/v3.
|
|
5
|
+
[Full Changelog](https://github.com/hopsoft/stimulus_reflex/compare/v3.3.0.pre0...HEAD)
|
|
6
|
+
|
|
7
|
+
**Merged pull requests:**
|
|
8
|
+
|
|
9
|
+
- alternate solution [\#262](https://github.com/hopsoft/stimulus_reflex/pull/262) ([leastbad](https://github.com/leastbad))
|
|
10
|
+
|
|
11
|
+
## [v3.3.0.pre0](https://github.com/hopsoft/stimulus_reflex/tree/v3.3.0.pre0) (2020-07-04)
|
|
12
|
+
|
|
13
|
+
[Full Changelog](https://github.com/hopsoft/stimulus_reflex/compare/v3.2.3...v3.3.0.pre0)
|
|
14
|
+
|
|
15
|
+
**Implemented enhancements:**
|
|
16
|
+
|
|
17
|
+
- Returns more helpful error message if Reflex doesn't exist [\#254](https://github.com/hopsoft/stimulus_reflex/pull/254) ([leastbad](https://github.com/leastbad))
|
|
18
|
+
- Update install.rake to handle Typescript [\#241](https://github.com/hopsoft/stimulus_reflex/pull/241) ([iv-mexx](https://github.com/iv-mexx))
|
|
19
|
+
- Morph Modes: page, selector and nothing [\#211](https://github.com/hopsoft/stimulus_reflex/pull/211) ([leastbad](https://github.com/leastbad))
|
|
20
|
+
|
|
21
|
+
**Fixed bugs:**
|
|
22
|
+
|
|
23
|
+
- Limit MutationObserver mutations [\#256](https://github.com/hopsoft/stimulus_reflex/pull/256) ([jasoncharnes](https://github.com/jasoncharnes))
|
|
24
|
+
|
|
25
|
+
**Closed issues:**
|
|
26
|
+
|
|
27
|
+
- beforeUpdate/updateSuccess/updateError functions deprecated? [\#255](https://github.com/hopsoft/stimulus_reflex/issues/255)
|
|
28
|
+
- Error handling will fail if reflex is not defined [\#253](https://github.com/hopsoft/stimulus_reflex/issues/253)
|
|
29
|
+
- Select with data-reflex in Firefox flickers [\#251](https://github.com/hopsoft/stimulus_reflex/issues/251)
|
|
30
|
+
- data-reflex-attributes vs data-reflex-dataset [\#237](https://github.com/hopsoft/stimulus_reflex/issues/237)
|
|
31
|
+
- Shorthand action notations corresponding to stimulus [\#233](https://github.com/hopsoft/stimulus_reflex/issues/233)
|
|
32
|
+
- Lifecycle methods only called for one reflex [\#225](https://github.com/hopsoft/stimulus_reflex/issues/225)
|
|
33
|
+
- Tweak the generator so we can specify reflex actions [\#219](https://github.com/hopsoft/stimulus_reflex/issues/219)
|
|
34
|
+
- Docs: Clarify forcing DOM update with authentication [\#123](https://github.com/hopsoft/stimulus_reflex/issues/123)
|
|
35
|
+
- ActiveJob integration example [\#112](https://github.com/hopsoft/stimulus_reflex/issues/112)
|
|
36
|
+
|
|
37
|
+
**Merged pull requests:**
|
|
38
|
+
|
|
39
|
+
- Prep for pre release of 3.3.0 [\#259](https://github.com/hopsoft/stimulus_reflex/pull/259) ([hopsoft](https://github.com/hopsoft))
|
|
40
|
+
- Fallback to first Stimulus controller in array [\#257](https://github.com/hopsoft/stimulus_reflex/pull/257) ([jasoncharnes](https://github.com/jasoncharnes))
|
|
41
|
+
- Fix cases where plural reflexes were unresolved [\#252](https://github.com/hopsoft/stimulus_reflex/pull/252) ([joshleblanc](https://github.com/joshleblanc))
|
|
42
|
+
- warn against collections of identical elements that trigger reflexes [\#250](https://github.com/hopsoft/stimulus_reflex/pull/250) ([leastbad](https://github.com/leastbad))
|
|
43
|
+
- always calls params to persist them into controller action [\#249](https://github.com/hopsoft/stimulus_reflex/pull/249) ([RolandStuder](https://github.com/RolandStuder))
|
|
44
|
+
- Update deployment.md [\#248](https://github.com/hopsoft/stimulus_reflex/pull/248) ([user073](https://github.com/user073))
|
|
45
|
+
- Update reflexes.md [\#247](https://github.com/hopsoft/stimulus_reflex/pull/247) ([user073](https://github.com/user073))
|
|
46
|
+
- Bump actionpack from 6.0.3.1 to 6.0.3.2 [\#245](https://github.com/hopsoft/stimulus_reflex/pull/245) ([dependabot[bot]](https://github.com/apps/dependabot))
|
|
47
|
+
- Bump rack from 2.2.2 to 2.2.3 [\#244](https://github.com/hopsoft/stimulus_reflex/pull/244) ([dependabot[bot]](https://github.com/apps/dependabot))
|
|
48
|
+
- Revert "Revert "Add instructions for pulling the user id out of session storage"" [\#240](https://github.com/hopsoft/stimulus_reflex/pull/240) ([leastbad](https://github.com/leastbad))
|
|
49
|
+
- Revert "Add instructions for pulling the user id out of session storage" [\#239](https://github.com/hopsoft/stimulus_reflex/pull/239) ([leastbad](https://github.com/leastbad))
|
|
50
|
+
- Add instructions for pulling the user id out of session storage [\#238](https://github.com/hopsoft/stimulus_reflex/pull/238) ([mtomov](https://github.com/mtomov))
|
|
51
|
+
- adds params documentation [\#230](https://github.com/hopsoft/stimulus_reflex/pull/230) ([RolandStuder](https://github.com/RolandStuder))
|
|
52
|
+
- Fix calling wrong controller lifecycle methods [\#226](https://github.com/hopsoft/stimulus_reflex/pull/226) ([davidalejandroaguilar](https://github.com/davidalejandroaguilar))
|
|
53
|
+
- Allow to pass reflex action names to reflex generator [\#224](https://github.com/hopsoft/stimulus_reflex/pull/224) ([marcoroth](https://github.com/marcoroth))
|
|
54
|
+
|
|
55
|
+
## [v3.2.3](https://github.com/hopsoft/stimulus_reflex/tree/v3.2.3) (2020-06-15)
|
|
56
|
+
|
|
57
|
+
[Full Changelog](https://github.com/hopsoft/stimulus_reflex/compare/v3.2.2...v3.2.3)
|
|
58
|
+
|
|
59
|
+
**Fixed bugs:**
|
|
60
|
+
|
|
61
|
+
- Add more smarts to \_\_perform [\#235](https://github.com/hopsoft/stimulus_reflex/pull/235) ([hopsoft](https://github.com/hopsoft))
|
|
62
|
+
- \_\_perform had a bug where it was only ever calling the first event [\#234](https://github.com/hopsoft/stimulus_reflex/pull/234) ([leastbad](https://github.com/leastbad))
|
|
63
|
+
- merges insteads of overwrites params for reflex actions with form data [\#231](https://github.com/hopsoft/stimulus_reflex/pull/231) ([RolandStuder](https://github.com/RolandStuder))
|
|
64
|
+
|
|
65
|
+
**Closed issues:**
|
|
66
|
+
|
|
67
|
+
- "Uncaught \(in promise\)" error after failed declarative reflex [\#170](https://github.com/hopsoft/stimulus_reflex/issues/170)
|
|
68
|
+
|
|
69
|
+
**Merged pull requests:**
|
|
70
|
+
|
|
71
|
+
- Fix typos in the documentation [\#228](https://github.com/hopsoft/stimulus_reflex/pull/228) ([dlt](https://github.com/dlt))
|
|
72
|
+
|
|
73
|
+
## [v3.2.2](https://github.com/hopsoft/stimulus_reflex/tree/v3.2.2) (2020-06-06)
|
|
74
|
+
|
|
75
|
+
[Full Changelog](https://github.com/hopsoft/stimulus_reflex/compare/v3.2.2.pre1...v3.2.2)
|
|
76
|
+
|
|
77
|
+
**Closed issues:**
|
|
78
|
+
|
|
79
|
+
- Issue with doing a partial dom update [\#223](https://github.com/hopsoft/stimulus_reflex/issues/223)
|
|
80
|
+
|
|
81
|
+
## [v3.2.2.pre1](https://github.com/hopsoft/stimulus_reflex/tree/v3.2.2.pre1) (2020-05-30)
|
|
82
|
+
|
|
83
|
+
[Full Changelog](https://github.com/hopsoft/stimulus_reflex/compare/v3.2.2.pre0...v3.2.2.pre1)
|
|
84
|
+
|
|
85
|
+
**Fixed bugs:**
|
|
86
|
+
|
|
87
|
+
- Session lost after throw :abort [\#221](https://github.com/hopsoft/stimulus_reflex/issues/221)
|
|
88
|
+
- Fix multipleInstances convenience method [\#220](https://github.com/hopsoft/stimulus_reflex/pull/220) ([julianrubisch](https://github.com/julianrubisch))
|
|
89
|
+
|
|
90
|
+
**Merged pull requests:**
|
|
91
|
+
|
|
92
|
+
- Always commit session [\#222](https://github.com/hopsoft/stimulus_reflex/pull/222) ([hopsoft](https://github.com/hopsoft))
|
|
93
|
+
|
|
94
|
+
## [v3.2.2.pre0](https://github.com/hopsoft/stimulus_reflex/tree/v3.2.2.pre0) (2020-05-27)
|
|
95
|
+
|
|
96
|
+
[Full Changelog](https://github.com/hopsoft/stimulus_reflex/compare/v3.2.1...v3.2.2.pre0)
|
|
6
97
|
|
|
7
98
|
**Implemented enhancements:**
|
|
8
99
|
|
data/Gemfile.lock
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
stimulus_reflex (3.
|
|
4
|
+
stimulus_reflex (3.3.0.pre1)
|
|
5
5
|
cable_ready (>= 4.1.2)
|
|
6
6
|
nokogiri
|
|
7
7
|
rack
|
|
@@ -10,74 +10,74 @@ PATH
|
|
|
10
10
|
GEM
|
|
11
11
|
remote: https://rubygems.org/
|
|
12
12
|
specs:
|
|
13
|
-
actioncable (6.0.3.
|
|
14
|
-
actionpack (= 6.0.3.
|
|
13
|
+
actioncable (6.0.3.2)
|
|
14
|
+
actionpack (= 6.0.3.2)
|
|
15
15
|
nio4r (~> 2.0)
|
|
16
16
|
websocket-driver (>= 0.6.1)
|
|
17
|
-
actionmailbox (6.0.3.
|
|
18
|
-
actionpack (= 6.0.3.
|
|
19
|
-
activejob (= 6.0.3.
|
|
20
|
-
activerecord (= 6.0.3.
|
|
21
|
-
activestorage (= 6.0.3.
|
|
22
|
-
activesupport (= 6.0.3.
|
|
17
|
+
actionmailbox (6.0.3.2)
|
|
18
|
+
actionpack (= 6.0.3.2)
|
|
19
|
+
activejob (= 6.0.3.2)
|
|
20
|
+
activerecord (= 6.0.3.2)
|
|
21
|
+
activestorage (= 6.0.3.2)
|
|
22
|
+
activesupport (= 6.0.3.2)
|
|
23
23
|
mail (>= 2.7.1)
|
|
24
|
-
actionmailer (6.0.3.
|
|
25
|
-
actionpack (= 6.0.3.
|
|
26
|
-
actionview (= 6.0.3.
|
|
27
|
-
activejob (= 6.0.3.
|
|
24
|
+
actionmailer (6.0.3.2)
|
|
25
|
+
actionpack (= 6.0.3.2)
|
|
26
|
+
actionview (= 6.0.3.2)
|
|
27
|
+
activejob (= 6.0.3.2)
|
|
28
28
|
mail (~> 2.5, >= 2.5.4)
|
|
29
29
|
rails-dom-testing (~> 2.0)
|
|
30
|
-
actionpack (6.0.3.
|
|
31
|
-
actionview (= 6.0.3.
|
|
32
|
-
activesupport (= 6.0.3.
|
|
30
|
+
actionpack (6.0.3.2)
|
|
31
|
+
actionview (= 6.0.3.2)
|
|
32
|
+
activesupport (= 6.0.3.2)
|
|
33
33
|
rack (~> 2.0, >= 2.0.8)
|
|
34
34
|
rack-test (>= 0.6.3)
|
|
35
35
|
rails-dom-testing (~> 2.0)
|
|
36
36
|
rails-html-sanitizer (~> 1.0, >= 1.2.0)
|
|
37
|
-
actiontext (6.0.3.
|
|
38
|
-
actionpack (= 6.0.3.
|
|
39
|
-
activerecord (= 6.0.3.
|
|
40
|
-
activestorage (= 6.0.3.
|
|
41
|
-
activesupport (= 6.0.3.
|
|
37
|
+
actiontext (6.0.3.2)
|
|
38
|
+
actionpack (= 6.0.3.2)
|
|
39
|
+
activerecord (= 6.0.3.2)
|
|
40
|
+
activestorage (= 6.0.3.2)
|
|
41
|
+
activesupport (= 6.0.3.2)
|
|
42
42
|
nokogiri (>= 1.8.5)
|
|
43
|
-
actionview (6.0.3.
|
|
44
|
-
activesupport (= 6.0.3.
|
|
43
|
+
actionview (6.0.3.2)
|
|
44
|
+
activesupport (= 6.0.3.2)
|
|
45
45
|
builder (~> 3.1)
|
|
46
46
|
erubi (~> 1.4)
|
|
47
47
|
rails-dom-testing (~> 2.0)
|
|
48
48
|
rails-html-sanitizer (~> 1.1, >= 1.2.0)
|
|
49
|
-
activejob (6.0.3.
|
|
50
|
-
activesupport (= 6.0.3.
|
|
49
|
+
activejob (6.0.3.2)
|
|
50
|
+
activesupport (= 6.0.3.2)
|
|
51
51
|
globalid (>= 0.3.6)
|
|
52
|
-
activemodel (6.0.3.
|
|
53
|
-
activesupport (= 6.0.3.
|
|
54
|
-
activerecord (6.0.3.
|
|
55
|
-
activemodel (= 6.0.3.
|
|
56
|
-
activesupport (= 6.0.3.
|
|
57
|
-
activestorage (6.0.3.
|
|
58
|
-
actionpack (= 6.0.3.
|
|
59
|
-
activejob (= 6.0.3.
|
|
60
|
-
activerecord (= 6.0.3.
|
|
52
|
+
activemodel (6.0.3.2)
|
|
53
|
+
activesupport (= 6.0.3.2)
|
|
54
|
+
activerecord (6.0.3.2)
|
|
55
|
+
activemodel (= 6.0.3.2)
|
|
56
|
+
activesupport (= 6.0.3.2)
|
|
57
|
+
activestorage (6.0.3.2)
|
|
58
|
+
actionpack (= 6.0.3.2)
|
|
59
|
+
activejob (= 6.0.3.2)
|
|
60
|
+
activerecord (= 6.0.3.2)
|
|
61
61
|
marcel (~> 0.3.1)
|
|
62
|
-
activesupport (6.0.3.
|
|
62
|
+
activesupport (6.0.3.2)
|
|
63
63
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
|
64
64
|
i18n (>= 0.7, < 2)
|
|
65
65
|
minitest (~> 5.1)
|
|
66
66
|
tzinfo (~> 1.1)
|
|
67
67
|
zeitwerk (~> 2.2, >= 2.2.2)
|
|
68
|
-
ast (2.4.
|
|
68
|
+
ast (2.4.1)
|
|
69
69
|
builder (3.2.4)
|
|
70
|
-
cable_ready (4.
|
|
70
|
+
cable_ready (4.3.0)
|
|
71
71
|
rails (>= 5.2)
|
|
72
|
-
coderay (1.1.
|
|
72
|
+
coderay (1.1.3)
|
|
73
73
|
concurrent-ruby (1.1.6)
|
|
74
74
|
crass (1.0.6)
|
|
75
75
|
erubi (1.9.0)
|
|
76
76
|
globalid (0.4.2)
|
|
77
77
|
activesupport (>= 4.2.0)
|
|
78
|
-
i18n (1.8.
|
|
78
|
+
i18n (1.8.3)
|
|
79
79
|
concurrent-ruby (~> 1.0)
|
|
80
|
-
loofah (2.
|
|
80
|
+
loofah (2.6.0)
|
|
81
81
|
crass (~> 1.0.2)
|
|
82
82
|
nokogiri (>= 1.5.9)
|
|
83
83
|
mail (2.7.1)
|
|
@@ -90,68 +90,73 @@ GEM
|
|
|
90
90
|
mini_portile2 (2.4.0)
|
|
91
91
|
minitest (5.14.1)
|
|
92
92
|
nio4r (2.5.2)
|
|
93
|
-
nokogiri (1.10.
|
|
93
|
+
nokogiri (1.10.10)
|
|
94
94
|
mini_portile2 (~> 2.4.0)
|
|
95
|
-
parallel (1.19.
|
|
96
|
-
parser (2.7.1.
|
|
97
|
-
ast (~> 2.4.
|
|
95
|
+
parallel (1.19.2)
|
|
96
|
+
parser (2.7.1.4)
|
|
97
|
+
ast (~> 2.4.1)
|
|
98
98
|
pry (0.12.2)
|
|
99
99
|
coderay (~> 1.1.0)
|
|
100
100
|
method_source (~> 0.9.0)
|
|
101
101
|
pry-nav (0.3.0)
|
|
102
102
|
pry (>= 0.9.10, < 0.13.0)
|
|
103
|
-
rack (2.2.
|
|
103
|
+
rack (2.2.3)
|
|
104
104
|
rack-test (1.1.0)
|
|
105
105
|
rack (>= 1.0, < 3)
|
|
106
|
-
rails (6.0.3.
|
|
107
|
-
actioncable (= 6.0.3.
|
|
108
|
-
actionmailbox (= 6.0.3.
|
|
109
|
-
actionmailer (= 6.0.3.
|
|
110
|
-
actionpack (= 6.0.3.
|
|
111
|
-
actiontext (= 6.0.3.
|
|
112
|
-
actionview (= 6.0.3.
|
|
113
|
-
activejob (= 6.0.3.
|
|
114
|
-
activemodel (= 6.0.3.
|
|
115
|
-
activerecord (= 6.0.3.
|
|
116
|
-
activestorage (= 6.0.3.
|
|
117
|
-
activesupport (= 6.0.3.
|
|
106
|
+
rails (6.0.3.2)
|
|
107
|
+
actioncable (= 6.0.3.2)
|
|
108
|
+
actionmailbox (= 6.0.3.2)
|
|
109
|
+
actionmailer (= 6.0.3.2)
|
|
110
|
+
actionpack (= 6.0.3.2)
|
|
111
|
+
actiontext (= 6.0.3.2)
|
|
112
|
+
actionview (= 6.0.3.2)
|
|
113
|
+
activejob (= 6.0.3.2)
|
|
114
|
+
activemodel (= 6.0.3.2)
|
|
115
|
+
activerecord (= 6.0.3.2)
|
|
116
|
+
activestorage (= 6.0.3.2)
|
|
117
|
+
activesupport (= 6.0.3.2)
|
|
118
118
|
bundler (>= 1.3.0)
|
|
119
|
-
railties (= 6.0.3.
|
|
119
|
+
railties (= 6.0.3.2)
|
|
120
120
|
sprockets-rails (>= 2.0.0)
|
|
121
121
|
rails-dom-testing (2.0.3)
|
|
122
122
|
activesupport (>= 4.2.0)
|
|
123
123
|
nokogiri (>= 1.6)
|
|
124
124
|
rails-html-sanitizer (1.3.0)
|
|
125
125
|
loofah (~> 2.3)
|
|
126
|
-
railties (6.0.3.
|
|
127
|
-
actionpack (= 6.0.3.
|
|
128
|
-
activesupport (= 6.0.3.
|
|
126
|
+
railties (6.0.3.2)
|
|
127
|
+
actionpack (= 6.0.3.2)
|
|
128
|
+
activesupport (= 6.0.3.2)
|
|
129
129
|
method_source
|
|
130
130
|
rake (>= 0.8.7)
|
|
131
131
|
thor (>= 0.20.3, < 2.0)
|
|
132
132
|
rainbow (3.0.0)
|
|
133
133
|
rake (13.0.1)
|
|
134
|
+
regexp_parser (1.7.1)
|
|
134
135
|
rexml (3.2.4)
|
|
135
|
-
rubocop (0.
|
|
136
|
+
rubocop (0.85.1)
|
|
136
137
|
parallel (~> 1.10)
|
|
137
138
|
parser (>= 2.7.0.1)
|
|
138
139
|
rainbow (>= 2.2.2, < 4.0)
|
|
140
|
+
regexp_parser (>= 1.7)
|
|
139
141
|
rexml
|
|
142
|
+
rubocop-ast (>= 0.0.3)
|
|
140
143
|
ruby-progressbar (~> 1.7)
|
|
141
144
|
unicode-display_width (>= 1.4.0, < 2.0)
|
|
142
|
-
rubocop-
|
|
145
|
+
rubocop-ast (0.1.0)
|
|
146
|
+
parser (>= 2.7.0.1)
|
|
147
|
+
rubocop-performance (1.6.1)
|
|
143
148
|
rubocop (>= 0.71.0)
|
|
144
149
|
ruby-progressbar (1.10.1)
|
|
145
|
-
sprockets (4.0.
|
|
150
|
+
sprockets (4.0.2)
|
|
146
151
|
concurrent-ruby (~> 1.0)
|
|
147
152
|
rack (> 1, < 3)
|
|
148
153
|
sprockets-rails (3.2.1)
|
|
149
154
|
actionpack (>= 4.0)
|
|
150
155
|
activesupport (>= 4.0)
|
|
151
156
|
sprockets (>= 3.0.0)
|
|
152
|
-
standard (0.4.
|
|
153
|
-
rubocop (~> 0.
|
|
154
|
-
rubocop-performance (~> 1.
|
|
157
|
+
standard (0.4.7)
|
|
158
|
+
rubocop (~> 0.85.0)
|
|
159
|
+
rubocop-performance (~> 1.6.0)
|
|
155
160
|
standardrb (1.0.0)
|
|
156
161
|
standard
|
|
157
162
|
thor (1.0.1)
|
|
@@ -161,8 +166,8 @@ GEM
|
|
|
161
166
|
unicode-display_width (1.7.0)
|
|
162
167
|
websocket-driver (0.7.2)
|
|
163
168
|
websocket-extensions (>= 0.1.0)
|
|
164
|
-
websocket-extensions (0.1.
|
|
165
|
-
zeitwerk (2.3.
|
|
169
|
+
websocket-extensions (0.1.5)
|
|
170
|
+
zeitwerk (2.3.1)
|
|
166
171
|
|
|
167
172
|
PLATFORMS
|
|
168
173
|
ruby
|
data/README.md
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
<img alt="License: MIT" src="https://img.shields.io/badge/license-MIT-brightgreen.svg" target="_blank" />
|
|
12
12
|
</a>
|
|
13
13
|
<a href="http://blog.codinghorror.com/the-best-code-is-no-code-at-all/" target="_blank">
|
|
14
|
-
<img alt="Lines of Code" src="https://img.shields.io/badge/lines_of_code-
|
|
14
|
+
<img alt="Lines of Code" src="https://img.shields.io/badge/lines_of_code-1084-brightgreen.svg?style=flat" />
|
|
15
15
|
</a>
|
|
16
16
|
<a href="https://docs.stimulusreflex.com/" target="_blank">
|
|
17
17
|
<img alt="Documentation" src="https://img.shields.io/badge/documentation-yes-brightgreen.svg" />
|
data/lib/generators/USAGE
CHANGED
|
@@ -2,7 +2,7 @@ Description:
|
|
|
2
2
|
Generate boilerplate files to help get you up and running with StimulusReflex
|
|
3
3
|
|
|
4
4
|
Example:
|
|
5
|
-
rails generate stimulus_reflex User
|
|
5
|
+
rails generate stimulus_reflex User update do_stuff [options]
|
|
6
6
|
|
|
7
7
|
This will create, but not overwrite the following files:
|
|
8
8
|
|
|
@@ -5,33 +5,22 @@ require "rails/generators"
|
|
|
5
5
|
class StimulusReflexGenerator < Rails::Generators::NamedBase
|
|
6
6
|
source_root File.expand_path("templates", __dir__)
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
def initialize_reflexes
|
|
13
|
-
copy_reflex_files
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
def initialize_controllers
|
|
17
|
-
copy_controller_files
|
|
18
|
-
end
|
|
8
|
+
argument :name, type: :string, required: true, banner: "NAME"
|
|
9
|
+
argument :actions, type: :array, default: [], banner: "action action"
|
|
19
10
|
|
|
20
|
-
|
|
11
|
+
def execute
|
|
12
|
+
actions.map!(&:underscore)
|
|
21
13
|
|
|
22
|
-
|
|
23
|
-
REFLEX_BASE_PATH = "app/reflexes"
|
|
14
|
+
copy_application_files if behavior == :invoke
|
|
24
15
|
|
|
25
|
-
|
|
26
|
-
template "
|
|
16
|
+
template "app/reflexes/%file_name%_reflex.rb"
|
|
17
|
+
template "app/javascript/controllers/%file_name%_controller.js"
|
|
27
18
|
end
|
|
28
19
|
|
|
29
|
-
|
|
30
|
-
template "custom_controller.js", File.join(CONTROLLER_BASE_PATH, "#{name.underscore}_controller.js")
|
|
31
|
-
end
|
|
20
|
+
private
|
|
32
21
|
|
|
33
22
|
def copy_application_files
|
|
34
|
-
template "application_reflex.rb"
|
|
35
|
-
template "application_controller.js"
|
|
23
|
+
template "app/reflexes/application_reflex.rb"
|
|
24
|
+
template "app/javascript/controllers/application_controller.js"
|
|
36
25
|
end
|
|
37
26
|
end
|
|
@@ -22,6 +22,7 @@ export default class extends ApplicationController {
|
|
|
22
22
|
* error - error message from the server
|
|
23
23
|
*/
|
|
24
24
|
|
|
25
|
+
<% if actions.empty? -%>
|
|
25
26
|
// beforeUpdate(element, reflex) {
|
|
26
27
|
// element.innerText = 'Updating...'
|
|
27
28
|
// }
|
|
@@ -34,4 +35,23 @@ export default class extends ApplicationController {
|
|
|
34
35
|
// console.error('updateError', error);
|
|
35
36
|
// element.innerText = 'Update Failed!'
|
|
36
37
|
// }
|
|
38
|
+
<% end -%>
|
|
39
|
+
<% actions.each do |action| -%>
|
|
40
|
+
// <%= "before_#{action}".camelize(:lower) %>(element, reflex) {
|
|
41
|
+
// console.log("before <%= action %>", element, reflex)
|
|
42
|
+
// }
|
|
43
|
+
|
|
44
|
+
// <%= "#{action}_success".camelize(:lower) %>(element, reflex) {
|
|
45
|
+
// console.log("<%= action %> success", element, reflex)
|
|
46
|
+
// }
|
|
47
|
+
|
|
48
|
+
// <%= "#{action}_error".camelize(:lower) %>(element, reflex, error) {
|
|
49
|
+
// console.error("<%= action %> error", element, reflex, error)
|
|
50
|
+
// }
|
|
51
|
+
|
|
52
|
+
// <%= "after_#{action}".camelize(:lower) %>(element, reflex, error) {
|
|
53
|
+
// console.log("after <%= action %>", element, reflex, error)
|
|
54
|
+
// }
|
|
55
|
+
<%= "\n" unless action == actions.last -%>
|
|
56
|
+
<% end -%>
|
|
37
57
|
}
|
|
File without changes
|
data/lib/generators/templates/{application_reflex.rb → app/reflexes/application_reflex.rb.tt}
RENAMED
|
File without changes
|
data/lib/stimulus_reflex.rb
CHANGED
|
@@ -11,7 +11,12 @@ require "cable_ready"
|
|
|
11
11
|
require "stimulus_reflex/version"
|
|
12
12
|
require "stimulus_reflex/reflex"
|
|
13
13
|
require "stimulus_reflex/element"
|
|
14
|
+
require "stimulus_reflex/broadcaster"
|
|
15
|
+
require "stimulus_reflex/morph_mode"
|
|
14
16
|
require "stimulus_reflex/channel"
|
|
17
|
+
require "stimulus_reflex/morph_mode/nothing_morph_mode"
|
|
18
|
+
require "stimulus_reflex/morph_mode/page_morph_mode"
|
|
19
|
+
require "stimulus_reflex/morph_mode/selector_morph_mode"
|
|
15
20
|
require "generators/stimulus_reflex_generator"
|
|
16
21
|
|
|
17
22
|
module StimulusReflex
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
module StimulusReflex
|
|
2
|
+
module Broadcaster
|
|
3
|
+
include CableReady::Broadcaster
|
|
4
|
+
|
|
5
|
+
def render_page_and_broadcast_morph(reflex, selectors, data = {})
|
|
6
|
+
html = render_page(reflex)
|
|
7
|
+
broadcast_morphs selectors, data, html if html.present?
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def render_page(reflex)
|
|
11
|
+
reflex.controller.process reflex.url_params[:action]
|
|
12
|
+
reflex.controller.response.body
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def broadcast_morphs(selectors, data, html)
|
|
16
|
+
document = Nokogiri::HTML(html)
|
|
17
|
+
selectors = selectors.select { |s| document.css(s).present? }
|
|
18
|
+
selectors.each do |selector|
|
|
19
|
+
cable_ready[stream_name].morph(
|
|
20
|
+
selector: selector,
|
|
21
|
+
html: document.css(selector).inner_html,
|
|
22
|
+
children_only: true,
|
|
23
|
+
permanent_attribute_name: data["permanent_attribute_name"],
|
|
24
|
+
stimulus_reflex: data.merge({
|
|
25
|
+
last: selector == selectors.last,
|
|
26
|
+
morph_mode: "page"
|
|
27
|
+
})
|
|
28
|
+
)
|
|
29
|
+
end
|
|
30
|
+
cable_ready.broadcast
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def broadcast_message(subject:, body: nil, data: {})
|
|
34
|
+
message = {
|
|
35
|
+
subject: subject,
|
|
36
|
+
body: body
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
logger.error "\e[31m#{body}\e[0m" if subject == "error"
|
|
40
|
+
|
|
41
|
+
data[:morph_mode] = "page"
|
|
42
|
+
data[:server_message] = message
|
|
43
|
+
data[:morph_mode] = "selector" if subject == "selector"
|
|
44
|
+
data[:morph_mode] = "nothing" if subject == "nothing"
|
|
45
|
+
|
|
46
|
+
cable_ready[stream_name].dispatch_event(
|
|
47
|
+
name: "stimulus-reflex:server-message",
|
|
48
|
+
detail: {stimulus_reflex: data}
|
|
49
|
+
)
|
|
50
|
+
cable_ready.broadcast
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
end
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
class StimulusReflex::Channel < ActionCable::Channel::Base
|
|
4
|
-
include
|
|
4
|
+
include StimulusReflex::Broadcaster
|
|
5
5
|
|
|
6
6
|
def stream_name
|
|
7
7
|
ids = connection.identifiers.map { |identifier| send(identifier).try(:id) || send(identifier) }
|
|
@@ -21,32 +21,38 @@ class StimulusReflex::Channel < ActionCable::Channel::Base
|
|
|
21
21
|
selectors = data["selectors"] = ["body"] if selectors.blank?
|
|
22
22
|
target = data["target"].to_s
|
|
23
23
|
reflex_name, method_name = target.split("#")
|
|
24
|
-
reflex_name = reflex_name.
|
|
24
|
+
reflex_name = reflex_name.camelize
|
|
25
25
|
reflex_name = reflex_name.end_with?("Reflex") ? reflex_name : "#{reflex_name}Reflex"
|
|
26
26
|
arguments = (data["args"] || []).map { |arg| object_with_indifferent_access arg }
|
|
27
27
|
element = StimulusReflex::Element.new(data)
|
|
28
|
+
permanent_attribute_name = data["permanent_attribute_name"]
|
|
28
29
|
params = data["params"] || {}
|
|
29
30
|
|
|
30
31
|
begin
|
|
31
|
-
reflex_class = reflex_name.constantize.tap { |klass| raise ArgumentError.new("#{reflex_name} is not a StimulusReflex::Reflex") unless is_reflex?(klass) }
|
|
32
|
-
reflex = reflex_class.new(self, url: url, element: element, selectors: selectors, method_name: method_name, params: params)
|
|
33
|
-
delegate_call_to_reflex reflex, method_name, arguments
|
|
34
|
-
rescue => invoke_error
|
|
35
|
-
reflex.rescue_with_handler(invoke_error)
|
|
36
|
-
message = exception_message_with_backtrace(invoke_error)
|
|
37
|
-
return broadcast_message subject: "error", body: "StimulusReflex::Channel Failed to invoke #{target}! #{url} #{message}", data: data
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
if reflex.halted?
|
|
41
|
-
broadcast_message subject: "halted", data: data
|
|
42
|
-
else
|
|
43
32
|
begin
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
reflex
|
|
47
|
-
|
|
48
|
-
|
|
33
|
+
reflex_class = reflex_name.constantize.tap { |klass| raise ArgumentError.new("#{reflex_name} is not a StimulusReflex::Reflex") unless is_reflex?(klass) }
|
|
34
|
+
reflex = reflex_class.new(self, url: url, element: element, selectors: selectors, method_name: method_name, permanent_attribute_name: permanent_attribute_name, params: params)
|
|
35
|
+
delegate_call_to_reflex reflex, method_name, arguments
|
|
36
|
+
rescue => invoke_error
|
|
37
|
+
reflex&.rescue_with_handler(invoke_error)
|
|
38
|
+
message = exception_message_with_backtrace(invoke_error)
|
|
39
|
+
return broadcast_message subject: "error", body: "StimulusReflex::Channel Failed to invoke #{target}! #{url} #{message}", data: data
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
if reflex.halted?
|
|
43
|
+
broadcast_message subject: "halted", data: data
|
|
44
|
+
else
|
|
45
|
+
begin
|
|
46
|
+
reflex.morph_mode.stream_name = stream_name
|
|
47
|
+
reflex.morph_mode.broadcast(reflex, selectors, data)
|
|
48
|
+
rescue => render_error
|
|
49
|
+
reflex.rescue_with_handler(render_error)
|
|
50
|
+
message = exception_message_with_backtrace(render_error)
|
|
51
|
+
broadcast_message subject: "error", body: "StimulusReflex::Channel Failed to re-render #{url} #{message}", data: data
|
|
52
|
+
end
|
|
49
53
|
end
|
|
54
|
+
ensure
|
|
55
|
+
commit_session reflex if reflex
|
|
50
56
|
end
|
|
51
57
|
end
|
|
52
58
|
|
|
@@ -76,63 +82,14 @@ class StimulusReflex::Channel < ActionCable::Channel::Base
|
|
|
76
82
|
end
|
|
77
83
|
end
|
|
78
84
|
|
|
79
|
-
def
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
end
|
|
83
|
-
|
|
84
|
-
def commit_session(request, response)
|
|
85
|
-
store = request.session.instance_variable_get("@by")
|
|
86
|
-
store.commit_session request, response
|
|
85
|
+
def commit_session(reflex)
|
|
86
|
+
store = reflex.request.session.instance_variable_get("@by")
|
|
87
|
+
store.commit_session reflex.request, reflex.controller.response
|
|
87
88
|
rescue => e
|
|
88
89
|
message = "Failed to commit session! #{exception_message_with_backtrace(e)}"
|
|
89
90
|
logger.error "\e[31m#{message}\e[0m"
|
|
90
91
|
end
|
|
91
92
|
|
|
92
|
-
def render_page(reflex)
|
|
93
|
-
controller = reflex.request.controller_class.new
|
|
94
|
-
controller.instance_variable_set :"@stimulus_reflex", true
|
|
95
|
-
reflex.instance_variables.each do |name|
|
|
96
|
-
controller.instance_variable_set name, reflex.instance_variable_get(name)
|
|
97
|
-
end
|
|
98
|
-
|
|
99
|
-
controller.request = reflex.request
|
|
100
|
-
controller.response = ActionDispatch::Response.new
|
|
101
|
-
controller.process reflex.url_params[:action]
|
|
102
|
-
commit_session reflex.request, controller.response
|
|
103
|
-
controller.response.body
|
|
104
|
-
end
|
|
105
|
-
|
|
106
|
-
def broadcast_morphs(selectors, data, html)
|
|
107
|
-
document = Nokogiri::HTML(html)
|
|
108
|
-
selectors = selectors.select { |s| document.css(s).present? }
|
|
109
|
-
selectors.each do |selector|
|
|
110
|
-
cable_ready[stream_name].morph(
|
|
111
|
-
selector: selector,
|
|
112
|
-
html: document.css(selector).inner_html,
|
|
113
|
-
children_only: true,
|
|
114
|
-
permanent_attribute_name: data["permanent_attribute_name"],
|
|
115
|
-
stimulus_reflex: data.merge(last: selector == selectors.last)
|
|
116
|
-
)
|
|
117
|
-
end
|
|
118
|
-
cable_ready.broadcast
|
|
119
|
-
end
|
|
120
|
-
|
|
121
|
-
def broadcast_message(subject:, body: nil, data: {})
|
|
122
|
-
message = {
|
|
123
|
-
subject: subject,
|
|
124
|
-
body: body
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
logger.error "\e[31m#{body}\e[0m" if subject == "error"
|
|
128
|
-
|
|
129
|
-
cable_ready[stream_name].dispatch_event(
|
|
130
|
-
name: "stimulus-reflex:server-message",
|
|
131
|
-
detail: {stimulus_reflex: data.merge(server_message: message)}
|
|
132
|
-
)
|
|
133
|
-
cable_ready.broadcast
|
|
134
|
-
end
|
|
135
|
-
|
|
136
93
|
def exception_message_with_backtrace(exception)
|
|
137
94
|
"#{exception} #{exception.backtrace.first}"
|
|
138
95
|
end
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
class StimulusReflex::Reflex
|
|
4
4
|
include ActiveSupport::Rescuable
|
|
5
5
|
include ActiveSupport::Callbacks
|
|
6
|
+
include CableReady::Broadcaster
|
|
6
7
|
|
|
7
8
|
define_callbacks :process, skip_after_callbacks_if_terminated: true
|
|
8
9
|
|
|
@@ -42,18 +43,21 @@ class StimulusReflex::Reflex
|
|
|
42
43
|
end
|
|
43
44
|
end
|
|
44
45
|
|
|
45
|
-
attr_reader :channel, :url, :element, :selectors, :method_name
|
|
46
|
+
attr_reader :channel, :url, :element, :selectors, :method_name, :morph_mode, :permanent_attribute_name
|
|
46
47
|
|
|
47
48
|
delegate :connection, to: :channel
|
|
48
49
|
delegate :session, to: :request
|
|
49
50
|
|
|
50
|
-
def initialize(channel, url: nil, element: nil, selectors: [], method_name: nil, params: {})
|
|
51
|
+
def initialize(channel, url: nil, element: nil, selectors: [], method_name: nil, stream_name: nil, permanent_attribute_name: nil, params: {})
|
|
51
52
|
@channel = channel
|
|
52
53
|
@url = url
|
|
53
54
|
@element = element
|
|
54
55
|
@selectors = selectors
|
|
55
56
|
@method_name = method_name
|
|
56
57
|
@params = params
|
|
58
|
+
@permanent_attribute_name = permanent_attribute_name
|
|
59
|
+
@morph_mode = StimulusReflex::PageMorphMode.new
|
|
60
|
+
self.params
|
|
57
61
|
end
|
|
58
62
|
|
|
59
63
|
def request
|
|
@@ -77,11 +81,54 @@ class StimulusReflex::Reflex
|
|
|
77
81
|
)
|
|
78
82
|
path_params = Rails.application.routes.recognize_path_with_request(req, url, req.env[:extras] || {})
|
|
79
83
|
req.env.merge(ActionDispatch::Http::Parameters::PARAMETERS_KEY => path_params)
|
|
80
|
-
req.env["action_dispatch.request.parameters"] = @params
|
|
84
|
+
req.env["action_dispatch.request.parameters"] = req.parameters.merge(@params)
|
|
81
85
|
req.tap { |r| r.session.send :load! }
|
|
82
86
|
end
|
|
83
87
|
end
|
|
84
88
|
|
|
89
|
+
def morph(selectors, html = "")
|
|
90
|
+
case selectors
|
|
91
|
+
when :page
|
|
92
|
+
raise StandardError.new("Cannot call :page morph after :#{@morph_mode.to_sym} morph") unless @morph_mode.page?
|
|
93
|
+
when :nothing
|
|
94
|
+
raise StandardError.new("Cannot call :nothing morph after :selector morph") if @morph_mode.selector?
|
|
95
|
+
@morph_mode = StimulusReflex::NothingMorphMode.new
|
|
96
|
+
else
|
|
97
|
+
raise StandardError.new("Cannot call :selector morph after :nothing morph") if @morph_mode.nothing?
|
|
98
|
+
@morph_mode = StimulusReflex::SelectorMorphMode.new
|
|
99
|
+
if selectors.is_a?(Hash)
|
|
100
|
+
selectors.each do |selector, html|
|
|
101
|
+
enqueue_selector_broadcast selector, html
|
|
102
|
+
end
|
|
103
|
+
else
|
|
104
|
+
enqueue_selector_broadcast selectors, html
|
|
105
|
+
end
|
|
106
|
+
cable_ready.broadcast
|
|
107
|
+
end
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
def enqueue_selector_broadcast(selector, html)
|
|
111
|
+
fragment = Nokogiri::HTML(html)
|
|
112
|
+
parent = fragment.at_css(selector)
|
|
113
|
+
cable_ready[channel.stream_name].morph(
|
|
114
|
+
selector: selector,
|
|
115
|
+
html: parent.present? ? parent.inner_html : fragment.to_html,
|
|
116
|
+
children_only: true,
|
|
117
|
+
permanent_attribute_name: permanent_attribute_name
|
|
118
|
+
)
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
def controller
|
|
122
|
+
@controller ||= begin
|
|
123
|
+
request.controller_class.new.tap do |c|
|
|
124
|
+
c.instance_variable_set :"@stimulus_reflex", true
|
|
125
|
+
instance_variables.each { |name| c.instance_variable_set name, instance_variable_get(name) }
|
|
126
|
+
c.request = request
|
|
127
|
+
c.response = ActionDispatch::Response.new
|
|
128
|
+
end
|
|
129
|
+
end
|
|
130
|
+
end
|
|
131
|
+
|
|
85
132
|
def url_params
|
|
86
133
|
@url_params ||= Rails.application.routes.recognize_path_with_request(request, request.path, request.env[:extras] || {})
|
|
87
134
|
end
|
|
@@ -11,11 +11,16 @@ namespace :stimulus_reflex do
|
|
|
11
11
|
FileUtils.mkdir_p Rails.root.join("app/javascript/controllers"), verbose: true
|
|
12
12
|
FileUtils.mkdir_p Rails.root.join("app/reflexes"), verbose: true
|
|
13
13
|
|
|
14
|
-
filepath =
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
14
|
+
filepath = %w[
|
|
15
|
+
app/javascript/controllers/index.js
|
|
16
|
+
app/javascript/controllers/index.ts
|
|
17
|
+
app/javascript/packs/application.js
|
|
18
|
+
app/javascript/packs/application.ts
|
|
19
|
+
]
|
|
20
|
+
.select { |path| File.exist?(path) }
|
|
21
|
+
.map { |path| Rails.root.join(path) }
|
|
22
|
+
.first
|
|
23
|
+
|
|
19
24
|
puts "Updating #{filepath}"
|
|
20
25
|
lines = File.open(filepath, "r") { |f| f.readlines }
|
|
21
26
|
|
|
@@ -23,4 +23,27 @@ class StimulusReflexGeneratorTest < Rails::Generators::TestCase
|
|
|
23
23
|
assert_file "app/reflexes/application_reflex.rb"
|
|
24
24
|
assert_file "app/reflexes/posts_reflex.rb", /PostsReflex/
|
|
25
25
|
end
|
|
26
|
+
|
|
27
|
+
test "creates reflex with given reflex actions" do
|
|
28
|
+
run_generator %w[User update do_stuff DoMoreStuff]
|
|
29
|
+
assert_file "app/reflexes/user_reflex.rb" do |reflex|
|
|
30
|
+
assert_instance_method :update, reflex
|
|
31
|
+
assert_instance_method :do_stuff, reflex
|
|
32
|
+
assert_instance_method :do_more_stuff, reflex
|
|
33
|
+
end
|
|
34
|
+
assert_file "app/javascript/controllers/user_controller.js" do |controller|
|
|
35
|
+
assert_match(/beforeUpdate/, controller)
|
|
36
|
+
assert_match(/updateSuccess/, controller)
|
|
37
|
+
assert_match(/updateError/, controller)
|
|
38
|
+
assert_match(/afterUpdate/, controller)
|
|
39
|
+
assert_match(/beforeDoStuff/, controller)
|
|
40
|
+
assert_match(/doStuffSuccess/, controller)
|
|
41
|
+
assert_match(/doStuffError/, controller)
|
|
42
|
+
assert_match(/afterDoStuff/, controller)
|
|
43
|
+
assert_match(/beforeDoMoreStuff/, controller)
|
|
44
|
+
assert_match(/doMoreStuffSuccess/, controller)
|
|
45
|
+
assert_match(/doMoreStuffError/, controller)
|
|
46
|
+
assert_match(/afterDoMoreStuff/, controller)
|
|
47
|
+
end
|
|
48
|
+
end
|
|
26
49
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: stimulus_reflex
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 3.
|
|
4
|
+
version: 3.3.0.pre1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Nathan Hopkins
|
|
8
|
-
autorequire:
|
|
8
|
+
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2020-
|
|
11
|
+
date: 2020-07-08 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: rack
|
|
@@ -136,7 +136,7 @@ dependencies:
|
|
|
136
136
|
- - ">="
|
|
137
137
|
- !ruby/object:Gem::Version
|
|
138
138
|
version: '0'
|
|
139
|
-
description:
|
|
139
|
+
description:
|
|
140
140
|
email:
|
|
141
141
|
- natehop@gmail.com
|
|
142
142
|
executables: []
|
|
@@ -157,13 +157,18 @@ files:
|
|
|
157
157
|
- bin/standardize
|
|
158
158
|
- lib/generators/USAGE
|
|
159
159
|
- lib/generators/stimulus_reflex_generator.rb
|
|
160
|
-
- lib/generators/templates/
|
|
161
|
-
- lib/generators/templates/
|
|
162
|
-
- lib/generators/templates/
|
|
163
|
-
- lib/generators/templates/
|
|
160
|
+
- lib/generators/templates/app/javascript/controllers/%file_name%_controller.js.tt
|
|
161
|
+
- lib/generators/templates/app/javascript/controllers/application_controller.js.tt
|
|
162
|
+
- lib/generators/templates/app/reflexes/%file_name%_reflex.rb.tt
|
|
163
|
+
- lib/generators/templates/app/reflexes/application_reflex.rb.tt
|
|
164
164
|
- lib/stimulus_reflex.rb
|
|
165
|
+
- lib/stimulus_reflex/broadcaster.rb
|
|
165
166
|
- lib/stimulus_reflex/channel.rb
|
|
166
167
|
- lib/stimulus_reflex/element.rb
|
|
168
|
+
- lib/stimulus_reflex/morph_mode.rb
|
|
169
|
+
- lib/stimulus_reflex/morph_mode/nothing_morph_mode.rb
|
|
170
|
+
- lib/stimulus_reflex/morph_mode/page_morph_mode.rb
|
|
171
|
+
- lib/stimulus_reflex/morph_mode/selector_morph_mode.rb
|
|
167
172
|
- lib/stimulus_reflex/reflex.rb
|
|
168
173
|
- lib/stimulus_reflex/version.rb
|
|
169
174
|
- lib/tasks/stimulus_reflex/install.rake
|
|
@@ -202,7 +207,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
202
207
|
version: 1.3.1
|
|
203
208
|
requirements: []
|
|
204
209
|
rubygems_version: 3.0.3
|
|
205
|
-
signing_key:
|
|
210
|
+
signing_key:
|
|
206
211
|
specification_version: 4
|
|
207
212
|
summary: Build reactive applications with the Rails tooling you already know and love.
|
|
208
213
|
test_files:
|