wallaby-core 0.2.11 → 0.3.0.beta2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/wallaby/resources_controller.rb +20 -7
- data/app/security/ability.rb +1 -1
- data/config/routes.rb +21 -14
- data/lib/adaptors/wallaby/custom/default_provider.rb +1 -1
- data/lib/adaptors/wallaby/custom/model_decorator.rb +5 -17
- data/lib/adaptors/wallaby/custom/model_finder.rb +3 -3
- data/lib/adaptors/wallaby/custom/model_pagination_provider.rb +1 -1
- data/lib/adaptors/wallaby/custom/model_service_provider.rb +1 -1
- data/lib/authorizers/wallaby/cancancan_authorization_provider.rb +12 -5
- data/lib/authorizers/wallaby/default_authorization_provider.rb +10 -1
- data/lib/authorizers/wallaby/model_authorizer.rb +41 -16
- data/lib/authorizers/wallaby/pundit_authorization_provider.rb +22 -8
- data/lib/concerns/wallaby/application_concern.rb +41 -71
- data/lib/concerns/wallaby/authentication_concern.rb +29 -127
- data/lib/concerns/wallaby/authorizable.rb +14 -57
- data/lib/concerns/wallaby/baseable.rb +24 -57
- data/lib/concerns/wallaby/configurable.rb +416 -0
- data/lib/concerns/wallaby/decoratable.rb +29 -60
- data/lib/concerns/wallaby/engineable.rb +29 -46
- data/lib/concerns/wallaby/fieldable.rb +45 -56
- data/lib/concerns/wallaby/paginatable.rb +20 -51
- data/lib/concerns/wallaby/prefixable.rb +24 -4
- data/lib/concerns/wallaby/resourcable.rb +130 -72
- data/lib/concerns/wallaby/resources_concern.rb +205 -305
- data/lib/concerns/wallaby/servicable.rb +8 -48
- data/lib/concerns/wallaby/urlable.rb +69 -0
- data/lib/decorators/wallaby/resource_decorator.rb +91 -34
- data/lib/errors/wallaby/class_not_found.rb +1 -2
- data/lib/errors/wallaby/forbidden.rb +1 -2
- data/lib/errors/wallaby/general_error.rb +1 -1
- data/lib/errors/wallaby/invalid_error.rb +1 -2
- data/lib/errors/wallaby/method_removed.rb +5 -0
- data/lib/errors/wallaby/model_not_found.rb +1 -2
- data/lib/errors/wallaby/not_authenticated.rb +1 -2
- data/lib/errors/wallaby/not_found.rb +1 -2
- data/lib/errors/wallaby/not_implemented.rb +1 -2
- data/lib/errors/wallaby/resource_not_found.rb +1 -2
- data/lib/errors/wallaby/unprocessable_entity.rb +1 -2
- data/lib/fields/wallaby/all_fields.rb +63 -0
- data/lib/forms/wallaby/form_builder.rb +1 -1
- data/lib/generators/wallaby/engine/application_generator.rb +33 -0
- data/lib/generators/wallaby/engine/authorizer/USAGE +20 -0
- data/lib/generators/wallaby/engine/authorizer/authorizer_generator.rb +19 -0
- data/lib/generators/wallaby/engine/authorizer/templates/authorizer.rb.erb +35 -0
- data/lib/generators/wallaby/engine/controller/USAGE +20 -0
- data/lib/generators/wallaby/engine/controller/controller_generator.rb +23 -0
- data/lib/generators/wallaby/engine/controller/templates/controller.rb.erb +130 -0
- data/lib/generators/wallaby/engine/decorator/USAGE +20 -0
- data/lib/generators/wallaby/engine/decorator/decorator_generator.rb +19 -0
- data/lib/generators/wallaby/engine/decorator/templates/decorator.rb.erb +5 -0
- data/lib/generators/wallaby/engine/install/USAGE +19 -0
- data/lib/generators/wallaby/engine/install/install_generator.rb +91 -0
- data/lib/generators/wallaby/engine/install/templates/application_authorizer.rb.erb +37 -0
- data/lib/generators/wallaby/engine/install/templates/application_controller.rb.erb +173 -0
- data/lib/generators/wallaby/engine/install/templates/application_decorator.rb.erb +7 -0
- data/lib/generators/wallaby/engine/install/templates/application_paginator.rb.erb +27 -0
- data/lib/generators/wallaby/engine/install/templates/application_servicer.rb.erb +47 -0
- data/lib/generators/wallaby/engine/install/templates/initializer.rb.erb +16 -0
- data/lib/generators/wallaby/engine/paginator/USAGE +20 -0
- data/lib/generators/wallaby/engine/paginator/paginator_generator.rb +19 -0
- data/lib/generators/wallaby/engine/paginator/templates/paginator.rb.erb +25 -0
- data/lib/generators/wallaby/engine/servicer/USAGE +20 -0
- data/lib/generators/wallaby/engine/servicer/servicer_generator.rb +19 -0
- data/lib/generators/wallaby/engine/servicer/templates/servicer.rb.erb +45 -0
- data/lib/helpers/wallaby/application_helper.rb +10 -59
- data/lib/helpers/wallaby/base_helper.rb +11 -11
- data/lib/helpers/wallaby/configuration_helper.rb +36 -4
- data/lib/helpers/wallaby/form_helper.rb +1 -1
- data/lib/helpers/wallaby/index_helper.rb +19 -9
- data/lib/helpers/wallaby/links_helper.rb +18 -85
- data/lib/helpers/wallaby/resources_helper.rb +39 -7
- data/lib/helpers/wallaby/secure_helper.rb +20 -19
- data/lib/interfaces/wallaby/mode.rb +8 -8
- data/lib/interfaces/wallaby/model_authorization_provider.rb +23 -22
- data/lib/interfaces/wallaby/model_decorator.rb +36 -48
- data/lib/interfaces/wallaby/model_finder.rb +3 -3
- data/lib/interfaces/wallaby/model_pagination_provider.rb +2 -6
- data/lib/interfaces/wallaby/model_service_provider.rb +4 -4
- data/lib/paginators/wallaby/model_paginator.rb +1 -1
- data/lib/responders/wallaby/json_api_responder.rb +10 -5
- data/lib/responders/wallaby/resources_responder.rb +10 -3
- data/lib/routes/wallaby/engines/base_route.rb +78 -0
- data/lib/routes/wallaby/engines/custom_app_route.rb +92 -0
- data/lib/routes/wallaby/engines/engine_route.rb +77 -0
- data/lib/routes/wallaby/resources_router.rb +100 -45
- data/lib/servicers/wallaby/model_servicer.rb +13 -13
- data/lib/services/wallaby/authorizer_finder.rb +23 -0
- data/lib/services/wallaby/class_finder.rb +42 -0
- data/lib/services/wallaby/controller_finder.rb +29 -0
- data/lib/services/wallaby/decorator_finder.rb +34 -0
- data/lib/services/wallaby/default_models_excluder.rb +45 -0
- data/lib/services/wallaby/engine_name_finder.rb +14 -11
- data/lib/services/wallaby/engine_url_for.rb +82 -37
- data/lib/services/wallaby/fields_regulator.rb +34 -0
- data/lib/services/wallaby/map/mode_mapper.rb +5 -5
- data/lib/services/wallaby/map/model_class_mapper.rb +1 -1
- data/lib/services/wallaby/model_class_filter.rb +29 -0
- data/lib/services/wallaby/paginator_finder.rb +24 -0
- data/lib/services/wallaby/prefixes_builder.rb +49 -8
- data/lib/services/wallaby/servicer_finder.rb +31 -0
- data/lib/services/wallaby/sorting/hash_builder.rb +9 -0
- data/lib/services/wallaby/sorting/link_builder.rb +7 -10
- data/lib/services/wallaby/sorting/next_builder.rb +1 -12
- data/lib/services/wallaby/sorting/single_builder.rb +1 -1
- data/lib/support/action_dispatch/routing/mapper.rb +29 -4
- data/lib/utils/wallaby/field_utils.rb +9 -8
- data/lib/utils/wallaby/inflector.rb +94 -0
- data/lib/utils/wallaby/locale.rb +2 -2
- data/lib/utils/wallaby/module_utils.rb +3 -10
- data/lib/utils/wallaby/utils.rb +21 -14
- data/lib/wallaby/class_array.rb +18 -13
- data/lib/wallaby/class_hash.rb +16 -14
- data/lib/wallaby/classifier.rb +4 -2
- data/lib/wallaby/configuration/features.rb +8 -2
- data/lib/wallaby/configuration/mapping.rb +66 -112
- data/lib/wallaby/configuration/metadata.rb +15 -12
- data/lib/wallaby/configuration/models.rb +27 -25
- data/lib/wallaby/configuration/pagination.rb +15 -19
- data/lib/wallaby/configuration/security.rb +88 -80
- data/lib/wallaby/configuration/sorting.rb +15 -17
- data/lib/wallaby/configuration.rb +58 -23
- data/lib/wallaby/constants.rb +21 -13
- data/lib/wallaby/core/version.rb +1 -1
- data/lib/wallaby/core.rb +34 -10
- data/lib/wallaby/deprecator.rb +81 -0
- data/lib/wallaby/engine.rb +1 -18
- data/lib/wallaby/guesser.rb +45 -0
- data/lib/wallaby/logger.rb +35 -13
- data/lib/wallaby/map.rb +11 -88
- data/lib/wallaby/preloader.rb +8 -28
- metadata +113 -14
- data/config/locales/wallaby_class.en.yml +0 -9
- data/lib/concerns/wallaby/defaultable.rb +0 -38
- data/lib/concerns/wallaby/shared_helpers.rb +0 -22
- data/lib/services/wallaby/map/model_class_collector.rb +0 -49
- data/lib/services/wallaby/type_renderer.rb +0 -40
- data/lib/utils/wallaby/model_utils.rb +0 -52
- data/lib/utils/wallaby/test_utils.rb +0 -34
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wallaby-core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0.beta2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tian Chen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-02-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activemodel
|
@@ -16,28 +16,34 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 6.0.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: 6.0.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: railties
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
33
|
+
version: 6.0.0
|
34
|
+
- - "<"
|
35
|
+
- !ruby/object:Gem::Version
|
36
|
+
version: 8.0.0
|
34
37
|
type: :runtime
|
35
38
|
prerelease: false
|
36
39
|
version_requirements: !ruby/object:Gem::Requirement
|
37
40
|
requirements:
|
38
41
|
- - ">="
|
39
42
|
- !ruby/object:Gem::Version
|
40
|
-
version:
|
43
|
+
version: 6.0.0
|
44
|
+
- - "<"
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: 8.0.0
|
41
47
|
- !ruby/object:Gem::Dependency
|
42
48
|
name: parslet
|
43
49
|
requirement: !ruby/object:Gem::Requirement
|
@@ -80,6 +86,34 @@ dependencies:
|
|
80
86
|
- - "~>"
|
81
87
|
- !ruby/object:Gem::Version
|
82
88
|
version: 0.1.2
|
89
|
+
- !ruby/object:Gem::Dependency
|
90
|
+
name: github-markup
|
91
|
+
requirement: !ruby/object:Gem::Requirement
|
92
|
+
requirements:
|
93
|
+
- - ">="
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: '0'
|
96
|
+
type: :development
|
97
|
+
prerelease: false
|
98
|
+
version_requirements: !ruby/object:Gem::Requirement
|
99
|
+
requirements:
|
100
|
+
- - ">="
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: '0'
|
103
|
+
- !ruby/object:Gem::Dependency
|
104
|
+
name: redcarpet
|
105
|
+
requirement: !ruby/object:Gem::Requirement
|
106
|
+
requirements:
|
107
|
+
- - ">="
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
110
|
+
type: :development
|
111
|
+
prerelease: false
|
112
|
+
version_requirements: !ruby/object:Gem::Requirement
|
113
|
+
requirements:
|
114
|
+
- - ">="
|
115
|
+
- !ruby/object:Gem::Version
|
116
|
+
version: '0'
|
83
117
|
- !ruby/object:Gem::Dependency
|
84
118
|
name: rspec-rails
|
85
119
|
requirement: !ruby/object:Gem::Requirement
|
@@ -94,6 +128,20 @@ dependencies:
|
|
94
128
|
- - ">="
|
95
129
|
- !ruby/object:Gem::Version
|
96
130
|
version: '0'
|
131
|
+
- !ruby/object:Gem::Dependency
|
132
|
+
name: simplecov
|
133
|
+
requirement: !ruby/object:Gem::Requirement
|
134
|
+
requirements:
|
135
|
+
- - ">="
|
136
|
+
- !ruby/object:Gem::Version
|
137
|
+
version: '0'
|
138
|
+
type: :development
|
139
|
+
prerelease: false
|
140
|
+
version_requirements: !ruby/object:Gem::Requirement
|
141
|
+
requirements:
|
142
|
+
- - ">="
|
143
|
+
- !ruby/object:Gem::Version
|
144
|
+
version: '0'
|
97
145
|
- !ruby/object:Gem::Dependency
|
98
146
|
name: wallaby-cop
|
99
147
|
requirement: !ruby/object:Gem::Requirement
|
@@ -108,6 +156,20 @@ dependencies:
|
|
108
156
|
- - ">="
|
109
157
|
- !ruby/object:Gem::Version
|
110
158
|
version: '0'
|
159
|
+
- !ruby/object:Gem::Dependency
|
160
|
+
name: yard
|
161
|
+
requirement: !ruby/object:Gem::Requirement
|
162
|
+
requirements:
|
163
|
+
- - ">="
|
164
|
+
- !ruby/object:Gem::Version
|
165
|
+
version: '0'
|
166
|
+
type: :development
|
167
|
+
prerelease: false
|
168
|
+
version_requirements: !ruby/object:Gem::Requirement
|
169
|
+
requirements:
|
170
|
+
- - ">="
|
171
|
+
- !ruby/object:Gem::Version
|
172
|
+
version: '0'
|
111
173
|
description: The core of Wallaby
|
112
174
|
email:
|
113
175
|
- me@tian.im
|
@@ -120,7 +182,6 @@ files:
|
|
120
182
|
- app/controllers/wallaby/resources_controller.rb
|
121
183
|
- app/security/ability.rb
|
122
184
|
- config/locales/wallaby.en.yml
|
123
|
-
- config/locales/wallaby_class.en.yml
|
124
185
|
- config/routes.rb
|
125
186
|
- lib/adaptors/wallaby/custom.rb
|
126
187
|
- lib/adaptors/wallaby/custom/default_provider.rb
|
@@ -136,8 +197,8 @@ files:
|
|
136
197
|
- lib/concerns/wallaby/authentication_concern.rb
|
137
198
|
- lib/concerns/wallaby/authorizable.rb
|
138
199
|
- lib/concerns/wallaby/baseable.rb
|
200
|
+
- lib/concerns/wallaby/configurable.rb
|
139
201
|
- lib/concerns/wallaby/decoratable.rb
|
140
|
-
- lib/concerns/wallaby/defaultable.rb
|
141
202
|
- lib/concerns/wallaby/engineable.rb
|
142
203
|
- lib/concerns/wallaby/fieldable.rb
|
143
204
|
- lib/concerns/wallaby/paginatable.rb
|
@@ -145,19 +206,45 @@ files:
|
|
145
206
|
- lib/concerns/wallaby/resourcable.rb
|
146
207
|
- lib/concerns/wallaby/resources_concern.rb
|
147
208
|
- lib/concerns/wallaby/servicable.rb
|
148
|
-
- lib/concerns/wallaby/
|
209
|
+
- lib/concerns/wallaby/urlable.rb
|
149
210
|
- lib/decorators/wallaby/resource_decorator.rb
|
150
211
|
- lib/errors/wallaby/class_not_found.rb
|
151
212
|
- lib/errors/wallaby/forbidden.rb
|
152
213
|
- lib/errors/wallaby/general_error.rb
|
153
214
|
- lib/errors/wallaby/invalid_error.rb
|
215
|
+
- lib/errors/wallaby/method_removed.rb
|
154
216
|
- lib/errors/wallaby/model_not_found.rb
|
155
217
|
- lib/errors/wallaby/not_authenticated.rb
|
156
218
|
- lib/errors/wallaby/not_found.rb
|
157
219
|
- lib/errors/wallaby/not_implemented.rb
|
158
220
|
- lib/errors/wallaby/resource_not_found.rb
|
159
221
|
- lib/errors/wallaby/unprocessable_entity.rb
|
222
|
+
- lib/fields/wallaby/all_fields.rb
|
160
223
|
- lib/forms/wallaby/form_builder.rb
|
224
|
+
- lib/generators/wallaby/engine/application_generator.rb
|
225
|
+
- lib/generators/wallaby/engine/authorizer/USAGE
|
226
|
+
- lib/generators/wallaby/engine/authorizer/authorizer_generator.rb
|
227
|
+
- lib/generators/wallaby/engine/authorizer/templates/authorizer.rb.erb
|
228
|
+
- lib/generators/wallaby/engine/controller/USAGE
|
229
|
+
- lib/generators/wallaby/engine/controller/controller_generator.rb
|
230
|
+
- lib/generators/wallaby/engine/controller/templates/controller.rb.erb
|
231
|
+
- lib/generators/wallaby/engine/decorator/USAGE
|
232
|
+
- lib/generators/wallaby/engine/decorator/decorator_generator.rb
|
233
|
+
- lib/generators/wallaby/engine/decorator/templates/decorator.rb.erb
|
234
|
+
- lib/generators/wallaby/engine/install/USAGE
|
235
|
+
- lib/generators/wallaby/engine/install/install_generator.rb
|
236
|
+
- lib/generators/wallaby/engine/install/templates/application_authorizer.rb.erb
|
237
|
+
- lib/generators/wallaby/engine/install/templates/application_controller.rb.erb
|
238
|
+
- lib/generators/wallaby/engine/install/templates/application_decorator.rb.erb
|
239
|
+
- lib/generators/wallaby/engine/install/templates/application_paginator.rb.erb
|
240
|
+
- lib/generators/wallaby/engine/install/templates/application_servicer.rb.erb
|
241
|
+
- lib/generators/wallaby/engine/install/templates/initializer.rb.erb
|
242
|
+
- lib/generators/wallaby/engine/paginator/USAGE
|
243
|
+
- lib/generators/wallaby/engine/paginator/paginator_generator.rb
|
244
|
+
- lib/generators/wallaby/engine/paginator/templates/paginator.rb.erb
|
245
|
+
- lib/generators/wallaby/engine/servicer/USAGE
|
246
|
+
- lib/generators/wallaby/engine/servicer/servicer_generator.rb
|
247
|
+
- lib/generators/wallaby/engine/servicer/templates/servicer.rb.erb
|
161
248
|
- lib/helpers/wallaby/application_helper.rb
|
162
249
|
- lib/helpers/wallaby/base_helper.rb
|
163
250
|
- lib/helpers/wallaby/configuration_helper.rb
|
@@ -177,29 +264,38 @@ files:
|
|
177
264
|
- lib/parsers/wallaby/parser.rb
|
178
265
|
- lib/responders/wallaby/json_api_responder.rb
|
179
266
|
- lib/responders/wallaby/resources_responder.rb
|
267
|
+
- lib/routes/wallaby/engines/base_route.rb
|
268
|
+
- lib/routes/wallaby/engines/custom_app_route.rb
|
269
|
+
- lib/routes/wallaby/engines/engine_route.rb
|
180
270
|
- lib/routes/wallaby/resources_router.rb
|
181
271
|
- lib/servicers/wallaby/model_servicer.rb
|
272
|
+
- lib/services/wallaby/authorizer_finder.rb
|
273
|
+
- lib/services/wallaby/class_finder.rb
|
274
|
+
- lib/services/wallaby/controller_finder.rb
|
275
|
+
- lib/services/wallaby/decorator_finder.rb
|
276
|
+
- lib/services/wallaby/default_models_excluder.rb
|
182
277
|
- lib/services/wallaby/engine_name_finder.rb
|
183
278
|
- lib/services/wallaby/engine_url_for.rb
|
279
|
+
- lib/services/wallaby/fields_regulator.rb
|
184
280
|
- lib/services/wallaby/link_options_normalizer.rb
|
185
281
|
- lib/services/wallaby/map/mode_mapper.rb
|
186
|
-
- lib/services/wallaby/map/model_class_collector.rb
|
187
282
|
- lib/services/wallaby/map/model_class_mapper.rb
|
283
|
+
- lib/services/wallaby/model_class_filter.rb
|
284
|
+
- lib/services/wallaby/paginator_finder.rb
|
188
285
|
- lib/services/wallaby/prefixes_builder.rb
|
286
|
+
- lib/services/wallaby/servicer_finder.rb
|
189
287
|
- lib/services/wallaby/sorting/hash_builder.rb
|
190
288
|
- lib/services/wallaby/sorting/link_builder.rb
|
191
289
|
- lib/services/wallaby/sorting/next_builder.rb
|
192
290
|
- lib/services/wallaby/sorting/single_builder.rb
|
193
|
-
- lib/services/wallaby/type_renderer.rb
|
194
291
|
- lib/support/action_dispatch/routing/mapper.rb
|
195
292
|
- lib/tree/wallaby/node.rb
|
196
293
|
- lib/utils/wallaby/field_utils.rb
|
197
294
|
- lib/utils/wallaby/filter_utils.rb
|
295
|
+
- lib/utils/wallaby/inflector.rb
|
198
296
|
- lib/utils/wallaby/locale.rb
|
199
|
-
- lib/utils/wallaby/model_utils.rb
|
200
297
|
- lib/utils/wallaby/module_utils.rb
|
201
298
|
- lib/utils/wallaby/params_utils.rb
|
202
|
-
- lib/utils/wallaby/test_utils.rb
|
203
299
|
- lib/utils/wallaby/utils.rb
|
204
300
|
- lib/wallaby/class_array.rb
|
205
301
|
- lib/wallaby/class_hash.rb
|
@@ -215,7 +311,9 @@ files:
|
|
215
311
|
- lib/wallaby/constants.rb
|
216
312
|
- lib/wallaby/core.rb
|
217
313
|
- lib/wallaby/core/version.rb
|
314
|
+
- lib/wallaby/deprecator.rb
|
218
315
|
- lib/wallaby/engine.rb
|
316
|
+
- lib/wallaby/guesser.rb
|
219
317
|
- lib/wallaby/logger.rb
|
220
318
|
- lib/wallaby/map.rb
|
221
319
|
- lib/wallaby/preloader.rb
|
@@ -226,6 +324,7 @@ metadata:
|
|
226
324
|
homepage_uri: https://github.com/wallaby-rails/wallaby-core
|
227
325
|
source_code_uri: https://github.com/wallaby-rails/wallaby-core
|
228
326
|
changelog_uri: https://github.com/wallaby-rails/wallaby-core/blob/master/CHANGELOG.md
|
327
|
+
rubygems_mfa_required: 'true'
|
229
328
|
post_install_message:
|
230
329
|
rdoc_options: []
|
231
330
|
require_paths:
|
@@ -241,7 +340,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
241
340
|
- !ruby/object:Gem::Version
|
242
341
|
version: '0'
|
243
342
|
requirements: []
|
244
|
-
rubygems_version: 3.
|
343
|
+
rubygems_version: 3.5.5
|
245
344
|
signing_key:
|
246
345
|
specification_version: 4
|
247
346
|
summary: The core of Wallaby
|
@@ -1,9 +0,0 @@
|
|
1
|
-
en:
|
2
|
-
wallaby:
|
3
|
-
map:
|
4
|
-
missing_mode_for_model_class: "Don't know how to handle this model %{model}."
|
5
|
-
model_class_mapper:
|
6
|
-
missing_model_class: "Please define self.model_class for %{model} or set it as global.\n @see Wallaby.configuration.mapping"
|
7
|
-
|
8
|
-
mode:
|
9
|
-
inherit_required: '%{klass} must inherit from %{parent}.'
|
@@ -1,38 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Wallaby
|
4
|
-
# Defaults related methods
|
5
|
-
module Defaultable
|
6
|
-
protected
|
7
|
-
|
8
|
-
# Set default options for create action
|
9
|
-
# @param options [Hash]
|
10
|
-
# @return [Hash] updated options with default values
|
11
|
-
def set_defaults_for(action, options)
|
12
|
-
case action.try(:to_sym)
|
13
|
-
when :create, :update then assign_create_and_update_defaults_with options
|
14
|
-
when :destroy then assign_destroy_defaults_with options
|
15
|
-
end
|
16
|
-
options
|
17
|
-
end
|
18
|
-
|
19
|
-
# @param options [Hash]
|
20
|
-
# @return [Hash] updated options with default values
|
21
|
-
def assign_create_and_update_defaults_with(options)
|
22
|
-
options[:params] ||= resource_params
|
23
|
-
options[:location] ||= -> { helpers.show_path resource, is_resource: params[:resource] }
|
24
|
-
end
|
25
|
-
|
26
|
-
# @param options [Hash]
|
27
|
-
# @return [Hash] updated options with default values
|
28
|
-
def assign_destroy_defaults_with(options)
|
29
|
-
options[:params] ||= params
|
30
|
-
options[:location] ||=
|
31
|
-
if params[:resource]
|
32
|
-
helpers.show_path resource, is_resource: params[:resource]
|
33
|
-
else
|
34
|
-
helpers.index_path current_model_class
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
@@ -1,22 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Wallaby
|
4
|
-
# Shared helpers
|
5
|
-
module SharedHelpers
|
6
|
-
protected
|
7
|
-
|
8
|
-
# Fetch value for given attribute.
|
9
|
-
#
|
10
|
-
# If it's used in controller, it will fetch it from class attribute.
|
11
|
-
# If it's used in view, it will fetch it from controller.
|
12
|
-
# @param attribute_name [String, Symbol] instance attribute name
|
13
|
-
# @param class_attribute_name [String, Symbol] class attribute name
|
14
|
-
# @return [Object] the value
|
15
|
-
def controller_to_get(attribute_name, class_attribute_name = nil)
|
16
|
-
class_attribute_name ||= attribute_name
|
17
|
-
return ModuleUtils.try_to self.class, class_attribute_name if is_a? ::ActionController::Base # controller?
|
18
|
-
|
19
|
-
ModuleUtils.try_to controller, attribute_name # view?
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
@@ -1,49 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Wallaby
|
4
|
-
class Map
|
5
|
-
# To collect model classes that are configured to be handled by Wallaby
|
6
|
-
class ModelClassCollector
|
7
|
-
# @param configuration [Configuration]
|
8
|
-
# @param models [Array<Class>]
|
9
|
-
def initialize(configuration, models = nil)
|
10
|
-
@configuration = configuration
|
11
|
-
@models = ClassArray.new(models || [])
|
12
|
-
end
|
13
|
-
|
14
|
-
# @return [Array<Class>] model class
|
15
|
-
def collect
|
16
|
-
return @models - excluded_models if configured_models.blank?
|
17
|
-
|
18
|
-
invalid_models_check
|
19
|
-
configured_models
|
20
|
-
end
|
21
|
-
|
22
|
-
private
|
23
|
-
|
24
|
-
# Check if the models are valid, raise if invalid
|
25
|
-
def invalid_models_check
|
26
|
-
invalid_models = configured_models - @models
|
27
|
-
return if invalid_models.blank?
|
28
|
-
|
29
|
-
message = Locale.t 'errors.invalid.models', models: invalid_models.to_sentence
|
30
|
-
raise InvalidError, message
|
31
|
-
end
|
32
|
-
|
33
|
-
# @return [Wallaby::Configuration::Models]
|
34
|
-
def models
|
35
|
-
@configuration.models
|
36
|
-
end
|
37
|
-
|
38
|
-
# @return [Array<Class>] a list of models to exclude
|
39
|
-
def excluded_models
|
40
|
-
models.excludes
|
41
|
-
end
|
42
|
-
|
43
|
-
# @return [Array<Class>] a list of models to set
|
44
|
-
def configured_models
|
45
|
-
models.presence
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|
@@ -1,40 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Wallaby
|
4
|
-
# Type renderer
|
5
|
-
class TypeRenderer
|
6
|
-
class << self
|
7
|
-
# Render partial
|
8
|
-
# @param view [ActionView]
|
9
|
-
# @param options [Hash]
|
10
|
-
# @param locals [Hash]
|
11
|
-
# @return [String] HTML
|
12
|
-
def render(view, options = {}, locals = {}, &block)
|
13
|
-
locals[:object] ||= locals[:form].try :object
|
14
|
-
check locals
|
15
|
-
complete locals, view.params[:action]
|
16
|
-
view.render options, locals, &block
|
17
|
-
end
|
18
|
-
|
19
|
-
private
|
20
|
-
|
21
|
-
# @param locals [Hash]
|
22
|
-
# @raise [ArgumentError] if form is set but blank
|
23
|
-
# @raise [ArgumentError] if field_name is not provided
|
24
|
-
# @raise [ArgumentError] if object is not decorated
|
25
|
-
def check(locals)
|
26
|
-
raise ArgumentError, Locale.t('errors.required', subject: 'form') if locals.key?(:form) && locals[:form].blank?
|
27
|
-
raise ArgumentError, Locale.t('errors.required', subject: 'field_name') if locals[:field_name].blank?
|
28
|
-
raise ArgumentError, 'Object is not decorated.' unless locals[:object].is_a? ResourceDecorator
|
29
|
-
end
|
30
|
-
|
31
|
-
# @param locals [Hash]
|
32
|
-
# @param action [String]
|
33
|
-
def complete(locals, action)
|
34
|
-
action_name = FORM_ACTIONS[action] || action
|
35
|
-
locals[:metadata] = locals[:object].public_send :"#{action_name}_metadata_of", locals[:field_name]
|
36
|
-
locals[:value] = locals[:object].public_send locals[:field_name]
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
@@ -1,52 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Wallaby
|
4
|
-
# Model related utils
|
5
|
-
module ModelUtils
|
6
|
-
class << self
|
7
|
-
# Convert model class (e.g. `Namespace::Product`) into resources name (e.g. `namespace::products`)
|
8
|
-
# @param model_class [Class, String] model class
|
9
|
-
# @return [String] resources name
|
10
|
-
def to_resources_name(model_class)
|
11
|
-
return EMPTY_STRING if model_class.blank?
|
12
|
-
|
13
|
-
model_class.to_s.underscore.gsub(SLASH, COLONS).pluralize
|
14
|
-
end
|
15
|
-
|
16
|
-
# Produce model label (e.g. `Namespace / Product`) for model class (e.g. `Namespace::Product`)
|
17
|
-
# @param model_class [Class, String] model class
|
18
|
-
# @return [String] model label
|
19
|
-
def to_model_label(model_class)
|
20
|
-
# TODO: change to use i18n translation
|
21
|
-
return EMPTY_STRING if model_class.blank?
|
22
|
-
|
23
|
-
model_class_name = to_model_name model_class
|
24
|
-
model_class_name.titleize.gsub(SLASH, SPACE + SLASH + SPACE)
|
25
|
-
end
|
26
|
-
|
27
|
-
# Convert resources name (e.g. `namespace::products`) into model class (e.g. `Namespace::Product`)
|
28
|
-
# @param resources_name [String] resources name
|
29
|
-
# @return [Class] model class
|
30
|
-
# @return [nil] when not found
|
31
|
-
def to_model_class(resources_name)
|
32
|
-
return if resources_name.blank?
|
33
|
-
|
34
|
-
class_name = to_model_name resources_name
|
35
|
-
# NOTE: DO NOT try to use const_defined? and const_get EVER.
|
36
|
-
# This is Rails, use constantize
|
37
|
-
class_name.constantize
|
38
|
-
rescue NameError
|
39
|
-
Logger.warn Locale.t('errors.not_found.model', model: class_name), sourcing: 2..10
|
40
|
-
end
|
41
|
-
|
42
|
-
# Convert resources name (e.g. `namespace::products`) into model name (e.g. `Namespace::Product`)
|
43
|
-
# @param resources_name [String] resources name
|
44
|
-
# @return [String] model name
|
45
|
-
def to_model_name(resources_name)
|
46
|
-
return EMPTY_STRING if resources_name.blank?
|
47
|
-
|
48
|
-
resources_name.to_s.singularize.gsub(COLONS, SLASH).camelize
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
@@ -1,34 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Wallaby
|
4
|
-
# Utils for test
|
5
|
-
module TestUtils
|
6
|
-
class << self
|
7
|
-
# @param context
|
8
|
-
# @param controller_class [Class]
|
9
|
-
def around_crud(context, controller_class = nil)
|
10
|
-
context.before do
|
11
|
-
controller_class ||= described_class
|
12
|
-
controller_path = controller_class.controller_path
|
13
|
-
Wallaby::TestUtils.draw(routes, controller_path)
|
14
|
-
end
|
15
|
-
|
16
|
-
context.after { Rails.application.reload_routes! }
|
17
|
-
end
|
18
|
-
|
19
|
-
# @param routes
|
20
|
-
# @param controller_path [String]
|
21
|
-
def draw(routes, controller_path)
|
22
|
-
routes.draw do
|
23
|
-
get ':resources', to: "#{controller_path}#index", as: :resources
|
24
|
-
get ':resources/:id', to: "#{controller_path}#show", as: :resource
|
25
|
-
get ':resources/new', to: "#{controller_path}#new"
|
26
|
-
get ':resources/:id/edit', to: "#{controller_path}#edit"
|
27
|
-
post ':resources', to: "#{controller_path}#create"
|
28
|
-
patch ':resources/:id', to: "#{controller_path}#update"
|
29
|
-
delete ':resources/:id', to: "#{controller_path}#destroy"
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|