stimulus_reflex 3.2.2.pre0 → 3.2.2.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 +16 -3
- data/Gemfile.lock +2 -2
- data/README.md +1 -1
- data/lib/stimulus_reflex/channel.rb +26 -31
- data/lib/stimulus_reflex/reflex.rb +11 -0
- data/lib/stimulus_reflex/version.rb +1 -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: 942a479c551dc9a4cbcb6b70e4b51b5bf1ae947ad8b5fd159f69bdb92c580349
|
|
4
|
+
data.tar.gz: 7e0eda3f0e7f50f132f8bcfa2528df67502afba73348393b795ed99e15ce6031
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 2df9156de41dda64ff63b1faf2c4a14bd10f9c5fb492018c688438f901a0d16c3646303c1d01484efd7dbaefd7351b4c52ed284e4d4668e2043afe728cd2eb1a
|
|
7
|
+
data.tar.gz: 5afb2906a4b29e8649e77f488e779ec07e47607802a55eceeae56068db96db2a84cd8a12e921d16d01b7f007c380df92f341752779cf436e2ddfed1441154088
|
data/CHANGELOG.md
CHANGED
|
@@ -2,7 +2,20 @@
|
|
|
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.2.
|
|
5
|
+
[Full Changelog](https://github.com/hopsoft/stimulus_reflex/compare/v3.2.2.pre0...HEAD)
|
|
6
|
+
|
|
7
|
+
**Fixed bugs:**
|
|
8
|
+
|
|
9
|
+
- Session lost after throw :abort [\#221](https://github.com/hopsoft/stimulus_reflex/issues/221)
|
|
10
|
+
- Fix multipleInstances convenience method [\#220](https://github.com/hopsoft/stimulus_reflex/pull/220) ([julianrubisch](https://github.com/julianrubisch))
|
|
11
|
+
|
|
12
|
+
**Merged pull requests:**
|
|
13
|
+
|
|
14
|
+
- Always commit session [\#222](https://github.com/hopsoft/stimulus_reflex/pull/222) ([hopsoft](https://github.com/hopsoft))
|
|
15
|
+
|
|
16
|
+
## [v3.2.2.pre0](https://github.com/hopsoft/stimulus_reflex/tree/v3.2.2.pre0) (2020-05-27)
|
|
17
|
+
|
|
18
|
+
[Full Changelog](https://github.com/hopsoft/stimulus_reflex/compare/v3.2.1...v3.2.2.pre0)
|
|
6
19
|
|
|
7
20
|
**Implemented enhancements:**
|
|
8
21
|
|
|
@@ -387,6 +400,7 @@
|
|
|
387
400
|
|
|
388
401
|
- Add support to configure room via register option [\#52](https://github.com/hopsoft/stimulus_reflex/pull/52) ([hopsoft](https://github.com/hopsoft))
|
|
389
402
|
- Move gitbook files to docs [\#49](https://github.com/hopsoft/stimulus_reflex/pull/49) ([hopsoft](https://github.com/hopsoft))
|
|
403
|
+
- Allow override of default controller [\#37](https://github.com/hopsoft/stimulus_reflex/pull/37) ([hopsoft](https://github.com/hopsoft))
|
|
390
404
|
|
|
391
405
|
**Closed issues:**
|
|
392
406
|
|
|
@@ -402,10 +416,10 @@
|
|
|
402
416
|
- Updated Minimal Javascript Example in README.md [\#47](https://github.com/hopsoft/stimulus_reflex/pull/47) ([kobaltz](https://github.com/kobaltz))
|
|
403
417
|
- Setup StimulusReflex controller callbacks [\#45](https://github.com/hopsoft/stimulus_reflex/pull/45) ([hopsoft](https://github.com/hopsoft))
|
|
404
418
|
- add .vscode directory to .gitignore [\#42](https://github.com/hopsoft/stimulus_reflex/pull/42) ([andrewmcodes](https://github.com/andrewmcodes))
|
|
405
|
-
- Allow override of default controller [\#37](https://github.com/hopsoft/stimulus_reflex/pull/37) ([hopsoft](https://github.com/hopsoft))
|
|
406
419
|
- update the name of the actions per feedback [\#36](https://github.com/hopsoft/stimulus_reflex/pull/36) ([andrewmcodes](https://github.com/andrewmcodes))
|
|
407
420
|
- update github templates [\#35](https://github.com/hopsoft/stimulus_reflex/pull/35) ([andrewmcodes](https://github.com/andrewmcodes))
|
|
408
421
|
- Tighten up security of remote invocation [\#32](https://github.com/hopsoft/stimulus_reflex/pull/32) ([hopsoft](https://github.com/hopsoft))
|
|
422
|
+
- Add Ruby magic comment [\#18](https://github.com/hopsoft/stimulus_reflex/pull/18) ([dixpac](https://github.com/dixpac))
|
|
409
423
|
|
|
410
424
|
**Fixed bugs:**
|
|
411
425
|
|
|
@@ -439,7 +453,6 @@
|
|
|
439
453
|
**Implemented enhancements:**
|
|
440
454
|
|
|
441
455
|
- Implicitly send DOM attributes to reflex methods [\#21](https://github.com/hopsoft/stimulus_reflex/pull/21) ([hopsoft](https://github.com/hopsoft))
|
|
442
|
-
- Add Ruby magic comment [\#18](https://github.com/hopsoft/stimulus_reflex/pull/18) ([dixpac](https://github.com/dixpac))
|
|
443
456
|
- Add GitHub Actions for Linters [\#17](https://github.com/hopsoft/stimulus_reflex/pull/17) ([andrewmcodes](https://github.com/andrewmcodes))
|
|
444
457
|
|
|
445
458
|
**Fixed bugs:**
|
data/Gemfile.lock
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
stimulus_reflex (3.2.2.
|
|
4
|
+
stimulus_reflex (3.2.2.pre1)
|
|
5
5
|
cable_ready (>= 4.1.2)
|
|
6
6
|
nokogiri
|
|
7
7
|
rack
|
|
@@ -69,7 +69,7 @@ GEM
|
|
|
69
69
|
builder (3.2.4)
|
|
70
70
|
cable_ready (4.1.2)
|
|
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)
|
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-929-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" />
|
|
@@ -28,25 +28,29 @@ class StimulusReflex::Channel < ActionCable::Channel::Base
|
|
|
28
28
|
params = data["params"] || {}
|
|
29
29
|
|
|
30
30
|
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
31
|
begin
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
reflex
|
|
47
|
-
|
|
48
|
-
|
|
32
|
+
reflex_class = reflex_name.constantize.tap { |klass| raise ArgumentError.new("#{reflex_name} is not a StimulusReflex::Reflex") unless is_reflex?(klass) }
|
|
33
|
+
reflex = reflex_class.new(self, url: url, element: element, selectors: selectors, method_name: method_name, params: params)
|
|
34
|
+
delegate_call_to_reflex reflex, method_name, arguments
|
|
35
|
+
rescue => invoke_error
|
|
36
|
+
reflex.rescue_with_handler(invoke_error)
|
|
37
|
+
message = exception_message_with_backtrace(invoke_error)
|
|
38
|
+
return broadcast_message subject: "error", body: "StimulusReflex::Channel Failed to invoke #{target}! #{url} #{message}", data: data
|
|
49
39
|
end
|
|
40
|
+
|
|
41
|
+
if reflex.halted?
|
|
42
|
+
broadcast_message subject: "halted", data: data
|
|
43
|
+
else
|
|
44
|
+
begin
|
|
45
|
+
render_page_and_broadcast_morph reflex, selectors, data
|
|
46
|
+
rescue => render_error
|
|
47
|
+
reflex.rescue_with_handler(render_error)
|
|
48
|
+
message = exception_message_with_backtrace(render_error)
|
|
49
|
+
broadcast_message subject: "error", body: "StimulusReflex::Channel Failed to re-render #{url} #{message}", data: data
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
ensure
|
|
53
|
+
commit_session reflex if reflex
|
|
50
54
|
end
|
|
51
55
|
end
|
|
52
56
|
|
|
@@ -81,26 +85,17 @@ class StimulusReflex::Channel < ActionCable::Channel::Base
|
|
|
81
85
|
broadcast_morphs selectors, data, html if html.present?
|
|
82
86
|
end
|
|
83
87
|
|
|
84
|
-
def commit_session(
|
|
85
|
-
store = request.session.instance_variable_get("@by")
|
|
86
|
-
store.commit_session request, response
|
|
88
|
+
def commit_session(reflex)
|
|
89
|
+
store = reflex.request.session.instance_variable_get("@by")
|
|
90
|
+
store.commit_session reflex.request, reflex.controller.response
|
|
87
91
|
rescue => e
|
|
88
92
|
message = "Failed to commit session! #{exception_message_with_backtrace(e)}"
|
|
89
93
|
logger.error "\e[31m#{message}\e[0m"
|
|
90
94
|
end
|
|
91
95
|
|
|
92
96
|
def render_page(reflex)
|
|
93
|
-
controller
|
|
94
|
-
controller.
|
|
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
|
|
97
|
+
reflex.controller.process reflex.url_params[:action]
|
|
98
|
+
reflex.controller.response.body
|
|
104
99
|
end
|
|
105
100
|
|
|
106
101
|
def broadcast_morphs(selectors, data, html)
|
|
@@ -82,6 +82,17 @@ class StimulusReflex::Reflex
|
|
|
82
82
|
end
|
|
83
83
|
end
|
|
84
84
|
|
|
85
|
+
def controller
|
|
86
|
+
@controller ||= begin
|
|
87
|
+
request.controller_class.new.tap do |c|
|
|
88
|
+
c.instance_variable_set :"@stimulus_reflex", true
|
|
89
|
+
instance_variables.each { |name| c.instance_variable_set name, instance_variable_get(name) }
|
|
90
|
+
c.request = request
|
|
91
|
+
c.response = ActionDispatch::Response.new
|
|
92
|
+
end
|
|
93
|
+
end
|
|
94
|
+
end
|
|
95
|
+
|
|
85
96
|
def url_params
|
|
86
97
|
@url_params ||= Rails.application.routes.recognize_path_with_request(request, request.path, request.env[:extras] || {})
|
|
87
98
|
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.2.2.
|
|
4
|
+
version: 3.2.2.pre1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Nathan Hopkins
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2020-05-
|
|
11
|
+
date: 2020-05-30 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: rack
|