stimulus_reflex 0.1.10 → 0.1.12
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of stimulus_reflex might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/Gemfile.lock +3 -3
- data/README.md +2 -2
- data/lib/stimulus_reflex/channel.rb +15 -4
- data/lib/stimulus_reflex/controller.rb +3 -2
- 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: bc25845c4e59c7277edc3b5c7fda8d1ff791b73236b7c30afb30fc479b4c9afd
|
4
|
+
data.tar.gz: 493422416a3d5a93bc14c9221a14f69c69e5ce4308bb0d921c7340ab39bcd302
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 58b5511c7a3113162267dceb406ef42b159773ffacbccb2aca08aa12f090cd0623a050982d0b688257648ef2a2d261ab48f1ffeda2cf6b958b960300b7969822
|
7
|
+
data.tar.gz: 8359589be188bc31e3b988a385de743efec45b732aaba7e0ba31c9ffd82c034a879ab2127fc255583efd7fbf88701f50066e54b43f22966945ef256f365ead77
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
stimulus_reflex (0.1.
|
4
|
+
stimulus_reflex (0.1.12)
|
5
5
|
actioncable (>= 5.2.1)
|
6
6
|
actionpack (>= 5.2.1)
|
7
7
|
cable_ready (>= 2.0.7)
|
@@ -36,12 +36,12 @@ GEM
|
|
36
36
|
builder (3.2.3)
|
37
37
|
cable_ready (2.0.7)
|
38
38
|
activesupport (>= 5.0.0)
|
39
|
-
concurrent-ruby (1.0
|
39
|
+
concurrent-ruby (1.1.0)
|
40
40
|
crass (1.0.4)
|
41
41
|
erubi (1.7.1)
|
42
42
|
i18n (1.1.1)
|
43
43
|
concurrent-ruby (~> 1.0)
|
44
|
-
loofah (2.2.
|
44
|
+
loofah (2.2.3)
|
45
45
|
crass (~> 1.0.2)
|
46
46
|
nokogiri (>= 1.5.9)
|
47
47
|
mini_portile2 (2.3.0)
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
[![Lines of Code](http://img.shields.io/badge/lines_of_code-
|
1
|
+
[![Lines of Code](http://img.shields.io/badge/lines_of_code-142-brightgreen.svg?style=flat)](http://blog.codinghorror.com/the-best-code-is-no-code-at-all/)
|
2
2
|
[![Maintainability](https://img.shields.io/codeclimate/maintainability/hopsoft/stimulus_reflex.svg)](https://codeclimate.com/github/hopsoft/stimulus_reflex)
|
3
3
|
|
4
4
|
# StimulusReflex
|
@@ -96,7 +96,7 @@ end
|
|
96
96
|
## JavaScript Development
|
97
97
|
|
98
98
|
The JavaScript source is located in `app/assets/javascripts/stimulus_reflex/src`
|
99
|
-
& transpiles to `app/assets/javascripts/stimulus_reflex
|
99
|
+
& transpiles to `app/assets/javascripts/stimulus_reflex.js` via Webpack.
|
100
100
|
|
101
101
|
```sh
|
102
102
|
# build the javascript
|
@@ -29,12 +29,17 @@ class StimulusReflex::Channel < ActionCable::Channel::Base
|
|
29
29
|
arguments = data["args"] || []
|
30
30
|
|
31
31
|
begin
|
32
|
-
stimulus_controller = stimulus_controller_name.constantize.new(self)
|
32
|
+
stimulus_controller = stimulus_controller_name.constantize.new(self, url: url)
|
33
33
|
delegate_call_to_stimulus_controller stimulus_controller, method_name, arguments
|
34
|
-
render_page_and_broadcast_morph url, stimulus_controller
|
35
34
|
rescue StandardError => invoke_error
|
36
35
|
logger.error "StimulusReflex::Channel Failed to invoke #{target}! #{url} #{invoke_error}"
|
37
36
|
end
|
37
|
+
|
38
|
+
begin
|
39
|
+
render_page_and_broadcast_morph url, stimulus_controller
|
40
|
+
rescue StandardError => render_error
|
41
|
+
logger.error "StimulusReflex::Channel Failed to rerender #{url} #{render_error}"
|
42
|
+
end
|
38
43
|
end
|
39
44
|
end
|
40
45
|
|
@@ -68,12 +73,18 @@ class StimulusReflex::Channel < ActionCable::Channel::Base
|
|
68
73
|
controller.instance_variable_set name, stimulus_controller.instance_variable_get(name)
|
69
74
|
end
|
70
75
|
|
76
|
+
query_hash = Rack::Utils.parse_nested_query(uri.query)
|
71
77
|
env = {
|
72
|
-
|
73
|
-
|
78
|
+
"action_dispatch.request.path_parameters" => url_params,
|
79
|
+
"action_dispatch.request.query_parameters" => query_hash,
|
80
|
+
"rack.request.query_hash" => query_hash,
|
81
|
+
"rack.request.query_string" => uri.query,
|
74
82
|
Rack::PATH_INFO => "",
|
83
|
+
Rack::QUERY_STRING => uri.query,
|
84
|
+
Rack::REQUEST_PATH => uri.path,
|
75
85
|
Rack::SCRIPT_NAME => "",
|
76
86
|
}
|
87
|
+
|
77
88
|
request = ActionDispatch::Request.new(connection.env.merge(env))
|
78
89
|
controller.request = request
|
79
90
|
controller.response = ActionDispatch::Response.new
|
@@ -1,11 +1,12 @@
|
|
1
1
|
class StimulusReflex::Controller
|
2
|
-
attr_reader :channel
|
2
|
+
attr_reader :channel, :url
|
3
3
|
|
4
4
|
delegate :connection, to: :channel
|
5
5
|
delegate :session, to: :request
|
6
6
|
|
7
|
-
def initialize(channel)
|
7
|
+
def initialize(channel, url: nil)
|
8
8
|
@channel = channel
|
9
|
+
@url = url
|
9
10
|
end
|
10
11
|
|
11
12
|
def request
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: stimulus_reflex
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.12
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nathan Hopkins
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2018-
|
12
|
+
date: 2018-11-03 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rack
|