steel_wheel 0.7.0 → 0.8.0
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 +43 -45
- data/lib/generators/steel_wheel/application_handler/templates/handler_template.rb +1 -0
- data/lib/generators/steel_wheel/scaffold_controller/templates/index.rb +1 -1
- data/lib/steel_wheel/components.rb +24 -6
- data/lib/steel_wheel/composition.rb +47 -0
- data/lib/steel_wheel/handler.rb +4 -3
- data/lib/steel_wheel/preconditions.rb +1 -1
- data/lib/steel_wheel/railtie.rb +1 -0
- data/lib/steel_wheel/version.rb +1 -1
- data/lib/steel_wheel.rb +1 -0
- data/steel_wheel.gemspec +2 -2
- metadata +6 -5
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 63187c69f05601bdc4504a3b85244d9ecd14c7ed882434ae3c87526f39e57b9a
|
|
4
|
+
data.tar.gz: 5c7734353306c7f214b370a35206cc71f3eb903a1b79b0b3331cba999afca3a0
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: ac0acddfa4074ac236e3f2bc1b2693d6cf58fb99f0da6c06bd8c409c53d625da91fdc384ec629cb7646edd0c82fe3ce4107338156fb068f4574772ca572d97ef
|
|
7
|
+
data.tar.gz: 81f1ff20c703273f06f683e836c6fc5966f5d1ed308f7ab0b45714b05bdae01ea2778116826a4c8cb3ecdbb1b4b9ec2e4db9b98ede03eb403b08a2011e5996ec
|
data/Gemfile.lock
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
steel_wheel (0.
|
|
5
|
-
action_form (~> 0.
|
|
6
|
-
easy_params (~> 0.
|
|
4
|
+
steel_wheel (0.8.0)
|
|
5
|
+
action_form (~> 0.6.6)
|
|
6
|
+
easy_params (~> 0.9.1)
|
|
7
7
|
memery (~> 1)
|
|
8
8
|
railties (>= 3.2, < 9)
|
|
9
9
|
|
|
10
10
|
GEM
|
|
11
11
|
remote: https://rubygems.org/
|
|
12
12
|
specs:
|
|
13
|
-
action_form (0.
|
|
14
|
-
easy_params (~> 0.
|
|
13
|
+
action_form (0.6.6)
|
|
14
|
+
easy_params (~> 0.9.1)
|
|
15
15
|
phlex (>= 2)
|
|
16
16
|
railties (>= 6.0.0)
|
|
17
|
-
actionpack (8.
|
|
18
|
-
actionview (= 8.
|
|
19
|
-
activesupport (= 8.
|
|
17
|
+
actionpack (8.1.1)
|
|
18
|
+
actionview (= 8.1.1)
|
|
19
|
+
activesupport (= 8.1.1)
|
|
20
20
|
nokogiri (>= 1.8.5)
|
|
21
21
|
rack (>= 2.2.4)
|
|
22
22
|
rack-session (>= 1.0.1)
|
|
@@ -24,22 +24,22 @@ GEM
|
|
|
24
24
|
rails-dom-testing (~> 2.2)
|
|
25
25
|
rails-html-sanitizer (~> 1.6)
|
|
26
26
|
useragent (~> 0.16)
|
|
27
|
-
actionview (8.
|
|
28
|
-
activesupport (= 8.
|
|
27
|
+
actionview (8.1.1)
|
|
28
|
+
activesupport (= 8.1.1)
|
|
29
29
|
builder (~> 3.1)
|
|
30
30
|
erubi (~> 1.11)
|
|
31
31
|
rails-dom-testing (~> 2.2)
|
|
32
32
|
rails-html-sanitizer (~> 1.6)
|
|
33
|
-
activemodel (8.
|
|
34
|
-
activesupport (= 8.
|
|
35
|
-
activesupport (8.
|
|
33
|
+
activemodel (8.1.1)
|
|
34
|
+
activesupport (= 8.1.1)
|
|
35
|
+
activesupport (8.1.1)
|
|
36
36
|
base64
|
|
37
|
-
benchmark (>= 0.3)
|
|
38
37
|
bigdecimal
|
|
39
38
|
concurrent-ruby (~> 1.0, >= 1.3.1)
|
|
40
39
|
connection_pool (>= 2.2.5)
|
|
41
40
|
drb
|
|
42
41
|
i18n (>= 1.6, < 2)
|
|
42
|
+
json
|
|
43
43
|
logger (>= 1.4.2)
|
|
44
44
|
minitest (>= 5.1)
|
|
45
45
|
securerandom (>= 0.3)
|
|
@@ -47,29 +47,28 @@ GEM
|
|
|
47
47
|
uri (>= 0.13.1)
|
|
48
48
|
ast (2.4.3)
|
|
49
49
|
base64 (0.3.0)
|
|
50
|
-
|
|
51
|
-
bigdecimal (3.2.3)
|
|
50
|
+
bigdecimal (3.3.1)
|
|
52
51
|
builder (3.3.0)
|
|
53
52
|
coderay (1.1.3)
|
|
54
53
|
concurrent-ruby (1.3.5)
|
|
55
54
|
connection_pool (2.5.4)
|
|
56
55
|
crass (1.0.6)
|
|
57
|
-
date (3.
|
|
56
|
+
date (3.5.0)
|
|
58
57
|
diff-lcs (1.6.2)
|
|
59
58
|
docile (1.4.1)
|
|
60
59
|
drb (2.2.3)
|
|
61
|
-
easy_params (0.
|
|
60
|
+
easy_params (0.9.1)
|
|
62
61
|
activemodel (>= 3.2)
|
|
63
|
-
erb (
|
|
62
|
+
erb (6.0.0)
|
|
64
63
|
erubi (1.13.1)
|
|
65
64
|
i18n (1.14.7)
|
|
66
65
|
concurrent-ruby (~> 1.0)
|
|
67
66
|
io-console (0.8.1)
|
|
68
|
-
irb (1.15.
|
|
67
|
+
irb (1.15.3)
|
|
69
68
|
pp (>= 0.6.0)
|
|
70
69
|
rdoc (>= 4.0.0)
|
|
71
70
|
reline (>= 0.4.2)
|
|
72
|
-
json (2.
|
|
71
|
+
json (2.15.2)
|
|
73
72
|
language_server-protocol (3.17.0.5)
|
|
74
73
|
lint_roller (1.1.0)
|
|
75
74
|
logger (1.7.0)
|
|
@@ -79,14 +78,14 @@ GEM
|
|
|
79
78
|
memery (1.8.0)
|
|
80
79
|
method_source (1.1.0)
|
|
81
80
|
mini_portile2 (2.8.9)
|
|
82
|
-
minitest (5.
|
|
81
|
+
minitest (5.26.1)
|
|
83
82
|
nokogiri (1.18.1)
|
|
84
83
|
mini_portile2 (~> 2.8.2)
|
|
85
84
|
racc (~> 1.4)
|
|
86
85
|
nokogiri (1.18.1-arm64-darwin)
|
|
87
86
|
racc (~> 1.4)
|
|
88
87
|
parallel (1.27.0)
|
|
89
|
-
parser (3.3.
|
|
88
|
+
parser (3.3.10.0)
|
|
90
89
|
ast (~> 2.4.1)
|
|
91
90
|
racc
|
|
92
91
|
phlex (2.3.1)
|
|
@@ -94,7 +93,7 @@ GEM
|
|
|
94
93
|
pp (0.6.3)
|
|
95
94
|
prettyprint
|
|
96
95
|
prettyprint (0.2.0)
|
|
97
|
-
prism (1.
|
|
96
|
+
prism (1.6.0)
|
|
98
97
|
pry (0.15.2)
|
|
99
98
|
coderay (~> 1.1)
|
|
100
99
|
method_source (~> 1.0)
|
|
@@ -102,7 +101,7 @@ GEM
|
|
|
102
101
|
date
|
|
103
102
|
stringio
|
|
104
103
|
racc (1.8.1)
|
|
105
|
-
rack (3.2.
|
|
104
|
+
rack (3.2.4)
|
|
106
105
|
rack-session (2.1.1)
|
|
107
106
|
base64 (>= 0.1.0)
|
|
108
107
|
rack (>= 3.0.0)
|
|
@@ -117,9 +116,9 @@ GEM
|
|
|
117
116
|
rails-html-sanitizer (1.6.2)
|
|
118
117
|
loofah (~> 2.21)
|
|
119
118
|
nokogiri (>= 1.15.7, != 1.16.7, != 1.16.6, != 1.16.5, != 1.16.4, != 1.16.3, != 1.16.2, != 1.16.1, != 1.16.0.rc1, != 1.16.0)
|
|
120
|
-
railties (8.
|
|
121
|
-
actionpack (= 8.
|
|
122
|
-
activesupport (= 8.
|
|
119
|
+
railties (8.1.1)
|
|
120
|
+
actionpack (= 8.1.1)
|
|
121
|
+
activesupport (= 8.1.1)
|
|
123
122
|
irb (~> 1.13)
|
|
124
123
|
rackup (>= 1.0.0)
|
|
125
124
|
rake (>= 12.2)
|
|
@@ -127,30 +126,30 @@ GEM
|
|
|
127
126
|
tsort (>= 0.2)
|
|
128
127
|
zeitwerk (~> 2.6)
|
|
129
128
|
rainbow (3.1.1)
|
|
130
|
-
rake (13.3.
|
|
131
|
-
rdoc (6.15.
|
|
129
|
+
rake (13.3.1)
|
|
130
|
+
rdoc (6.15.1)
|
|
132
131
|
erb
|
|
133
132
|
psych (>= 4.0.0)
|
|
134
133
|
tsort
|
|
135
|
-
regexp_parser (2.
|
|
136
|
-
reline (0.6.
|
|
134
|
+
regexp_parser (2.11.3)
|
|
135
|
+
reline (0.6.3)
|
|
137
136
|
io-console (~> 0.5)
|
|
138
|
-
rspec (3.13.
|
|
137
|
+
rspec (3.13.2)
|
|
139
138
|
rspec-core (~> 3.13.0)
|
|
140
139
|
rspec-expectations (~> 3.13.0)
|
|
141
140
|
rspec-mocks (~> 3.13.0)
|
|
142
|
-
rspec-core (3.13.
|
|
141
|
+
rspec-core (3.13.6)
|
|
143
142
|
rspec-support (~> 3.13.0)
|
|
144
143
|
rspec-expectations (3.13.5)
|
|
145
144
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
146
145
|
rspec-support (~> 3.13.0)
|
|
147
|
-
rspec-mocks (3.13.
|
|
146
|
+
rspec-mocks (3.13.7)
|
|
148
147
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
149
148
|
rspec-support (~> 3.13.0)
|
|
150
|
-
rspec-support (3.13.
|
|
149
|
+
rspec-support (3.13.6)
|
|
151
150
|
rspec_vars_helper (0.1.0)
|
|
152
151
|
rspec (>= 2.4)
|
|
153
|
-
rubocop (1.
|
|
152
|
+
rubocop (1.81.7)
|
|
154
153
|
json (~> 2.3)
|
|
155
154
|
language_server-protocol (~> 3.17.0.2)
|
|
156
155
|
lint_roller (~> 1.1.0)
|
|
@@ -158,11 +157,10 @@ GEM
|
|
|
158
157
|
parser (>= 3.3.0.2)
|
|
159
158
|
rainbow (>= 2.2.2, < 4.0)
|
|
160
159
|
regexp_parser (>= 2.9.3, < 3.0)
|
|
161
|
-
rubocop-ast (>= 1.
|
|
160
|
+
rubocop-ast (>= 1.47.1, < 2.0)
|
|
162
161
|
ruby-progressbar (~> 1.7)
|
|
163
|
-
tsort (>= 0.2.0)
|
|
164
162
|
unicode-display_width (>= 2.4.0, < 4.0)
|
|
165
|
-
rubocop-ast (1.
|
|
163
|
+
rubocop-ast (1.47.1)
|
|
166
164
|
parser (>= 3.3.7.2)
|
|
167
165
|
prism (~> 1.4)
|
|
168
166
|
ruby-progressbar (1.13.0)
|
|
@@ -173,15 +171,15 @@ GEM
|
|
|
173
171
|
simplecov_json_formatter (~> 0.1)
|
|
174
172
|
simplecov-html (0.13.2)
|
|
175
173
|
simplecov_json_formatter (0.1.4)
|
|
176
|
-
stringio (3.1.
|
|
174
|
+
stringio (3.1.8)
|
|
177
175
|
thor (1.4.0)
|
|
178
176
|
tsort (0.2.0)
|
|
179
177
|
tzinfo (2.0.6)
|
|
180
178
|
concurrent-ruby (~> 1.0)
|
|
181
|
-
unicode-display_width (3.
|
|
182
|
-
unicode-emoji (~> 4.
|
|
183
|
-
unicode-emoji (4.0
|
|
184
|
-
uri (1.
|
|
179
|
+
unicode-display_width (3.2.0)
|
|
180
|
+
unicode-emoji (~> 4.1)
|
|
181
|
+
unicode-emoji (4.1.0)
|
|
182
|
+
uri (1.1.1)
|
|
185
183
|
useragent (0.16.11)
|
|
186
184
|
zeitwerk (2.7.3)
|
|
187
185
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
class <%= controller_class_name %>::IndexHandler < ApplicationHandler
|
|
2
2
|
def form_attributes
|
|
3
|
-
{ method: :get, action: helpers.<%= index_helper %>_path
|
|
3
|
+
{ method: :get, action: helpers.<%= index_helper %>_path }
|
|
4
4
|
end
|
|
5
5
|
|
|
6
6
|
form <%= controller_class_name %>::SearchForm
|
|
@@ -14,6 +14,10 @@ module SteelWheel
|
|
|
14
14
|
@url_params_definition ||= Class.new(SteelWheel::Params)
|
|
15
15
|
end
|
|
16
16
|
|
|
17
|
+
def form_params_definition
|
|
18
|
+
@form_params_definition ||= form_definition.params_definition
|
|
19
|
+
end
|
|
20
|
+
|
|
17
21
|
def form_definition
|
|
18
22
|
@form_definition ||= Class.new(ActionForm::Rails::Base)
|
|
19
23
|
end
|
|
@@ -35,15 +39,29 @@ module SteelWheel
|
|
|
35
39
|
end
|
|
36
40
|
|
|
37
41
|
def form_params
|
|
38
|
-
@form_params ||=
|
|
39
|
-
self.class.form_definition.params_definition.schema[@form_scope].class.new(form_input)
|
|
40
|
-
else
|
|
41
|
-
self.class.form_definition.params_definition.new(form_input)
|
|
42
|
-
end
|
|
42
|
+
@form_params ||= self.class.form_params_definition.new(form_input)
|
|
43
43
|
end
|
|
44
44
|
|
|
45
45
|
def form(attrs = form_attributes)
|
|
46
|
-
@form ||=
|
|
46
|
+
@form ||= create_form(attrs)
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
private
|
|
50
|
+
|
|
51
|
+
def create_form(attrs)
|
|
52
|
+
if form_input.present?
|
|
53
|
+
create_form_from_form_params
|
|
54
|
+
else
|
|
55
|
+
create_form_from_definition(attrs)
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
def create_form_from_definition(attrs)
|
|
60
|
+
self.class.form_definition.new(owner: self, **attrs)
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
def create_form_from_form_params
|
|
64
|
+
form_params&.create_form(owner: self, method: owner_request.request_method, action: owner_request.path)
|
|
47
65
|
end
|
|
48
66
|
|
|
49
67
|
def form_attributes
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module SteelWheel
|
|
4
|
+
# Provides host–guest association helpers for ActionForm components.
|
|
5
|
+
# When included, it exposes `host_object` and `host_association_name` accessors
|
|
6
|
+
# and delegates `host_*` method calls to the associated host via `method_missing`.
|
|
7
|
+
module Composition
|
|
8
|
+
def self.included(base)
|
|
9
|
+
base.attr_accessor :owner
|
|
10
|
+
base.include(InstanceMethods)
|
|
11
|
+
base.extend(ClassMethods)
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
module ClassMethods # rubocop:disable Style/Documentation
|
|
15
|
+
def part_of(owner_name)
|
|
16
|
+
@owner_name = owner_name
|
|
17
|
+
alias_method owner_name, :owner
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
module InstanceMethods # rubocop:disable Style/Documentation
|
|
22
|
+
def method_missing(name, *attrs, **kwargs, &block)
|
|
23
|
+
return super unless name.to_s.start_with?('owner_')
|
|
24
|
+
|
|
25
|
+
owner_method = name.to_s.sub('owner_', '').to_sym
|
|
26
|
+
return super unless (handler = owners_chain.detect { |o| o.respond_to?(owner_method) })
|
|
27
|
+
|
|
28
|
+
handler.public_send(owner_method, *attrs, **kwargs, &block)
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def respond_to_missing?(method_name, include_private = false)
|
|
32
|
+
return super unless method_name.to_s.start_with?('owner_')
|
|
33
|
+
|
|
34
|
+
owners_chain.any? { |o| o.respond_to?(method_name.to_s.sub('owner_', '').to_sym, include_private) }
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
private
|
|
38
|
+
|
|
39
|
+
def owners_chain
|
|
40
|
+
@owners_chain ||= Enumerator.new do |y|
|
|
41
|
+
obj = self
|
|
42
|
+
y << obj = obj.owner while obj.respond_to?(:owner)
|
|
43
|
+
end.lazy
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
end
|
data/lib/steel_wheel/handler.rb
CHANGED
|
@@ -14,6 +14,7 @@ module SteelWheel
|
|
|
14
14
|
include SteelWheel::Shortcuts
|
|
15
15
|
include SteelWheel::Callbacks
|
|
16
16
|
include SteelWheel::Preconditions
|
|
17
|
+
include SteelWheel::Composition
|
|
17
18
|
|
|
18
19
|
attr_reader :input, :form_input
|
|
19
20
|
attr_accessor :http_status, :helpers
|
|
@@ -76,12 +77,12 @@ module SteelWheel
|
|
|
76
77
|
errors.map(&:type).first
|
|
77
78
|
end
|
|
78
79
|
|
|
79
|
-
private
|
|
80
|
-
|
|
81
80
|
def current_action
|
|
82
81
|
ActiveSupport::StringInquirer.new(url_params.action)
|
|
83
82
|
end
|
|
84
83
|
|
|
84
|
+
private
|
|
85
|
+
|
|
85
86
|
def prepare_params(params)
|
|
86
87
|
normalized_params = normalize_params(params)
|
|
87
88
|
@form_scope = self.class.form_definition.scope
|
|
@@ -90,7 +91,7 @@ module SteelWheel
|
|
|
90
91
|
@form_input = normalized_params.delete(@form_scope)
|
|
91
92
|
@validate_form = @form_input.present?
|
|
92
93
|
else
|
|
93
|
-
@form_input = normalized_params
|
|
94
|
+
@form_input = normalized_params.except(*self.class.url_params_definition.schema.keys)
|
|
94
95
|
end
|
|
95
96
|
@input = normalized_params
|
|
96
97
|
end
|
data/lib/steel_wheel/railtie.rb
CHANGED
|
@@ -13,6 +13,7 @@ module SteelWheel # rubocop:disable Style/Documentation
|
|
|
13
13
|
define_method(action_name) do
|
|
14
14
|
handler_klass = handler_class_for(handler)
|
|
15
15
|
handler_klass.handle(params) do |handler_instance|
|
|
16
|
+
handler_instance.owner = self
|
|
16
17
|
handler_instance.helpers = view_context
|
|
17
18
|
instance_exec(handler_instance, &block)
|
|
18
19
|
failure_callbacks(handler_instance)
|
data/lib/steel_wheel/version.rb
CHANGED
data/lib/steel_wheel.rb
CHANGED
data/steel_wheel.gemspec
CHANGED
|
@@ -42,7 +42,7 @@ Gem::Specification.new do |spec|
|
|
|
42
42
|
|
|
43
43
|
spec.add_dependency 'railties', version_string
|
|
44
44
|
|
|
45
|
-
spec.add_dependency 'action_form', '~> 0.
|
|
46
|
-
spec.add_dependency 'easy_params', '~> 0.
|
|
45
|
+
spec.add_dependency 'action_form', '~> 0.6.6'
|
|
46
|
+
spec.add_dependency 'easy_params', '~> 0.9.1'
|
|
47
47
|
spec.add_dependency 'memery', '~> 1'
|
|
48
48
|
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: steel_wheel
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.8.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Andrii Baran
|
|
@@ -35,28 +35,28 @@ dependencies:
|
|
|
35
35
|
requirements:
|
|
36
36
|
- - "~>"
|
|
37
37
|
- !ruby/object:Gem::Version
|
|
38
|
-
version:
|
|
38
|
+
version: 0.6.6
|
|
39
39
|
type: :runtime
|
|
40
40
|
prerelease: false
|
|
41
41
|
version_requirements: !ruby/object:Gem::Requirement
|
|
42
42
|
requirements:
|
|
43
43
|
- - "~>"
|
|
44
44
|
- !ruby/object:Gem::Version
|
|
45
|
-
version:
|
|
45
|
+
version: 0.6.6
|
|
46
46
|
- !ruby/object:Gem::Dependency
|
|
47
47
|
name: easy_params
|
|
48
48
|
requirement: !ruby/object:Gem::Requirement
|
|
49
49
|
requirements:
|
|
50
50
|
- - "~>"
|
|
51
51
|
- !ruby/object:Gem::Version
|
|
52
|
-
version:
|
|
52
|
+
version: 0.9.1
|
|
53
53
|
type: :runtime
|
|
54
54
|
prerelease: false
|
|
55
55
|
version_requirements: !ruby/object:Gem::Requirement
|
|
56
56
|
requirements:
|
|
57
57
|
- - "~>"
|
|
58
58
|
- !ruby/object:Gem::Version
|
|
59
|
-
version:
|
|
59
|
+
version: 0.9.1
|
|
60
60
|
- !ruby/object:Gem::Dependency
|
|
61
61
|
name: memery
|
|
62
62
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -117,6 +117,7 @@ files:
|
|
|
117
117
|
- lib/steel_wheel.rb
|
|
118
118
|
- lib/steel_wheel/callbacks.rb
|
|
119
119
|
- lib/steel_wheel/components.rb
|
|
120
|
+
- lib/steel_wheel/composition.rb
|
|
120
121
|
- lib/steel_wheel/filters.rb
|
|
121
122
|
- lib/steel_wheel/handler.rb
|
|
122
123
|
- lib/steel_wheel/params.rb
|