auxiliary_rails 0.2.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitlab-ci.yml +26 -0
- data/.rubocop.yml +31 -3
- data/.rubocop_todo.yml +3 -19
- data/.ruby-version +1 -1
- data/.yardopts +5 -0
- data/CHANGELOG.md +39 -2
- data/CODE_OF_CONDUCT.md +128 -0
- data/CONTRIBUTING.md +0 -6
- data/Gemfile.lock +164 -132
- data/README.md +267 -5
- data/auxiliary_rails.gemspec +18 -13
- data/bin/rspec +29 -0
- data/bin/rubocop +29 -0
- data/bitbucket-pipelines.yml +35 -0
- data/lib/auxiliary_rails/application/command.rb +53 -0
- data/lib/auxiliary_rails/application/error.rb +50 -0
- data/lib/auxiliary_rails/application/form.rb +31 -0
- data/lib/auxiliary_rails/application/query.rb +75 -0
- data/lib/auxiliary_rails/application/service.rb +42 -0
- data/lib/auxiliary_rails/cli.rb +18 -5
- data/lib/auxiliary_rails/concerns/callable.rb +23 -0
- data/lib/auxiliary_rails/concerns/errorable.rb +22 -0
- data/lib/auxiliary_rails/concerns/performable.rb +120 -0
- 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 +7 -3
- data/lib/generators/auxiliary_rails/command_generator.rb +1 -1
- data/lib/generators/auxiliary_rails/install_commands_generator.rb +5 -0
- data/lib/generators/auxiliary_rails/install_errors_controller_generator.rb +31 -0
- data/lib/generators/auxiliary_rails/install_generator.rb +1 -1
- data/lib/generators/auxiliary_rails/service_generator.rb +48 -0
- data/lib/generators/auxiliary_rails/templates/application_error_template.rb +1 -1
- data/lib/generators/auxiliary_rails/templates/commands/application_command_template.rb +1 -1
- data/lib/generators/auxiliary_rails/templates/commands/command_spec_template.rb +1 -1
- data/lib/generators/auxiliary_rails/templates/commands/command_template.rb +2 -2
- data/lib/generators/auxiliary_rails/templates/commands/commands.en_template.yml +5 -0
- 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
- data/templates/rails/elementary.rb +39 -10
- metadata +87 -32
- data/lib/auxiliary_rails/abstract_command.rb +0 -95
- data/lib/auxiliary_rails/abstract_error.rb +0 -7
- data/lib/generators/auxiliary_rails/install_rubocop_generator.rb +0 -29
- data/lib/generators/auxiliary_rails/templates/rubocop/rubocop_auxiliary_rails_template.yml +0 -65
- data/lib/generators/auxiliary_rails/templates/rubocop/rubocop_template.yml +0 -11
data/lib/auxiliary_rails.rb
CHANGED
@@ -1,6 +1,10 @@
|
|
1
|
-
require 'auxiliary_rails/
|
2
|
-
require 'auxiliary_rails/
|
3
|
-
require 'auxiliary_rails/
|
1
|
+
require 'auxiliary_rails/application/command'
|
2
|
+
require 'auxiliary_rails/application/error'
|
3
|
+
require 'auxiliary_rails/application/form'
|
4
|
+
require 'auxiliary_rails/application/service'
|
5
|
+
require 'auxiliary_rails/application/query'
|
6
|
+
|
7
|
+
require 'auxiliary_rails/railtie'
|
4
8
|
require 'auxiliary_rails/version'
|
5
9
|
|
6
10
|
module AuxiliaryRails
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'rails'
|
2
|
+
|
3
|
+
module AuxiliaryRails
|
4
|
+
class InstallErrorsControllerGenerator < ::Rails::Generators::Base
|
5
|
+
source_root File.expand_path('templates/errors_controller', __dir__)
|
6
|
+
|
7
|
+
VIEW_TEMPLATES = %w[show not_found unacceptable].freeze
|
8
|
+
|
9
|
+
def copy_controller_file
|
10
|
+
copy_file 'errors_controller_template.rb',
|
11
|
+
'app/controllers/errors_controller.rb'
|
12
|
+
end
|
13
|
+
|
14
|
+
def copy_view_files
|
15
|
+
VIEW_TEMPLATES.each do |tempate_name|
|
16
|
+
copy_file "#{tempate_name}_template.html.erb",
|
17
|
+
"app/views/errors/#{tempate_name}.html.erb"
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def add_route
|
22
|
+
route "match '/404', to: 'errors#not_found', via: :all"
|
23
|
+
route "match '/422', to: 'errors#unacceptable', via: :all"
|
24
|
+
route "match '/500', to: 'errors#show', via: :all"
|
25
|
+
end
|
26
|
+
|
27
|
+
def add_exceptions_app_config
|
28
|
+
application 'config.exceptions_app = routes'
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
require 'rails'
|
2
|
+
|
3
|
+
module AuxiliaryRails
|
4
|
+
class ServiceGenerator < ::Rails::Generators::NamedBase
|
5
|
+
desc 'Stubs out a new Service and spec.'
|
6
|
+
|
7
|
+
source_root File.expand_path('templates/services', __dir__)
|
8
|
+
|
9
|
+
class_option :path,
|
10
|
+
type: :string,
|
11
|
+
default: 'app/services',
|
12
|
+
desc: 'Service location'
|
13
|
+
|
14
|
+
def create_service_dir
|
15
|
+
FileUtils.mkdir_p("#{service_file_path}/#{service_file_name}")
|
16
|
+
end
|
17
|
+
|
18
|
+
def create_service_file
|
19
|
+
FileUtils.mkdir_p(service_file_path)
|
20
|
+
template 'service_template.rb',
|
21
|
+
"#{service_file_path}/#{service_file_name}.rb"
|
22
|
+
end
|
23
|
+
|
24
|
+
def create_service_spec_file
|
25
|
+
FileUtils.mkdir_p(service_spec_path)
|
26
|
+
template 'service_spec_template.rb',
|
27
|
+
"#{service_spec_path}/#{service_file_name}_spec.rb"
|
28
|
+
end
|
29
|
+
|
30
|
+
private
|
31
|
+
|
32
|
+
def service_module_name
|
33
|
+
"#{class_name.gsub(/Service$/, '')}Service"
|
34
|
+
end
|
35
|
+
|
36
|
+
def service_file_name
|
37
|
+
service_module_name.underscore
|
38
|
+
end
|
39
|
+
|
40
|
+
def service_file_path
|
41
|
+
options[:path]
|
42
|
+
end
|
43
|
+
|
44
|
+
def service_spec_path
|
45
|
+
service_file_path.gsub(%r{^app/}, 'spec/')
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -1,2 +1,2 @@
|
|
1
|
-
class ApplicationError < AuxiliaryRails::
|
1
|
+
class ApplicationError < AuxiliaryRails::Application::Error
|
2
2
|
end
|
@@ -1,2 +1,2 @@
|
|
1
|
-
class ApplicationCommand < AuxiliaryRails::
|
1
|
+
class ApplicationCommand < AuxiliaryRails::Application::Command
|
2
2
|
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
class ErrorsController < ApplicationController
|
2
|
+
DEFAULT_ERROR_STATUS = 500
|
3
|
+
|
4
|
+
def show
|
5
|
+
render status: params[:status] || DEFAULT_ERROR_STATUS
|
6
|
+
end
|
7
|
+
|
8
|
+
def not_found
|
9
|
+
render status: :not_found
|
10
|
+
end
|
11
|
+
|
12
|
+
def unacceptable
|
13
|
+
render status: :unprocessable_entity
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
<h1>We're sorry, but something went wrong.</h1>
|
@@ -3,22 +3,43 @@ gsub_file 'Gemfile', /^\s*#.*$\n/, ''
|
|
3
3
|
gsub_file 'Gemfile', /^.*coffee.*$\n/, ''
|
4
4
|
gsub_file 'Gemfile', /^.*jbuilder.*$\n/, ''
|
5
5
|
gsub_file 'Gemfile', /^.*tzinfo-data.*$\n/, ''
|
6
|
+
gsub_file 'Gemfile', /^group :development, :test do\n.*byebug.*\nend\n\n/, ''
|
6
7
|
|
7
|
-
|
8
|
-
|
9
|
-
|
8
|
+
gsub_file '.gitignore', /^\s*#.*$\n/, ''
|
9
|
+
gsub_file 'config/routes.rb', /^\s*#.*$\n/, ''
|
10
|
+
|
11
|
+
gsub_file 'config/database.yml', /^\s*#.*$\n/, ''
|
12
|
+
gsub_file 'config/database.yml', /^\s*pool.*$\n/, <<-FILE
|
13
|
+
host: <%= ENV['DATABASE_HOST'] %>
|
14
|
+
username: <%= ENV['DATABASE_USERNAME'] %>
|
15
|
+
pool: <%= ENV.fetch('RAILS_MAX_THREADS') { 5 } %>
|
16
|
+
FILE
|
17
|
+
|
18
|
+
# Create RuboCop files
|
19
|
+
file '.rubocop.yml', <<~FILE
|
20
|
+
inherit_gem:
|
21
|
+
rubocop-ergoserv:
|
22
|
+
- config/default.yml
|
23
|
+
FILE
|
24
|
+
|
25
|
+
run 'touch .env'
|
26
|
+
append_file '.gitignore', <<~FILE
|
27
|
+
.env*.local
|
28
|
+
FILE
|
29
|
+
|
30
|
+
# Gemfile additions
|
31
|
+
gem 'auxiliary_rails'
|
10
32
|
|
11
33
|
gem_group :development, :test do
|
34
|
+
gem 'byebug'
|
12
35
|
gem 'dotenv-rails'
|
13
36
|
gem 'factory_bot_rails'
|
14
37
|
gem 'faker'
|
15
|
-
gem 'pry-byebug'
|
16
38
|
gem 'pry-rails'
|
17
39
|
gem 'rspec-rails'
|
18
|
-
gem 'rubocop'
|
19
|
-
|
20
|
-
|
21
|
-
gem 'rubocop-rspec'
|
40
|
+
gem 'rubocop-ergoserv',
|
41
|
+
git: 'https://github.com/ergoserv/rubocop-ergoserv',
|
42
|
+
require: false
|
22
43
|
end
|
23
44
|
|
24
45
|
gem_group :test do
|
@@ -29,6 +50,14 @@ end
|
|
29
50
|
after_bundle do
|
30
51
|
# ensure using the latest versions of gems
|
31
52
|
run 'bundle update'
|
32
|
-
|
33
|
-
|
53
|
+
run 'bundle binstubs rubocop'
|
54
|
+
|
55
|
+
generate 'rspec:install'
|
56
|
+
|
57
|
+
generate 'controller', 'pages', 'home',
|
58
|
+
'--no-assets',
|
59
|
+
'--no-helper',
|
60
|
+
'--no-test-framework',
|
61
|
+
'--skip-routes'
|
62
|
+
route "root to: 'pages#home'"
|
34
63
|
end
|
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: auxiliary_rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dmitry Babenko
|
8
8
|
- ErgoServ
|
9
|
-
autorequire:
|
9
|
+
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2022-08-28 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -40,27 +40,49 @@ dependencies:
|
|
40
40
|
- !ruby/object:Gem::Version
|
41
41
|
version: '0'
|
42
42
|
- !ruby/object:Gem::Dependency
|
43
|
-
name:
|
43
|
+
name: rake
|
44
44
|
requirement: !ruby/object:Gem::Requirement
|
45
45
|
requirements:
|
46
46
|
- - ">="
|
47
47
|
- !ruby/object:Gem::Version
|
48
|
-
version: '
|
49
|
-
- - "<"
|
50
|
-
- !ruby/object:Gem::Version
|
51
|
-
version: '7'
|
48
|
+
version: '0'
|
52
49
|
type: :development
|
53
50
|
prerelease: false
|
54
51
|
version_requirements: !ruby/object:Gem::Requirement
|
55
52
|
requirements:
|
56
53
|
- - ">="
|
57
54
|
- !ruby/object:Gem::Version
|
58
|
-
version: '
|
59
|
-
|
55
|
+
version: '0'
|
56
|
+
- !ruby/object:Gem::Dependency
|
57
|
+
name: rspec
|
58
|
+
requirement: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - "~>"
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '3.8'
|
63
|
+
type: :development
|
64
|
+
prerelease: false
|
65
|
+
version_requirements: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - "~>"
|
60
68
|
- !ruby/object:Gem::Version
|
61
|
-
version: '
|
69
|
+
version: '3.8'
|
62
70
|
- !ruby/object:Gem::Dependency
|
63
|
-
name:
|
71
|
+
name: rubocop
|
72
|
+
requirement: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - '='
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: 1.20.0
|
77
|
+
type: :development
|
78
|
+
prerelease: false
|
79
|
+
version_requirements: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - '='
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: 1.20.0
|
84
|
+
- !ruby/object:Gem::Dependency
|
85
|
+
name: rubocop-performance
|
64
86
|
requirement: !ruby/object:Gem::Requirement
|
65
87
|
requirements:
|
66
88
|
- - ">="
|
@@ -74,21 +96,21 @@ dependencies:
|
|
74
96
|
- !ruby/object:Gem::Version
|
75
97
|
version: '0'
|
76
98
|
- !ruby/object:Gem::Dependency
|
77
|
-
name:
|
99
|
+
name: rubocop-rake
|
78
100
|
requirement: !ruby/object:Gem::Requirement
|
79
101
|
requirements:
|
80
|
-
- - "
|
102
|
+
- - ">="
|
81
103
|
- !ruby/object:Gem::Version
|
82
|
-
version: '
|
104
|
+
version: '0'
|
83
105
|
type: :development
|
84
106
|
prerelease: false
|
85
107
|
version_requirements: !ruby/object:Gem::Requirement
|
86
108
|
requirements:
|
87
|
-
- - "
|
109
|
+
- - ">="
|
88
110
|
- !ruby/object:Gem::Version
|
89
|
-
version: '
|
111
|
+
version: '0'
|
90
112
|
- !ruby/object:Gem::Dependency
|
91
|
-
name: rubocop
|
113
|
+
name: rubocop-rspec
|
92
114
|
requirement: !ruby/object:Gem::Requirement
|
93
115
|
requirements:
|
94
116
|
- - ">="
|
@@ -102,13 +124,13 @@ dependencies:
|
|
102
124
|
- !ruby/object:Gem::Version
|
103
125
|
version: '0'
|
104
126
|
- !ruby/object:Gem::Dependency
|
105
|
-
name:
|
127
|
+
name: dry-core
|
106
128
|
requirement: !ruby/object:Gem::Requirement
|
107
129
|
requirements:
|
108
130
|
- - ">="
|
109
131
|
- !ruby/object:Gem::Version
|
110
132
|
version: '0'
|
111
|
-
type: :
|
133
|
+
type: :runtime
|
112
134
|
prerelease: false
|
113
135
|
version_requirements: !ruby/object:Gem::Requirement
|
114
136
|
requirements:
|
@@ -116,13 +138,13 @@ dependencies:
|
|
116
138
|
- !ruby/object:Gem::Version
|
117
139
|
version: '0'
|
118
140
|
- !ruby/object:Gem::Dependency
|
119
|
-
name:
|
141
|
+
name: dry-initializer
|
120
142
|
requirement: !ruby/object:Gem::Requirement
|
121
143
|
requirements:
|
122
144
|
- - ">="
|
123
145
|
- !ruby/object:Gem::Version
|
124
146
|
version: '0'
|
125
|
-
type: :
|
147
|
+
type: :runtime
|
126
148
|
prerelease: false
|
127
149
|
version_requirements: !ruby/object:Gem::Requirement
|
128
150
|
requirements:
|
@@ -143,6 +165,20 @@ dependencies:
|
|
143
165
|
- - ">="
|
144
166
|
- !ruby/object:Gem::Version
|
145
167
|
version: '0'
|
168
|
+
- !ruby/object:Gem::Dependency
|
169
|
+
name: rails
|
170
|
+
requirement: !ruby/object:Gem::Requirement
|
171
|
+
requirements:
|
172
|
+
- - ">="
|
173
|
+
- !ruby/object:Gem::Version
|
174
|
+
version: '5.2'
|
175
|
+
type: :runtime
|
176
|
+
prerelease: false
|
177
|
+
version_requirements: !ruby/object:Gem::Requirement
|
178
|
+
requirements:
|
179
|
+
- - ">="
|
180
|
+
- !ruby/object:Gem::Version
|
181
|
+
version: '5.2'
|
146
182
|
- !ruby/object:Gem::Dependency
|
147
183
|
name: thor
|
148
184
|
requirement: !ruby/object:Gem::Requirement
|
@@ -169,12 +205,15 @@ extensions: []
|
|
169
205
|
extra_rdoc_files: []
|
170
206
|
files:
|
171
207
|
- ".gitignore"
|
208
|
+
- ".gitlab-ci.yml"
|
172
209
|
- ".rspec"
|
173
210
|
- ".rubocop.yml"
|
174
211
|
- ".rubocop_todo.yml"
|
175
212
|
- ".ruby-version"
|
176
213
|
- ".travis.yml"
|
214
|
+
- ".yardopts"
|
177
215
|
- CHANGELOG.md
|
216
|
+
- CODE_OF_CONDUCT.md
|
178
217
|
- CONTRIBUTING.md
|
179
218
|
- Gemfile
|
180
219
|
- Gemfile.lock
|
@@ -185,20 +224,31 @@ files:
|
|
185
224
|
- auxiliary_rails.gemspec
|
186
225
|
- bin/auxiliary_rails
|
187
226
|
- bin/console
|
227
|
+
- bin/rspec
|
228
|
+
- bin/rubocop
|
188
229
|
- bin/setup
|
230
|
+
- bitbucket-pipelines.yml
|
189
231
|
- lib/auxiliary_rails.rb
|
190
|
-
- lib/auxiliary_rails/
|
191
|
-
- lib/auxiliary_rails/
|
232
|
+
- lib/auxiliary_rails/application/command.rb
|
233
|
+
- lib/auxiliary_rails/application/error.rb
|
234
|
+
- lib/auxiliary_rails/application/form.rb
|
235
|
+
- lib/auxiliary_rails/application/query.rb
|
236
|
+
- lib/auxiliary_rails/application/service.rb
|
192
237
|
- lib/auxiliary_rails/cli.rb
|
238
|
+
- lib/auxiliary_rails/concerns/callable.rb
|
239
|
+
- lib/auxiliary_rails/concerns/errorable.rb
|
240
|
+
- lib/auxiliary_rails/concerns/performable.rb
|
193
241
|
- lib/auxiliary_rails/railtie.rb
|
194
242
|
- lib/auxiliary_rails/version.rb
|
195
243
|
- lib/auxiliary_rails/view_helpers.rb
|
244
|
+
- lib/auxiliary_rails/view_helpers/display_helper.rb
|
196
245
|
- lib/generators/auxiliary_rails/api_resource_generator.rb
|
197
246
|
- lib/generators/auxiliary_rails/command_generator.rb
|
198
247
|
- lib/generators/auxiliary_rails/install_commands_generator.rb
|
248
|
+
- lib/generators/auxiliary_rails/install_errors_controller_generator.rb
|
199
249
|
- lib/generators/auxiliary_rails/install_errors_generator.rb
|
200
250
|
- lib/generators/auxiliary_rails/install_generator.rb
|
201
|
-
- lib/generators/auxiliary_rails/
|
251
|
+
- lib/generators/auxiliary_rails/service_generator.rb
|
202
252
|
- lib/generators/auxiliary_rails/templates/apis/api_entity_template.rb.erb
|
203
253
|
- lib/generators/auxiliary_rails/templates/apis/api_helper_template.rb.erb
|
204
254
|
- lib/generators/auxiliary_rails/templates/apis/api_resource_spec_template.rb.erb
|
@@ -207,8 +257,13 @@ files:
|
|
207
257
|
- lib/generators/auxiliary_rails/templates/commands/application_command_template.rb
|
208
258
|
- lib/generators/auxiliary_rails/templates/commands/command_spec_template.rb
|
209
259
|
- lib/generators/auxiliary_rails/templates/commands/command_template.rb
|
210
|
-
- lib/generators/auxiliary_rails/templates/
|
211
|
-
- lib/generators/auxiliary_rails/templates/
|
260
|
+
- lib/generators/auxiliary_rails/templates/commands/commands.en_template.yml
|
261
|
+
- lib/generators/auxiliary_rails/templates/errors_controller/errors_controller_template.rb
|
262
|
+
- lib/generators/auxiliary_rails/templates/errors_controller/not_found_template.html.erb
|
263
|
+
- lib/generators/auxiliary_rails/templates/errors_controller/show_template.html.erb
|
264
|
+
- lib/generators/auxiliary_rails/templates/errors_controller/unacceptable_template.html.erb
|
265
|
+
- lib/generators/auxiliary_rails/templates/services/service_spec_template.rb
|
266
|
+
- lib/generators/auxiliary_rails/templates/services/service_template.rb
|
212
267
|
- templates/rails/elementary.rb
|
213
268
|
homepage: https://github.com/ergoserv/auxiliary_rails
|
214
269
|
licenses:
|
@@ -216,8 +271,8 @@ licenses:
|
|
216
271
|
metadata:
|
217
272
|
homepage_uri: https://github.com/ergoserv/auxiliary_rails
|
218
273
|
source_code_uri: https://github.com/ergoserv/auxiliary_rails
|
219
|
-
changelog_uri: https://github.com/ergoserv/auxiliary_rails/
|
220
|
-
post_install_message:
|
274
|
+
changelog_uri: https://github.com/ergoserv/auxiliary_rails/releases
|
275
|
+
post_install_message:
|
221
276
|
rdoc_options: []
|
222
277
|
require_paths:
|
223
278
|
- lib
|
@@ -225,15 +280,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
225
280
|
requirements:
|
226
281
|
- - ">="
|
227
282
|
- !ruby/object:Gem::Version
|
228
|
-
version: '
|
283
|
+
version: '2.5'
|
229
284
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
230
285
|
requirements:
|
231
286
|
- - ">="
|
232
287
|
- !ruby/object:Gem::Version
|
233
288
|
version: '0'
|
234
289
|
requirements: []
|
235
|
-
rubygems_version: 3.
|
236
|
-
signing_key:
|
290
|
+
rubygems_version: 3.1.6
|
291
|
+
signing_key:
|
237
292
|
specification_version: 4
|
238
293
|
summary: AuxiliaryRails provides extra layers and utils for helping to build solid
|
239
294
|
and clean Ruby on Rails applications
|
@@ -1,95 +0,0 @@
|
|
1
|
-
require 'dry-initializer-rails'
|
2
|
-
require 'active_model'
|
3
|
-
|
4
|
-
module AuxiliaryRails
|
5
|
-
class AbstractCommand
|
6
|
-
extend Dry::Initializer
|
7
|
-
include ActiveModel::Validations
|
8
|
-
|
9
|
-
def self.call(*args)
|
10
|
-
new(*args).call
|
11
|
-
end
|
12
|
-
|
13
|
-
def call
|
14
|
-
raise NotImplementedError
|
15
|
-
end
|
16
|
-
|
17
|
-
def failure?
|
18
|
-
status?(:failure)
|
19
|
-
end
|
20
|
-
|
21
|
-
def status?(value)
|
22
|
-
ensure_execution!
|
23
|
-
|
24
|
-
status == value&.to_sym
|
25
|
-
end
|
26
|
-
|
27
|
-
def success?
|
28
|
-
status?(:success)
|
29
|
-
end
|
30
|
-
|
31
|
-
# Shortcut for `ActiveRecord::Base.transaction`
|
32
|
-
def transaction(&block)
|
33
|
-
ActiveRecord::Base.transaction(&block) if block_given?
|
34
|
-
end
|
35
|
-
|
36
|
-
# Method for ActiveModel::Errors
|
37
|
-
def read_attribute_for_validation(attr_name)
|
38
|
-
attr_name = attr_name.to_sym
|
39
|
-
if attr_name == :command
|
40
|
-
self
|
41
|
-
else
|
42
|
-
self.class.dry_initializer.attributes(self)[attr_name]
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
# Method for ActiveModel::Translation
|
47
|
-
def self.i18n_scope
|
48
|
-
:commands
|
49
|
-
end
|
50
|
-
|
51
|
-
protected
|
52
|
-
|
53
|
-
attr_accessor :status
|
54
|
-
|
55
|
-
def ensure_empty_errors!
|
56
|
-
return if errors.empty?
|
57
|
-
|
58
|
-
error!("`#{self.class}` contains errors.")
|
59
|
-
end
|
60
|
-
|
61
|
-
def ensure_empty_status!
|
62
|
-
return if status.nil?
|
63
|
-
|
64
|
-
error!("`#{self.class}` was already executed.")
|
65
|
-
end
|
66
|
-
|
67
|
-
def ensure_execution!
|
68
|
-
return if status.present?
|
69
|
-
|
70
|
-
error!("`#{self.class}` was not executed yet.")
|
71
|
-
end
|
72
|
-
|
73
|
-
def error!(message = nil)
|
74
|
-
message ||= "`#{self.class}` raised error."
|
75
|
-
raise ApplicationError, message
|
76
|
-
end
|
77
|
-
|
78
|
-
def failure!(message = nil)
|
79
|
-
ensure_empty_status!
|
80
|
-
|
81
|
-
errors.add(:command, :failed, message: message) unless message.nil?
|
82
|
-
|
83
|
-
self.status = :failure
|
84
|
-
self
|
85
|
-
end
|
86
|
-
|
87
|
-
def success!
|
88
|
-
ensure_empty_errors!
|
89
|
-
ensure_empty_status!
|
90
|
-
|
91
|
-
self.status = :success
|
92
|
-
self
|
93
|
-
end
|
94
|
-
end
|
95
|
-
end
|
@@ -1,29 +0,0 @@
|
|
1
|
-
require 'rails'
|
2
|
-
|
3
|
-
module AuxiliaryRails
|
4
|
-
class InstallRubocopGenerator < ::Rails::Generators::Base
|
5
|
-
class_option :specify_gems,
|
6
|
-
type: :boolean,
|
7
|
-
default: true,
|
8
|
-
desc: 'Indicates if `rubocop` gem needs to be added to Gemfile'
|
9
|
-
source_root File.expand_path('templates/rubocop', __dir__)
|
10
|
-
|
11
|
-
def copy_config_files
|
12
|
-
copy_file 'rubocop_template.yml',
|
13
|
-
'.rubocop.yml'
|
14
|
-
copy_file 'rubocop_auxiliary_rails_template.yml',
|
15
|
-
'.rubocop_auxiliary_rails.yml'
|
16
|
-
end
|
17
|
-
|
18
|
-
def specify_gems_dependency
|
19
|
-
return unless options[:specify_gems]
|
20
|
-
|
21
|
-
gem_group :development, :test do
|
22
|
-
gem 'rubocop'
|
23
|
-
gem 'rubocop-performance'
|
24
|
-
gem 'rubocop-rails'
|
25
|
-
gem 'rubocop-rspec'
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|