stimulus_reflex 2.2.2 → 2.2.3
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/Gemfile.lock +53 -53
- data/README.md +1 -1
- data/bin/standardize +1 -1
- data/lib/stimulus_reflex/channel.rb +8 -26
- data/lib/stimulus_reflex/reflex.rb +25 -1
- data/lib/stimulus_reflex/version.rb +1 -1
- data/tags +5 -2
- 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: 7a7933a5f33cb6c9986a8c3f0ac36817654fd5d53643056604441e04a247de33
|
|
4
|
+
data.tar.gz: e6cd16e9664361211ca7d2fe7024ebc297271fbad8329db991aa84fa4df3003b
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e3e700194f46dfcfeffd4a049cf7af83880ca873888cd236422191383eceafd6986c372f83e086bfe3e496076b5d44477eba6f788456c02c4e305838739b3e1c
|
|
7
|
+
data.tar.gz: 4534f5d62f1def3a1ad51fa4174cb074234a1f2c81608c750cccfcdcece037e4096ae15e97894ca6b87a9d72cd1ec012eb67877eb5569be8592113a568bf9fae
|
data/Gemfile.lock
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
stimulus_reflex (2.2.
|
|
4
|
+
stimulus_reflex (2.2.3)
|
|
5
5
|
cable_ready (>= 4.0)
|
|
6
6
|
nokogiri
|
|
7
7
|
rack
|
|
@@ -10,56 +10,56 @@ PATH
|
|
|
10
10
|
GEM
|
|
11
11
|
remote: https://rubygems.org/
|
|
12
12
|
specs:
|
|
13
|
-
actioncable (6.0.2.
|
|
14
|
-
actionpack (= 6.0.2.
|
|
13
|
+
actioncable (6.0.2.2)
|
|
14
|
+
actionpack (= 6.0.2.2)
|
|
15
15
|
nio4r (~> 2.0)
|
|
16
16
|
websocket-driver (>= 0.6.1)
|
|
17
|
-
actionmailbox (6.0.2.
|
|
18
|
-
actionpack (= 6.0.2.
|
|
19
|
-
activejob (= 6.0.2.
|
|
20
|
-
activerecord (= 6.0.2.
|
|
21
|
-
activestorage (= 6.0.2.
|
|
22
|
-
activesupport (= 6.0.2.
|
|
17
|
+
actionmailbox (6.0.2.2)
|
|
18
|
+
actionpack (= 6.0.2.2)
|
|
19
|
+
activejob (= 6.0.2.2)
|
|
20
|
+
activerecord (= 6.0.2.2)
|
|
21
|
+
activestorage (= 6.0.2.2)
|
|
22
|
+
activesupport (= 6.0.2.2)
|
|
23
23
|
mail (>= 2.7.1)
|
|
24
|
-
actionmailer (6.0.2.
|
|
25
|
-
actionpack (= 6.0.2.
|
|
26
|
-
actionview (= 6.0.2.
|
|
27
|
-
activejob (= 6.0.2.
|
|
24
|
+
actionmailer (6.0.2.2)
|
|
25
|
+
actionpack (= 6.0.2.2)
|
|
26
|
+
actionview (= 6.0.2.2)
|
|
27
|
+
activejob (= 6.0.2.2)
|
|
28
28
|
mail (~> 2.5, >= 2.5.4)
|
|
29
29
|
rails-dom-testing (~> 2.0)
|
|
30
|
-
actionpack (6.0.2.
|
|
31
|
-
actionview (= 6.0.2.
|
|
32
|
-
activesupport (= 6.0.2.
|
|
30
|
+
actionpack (6.0.2.2)
|
|
31
|
+
actionview (= 6.0.2.2)
|
|
32
|
+
activesupport (= 6.0.2.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.2.
|
|
38
|
-
actionpack (= 6.0.2.
|
|
39
|
-
activerecord (= 6.0.2.
|
|
40
|
-
activestorage (= 6.0.2.
|
|
41
|
-
activesupport (= 6.0.2.
|
|
37
|
+
actiontext (6.0.2.2)
|
|
38
|
+
actionpack (= 6.0.2.2)
|
|
39
|
+
activerecord (= 6.0.2.2)
|
|
40
|
+
activestorage (= 6.0.2.2)
|
|
41
|
+
activesupport (= 6.0.2.2)
|
|
42
42
|
nokogiri (>= 1.8.5)
|
|
43
|
-
actionview (6.0.2.
|
|
44
|
-
activesupport (= 6.0.2.
|
|
43
|
+
actionview (6.0.2.2)
|
|
44
|
+
activesupport (= 6.0.2.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.2.
|
|
50
|
-
activesupport (= 6.0.2.
|
|
49
|
+
activejob (6.0.2.2)
|
|
50
|
+
activesupport (= 6.0.2.2)
|
|
51
51
|
globalid (>= 0.3.6)
|
|
52
|
-
activemodel (6.0.2.
|
|
53
|
-
activesupport (= 6.0.2.
|
|
54
|
-
activerecord (6.0.2.
|
|
55
|
-
activemodel (= 6.0.2.
|
|
56
|
-
activesupport (= 6.0.2.
|
|
57
|
-
activestorage (6.0.2.
|
|
58
|
-
actionpack (= 6.0.2.
|
|
59
|
-
activejob (= 6.0.2.
|
|
60
|
-
activerecord (= 6.0.2.
|
|
52
|
+
activemodel (6.0.2.2)
|
|
53
|
+
activesupport (= 6.0.2.2)
|
|
54
|
+
activerecord (6.0.2.2)
|
|
55
|
+
activemodel (= 6.0.2.2)
|
|
56
|
+
activesupport (= 6.0.2.2)
|
|
57
|
+
activestorage (6.0.2.2)
|
|
58
|
+
actionpack (= 6.0.2.2)
|
|
59
|
+
activejob (= 6.0.2.2)
|
|
60
|
+
activerecord (= 6.0.2.2)
|
|
61
61
|
marcel (~> 0.3.1)
|
|
62
|
-
activesupport (6.0.2.
|
|
62
|
+
activesupport (6.0.2.2)
|
|
63
63
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
|
64
64
|
i18n (>= 0.7, < 2)
|
|
65
65
|
minitest (~> 5.1)
|
|
@@ -94,7 +94,7 @@ GEM
|
|
|
94
94
|
nokogiri (1.10.9)
|
|
95
95
|
mini_portile2 (~> 2.4.0)
|
|
96
96
|
parallel (1.19.1)
|
|
97
|
-
parser (2.7.0.
|
|
97
|
+
parser (2.7.0.5)
|
|
98
98
|
ast (~> 2.4.0)
|
|
99
99
|
pry (0.12.2)
|
|
100
100
|
coderay (~> 1.1.0)
|
|
@@ -104,29 +104,29 @@ GEM
|
|
|
104
104
|
rack (2.2.2)
|
|
105
105
|
rack-test (1.1.0)
|
|
106
106
|
rack (>= 1.0, < 3)
|
|
107
|
-
rails (6.0.2.
|
|
108
|
-
actioncable (= 6.0.2.
|
|
109
|
-
actionmailbox (= 6.0.2.
|
|
110
|
-
actionmailer (= 6.0.2.
|
|
111
|
-
actionpack (= 6.0.2.
|
|
112
|
-
actiontext (= 6.0.2.
|
|
113
|
-
actionview (= 6.0.2.
|
|
114
|
-
activejob (= 6.0.2.
|
|
115
|
-
activemodel (= 6.0.2.
|
|
116
|
-
activerecord (= 6.0.2.
|
|
117
|
-
activestorage (= 6.0.2.
|
|
118
|
-
activesupport (= 6.0.2.
|
|
107
|
+
rails (6.0.2.2)
|
|
108
|
+
actioncable (= 6.0.2.2)
|
|
109
|
+
actionmailbox (= 6.0.2.2)
|
|
110
|
+
actionmailer (= 6.0.2.2)
|
|
111
|
+
actionpack (= 6.0.2.2)
|
|
112
|
+
actiontext (= 6.0.2.2)
|
|
113
|
+
actionview (= 6.0.2.2)
|
|
114
|
+
activejob (= 6.0.2.2)
|
|
115
|
+
activemodel (= 6.0.2.2)
|
|
116
|
+
activerecord (= 6.0.2.2)
|
|
117
|
+
activestorage (= 6.0.2.2)
|
|
118
|
+
activesupport (= 6.0.2.2)
|
|
119
119
|
bundler (>= 1.3.0)
|
|
120
|
-
railties (= 6.0.2.
|
|
120
|
+
railties (= 6.0.2.2)
|
|
121
121
|
sprockets-rails (>= 2.0.0)
|
|
122
122
|
rails-dom-testing (2.0.3)
|
|
123
123
|
activesupport (>= 4.2.0)
|
|
124
124
|
nokogiri (>= 1.6)
|
|
125
125
|
rails-html-sanitizer (1.3.0)
|
|
126
126
|
loofah (~> 2.3)
|
|
127
|
-
railties (6.0.2.
|
|
128
|
-
actionpack (= 6.0.2.
|
|
129
|
-
activesupport (= 6.0.2.
|
|
127
|
+
railties (6.0.2.2)
|
|
128
|
+
actionpack (= 6.0.2.2)
|
|
129
|
+
activesupport (= 6.0.2.2)
|
|
130
130
|
method_source
|
|
131
131
|
rake (>= 0.8.7)
|
|
132
132
|
thor (>= 0.20.3, < 2.0)
|
|
@@ -149,7 +149,7 @@ GEM
|
|
|
149
149
|
actionpack (>= 4.0)
|
|
150
150
|
activesupport (>= 4.0)
|
|
151
151
|
sprockets (>= 3.0.0)
|
|
152
|
-
standard (0.2.
|
|
152
|
+
standard (0.2.2)
|
|
153
153
|
rubocop (~> 0.79.0)
|
|
154
154
|
rubocop-performance (~> 1.5.1)
|
|
155
155
|
standardrb (1.0.0)
|
data/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
[](http://blog.codinghorror.com/the-best-code-is-no-code-at-all/)
|
|
2
2
|
[](https://codeclimate.com/github/hopsoft/stimulus_reflex/maintainability)
|
|
3
3
|

|
|
4
4
|

|
data/bin/standardize
CHANGED
|
@@ -36,7 +36,7 @@ class StimulusReflex::Channel < ActionCable::Channel::Base
|
|
|
36
36
|
end
|
|
37
37
|
|
|
38
38
|
begin
|
|
39
|
-
render_page_and_broadcast_morph
|
|
39
|
+
render_page_and_broadcast_morph reflex, selectors, data
|
|
40
40
|
rescue => render_error
|
|
41
41
|
message = exception_message_with_backtrace(render_error)
|
|
42
42
|
broadcast_error "StimulusReflex::Channel Failed to re-render #{url} #{message}", data
|
|
@@ -63,8 +63,8 @@ class StimulusReflex::Channel < ActionCable::Channel::Base
|
|
|
63
63
|
end
|
|
64
64
|
end
|
|
65
65
|
|
|
66
|
-
def render_page_and_broadcast_morph(
|
|
67
|
-
html = render_page(
|
|
66
|
+
def render_page_and_broadcast_morph(reflex, selectors, data = {})
|
|
67
|
+
html = render_page(reflex)
|
|
68
68
|
broadcast_morphs selectors, data, html if html.present?
|
|
69
69
|
end
|
|
70
70
|
|
|
@@ -76,35 +76,17 @@ class StimulusReflex::Channel < ActionCable::Channel::Base
|
|
|
76
76
|
logger.error "\e[31m#{message}\e[0m"
|
|
77
77
|
end
|
|
78
78
|
|
|
79
|
-
def render_page(
|
|
80
|
-
|
|
81
|
-
path = ActionDispatch::Journey::Router::Utils.normalize_path(uri.path)
|
|
82
|
-
query_hash = Rack::Utils.parse_nested_query(uri.query)
|
|
83
|
-
request = ActionDispatch::Request.new(
|
|
84
|
-
connection.env.merge(
|
|
85
|
-
Rack::MockRequest.env_for(uri.to_s).merge(
|
|
86
|
-
"rack.request.query_hash" => query_hash,
|
|
87
|
-
"rack.request.query_string" => uri.query,
|
|
88
|
-
"ORIGINAL_SCRIPT_NAME" => "",
|
|
89
|
-
"ORIGINAL_FULLPATH" => path,
|
|
90
|
-
Rack::SCRIPT_NAME => "",
|
|
91
|
-
Rack::PATH_INFO => path,
|
|
92
|
-
Rack::REQUEST_PATH => path,
|
|
93
|
-
Rack::QUERY_STRING => uri.query
|
|
94
|
-
)
|
|
95
|
-
)
|
|
96
|
-
)
|
|
97
|
-
url_params = Rails.application.routes.recognize_path_with_request(request, request.path, request.env[:extras] || {})
|
|
98
|
-
controller = request.controller_class.new
|
|
79
|
+
def render_page(reflex)
|
|
80
|
+
controller = reflex.request.controller_class.new
|
|
99
81
|
controller.instance_variable_set :"@stimulus_reflex", true
|
|
100
82
|
reflex.instance_variables.each do |name|
|
|
101
83
|
controller.instance_variable_set name, reflex.instance_variable_get(name)
|
|
102
84
|
end
|
|
103
85
|
|
|
104
|
-
controller.request = request
|
|
86
|
+
controller.request = reflex.request
|
|
105
87
|
controller.response = ActionDispatch::Response.new
|
|
106
|
-
controller.process url_params[:action]
|
|
107
|
-
commit_session request, controller.response
|
|
88
|
+
controller.process reflex.url_params[:action]
|
|
89
|
+
commit_session reflex.request, controller.response
|
|
108
90
|
controller.response.body
|
|
109
91
|
end
|
|
110
92
|
|
|
@@ -14,6 +14,30 @@ class StimulusReflex::Reflex
|
|
|
14
14
|
end
|
|
15
15
|
|
|
16
16
|
def request
|
|
17
|
-
@request ||=
|
|
17
|
+
@request ||= begin
|
|
18
|
+
uri = URI.parse(url)
|
|
19
|
+
path = ActionDispatch::Journey::Router::Utils.normalize_path(uri.path)
|
|
20
|
+
path_params = Rails.application.routes.recognize_path(path)
|
|
21
|
+
query_hash = Rack::Utils.parse_nested_query(uri.query)
|
|
22
|
+
ActionDispatch::Request.new(
|
|
23
|
+
connection.env.merge(
|
|
24
|
+
Rack::MockRequest.env_for(uri.to_s).merge(
|
|
25
|
+
"rack.request.query_hash" => query_hash,
|
|
26
|
+
"rack.request.query_string" => uri.query,
|
|
27
|
+
"ORIGINAL_SCRIPT_NAME" => "",
|
|
28
|
+
"ORIGINAL_FULLPATH" => path,
|
|
29
|
+
Rack::SCRIPT_NAME => "",
|
|
30
|
+
Rack::PATH_INFO => path,
|
|
31
|
+
Rack::REQUEST_PATH => path,
|
|
32
|
+
Rack::QUERY_STRING => uri.query,
|
|
33
|
+
ActionDispatch::Http::Parameters::PARAMETERS_KEY => path_params
|
|
34
|
+
)
|
|
35
|
+
)
|
|
36
|
+
).tap { |req| req.session.send :load! }
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def url_params
|
|
41
|
+
@url_params ||= Rails.application.routes.recognize_path_with_request(request, request.path, request.env[:extras] || {})
|
|
18
42
|
end
|
|
19
43
|
end
|
data/tags
CHANGED
|
@@ -17,6 +17,8 @@ StimulusReflexGenerator lib/generators/stimulus_reflex_generator.rb /^class Stim
|
|
|
17
17
|
StimulusReflexGeneratorTest test/generators/stimulus_reflex_generator_test.rb /^class StimulusReflexGeneratorTest < Rails::Generators::TestCase$/;" c
|
|
18
18
|
broadcast_error lib/stimulus_reflex/channel.rb /^ def broadcast_error(message, data = {})$/;" f class:StimulusReflex
|
|
19
19
|
broadcast_morphs lib/stimulus_reflex/channel.rb /^ def broadcast_morphs(selectors, data, html)$/;" f class:StimulusReflex
|
|
20
|
+
build_request lib/stimulus_reflex/channel.rb /^ def build_request$/;" f class:StimulusReflex
|
|
21
|
+
commit_session lib/stimulus_reflex/channel.rb /^ def commit_session(request, response)$/;" f class:StimulusReflex
|
|
20
22
|
copy_controller_files lib/generators/stimulus_reflex_generator.rb /^ def copy_controller_files$/;" f class:StimulusReflexGenerator
|
|
21
23
|
copy_reflex_files lib/generators/stimulus_reflex_generator.rb /^ def copy_reflex_files$/;" f class:StimulusReflexGenerator
|
|
22
24
|
dataset lib/stimulus_reflex/element.rb /^ def dataset$/;" f class:StimulusReflex
|
|
@@ -32,8 +34,9 @@ initialize_controllers lib/generators/stimulus_reflex_generator.rb /^ def initi
|
|
|
32
34
|
initialize_reflexes lib/generators/stimulus_reflex_generator.rb /^ def initialize_reflexes$/;" f class:StimulusReflexGenerator
|
|
33
35
|
is_reflex? lib/stimulus_reflex/channel.rb /^ def is_reflex?(reflex_class)$/;" f class:StimulusReflex
|
|
34
36
|
receive lib/stimulus_reflex/channel.rb /^ def receive(data)$/;" f class:StimulusReflex
|
|
35
|
-
render_page lib/stimulus_reflex/channel.rb /^ def render_page(
|
|
36
|
-
render_page_and_broadcast_morph lib/stimulus_reflex/channel.rb /^ def render_page_and_broadcast_morph(
|
|
37
|
+
render_page lib/stimulus_reflex/channel.rb /^ def render_page(reflex)$/;" f class:StimulusReflex
|
|
38
|
+
render_page_and_broadcast_morph lib/stimulus_reflex/channel.rb /^ def render_page_and_broadcast_morph(reflex, selectors, data = {})$/;" f class:StimulusReflex
|
|
37
39
|
request lib/stimulus_reflex/reflex.rb /^ def request$/;" f class:StimulusReflex
|
|
38
40
|
stream_name lib/stimulus_reflex/channel.rb /^ def stream_name$/;" f class:StimulusReflex
|
|
39
41
|
subscribed lib/stimulus_reflex/channel.rb /^ def subscribed$/;" f class:StimulusReflex
|
|
42
|
+
url_params lib/stimulus_reflex/reflex.rb /^ def url_params$/;" f class:StimulusReflex
|
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: 2.2.
|
|
4
|
+
version: 2.2.3
|
|
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-03-
|
|
11
|
+
date: 2020-03-27 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: rack
|