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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: dd9af85e63dfa792a38d7dd4a560f86c1bcca6898aa8f38882ccfea57e726dbd
4
- data.tar.gz: d4fdcadaae536283af5db9e98551a5dbd1cd9aa3100bba806be82e5cf6aecd18
3
+ metadata.gz: 942a479c551dc9a4cbcb6b70e4b51b5bf1ae947ad8b5fd159f69bdb92c580349
4
+ data.tar.gz: 7e0eda3f0e7f50f132f8bcfa2528df67502afba73348393b795ed99e15ce6031
5
5
  SHA512:
6
- metadata.gz: a64205414cfc3630ecb2c537abe5f0deacd0737f5abcf9d33873d57b317d5bf0dfccee6ae09706fdf1e38a5ca7ea6d3159272abd4a293523f9451600ce8d43f7
7
- data.tar.gz: 81792f053d071fe1fc63db27609a53b4147b9d0f02f85714ba8c81f7cf7e937f94aca5037845badcdbb7b24e78992152549a991a3a1db5a1e1563d9b1f574713
6
+ metadata.gz: 2df9156de41dda64ff63b1faf2c4a14bd10f9c5fb492018c688438f901a0d16c3646303c1d01484efd7dbaefd7351b4c52ed284e4d4668e2043afe728cd2eb1a
7
+ data.tar.gz: 5afb2906a4b29e8649e77f488e779ec07e47607802a55eceeae56068db96db2a84cd8a12e921d16d01b7f007c380df92f341752779cf436e2ddfed1441154088
@@ -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.1...HEAD)
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:**
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- stimulus_reflex (3.2.2.pre0)
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.2)
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-923-brightgreen.svg?style=flat" />
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
- render_page_and_broadcast_morph reflex, selectors, data
45
- rescue => render_error
46
- reflex.rescue_with_handler(render_error)
47
- message = exception_message_with_backtrace(render_error)
48
- broadcast_message subject: "error", body: "StimulusReflex::Channel Failed to re-render #{url} #{message}", data: data
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(request, response)
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 = 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
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module StimulusReflex
4
- VERSION = "3.2.2.pre0"
4
+ VERSION = "3.2.2.pre1"
5
5
  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.pre0
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-27 00:00:00.000000000 Z
11
+ date: 2020-05-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rack