auxiliary_rails 0.2.0 → 0.4.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.
Files changed (52) hide show
  1. checksums.yaml +4 -4
  2. data/.gitlab-ci.yml +26 -0
  3. data/.rubocop.yml +31 -3
  4. data/.rubocop_todo.yml +3 -19
  5. data/.ruby-version +1 -1
  6. data/.yardopts +5 -0
  7. data/CHANGELOG.md +39 -2
  8. data/CODE_OF_CONDUCT.md +128 -0
  9. data/CONTRIBUTING.md +0 -6
  10. data/Gemfile.lock +164 -132
  11. data/README.md +267 -5
  12. data/auxiliary_rails.gemspec +18 -13
  13. data/bin/rspec +29 -0
  14. data/bin/rubocop +29 -0
  15. data/bitbucket-pipelines.yml +35 -0
  16. data/lib/auxiliary_rails/application/command.rb +53 -0
  17. data/lib/auxiliary_rails/application/error.rb +50 -0
  18. data/lib/auxiliary_rails/application/form.rb +31 -0
  19. data/lib/auxiliary_rails/application/query.rb +75 -0
  20. data/lib/auxiliary_rails/application/service.rb +42 -0
  21. data/lib/auxiliary_rails/cli.rb +18 -5
  22. data/lib/auxiliary_rails/concerns/callable.rb +23 -0
  23. data/lib/auxiliary_rails/concerns/errorable.rb +22 -0
  24. data/lib/auxiliary_rails/concerns/performable.rb +120 -0
  25. data/lib/auxiliary_rails/railtie.rb +2 -1
  26. data/lib/auxiliary_rails/version.rb +1 -1
  27. data/lib/auxiliary_rails/view_helpers/display_helper.rb +30 -0
  28. data/lib/auxiliary_rails/view_helpers.rb +4 -0
  29. data/lib/auxiliary_rails.rb +7 -3
  30. data/lib/generators/auxiliary_rails/command_generator.rb +1 -1
  31. data/lib/generators/auxiliary_rails/install_commands_generator.rb +5 -0
  32. data/lib/generators/auxiliary_rails/install_errors_controller_generator.rb +31 -0
  33. data/lib/generators/auxiliary_rails/install_generator.rb +1 -1
  34. data/lib/generators/auxiliary_rails/service_generator.rb +48 -0
  35. data/lib/generators/auxiliary_rails/templates/application_error_template.rb +1 -1
  36. data/lib/generators/auxiliary_rails/templates/commands/application_command_template.rb +1 -1
  37. data/lib/generators/auxiliary_rails/templates/commands/command_spec_template.rb +1 -1
  38. data/lib/generators/auxiliary_rails/templates/commands/command_template.rb +2 -2
  39. data/lib/generators/auxiliary_rails/templates/commands/commands.en_template.yml +5 -0
  40. data/lib/generators/auxiliary_rails/templates/errors_controller/errors_controller_template.rb +15 -0
  41. data/lib/generators/auxiliary_rails/templates/errors_controller/not_found_template.html.erb +2 -0
  42. data/lib/generators/auxiliary_rails/templates/errors_controller/show_template.html.erb +1 -0
  43. data/lib/generators/auxiliary_rails/templates/errors_controller/unacceptable_template.html.erb +2 -0
  44. data/lib/generators/auxiliary_rails/templates/services/service_spec_template.rb +5 -0
  45. data/lib/generators/auxiliary_rails/templates/services/service_template.rb +10 -0
  46. data/templates/rails/elementary.rb +39 -10
  47. metadata +87 -32
  48. data/lib/auxiliary_rails/abstract_command.rb +0 -95
  49. data/lib/auxiliary_rails/abstract_error.rb +0 -7
  50. data/lib/generators/auxiliary_rails/install_rubocop_generator.rb +0 -29
  51. data/lib/generators/auxiliary_rails/templates/rubocop/rubocop_auxiliary_rails_template.yml +0 -65
  52. data/lib/generators/auxiliary_rails/templates/rubocop/rubocop_template.yml +0 -11
@@ -1,6 +1,10 @@
1
- require 'auxiliary_rails/abstract_error'
2
- require 'auxiliary_rails/abstract_command'
3
- require 'auxiliary_rails/railtie' if defined?(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
@@ -38,7 +38,7 @@ module AuxiliaryRails
38
38
  end
39
39
 
40
40
  def command_spec_path
41
- command_file_path.gsub(/^app\//, 'spec/')
41
+ command_file_path.gsub(%r{^app/}, 'spec/')
42
42
  end
43
43
  end
44
44
  end
@@ -8,5 +8,10 @@ module AuxiliaryRails
8
8
  copy_file 'application_command_template.rb',
9
9
  'app/commands/application_command.rb'
10
10
  end
11
+
12
+ def copy_locale_command_file
13
+ copy_file 'commands.en_template.yml',
14
+ 'config/locales/commands.en.yml'
15
+ end
11
16
  end
12
17
  end
@@ -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
@@ -5,7 +5,7 @@ module AuxiliaryRails
5
5
  def install
6
6
  generate 'auxiliary_rails:install_commands'
7
7
  generate 'auxiliary_rails:install_errors'
8
- generate 'auxiliary_rails:install_rubocop --no-specify-gems'
8
+ generate 'auxiliary_rails:install_errors_controller'
9
9
  end
10
10
  end
11
11
  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::AbstractError
1
+ class ApplicationError < AuxiliaryRails::Application::Error
2
2
  end
@@ -1,2 +1,2 @@
1
- class ApplicationCommand < AuxiliaryRails::AbstractCommand
1
+ class ApplicationCommand < AuxiliaryRails::Application::Command
2
2
  end
@@ -1,6 +1,6 @@
1
1
  require 'rails_helper'
2
2
 
3
- describe <%= command_class_name %> do
3
+ RSpec.describe <%= command_class_name %> do
4
4
  describe '#call' do
5
5
  it 'succeeds' do
6
6
  # TODO: implement spec for command
@@ -1,6 +1,6 @@
1
1
  class <%= command_class_name %> < ApplicationCommand
2
- def call
3
- # TODO: implement <%= command_class_name %>.call method
2
+ def perform
3
+ # TODO: implement <%= command_class_name %>.perform method
4
4
  success!
5
5
  end
6
6
  end
@@ -0,0 +1,5 @@
1
+ en:
2
+ commands:
3
+ errors:
4
+ messages:
5
+ validation_failed: validation failed
@@ -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,2 @@
1
+ <h1>The page you were looking for doesn't exist.</h1>
2
+ <p>You may have mistyped the address or the page may have moved.</p>
@@ -0,0 +1 @@
1
+ <h1>We're sorry, but something went wrong.</h1>
@@ -0,0 +1,2 @@
1
+ <h1>The change you wanted was rejected.</h1>
2
+ <p>Maybe you tried to change something you didn't have access to.</p>
@@ -0,0 +1,5 @@
1
+ require 'rails_helper'
2
+
3
+ RSpec.describe <%= service_module_name %> do
4
+ pending "add some examples to (or delete) #{__FILE__}"
5
+ end
@@ -0,0 +1,10 @@
1
+ module <%= service_module_name %>
2
+ extend AuxiliaryRails::Application::Service
3
+
4
+ module_function
5
+
6
+ CONFIG = {
7
+ key: 'value'
8
+ }.freeze
9
+
10
+ end
@@ -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
- gem 'auxiliary_rails',
8
- git: 'https://github.com/ergoserv/auxiliary_rails',
9
- branch: 'develop'
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
- gem 'rubocop-performance'
20
- gem 'rubocop-rails'
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
- rails_command 'generate auxiliary_rails:install_rubocop --no-specify-gems'
33
- rails_command 'generate rspec:install'
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.2.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: 2020-01-05 00:00:00.000000000 Z
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: rails
43
+ name: rake
44
44
  requirement: !ruby/object:Gem::Requirement
45
45
  requirements:
46
46
  - - ">="
47
47
  - !ruby/object:Gem::Version
48
- version: '5.2'
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: '5.2'
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: '7'
69
+ version: '3.8'
62
70
  - !ruby/object:Gem::Dependency
63
- name: rake
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: rspec
99
+ name: rubocop-rake
78
100
  requirement: !ruby/object:Gem::Requirement
79
101
  requirements:
80
- - - "~>"
102
+ - - ">="
81
103
  - !ruby/object:Gem::Version
82
- version: '3.8'
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: '3.8'
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: rubocop-performance
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: :development
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: rubocop-rspec
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: :development
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/abstract_command.rb
191
- - lib/auxiliary_rails/abstract_error.rb
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/install_rubocop_generator.rb
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/rubocop/rubocop_auxiliary_rails_template.yml
211
- - lib/generators/auxiliary_rails/templates/rubocop/rubocop_template.yml
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/blob/master/CHANGELOG.md
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: '0'
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.0.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,7 +0,0 @@
1
- module AuxiliaryRails
2
- class AbstractError < StandardError
3
- def self.wrap(error)
4
- new(error.message)
5
- end
6
- end
7
- 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