auxiliary_rails 0.1.5 → 0.1.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +4 -5
- data/.ruby-version +1 -1
- data/CHANGELOG.md +8 -3
- data/Gemfile.lock +108 -2
- data/README.md +5 -0
- data/auxiliary_rails.gemspec +1 -0
- data/lib/auxiliary_rails.rb +1 -0
- data/lib/auxiliary_rails/abstract_command.rb +96 -0
- data/lib/auxiliary_rails/version.rb +1 -1
- data/lib/generators/auxiliary_rails/api_resource_generator.rb +63 -0
- data/lib/generators/auxiliary_rails/install_commands_generator.rb +12 -0
- data/lib/generators/auxiliary_rails/install_generator.rb +11 -0
- data/lib/generators/auxiliary_rails/install_rubocop_generator.rb +1 -0
- data/lib/generators/auxiliary_rails/templates/apis/api_entity_template.rb.erb +7 -0
- data/lib/generators/auxiliary_rails/templates/apis/api_helper_template.rb.erb +5 -0
- data/lib/generators/auxiliary_rails/templates/apis/api_resource_spec_template.rb.erb +32 -0
- data/lib/generators/auxiliary_rails/templates/apis/api_resource_template.rb.erb +70 -0
- data/lib/generators/auxiliary_rails/templates/application_command_template.rb +2 -0
- data/lib/generators/auxiliary_rails/templates/rubocop/rubocop_auxiliary_rails_template.yml +8 -1
- data/lib/generators/auxiliary_rails/templates/rubocop/rubocop_template.yml +4 -3
- data/templates/rails/elementary.rb +3 -0
- metadata +25 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 10bf9425fca5d5db8bc1165679479bb68235fca8d5b98e044c8fce1b9046d719
|
4
|
+
data.tar.gz: 1d5dae27ee43d35db611fca2fdda64a10f55d0d3b0570c341c33ed5a86237d9e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d1ff270855fee39b2cadf2043bcc50e8f8714c9ff24c35b6309391b074fdec0654566a3d9cd2dbc54c401a3c9d19ee2479d13afbefa9126bf81004ceb706f383
|
7
|
+
data.tar.gz: ee2960e8df4235fdaad9c879c21ff2753044f2064f1b7d4b8604ff5d47105bca682ce22f1c3f9d884bedadcdfb42783f4eb725cd643ddd01f60a633489506fce
|
data/.rubocop.yml
CHANGED
@@ -1,4 +1,5 @@
|
|
1
|
-
inherit_from:
|
1
|
+
inherit_from:
|
2
|
+
- .rubocop_todo.yml
|
2
3
|
|
3
4
|
require:
|
4
5
|
- rubocop-performance
|
@@ -6,7 +7,6 @@ require:
|
|
6
7
|
|
7
8
|
AllCops:
|
8
9
|
Exclude:
|
9
|
-
# - auxiliary_rails.gemspec
|
10
10
|
- vendor/bundle/**/* # fix for running on Travis CI
|
11
11
|
|
12
12
|
#################### Layout ##############################
|
@@ -17,9 +17,8 @@ Layout/AlignArguments:
|
|
17
17
|
#################### Metrics ##############################
|
18
18
|
|
19
19
|
Metrics/BlockLength:
|
20
|
-
|
21
|
-
-
|
22
|
-
- 'spec/**/*_spec.rb'
|
20
|
+
ExcludedMethods:
|
21
|
+
- describe
|
23
22
|
|
24
23
|
#################### Style ###############################
|
25
24
|
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.6.
|
1
|
+
2.6.3
|
data/CHANGELOG.md
CHANGED
@@ -1,19 +1,24 @@
|
|
1
1
|
# AuxiliaryRails Changelog
|
2
2
|
|
3
|
+
## v0.1.6
|
4
|
+
|
5
|
+
* API Resource generator
|
6
|
+
* Command Object
|
7
|
+
|
3
8
|
## v0.1.5
|
4
9
|
|
5
10
|
* Fix Gemfile.lock
|
6
11
|
|
7
12
|
## v0.1.4
|
8
13
|
|
9
|
-
* Rename CLI
|
10
|
-
* Code style updates in auxiliary_rails.gemspec
|
14
|
+
* Rename CLI command `create_rails_app` to `new`
|
15
|
+
* Code style updates in `auxiliary_rails.gemspec`
|
11
16
|
* Fix order of gems in Rails template, rename template
|
12
17
|
|
13
18
|
## v0.1.3
|
14
19
|
|
15
20
|
* Upgrate `rubocop` gem and its configs
|
16
|
-
* `rubocop-rspec` and `rubocop-performance` gem
|
21
|
+
* `rubocop-rspec` and `rubocop-performance` gem iteration
|
17
22
|
* Added basic Rails application template
|
18
23
|
* CLI with `create_rails_app` command
|
19
24
|
|
data/Gemfile.lock
CHANGED
@@ -1,17 +1,82 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
auxiliary_rails (0.1.
|
4
|
+
auxiliary_rails (0.1.6)
|
5
5
|
thor
|
6
6
|
|
7
7
|
GEM
|
8
8
|
remote: https://rubygems.org/
|
9
9
|
specs:
|
10
|
+
actioncable (5.2.3)
|
11
|
+
actionpack (= 5.2.3)
|
12
|
+
nio4r (~> 2.0)
|
13
|
+
websocket-driver (>= 0.6.1)
|
14
|
+
actionmailer (5.2.3)
|
15
|
+
actionpack (= 5.2.3)
|
16
|
+
actionview (= 5.2.3)
|
17
|
+
activejob (= 5.2.3)
|
18
|
+
mail (~> 2.5, >= 2.5.4)
|
19
|
+
rails-dom-testing (~> 2.0)
|
20
|
+
actionpack (5.2.3)
|
21
|
+
actionview (= 5.2.3)
|
22
|
+
activesupport (= 5.2.3)
|
23
|
+
rack (~> 2.0)
|
24
|
+
rack-test (>= 0.6.3)
|
25
|
+
rails-dom-testing (~> 2.0)
|
26
|
+
rails-html-sanitizer (~> 1.0, >= 1.0.2)
|
27
|
+
actionview (5.2.3)
|
28
|
+
activesupport (= 5.2.3)
|
29
|
+
builder (~> 3.1)
|
30
|
+
erubi (~> 1.4)
|
31
|
+
rails-dom-testing (~> 2.0)
|
32
|
+
rails-html-sanitizer (~> 1.0, >= 1.0.3)
|
33
|
+
activejob (5.2.3)
|
34
|
+
activesupport (= 5.2.3)
|
35
|
+
globalid (>= 0.3.6)
|
36
|
+
activemodel (5.2.3)
|
37
|
+
activesupport (= 5.2.3)
|
38
|
+
activerecord (5.2.3)
|
39
|
+
activemodel (= 5.2.3)
|
40
|
+
activesupport (= 5.2.3)
|
41
|
+
arel (>= 9.0)
|
42
|
+
activestorage (5.2.3)
|
43
|
+
actionpack (= 5.2.3)
|
44
|
+
activerecord (= 5.2.3)
|
45
|
+
marcel (~> 0.3.1)
|
46
|
+
activesupport (5.2.3)
|
47
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
48
|
+
i18n (>= 0.7, < 2)
|
49
|
+
minitest (~> 5.1)
|
50
|
+
tzinfo (~> 1.1)
|
51
|
+
arel (9.0.0)
|
10
52
|
ast (2.4.0)
|
53
|
+
builder (3.2.3)
|
11
54
|
coderay (1.1.2)
|
55
|
+
concurrent-ruby (1.1.5)
|
56
|
+
crass (1.0.4)
|
12
57
|
diff-lcs (1.3)
|
58
|
+
erubi (1.8.0)
|
59
|
+
globalid (0.4.2)
|
60
|
+
activesupport (>= 4.2.0)
|
61
|
+
i18n (1.6.0)
|
62
|
+
concurrent-ruby (~> 1.0)
|
13
63
|
jaro_winkler (1.5.2)
|
64
|
+
loofah (2.2.3)
|
65
|
+
crass (~> 1.0.2)
|
66
|
+
nokogiri (>= 1.5.9)
|
67
|
+
mail (2.7.1)
|
68
|
+
mini_mime (>= 0.1.1)
|
69
|
+
marcel (0.3.3)
|
70
|
+
mimemagic (~> 0.3.2)
|
14
71
|
method_source (0.9.2)
|
72
|
+
ast (~> 2.4.0)
|
73
|
+
mimemagic (0.3.3)
|
74
|
+
mini_mime (1.0.2)
|
75
|
+
mini_portile2 (2.4.0)
|
76
|
+
minitest (5.11.3)
|
77
|
+
nio4r (2.4.0)
|
78
|
+
nokogiri (1.10.3)
|
79
|
+
mini_portile2 (~> 2.4.0)
|
15
80
|
parallel (1.17.0)
|
16
81
|
parser (2.6.3.0)
|
17
82
|
ast (~> 2.4.0)
|
@@ -19,6 +84,33 @@ GEM
|
|
19
84
|
coderay (~> 1.1.0)
|
20
85
|
method_source (~> 0.9.0)
|
21
86
|
psych (3.1.0)
|
87
|
+
rack (2.0.7)
|
88
|
+
rack-test (1.1.0)
|
89
|
+
rack (>= 1.0, < 3)
|
90
|
+
rails (5.2.3)
|
91
|
+
actioncable (= 5.2.3)
|
92
|
+
actionmailer (= 5.2.3)
|
93
|
+
actionpack (= 5.2.3)
|
94
|
+
actionview (= 5.2.3)
|
95
|
+
activejob (= 5.2.3)
|
96
|
+
activemodel (= 5.2.3)
|
97
|
+
activerecord (= 5.2.3)
|
98
|
+
activestorage (= 5.2.3)
|
99
|
+
activesupport (= 5.2.3)
|
100
|
+
bundler (>= 1.3.0)
|
101
|
+
railties (= 5.2.3)
|
102
|
+
sprockets-rails (>= 2.0.0)
|
103
|
+
rails-dom-testing (2.0.3)
|
104
|
+
activesupport (>= 4.2.0)
|
105
|
+
nokogiri (>= 1.6)
|
106
|
+
rails-html-sanitizer (1.0.4)
|
107
|
+
loofah (~> 2.2, >= 2.2.2)
|
108
|
+
railties (5.2.3)
|
109
|
+
actionpack (= 5.2.3)
|
110
|
+
activesupport (= 5.2.3)
|
111
|
+
method_source
|
112
|
+
rake (>= 0.8.7)
|
113
|
+
thor (>= 0.19.0, < 2.0)
|
22
114
|
rainbow (3.0.0)
|
23
115
|
rake (10.5.0)
|
24
116
|
rspec (3.8.0)
|
@@ -47,8 +139,21 @@ GEM
|
|
47
139
|
rubocop-rspec (1.32.0)
|
48
140
|
rubocop (>= 0.60.0)
|
49
141
|
ruby-progressbar (1.10.0)
|
142
|
+
sprockets (3.7.2)
|
143
|
+
concurrent-ruby (~> 1.0)
|
144
|
+
rack (> 1, < 3)
|
145
|
+
sprockets-rails (3.2.1)
|
146
|
+
actionpack (>= 4.0)
|
147
|
+
activesupport (>= 4.0)
|
148
|
+
sprockets (>= 3.0.0)
|
50
149
|
thor (0.20.3)
|
150
|
+
thread_safe (0.3.6)
|
151
|
+
tzinfo (1.2.5)
|
152
|
+
thread_safe (~> 0.1)
|
51
153
|
unicode-display_width (1.5.0)
|
154
|
+
websocket-driver (0.7.1)
|
155
|
+
websocket-extensions (>= 0.1.0)
|
156
|
+
websocket-extensions (0.1.4)
|
52
157
|
|
53
158
|
PLATFORMS
|
54
159
|
ruby
|
@@ -57,6 +162,7 @@ DEPENDENCIES
|
|
57
162
|
auxiliary_rails!
|
58
163
|
bundler (~> 2.0)
|
59
164
|
pry
|
165
|
+
rails (~> 5.2)
|
60
166
|
rake (~> 10.0)
|
61
167
|
rspec (~> 3.0)
|
62
168
|
rubocop
|
@@ -64,4 +170,4 @@ DEPENDENCIES
|
|
64
170
|
rubocop-rspec
|
65
171
|
|
66
172
|
BUNDLED WITH
|
67
|
-
2.0.
|
173
|
+
2.0.2
|
data/README.md
CHANGED
@@ -46,6 +46,11 @@ rails new APP_PATH --skip-action-cable --skip-coffee --skip-test --database=post
|
|
46
46
|
### Generators
|
47
47
|
|
48
48
|
```sh
|
49
|
+
# install everything
|
50
|
+
rails generate auxiliary_rails:install
|
51
|
+
|
52
|
+
# install one by one
|
53
|
+
rails generate auxiliary_rails:install_commands
|
49
54
|
rails generate auxiliary_rails:install_errors
|
50
55
|
rails generate auxiliary_rails:install_rubocop
|
51
56
|
rails generate auxiliary_rails:install_rubocop --no-specify-gems
|
data/auxiliary_rails.gemspec
CHANGED
@@ -35,6 +35,7 @@ Gem::Specification.new do |spec|
|
|
35
35
|
|
36
36
|
spec.add_development_dependency 'bundler', '~> 2.0'
|
37
37
|
spec.add_development_dependency 'pry'
|
38
|
+
spec.add_development_dependency 'rails', '~> 5.2'
|
38
39
|
spec.add_development_dependency 'rake', '~> 10.0'
|
39
40
|
spec.add_development_dependency 'rspec', '~> 3.0'
|
40
41
|
spec.add_development_dependency 'rubocop'
|
data/lib/auxiliary_rails.rb
CHANGED
@@ -0,0 +1,96 @@
|
|
1
|
+
require 'active_model'
|
2
|
+
|
3
|
+
module AuxiliaryRails
|
4
|
+
class AbstractCommand
|
5
|
+
include ActiveModel::Model
|
6
|
+
include ActiveModel::Attributes
|
7
|
+
|
8
|
+
def self.call(*args)
|
9
|
+
new(*args).call
|
10
|
+
end
|
11
|
+
|
12
|
+
def call
|
13
|
+
raise NotImplementedError
|
14
|
+
end
|
15
|
+
|
16
|
+
def errors
|
17
|
+
@errors ||= ActiveModel::Errors.new(self)
|
18
|
+
end
|
19
|
+
|
20
|
+
def failure?
|
21
|
+
status?(:failure)
|
22
|
+
end
|
23
|
+
|
24
|
+
def status?(value)
|
25
|
+
ensure_execution!
|
26
|
+
|
27
|
+
status == value&.to_sym
|
28
|
+
end
|
29
|
+
|
30
|
+
def success?
|
31
|
+
status?(:success)
|
32
|
+
end
|
33
|
+
|
34
|
+
def transaction(&block)
|
35
|
+
ActiveRecord::Base.transaction(&block) if block_given?
|
36
|
+
end
|
37
|
+
|
38
|
+
# Method for ActiveModel::Errors
|
39
|
+
def read_attribute_for_validation(attr_name)
|
40
|
+
if attr_name == :command
|
41
|
+
self
|
42
|
+
else
|
43
|
+
attribute(attr_name)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
# Method for ActiveModel::Translation
|
48
|
+
def self.i18n_scope
|
49
|
+
:commands
|
50
|
+
end
|
51
|
+
|
52
|
+
protected
|
53
|
+
|
54
|
+
attr_accessor :status
|
55
|
+
|
56
|
+
def ensure_empty_errors!
|
57
|
+
return if errors.empty?
|
58
|
+
|
59
|
+
error!("`#{self.class}` contains errors.")
|
60
|
+
end
|
61
|
+
|
62
|
+
def ensure_empty_status!
|
63
|
+
return if status.nil?
|
64
|
+
|
65
|
+
error!("`#{self.class}` was already executed.")
|
66
|
+
end
|
67
|
+
|
68
|
+
def ensure_execution!
|
69
|
+
return if status.present?
|
70
|
+
|
71
|
+
error!("`#{self.class}` was not executed yet.")
|
72
|
+
end
|
73
|
+
|
74
|
+
def error!(message = nil)
|
75
|
+
message ||= "`#{self.class}` raised error."
|
76
|
+
raise ApplicationError, message
|
77
|
+
end
|
78
|
+
|
79
|
+
def failure!(message = nil)
|
80
|
+
ensure_empty_status!
|
81
|
+
|
82
|
+
errors.add(:command, :failed, message: message) unless message.nil?
|
83
|
+
|
84
|
+
self.status = :failure
|
85
|
+
self
|
86
|
+
end
|
87
|
+
|
88
|
+
def success!
|
89
|
+
ensure_empty_errors!
|
90
|
+
ensure_empty_status!
|
91
|
+
|
92
|
+
self.status = :success
|
93
|
+
self
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
require 'rails'
|
2
|
+
|
3
|
+
module AuxiliaryRails
|
4
|
+
class ApiResourceGenerator < ::Rails::Generators::NamedBase
|
5
|
+
desc 'Stubs out a new API resource including an empty entity and spec.'
|
6
|
+
|
7
|
+
class_option :api_module,
|
8
|
+
type: :string,
|
9
|
+
default: 'app',
|
10
|
+
desc: 'API module name'
|
11
|
+
class_option :api_version,
|
12
|
+
type: :numeric,
|
13
|
+
default: 1,
|
14
|
+
desc: 'API version'
|
15
|
+
class_option :skip_helper,
|
16
|
+
type: :boolean,
|
17
|
+
default: true,
|
18
|
+
desc: 'Indicates if helper generation needs to be skipped'
|
19
|
+
source_root File.expand_path('templates/apis', __dir__)
|
20
|
+
|
21
|
+
def create_api_resource_file
|
22
|
+
template 'api_resource_template.rb.erb',
|
23
|
+
"app/#{api_module_path}/resources/#{plural_file_name}_resource.rb"
|
24
|
+
end
|
25
|
+
|
26
|
+
def create_api_entity_file
|
27
|
+
template 'api_entity_template.rb.erb',
|
28
|
+
"app/#{api_module_path}/entities/#{file_name}_entity.rb"
|
29
|
+
end
|
30
|
+
|
31
|
+
def create_api_helper_file
|
32
|
+
return if options[:skip_helper]
|
33
|
+
|
34
|
+
template 'api_helper_template.rb.erb',
|
35
|
+
"app/#{api_module_path}/helpers/#{plural_file_name}_api_helper.rb"
|
36
|
+
end
|
37
|
+
|
38
|
+
def create_api_resource_spec_file
|
39
|
+
template 'api_resource_spec_template.rb.erb',
|
40
|
+
"spec/#{api_module_path}/#{plural_file_name}_resource_spec.rb"
|
41
|
+
end
|
42
|
+
|
43
|
+
private
|
44
|
+
|
45
|
+
def api_module_name
|
46
|
+
"#{options[:api_module].camelize}V#{options[:api_version]}API"
|
47
|
+
end
|
48
|
+
|
49
|
+
def api_module_path
|
50
|
+
"apis/#{options[:api_module]}_v#{options[:api_version]}_api"
|
51
|
+
end
|
52
|
+
|
53
|
+
def api_url_path
|
54
|
+
api_name = 'api'
|
55
|
+
api_name += "-#{options[:api_module]}" if options[:api_module] != 'app'
|
56
|
+
"/#{api_name}/v#{options[:api_version]}/#{plural_name}"
|
57
|
+
end
|
58
|
+
|
59
|
+
def entity_class_name
|
60
|
+
"#{api_module_name}::Entities::#{class_name}Entity"
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
require 'rails'
|
2
|
+
|
3
|
+
module AuxiliaryRails
|
4
|
+
class InstallCommandsGenerator < ::Rails::Generators::Base
|
5
|
+
source_root File.expand_path('templates', __dir__)
|
6
|
+
|
7
|
+
def copy_application_command_file
|
8
|
+
copy_file 'application_command_template.rb',
|
9
|
+
'app/commands/application_command.rb'
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
require 'rails'
|
2
|
+
|
3
|
+
module AuxiliaryRails
|
4
|
+
class InstallGenerator < ::Rails::Generators::Base
|
5
|
+
def install
|
6
|
+
generate 'auxiliary_rails:install_commands'
|
7
|
+
generate 'auxiliary_rails:install_errors'
|
8
|
+
generate 'auxiliary_rails:install_rubocop --no-specify-gems'
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'rails_helper'
|
2
|
+
|
3
|
+
RSpec.describe <%= api_module_name %>::Resources::<%= plural_name.camelize %>Resource, type: :request do
|
4
|
+
describe 'GET <%= api_url_path %>' do
|
5
|
+
subject { get '<%= api_url_path %>' }
|
6
|
+
|
7
|
+
# TODO: write some tests
|
8
|
+
skip
|
9
|
+
end
|
10
|
+
|
11
|
+
describe 'POST <%= api_url_path %>' do
|
12
|
+
subject { post '<%= api_url_path %>' }
|
13
|
+
|
14
|
+
# TODO: write some tests
|
15
|
+
skip
|
16
|
+
end
|
17
|
+
|
18
|
+
describe 'GET <%= api_url_path %>/:id' do
|
19
|
+
# TODO: write some tests
|
20
|
+
skip
|
21
|
+
end
|
22
|
+
|
23
|
+
describe 'PUT <%= api_url_path %>/:id' do
|
24
|
+
# TODO: write some tests
|
25
|
+
skip
|
26
|
+
end
|
27
|
+
|
28
|
+
describe 'DELETE <%= api_url_path %>/:id' do
|
29
|
+
# TODO: write some tests
|
30
|
+
skip
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,70 @@
|
|
1
|
+
module <%= api_module_name %>::Resources
|
2
|
+
class <%= plural_name.camelize %>Resource < Grape::API
|
3
|
+
helpers do
|
4
|
+
def collection
|
5
|
+
# TODO: add `policy_scope`?
|
6
|
+
@<%= plural_name %> ||= <%= class_name %>.all
|
7
|
+
end
|
8
|
+
|
9
|
+
def resource
|
10
|
+
@<%= singular_name %> ||= <%= class_name %>.find(params[:id])
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
resource :<%= plural_name %> do
|
15
|
+
desc 'Returns resource collection'
|
16
|
+
get do
|
17
|
+
# TODO: authorize resource, :index?
|
18
|
+
present collection,
|
19
|
+
with: <%= entity_class_name %>
|
20
|
+
end
|
21
|
+
|
22
|
+
desc 'Creates a <%= class_name %>'
|
23
|
+
params do
|
24
|
+
requires :<%= singular_name %>, type: Hash do
|
25
|
+
# TODO: define resource params or remove `params` block
|
26
|
+
end
|
27
|
+
end
|
28
|
+
post do
|
29
|
+
@<%= singular_name %> = <%= class_name %>.new(declared(params)[:<%= singular_name %>])
|
30
|
+
# TODO: authorize resource, :create?
|
31
|
+
resource.save!
|
32
|
+
present resource,
|
33
|
+
with: <%= entity_class_name %>
|
34
|
+
end
|
35
|
+
|
36
|
+
params do
|
37
|
+
requires :id, type: Integer, desc: '<%= class_name %> ID'
|
38
|
+
end
|
39
|
+
route_param :id do
|
40
|
+
desc 'Returns a <%= class_name %>'
|
41
|
+
get do
|
42
|
+
# TODO: authorize resource, :show?
|
43
|
+
present resource,
|
44
|
+
with: <%= entity_class_name %>
|
45
|
+
end
|
46
|
+
|
47
|
+
desc 'Updates a <%= class_name %>'
|
48
|
+
params do
|
49
|
+
requires :<%= singular_name %>, type: Hash do
|
50
|
+
# TODO: define resource params or remove `params` block
|
51
|
+
end
|
52
|
+
end
|
53
|
+
put do
|
54
|
+
resource.assign_attributes(declared(params)[:<%= singular_name %>])
|
55
|
+
# TODO: authorize resource, :update?
|
56
|
+
resource.save!
|
57
|
+
present resource,
|
58
|
+
with: <%= entity_class_name %>
|
59
|
+
end
|
60
|
+
|
61
|
+
desc 'Deletes a <%= class_name %>'
|
62
|
+
delete do
|
63
|
+
# TODO: authorize resource, :destroy?
|
64
|
+
resource.destroy!
|
65
|
+
body false
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
@@ -1,12 +1,13 @@
|
|
1
1
|
# AuxiliaryRails RuboCop Config
|
2
2
|
# Homepage: https://github.com/ergoserv/auxiliary_rails
|
3
|
-
# Version:
|
3
|
+
# Version: 7
|
4
4
|
|
5
5
|
AllCops:
|
6
6
|
Exclude:
|
7
7
|
- 'bin/*'
|
8
8
|
- 'db/schema.rb'
|
9
9
|
- 'db/migrate/*'
|
10
|
+
- 'node_modules/**/*'
|
10
11
|
- 'vendor/**/*'
|
11
12
|
|
12
13
|
#################### Layout ###############################
|
@@ -42,3 +43,9 @@ Style/IfUnlessModifier:
|
|
42
43
|
|
43
44
|
Style/NegatedIf:
|
44
45
|
EnforcedStyle: postfix
|
46
|
+
|
47
|
+
Style/NumericPredicate:
|
48
|
+
EnforcedStyle: comparison
|
49
|
+
|
50
|
+
Style/RescueStandardError:
|
51
|
+
EnforcedStyle: implicit
|
@@ -11,9 +11,12 @@ gem 'auxiliary_rails',
|
|
11
11
|
gem_group :development, :test do
|
12
12
|
gem 'factory_bot_rails'
|
13
13
|
gem 'faker'
|
14
|
+
gem 'pry-byebug'
|
15
|
+
gem 'pry-rails'
|
14
16
|
gem 'rspec-rails'
|
15
17
|
gem 'rubocop'
|
16
18
|
gem 'rubocop-performance'
|
19
|
+
gem 'rubocop-rails'
|
17
20
|
gem 'rubocop-rspec'
|
18
21
|
end
|
19
22
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: auxiliary_rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dmitry Babenko
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2019-
|
12
|
+
date: 2019-08-17 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -39,6 +39,20 @@ dependencies:
|
|
39
39
|
- - ">="
|
40
40
|
- !ruby/object:Gem::Version
|
41
41
|
version: '0'
|
42
|
+
- !ruby/object:Gem::Dependency
|
43
|
+
name: rails
|
44
|
+
requirement: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - "~>"
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: '5.2'
|
49
|
+
type: :development
|
50
|
+
prerelease: false
|
51
|
+
version_requirements: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - "~>"
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '5.2'
|
42
56
|
- !ruby/object:Gem::Dependency
|
43
57
|
name: rake
|
44
58
|
requirement: !ruby/object:Gem::Requirement
|
@@ -153,13 +167,22 @@ files:
|
|
153
167
|
- bin/console
|
154
168
|
- bin/setup
|
155
169
|
- lib/auxiliary_rails.rb
|
170
|
+
- lib/auxiliary_rails/abstract_command.rb
|
156
171
|
- lib/auxiliary_rails/abstract_error.rb
|
157
172
|
- lib/auxiliary_rails/cli.rb
|
158
173
|
- lib/auxiliary_rails/railtie.rb
|
159
174
|
- lib/auxiliary_rails/version.rb
|
160
175
|
- lib/auxiliary_rails/view_helpers.rb
|
176
|
+
- lib/generators/auxiliary_rails/api_resource_generator.rb
|
177
|
+
- lib/generators/auxiliary_rails/install_commands_generator.rb
|
161
178
|
- lib/generators/auxiliary_rails/install_errors_generator.rb
|
179
|
+
- lib/generators/auxiliary_rails/install_generator.rb
|
162
180
|
- lib/generators/auxiliary_rails/install_rubocop_generator.rb
|
181
|
+
- lib/generators/auxiliary_rails/templates/apis/api_entity_template.rb.erb
|
182
|
+
- lib/generators/auxiliary_rails/templates/apis/api_helper_template.rb.erb
|
183
|
+
- lib/generators/auxiliary_rails/templates/apis/api_resource_spec_template.rb.erb
|
184
|
+
- lib/generators/auxiliary_rails/templates/apis/api_resource_template.rb.erb
|
185
|
+
- lib/generators/auxiliary_rails/templates/application_command_template.rb
|
163
186
|
- lib/generators/auxiliary_rails/templates/application_error_template.rb
|
164
187
|
- lib/generators/auxiliary_rails/templates/rubocop/rubocop_auxiliary_rails_template.yml
|
165
188
|
- lib/generators/auxiliary_rails/templates/rubocop/rubocop_template.yml
|