auxiliary_rails 0.3.1 → 0.4.1
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/.github/workflows/main.yml +32 -0
- data/.github/workflows/publish-gpr.yml +32 -0
- data/.github/workflows/publish-rubygems.yml +31 -0
- data/.rubocop.yml +10 -6
- data/.rubocop_todo.yml +1 -7
- data/.ruby-version +1 -1
- data/CHANGELOG.md +11 -1
- data/CODE_OF_CONDUCT.md +128 -0
- data/Gemfile +9 -1
- data/Gemfile.lock +175 -138
- data/README.md +77 -17
- data/auxiliary_rails.gemspec +12 -15
- data/bin/rspec +29 -0
- data/lib/auxiliary_rails/application/command.rb +3 -6
- data/lib/auxiliary_rails/application/error.rb +44 -4
- data/lib/auxiliary_rails/application/form.rb +1 -0
- data/lib/auxiliary_rails/application/query.rb +11 -7
- data/lib/auxiliary_rails/application/service.rb +42 -0
- data/lib/auxiliary_rails/concerns/callable.rb +23 -0
- data/lib/auxiliary_rails/concerns/errorable.rb +12 -12
- data/lib/auxiliary_rails/concerns/performable.rb +14 -22
- data/lib/auxiliary_rails/railtie.rb +2 -1
- data/lib/auxiliary_rails/version.rb +1 -1
- data/lib/auxiliary_rails/view_helpers/display_helper.rb +30 -0
- data/lib/auxiliary_rails/view_helpers.rb +4 -0
- data/lib/auxiliary_rails.rb +3 -1
- data/lib/generators/auxiliary_rails/install_errors_controller_generator.rb +31 -0
- data/lib/generators/auxiliary_rails/install_generator.rb +1 -0
- data/lib/generators/auxiliary_rails/service_generator.rb +48 -0
- data/lib/generators/auxiliary_rails/templates/commands/command_spec_template.rb +1 -1
- data/lib/generators/auxiliary_rails/templates/errors_controller/errors_controller_template.rb +15 -0
- data/lib/generators/auxiliary_rails/templates/errors_controller/not_found_template.html.erb +2 -0
- data/lib/generators/auxiliary_rails/templates/errors_controller/show_template.html.erb +1 -0
- data/lib/generators/auxiliary_rails/templates/errors_controller/unacceptable_template.html.erb +2 -0
- data/lib/generators/auxiliary_rails/templates/services/service_spec_template.rb +5 -0
- data/lib/generators/auxiliary_rails/templates/services/service_template.rb +10 -0
- metadata +24 -111
data/Gemfile.lock
CHANGED
@@ -1,184 +1,220 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
auxiliary_rails (0.
|
4
|
+
auxiliary_rails (0.4.1)
|
5
5
|
dry-core
|
6
6
|
dry-initializer
|
7
7
|
dry-initializer-rails
|
8
|
-
rails (>= 5.2
|
8
|
+
rails (>= 5.2)
|
9
9
|
thor
|
10
10
|
|
11
11
|
GEM
|
12
12
|
remote: https://rubygems.org/
|
13
13
|
specs:
|
14
|
-
actioncable (
|
15
|
-
actionpack (=
|
14
|
+
actioncable (7.0.6)
|
15
|
+
actionpack (= 7.0.6)
|
16
|
+
activesupport (= 7.0.6)
|
16
17
|
nio4r (~> 2.0)
|
17
18
|
websocket-driver (>= 0.6.1)
|
18
|
-
actionmailbox (
|
19
|
-
actionpack (=
|
20
|
-
activejob (=
|
21
|
-
activerecord (=
|
22
|
-
activestorage (=
|
23
|
-
activesupport (=
|
19
|
+
actionmailbox (7.0.6)
|
20
|
+
actionpack (= 7.0.6)
|
21
|
+
activejob (= 7.0.6)
|
22
|
+
activerecord (= 7.0.6)
|
23
|
+
activestorage (= 7.0.6)
|
24
|
+
activesupport (= 7.0.6)
|
24
25
|
mail (>= 2.7.1)
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
26
|
+
net-imap
|
27
|
+
net-pop
|
28
|
+
net-smtp
|
29
|
+
actionmailer (7.0.6)
|
30
|
+
actionpack (= 7.0.6)
|
31
|
+
actionview (= 7.0.6)
|
32
|
+
activejob (= 7.0.6)
|
33
|
+
activesupport (= 7.0.6)
|
29
34
|
mail (~> 2.5, >= 2.5.4)
|
35
|
+
net-imap
|
36
|
+
net-pop
|
37
|
+
net-smtp
|
30
38
|
rails-dom-testing (~> 2.0)
|
31
|
-
actionpack (
|
32
|
-
actionview (=
|
33
|
-
activesupport (=
|
34
|
-
rack (~> 2.0, >= 2.
|
39
|
+
actionpack (7.0.6)
|
40
|
+
actionview (= 7.0.6)
|
41
|
+
activesupport (= 7.0.6)
|
42
|
+
rack (~> 2.0, >= 2.2.4)
|
35
43
|
rack-test (>= 0.6.3)
|
36
44
|
rails-dom-testing (~> 2.0)
|
37
45
|
rails-html-sanitizer (~> 1.0, >= 1.2.0)
|
38
|
-
actiontext (
|
39
|
-
actionpack (=
|
40
|
-
activerecord (=
|
41
|
-
activestorage (=
|
42
|
-
activesupport (=
|
46
|
+
actiontext (7.0.6)
|
47
|
+
actionpack (= 7.0.6)
|
48
|
+
activerecord (= 7.0.6)
|
49
|
+
activestorage (= 7.0.6)
|
50
|
+
activesupport (= 7.0.6)
|
51
|
+
globalid (>= 0.6.0)
|
43
52
|
nokogiri (>= 1.8.5)
|
44
|
-
actionview (
|
45
|
-
activesupport (=
|
53
|
+
actionview (7.0.6)
|
54
|
+
activesupport (= 7.0.6)
|
46
55
|
builder (~> 3.1)
|
47
56
|
erubi (~> 1.4)
|
48
57
|
rails-dom-testing (~> 2.0)
|
49
58
|
rails-html-sanitizer (~> 1.1, >= 1.2.0)
|
50
|
-
activejob (
|
51
|
-
activesupport (=
|
59
|
+
activejob (7.0.6)
|
60
|
+
activesupport (= 7.0.6)
|
52
61
|
globalid (>= 0.3.6)
|
53
|
-
activemodel (
|
54
|
-
activesupport (=
|
55
|
-
activerecord (
|
56
|
-
activemodel (=
|
57
|
-
activesupport (=
|
58
|
-
activestorage (
|
59
|
-
actionpack (=
|
60
|
-
activejob (=
|
61
|
-
activerecord (=
|
62
|
-
|
63
|
-
|
62
|
+
activemodel (7.0.6)
|
63
|
+
activesupport (= 7.0.6)
|
64
|
+
activerecord (7.0.6)
|
65
|
+
activemodel (= 7.0.6)
|
66
|
+
activesupport (= 7.0.6)
|
67
|
+
activestorage (7.0.6)
|
68
|
+
actionpack (= 7.0.6)
|
69
|
+
activejob (= 7.0.6)
|
70
|
+
activerecord (= 7.0.6)
|
71
|
+
activesupport (= 7.0.6)
|
72
|
+
marcel (~> 1.0)
|
73
|
+
mini_mime (>= 1.1.0)
|
74
|
+
activesupport (7.0.6)
|
64
75
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
65
|
-
i18n (>=
|
66
|
-
minitest (
|
67
|
-
tzinfo (~>
|
68
|
-
|
69
|
-
ast (2.4.0)
|
76
|
+
i18n (>= 1.6, < 2)
|
77
|
+
minitest (>= 5.1)
|
78
|
+
tzinfo (~> 2.0)
|
79
|
+
ast (2.4.2)
|
70
80
|
builder (3.2.4)
|
71
|
-
coderay (1.1.
|
72
|
-
concurrent-ruby (1.
|
81
|
+
coderay (1.1.3)
|
82
|
+
concurrent-ruby (1.2.2)
|
73
83
|
crass (1.0.6)
|
74
|
-
|
75
|
-
|
84
|
+
date (3.3.3)
|
85
|
+
diff-lcs (1.5.0)
|
86
|
+
dry-core (1.0.0)
|
76
87
|
concurrent-ruby (~> 1.0)
|
77
|
-
|
88
|
+
zeitwerk (~> 2.6)
|
89
|
+
dry-initializer (3.1.1)
|
78
90
|
dry-initializer-rails (3.1.1)
|
79
91
|
dry-initializer (>= 2.4, < 4)
|
80
92
|
rails (> 3.0)
|
81
|
-
erubi (1.
|
82
|
-
globalid (
|
83
|
-
activesupport (>=
|
84
|
-
i18n (1.
|
93
|
+
erubi (1.12.0)
|
94
|
+
globalid (1.1.0)
|
95
|
+
activesupport (>= 5.0)
|
96
|
+
i18n (1.14.1)
|
85
97
|
concurrent-ruby (~> 1.0)
|
86
|
-
|
87
|
-
|
98
|
+
json (2.6.3)
|
99
|
+
language_server-protocol (3.17.0.3)
|
100
|
+
loofah (2.21.3)
|
88
101
|
crass (~> 1.0.2)
|
89
|
-
nokogiri (>= 1.
|
90
|
-
mail (2.
|
102
|
+
nokogiri (>= 1.12.0)
|
103
|
+
mail (2.8.1)
|
91
104
|
mini_mime (>= 0.1.1)
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
105
|
+
net-imap
|
106
|
+
net-pop
|
107
|
+
net-smtp
|
108
|
+
marcel (1.0.2)
|
109
|
+
method_source (1.0.0)
|
110
|
+
mini_mime (1.1.2)
|
111
|
+
mini_portile2 (2.8.4)
|
112
|
+
minitest (5.18.1)
|
113
|
+
net-imap (0.3.6)
|
114
|
+
date
|
115
|
+
net-protocol
|
116
|
+
net-pop (0.1.2)
|
117
|
+
net-protocol
|
118
|
+
net-protocol (0.2.1)
|
119
|
+
timeout
|
120
|
+
net-smtp (0.3.3)
|
121
|
+
net-protocol
|
122
|
+
nio4r (2.5.9)
|
123
|
+
nokogiri (1.15.3)
|
124
|
+
mini_portile2 (~> 2.8.2)
|
125
|
+
racc (~> 1.4)
|
126
|
+
parallel (1.23.0)
|
127
|
+
parser (3.2.2.3)
|
128
|
+
ast (~> 2.4.1)
|
129
|
+
racc
|
130
|
+
pry (0.14.2)
|
131
|
+
coderay (~> 1.1)
|
132
|
+
method_source (~> 1.0)
|
133
|
+
racc (1.7.1)
|
134
|
+
rack (2.2.7)
|
135
|
+
rack-test (2.1.0)
|
136
|
+
rack (>= 1.3)
|
137
|
+
rails (7.0.6)
|
138
|
+
actioncable (= 7.0.6)
|
139
|
+
actionmailbox (= 7.0.6)
|
140
|
+
actionmailer (= 7.0.6)
|
141
|
+
actionpack (= 7.0.6)
|
142
|
+
actiontext (= 7.0.6)
|
143
|
+
actionview (= 7.0.6)
|
144
|
+
activejob (= 7.0.6)
|
145
|
+
activemodel (= 7.0.6)
|
146
|
+
activerecord (= 7.0.6)
|
147
|
+
activestorage (= 7.0.6)
|
148
|
+
activesupport (= 7.0.6)
|
149
|
+
bundler (>= 1.15.0)
|
150
|
+
railties (= 7.0.6)
|
151
|
+
rails-dom-testing (2.1.1)
|
152
|
+
activesupport (>= 5.0.0)
|
153
|
+
minitest
|
128
154
|
nokogiri (>= 1.6)
|
129
|
-
rails-html-sanitizer (1.
|
130
|
-
loofah (~> 2.
|
131
|
-
|
132
|
-
|
133
|
-
|
155
|
+
rails-html-sanitizer (1.6.0)
|
156
|
+
loofah (~> 2.21)
|
157
|
+
nokogiri (~> 1.14)
|
158
|
+
railties (7.0.6)
|
159
|
+
actionpack (= 7.0.6)
|
160
|
+
activesupport (= 7.0.6)
|
134
161
|
method_source
|
135
|
-
rake (>=
|
136
|
-
thor (
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
rspec-
|
144
|
-
|
145
|
-
rspec-
|
146
|
-
rspec-
|
162
|
+
rake (>= 12.2)
|
163
|
+
thor (~> 1.0)
|
164
|
+
zeitwerk (~> 2.5)
|
165
|
+
rainbow (3.1.1)
|
166
|
+
rake (13.0.6)
|
167
|
+
regexp_parser (2.8.1)
|
168
|
+
rexml (3.2.5)
|
169
|
+
rspec (3.12.0)
|
170
|
+
rspec-core (~> 3.12.0)
|
171
|
+
rspec-expectations (~> 3.12.0)
|
172
|
+
rspec-mocks (~> 3.12.0)
|
173
|
+
rspec-core (3.12.2)
|
174
|
+
rspec-support (~> 3.12.0)
|
175
|
+
rspec-expectations (3.12.3)
|
147
176
|
diff-lcs (>= 1.2.0, < 2.0)
|
148
|
-
rspec-support (~> 3.
|
149
|
-
rspec-mocks (3.
|
177
|
+
rspec-support (~> 3.12.0)
|
178
|
+
rspec-mocks (3.12.6)
|
150
179
|
diff-lcs (>= 1.2.0, < 2.0)
|
151
|
-
rspec-support (~> 3.
|
152
|
-
rspec-support (3.
|
153
|
-
rubocop (
|
154
|
-
|
180
|
+
rspec-support (~> 3.12.0)
|
181
|
+
rspec-support (3.12.1)
|
182
|
+
rubocop (1.54.2)
|
183
|
+
json (~> 2.3)
|
184
|
+
language_server-protocol (>= 3.17.0)
|
155
185
|
parallel (~> 1.10)
|
156
|
-
parser (>= 2.
|
186
|
+
parser (>= 3.2.2.3)
|
157
187
|
rainbow (>= 2.2.2, < 4.0)
|
158
|
-
|
188
|
+
regexp_parser (>= 1.8, < 3.0)
|
189
|
+
rexml (>= 3.2.5, < 4.0)
|
190
|
+
rubocop-ast (>= 1.28.0, < 2.0)
|
159
191
|
ruby-progressbar (~> 1.7)
|
160
|
-
unicode-display_width (>=
|
161
|
-
rubocop-
|
162
|
-
|
163
|
-
rubocop-
|
164
|
-
rubocop (
|
165
|
-
|
166
|
-
|
192
|
+
unicode-display_width (>= 2.4.0, < 3.0)
|
193
|
+
rubocop-ast (1.29.0)
|
194
|
+
parser (>= 3.2.1.0)
|
195
|
+
rubocop-capybara (2.18.0)
|
196
|
+
rubocop (~> 1.41)
|
197
|
+
rubocop-factory_bot (2.23.1)
|
198
|
+
rubocop (~> 1.33)
|
199
|
+
rubocop-performance (1.18.0)
|
200
|
+
rubocop (>= 1.7.0, < 2.0)
|
201
|
+
rubocop-ast (>= 0.4.0)
|
202
|
+
rubocop-rake (0.6.0)
|
203
|
+
rubocop (~> 1.0)
|
204
|
+
rubocop-rspec (2.22.0)
|
205
|
+
rubocop (~> 1.33)
|
206
|
+
rubocop-capybara (~> 2.17)
|
207
|
+
rubocop-factory_bot (~> 2.22)
|
208
|
+
ruby-progressbar (1.13.0)
|
209
|
+
thor (1.2.2)
|
210
|
+
timeout (0.4.0)
|
211
|
+
tzinfo (2.0.6)
|
167
212
|
concurrent-ruby (~> 1.0)
|
168
|
-
|
169
|
-
|
170
|
-
actionpack (>= 4.0)
|
171
|
-
activesupport (>= 4.0)
|
172
|
-
sprockets (>= 3.0.0)
|
173
|
-
thor (1.0.1)
|
174
|
-
thread_safe (0.3.6)
|
175
|
-
tzinfo (1.2.6)
|
176
|
-
thread_safe (~> 0.1)
|
177
|
-
unicode-display_width (1.6.1)
|
178
|
-
websocket-driver (0.7.1)
|
213
|
+
unicode-display_width (2.4.2)
|
214
|
+
websocket-driver (0.7.5)
|
179
215
|
websocket-extensions (>= 0.1.0)
|
180
216
|
websocket-extensions (0.1.5)
|
181
|
-
zeitwerk (2.
|
217
|
+
zeitwerk (2.6.8)
|
182
218
|
|
183
219
|
PLATFORMS
|
184
220
|
ruby
|
@@ -189,9 +225,10 @@ DEPENDENCIES
|
|
189
225
|
pry
|
190
226
|
rake
|
191
227
|
rspec (~> 3.8)
|
192
|
-
rubocop (~>
|
228
|
+
rubocop (~> 1.54)
|
193
229
|
rubocop-performance
|
230
|
+
rubocop-rake
|
194
231
|
rubocop-rspec
|
195
232
|
|
196
233
|
BUNDLED WITH
|
197
|
-
2.
|
234
|
+
2.4.17
|
data/README.md
CHANGED
@@ -3,7 +3,6 @@
|
|
3
3
|
Collection of classes, configs, scripts, generators for Ruby on Rails helping you get things done, better.
|
4
4
|
|
5
5
|
[](https://rubygems.org/gems/auxiliary_rails)
|
6
|
-
[](https://travis-ci.org/ergoserv/auxiliary_rails)
|
7
6
|
[](https://codeclimate.com/github/ergoserv/auxiliary_rails/maintainability)
|
8
7
|
|
9
8
|
## Installation
|
@@ -11,12 +10,15 @@ Collection of classes, configs, scripts, generators for Ruby on Rails helping yo
|
|
11
10
|
Add one of these lines to your application's `Gemfile`:
|
12
11
|
|
13
12
|
```ruby
|
14
|
-
# version released to RubyGems
|
13
|
+
# version released to RubyGems (recommended)
|
15
14
|
gem 'auxiliary_rails'
|
15
|
+
|
16
16
|
# or latest version from the repository
|
17
17
|
gem 'auxiliary_rails', git: 'https://github.com/ergoserv/auxiliary_rails'
|
18
|
-
# or from a specific branch of the repository
|
18
|
+
# or from a specific branch of the GitHub repository
|
19
19
|
gem 'auxiliary_rails', github: 'ergoserv/auxiliary_rails', branch: 'develop'
|
20
|
+
# or from a local path (for development and testing purposes)
|
21
|
+
gem 'auxiliary_rails', path: '../auxiliary_rails'
|
20
22
|
```
|
21
23
|
|
22
24
|
And then execute:
|
@@ -56,17 +58,35 @@ rails generate auxiliary_rails:install
|
|
56
58
|
# Install one by one
|
57
59
|
rails generate auxiliary_rails:install_commands
|
58
60
|
rails generate auxiliary_rails:install_errors
|
61
|
+
rails generate auxiliary_rails:install_errors_controller
|
59
62
|
|
60
63
|
# API resource generator
|
61
64
|
rails generate auxiliary_rails:api_resource
|
62
65
|
|
63
66
|
# Command generator
|
64
67
|
rails generate auxiliary_rails:command
|
68
|
+
|
69
|
+
# Service generator
|
70
|
+
rails generate auxiliary_rails:service
|
71
|
+
```
|
72
|
+
|
73
|
+
### API Resources
|
74
|
+
|
75
|
+
Read article [Building an API](https://github.com/ergoserv/handbook/blob/master/guides/building_api.md) for more details.
|
76
|
+
|
77
|
+
Use generator to generate appropriate classes and files (Resource, Entity, Helper, Spec) for the specified end-point:
|
78
|
+
|
79
|
+
```sh
|
80
|
+
rails generate auxiliary_rails:api_resource
|
65
81
|
```
|
66
82
|
|
83
|
+
## Application
|
84
|
+
|
67
85
|
### Command Objects
|
68
86
|
|
69
|
-
Variation of implementation of [Command pattern](https://
|
87
|
+
Variation of implementation of [Command pattern](https://refactoring.guru/design-patterns/command).
|
88
|
+
|
89
|
+
Read post [Command Objects - a.k.a Service Objects in Ruby on Rails - The Ergonomic Way](https://www.ergoserv.com/blog/command-objects-aka-service-objects-in-ruby-on-rails-the-ergonomic-way) for more details.
|
70
90
|
|
71
91
|
```ruby
|
72
92
|
# app/commands/application_command.rb
|
@@ -81,8 +101,8 @@ class RegisterUserCommand < ApplicationCommand
|
|
81
101
|
param :email
|
82
102
|
param :password
|
83
103
|
|
84
|
-
# Define the results of the command
|
85
|
-
#
|
104
|
+
# Define the results of the command using `attr_reader`
|
105
|
+
# and set it as a regular instance var inside the command
|
86
106
|
attr_reader :user
|
87
107
|
|
88
108
|
# Regular Active Model Validations can be used to validate params
|
@@ -90,9 +110,11 @@ class RegisterUserCommand < ApplicationCommand
|
|
90
110
|
# Use #valid?, #invalid?, #validate! methods to engage validations
|
91
111
|
validates :password, length: { in: 8..32 }
|
92
112
|
|
93
|
-
# Define the only public method `#perform`
|
94
|
-
# where command's flow is defined
|
113
|
+
# Define the only public method `#perform` where command's flow is defined
|
95
114
|
def perform
|
115
|
+
# Use `return failure!` and `return success!` inside `#perform` method
|
116
|
+
# to control exits from the command with appropriate status.
|
117
|
+
|
96
118
|
# Use `return failure!` to exit from the command with failure
|
97
119
|
return failure! if registration_disabled?
|
98
120
|
|
@@ -100,27 +122,27 @@ class RegisterUserCommand < ApplicationCommand
|
|
100
122
|
transaction do
|
101
123
|
# Keep the `#perform` method short and clean, put all the steps, actions
|
102
124
|
# and business logic into meaningful and self-explanatory methods
|
103
|
-
create_user
|
125
|
+
@user = create_user
|
104
126
|
|
105
127
|
# Use `error!` method to interrupt the flow raising an error
|
106
|
-
error! unless
|
128
|
+
error! unless user.persistent?
|
107
129
|
|
108
|
-
|
130
|
+
send_notifications
|
109
131
|
# ...
|
110
132
|
end
|
111
133
|
|
112
|
-
# Always end the `#perform` method with `success
|
113
|
-
#
|
134
|
+
# Always end the `#perform` method with `success!`.
|
135
|
+
# It will set the proper command's execution status.
|
114
136
|
success!
|
115
137
|
end
|
116
138
|
|
117
139
|
private
|
118
140
|
|
119
141
|
def create_user
|
120
|
-
|
142
|
+
User.create(email: email, password: password)
|
121
143
|
end
|
122
144
|
|
123
|
-
def
|
145
|
+
def send_notifications
|
124
146
|
# ...
|
125
147
|
end
|
126
148
|
end
|
@@ -150,6 +172,17 @@ class RegistrationsController
|
|
150
172
|
end
|
151
173
|
```
|
152
174
|
|
175
|
+
### Error Objects
|
176
|
+
|
177
|
+
Custom error objects.
|
178
|
+
Read article [Error Handling](https://github.com/ergoserv/handbook/blob/master/guides/error_handling.md) for more details.
|
179
|
+
|
180
|
+
```ruby
|
181
|
+
# app/errors/application_error.rb
|
182
|
+
class ApplicationError < AuxiliaryRails::Application::Error
|
183
|
+
end
|
184
|
+
```
|
185
|
+
|
153
186
|
### Form Objects
|
154
187
|
|
155
188
|
```ruby
|
@@ -252,7 +285,7 @@ end
|
|
252
285
|
### Usage ###
|
253
286
|
|
254
287
|
# it is possible to wrap query object in a scope and use as a regular scope
|
255
|
-
# app/models/
|
288
|
+
# app/models/author.rb
|
256
289
|
class Author < ApplicationRecord
|
257
290
|
scope :name_like, ->(value) { AuthorsQuery.call(name_like: value) }
|
258
291
|
end
|
@@ -263,11 +296,38 @@ authors = Author.name_like('Arthur')
|
|
263
296
|
authors = AuthorsWithBooksQuery.call(min_book_count: 10)
|
264
297
|
```
|
265
298
|
|
299
|
+
### Service Modules
|
300
|
+
|
301
|
+
Read [Service Modules](https://github.com/ergoserv/handbook/blob/master/guides/service_modules.md) for more details.
|
302
|
+
|
303
|
+
**Service Generator**
|
304
|
+
|
305
|
+
```sh
|
306
|
+
rails generate auxiliary_rails:service
|
307
|
+
```
|
308
|
+
|
309
|
+
**Service Config** - provides a unified access to a service configs and loads the first found from:
|
310
|
+
|
311
|
+
- Constant (`MyService::CONFIG`)
|
312
|
+
- Application config file (`config/settings.yml`, see gem [`config`](https://github.com/rubyconfig/config))
|
313
|
+
- Service config file (`config/services/my_service.yml`)
|
314
|
+
|
315
|
+
```ruby
|
316
|
+
# app/services/my_service.rb
|
317
|
+
module MyService
|
318
|
+
extend AuxiliaryRails::Application::Service
|
319
|
+
end
|
320
|
+
|
321
|
+
# usage
|
322
|
+
MyService.config.some_key
|
323
|
+
```
|
324
|
+
|
266
325
|
### View Helpers
|
267
326
|
|
268
327
|
```ruby
|
269
328
|
current_controller?(*ctrl_names)
|
270
329
|
current_action?(*action_names)
|
330
|
+
display_name(resource)
|
271
331
|
```
|
272
332
|
|
273
333
|
## Development
|
@@ -284,7 +344,7 @@ Bug reports and pull requests are welcome on GitHub at https://github.com/ergose
|
|
284
344
|
|
285
345
|
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
286
346
|
|
287
|
-
|
347
|
+
---
|
288
348
|
|
289
349
|
[](https://www.ergoserv.com)
|
290
350
|
|
data/auxiliary_rails.gemspec
CHANGED
@@ -8,9 +8,11 @@ Gem::Specification.new do |spec|
|
|
8
8
|
spec.authors = ['Dmitry Babenko', 'ErgoServ']
|
9
9
|
spec.email = ['dmitry@ergoserv.com', 'hello@ergoserv.com']
|
10
10
|
|
11
|
-
spec.summary
|
12
|
-
|
13
|
-
|
11
|
+
spec.summary = <<~DESC
|
12
|
+
AuxiliaryRails provides extra layers and utils
|
13
|
+
for helping to build solid and clean Ruby on Rails applications
|
14
|
+
DESC
|
15
|
+
spec.description = <<~DESC
|
14
16
|
AuxiliaryRails is a collection of classes, configs, scripts,
|
15
17
|
generators for Ruby on Rails helping you get things done, better.
|
16
18
|
DESC
|
@@ -20,6 +22,7 @@ Gem::Specification.new do |spec|
|
|
20
22
|
raise 'RubyGems 2.0 or newer is required' unless spec.respond_to?(:metadata)
|
21
23
|
|
22
24
|
spec.metadata['homepage_uri'] = spec.homepage
|
25
|
+
spec.metadata['rubygems_mfa_required'] = 'true'
|
23
26
|
spec.metadata['source_code_uri'] = spec.homepage
|
24
27
|
spec.metadata['changelog_uri'] = "#{spec.homepage}/releases"
|
25
28
|
|
@@ -31,17 +34,11 @@ Gem::Specification.new do |spec|
|
|
31
34
|
spec.executables = ['auxiliary_rails']
|
32
35
|
spec.require_paths = ['lib']
|
33
36
|
|
34
|
-
spec.
|
35
|
-
spec.add_development_dependency 'pry'
|
36
|
-
spec.add_development_dependency 'rake'
|
37
|
-
spec.add_development_dependency 'rspec', '~> 3.8'
|
38
|
-
spec.add_development_dependency 'rubocop', '~> 0.80'
|
39
|
-
spec.add_development_dependency 'rubocop-performance'
|
40
|
-
spec.add_development_dependency 'rubocop-rspec'
|
37
|
+
spec.required_ruby_version = '>= 2.5'
|
41
38
|
|
42
|
-
spec.
|
43
|
-
spec.
|
44
|
-
spec.
|
45
|
-
spec.
|
46
|
-
spec.
|
39
|
+
spec.add_dependency 'dry-core'
|
40
|
+
spec.add_dependency 'dry-initializer'
|
41
|
+
spec.add_dependency 'dry-initializer-rails'
|
42
|
+
spec.add_dependency 'rails', '>= 5.2'
|
43
|
+
spec.add_dependency 'thor'
|
47
44
|
end
|
data/bin/rspec
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
#
|
5
|
+
# This file was generated by Bundler.
|
6
|
+
#
|
7
|
+
# The application 'rspec' is installed as part of a gem, and
|
8
|
+
# this file is here to facilitate running it.
|
9
|
+
#
|
10
|
+
|
11
|
+
require "pathname"
|
12
|
+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
|
13
|
+
Pathname.new(__FILE__).realpath)
|
14
|
+
|
15
|
+
bundle_binstub = File.expand_path("../bundle", __FILE__)
|
16
|
+
|
17
|
+
if File.file?(bundle_binstub)
|
18
|
+
if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
|
19
|
+
load(bundle_binstub)
|
20
|
+
else
|
21
|
+
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
|
22
|
+
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
require "rubygems"
|
27
|
+
require "bundler/setup"
|
28
|
+
|
29
|
+
load Gem.bin_path("rspec-core", "rspec")
|
@@ -28,12 +28,9 @@ module AuxiliaryRails
|
|
28
28
|
# @param name [Symbol]
|
29
29
|
# @param options [Hash]
|
30
30
|
|
31
|
-
#
|
32
|
-
#
|
33
|
-
#
|
34
|
-
def call(*args)
|
35
|
-
new(*args).call
|
36
|
-
end
|
31
|
+
# @!method call(*args, **kws)
|
32
|
+
# @see AuxiliaryRails::Corcerns::Callable
|
33
|
+
# @return [self]
|
37
34
|
|
38
35
|
# Defines `scope` for <tt>ActiveModel::Translation</tt>
|
39
36
|
#
|