hmvc-rails 1.0.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 (33) hide show
  1. checksums.yaml +7 -0
  2. data/.rubocop.yml +34 -0
  3. data/CHANGELOG.md +5 -0
  4. data/CODE_OF_CONDUCT.md +84 -0
  5. data/Gemfile +20 -0
  6. data/Gemfile.lock +172 -0
  7. data/LICENSE.txt +21 -0
  8. data/README.md +302 -0
  9. data/Rakefile +14 -0
  10. data/lib/generators/hmvc_rails/hmvc_rails_generator.rb +155 -0
  11. data/lib/generators/hmvc_rails/install_generator.rb +84 -0
  12. data/lib/generators/hmvc_rails/templates/configures/hmvc_rails.rb.tt +27 -0
  13. data/lib/generators/hmvc_rails/templates/configures/hmvc_rails_api.rb.tt +27 -0
  14. data/lib/generators/hmvc_rails/templates/controllers/controller.rb.tt +10 -0
  15. data/lib/generators/hmvc_rails/templates/extras/error_resource.rb.tt +31 -0
  16. data/lib/generators/hmvc_rails/templates/extras/error_response.rb.tt +21 -0
  17. data/lib/generators/hmvc_rails/templates/extras/exception.rb.tt +59 -0
  18. data/lib/generators/hmvc_rails/templates/forms/application_form.rb.tt +32 -0
  19. data/lib/generators/hmvc_rails/templates/forms/form.rb.tt +5 -0
  20. data/lib/generators/hmvc_rails/templates/operations/application_operation.rb.tt +11 -0
  21. data/lib/generators/hmvc_rails/templates/operations/operation.rb.tt +6 -0
  22. data/lib/generators/hmvc_rails/templates/validators/email_validator.rb.tt +10 -0
  23. data/lib/generators/hmvc_rails/templates/validators/uniqueness_validator.rb.tt +29 -0
  24. data/lib/generators/hmvc_rails/templates/views/view.erb.tt +1 -0
  25. data/lib/generators/hmvc_rails/templates/views/view.haml.tt +1 -0
  26. data/lib/generators/hmvc_rails/templates/views/view.slim.tt +1 -0
  27. data/lib/hmvc/rails/version.rb +7 -0
  28. data/lib/hmvc/rails.rb +35 -0
  29. data/lib/rubocop/cop/hmvc_rails/formal_style.rb +16 -0
  30. data/lib/rubocop/cop/hmvc_rails/operating_style.rb +29 -0
  31. data/lib/rubocop/cop/hmvc_rails_cops.rb +4 -0
  32. data/sig/hmvc/rails.rbs +6 -0
  33. metadata +74 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 4dd3f8480d396c51dc8d60cc16c5df9596f66d246079db510e41847f8cc10140
4
+ data.tar.gz: 6318242634c8b11060724147d7b28f0e7dbecce9338e08a18c5dd041784ad515
5
+ SHA512:
6
+ metadata.gz: c905bd1b4a55b56c4c0265e21f4d4dfed4526a3d07d571c414475291f3f51ef105ba6c756860212924e3516ce076023449607f8be4846613d401060f1a80e94a
7
+ data.tar.gz: be42b1a104ff76ac32fbb8b12e21862094f64fab70b88f5a5915fffb78baf74fc25716d0fb865ef4b6aed9b4afadaf8d370511600f8c74170556777680857b09
data/.rubocop.yml ADDED
@@ -0,0 +1,34 @@
1
+ AllCops:
2
+ SuggestExtensions: false
3
+
4
+ Style/StringLiterals:
5
+ Enabled: true
6
+ EnforcedStyle: double_quotes
7
+
8
+ Style/StringLiteralsInInterpolation:
9
+ Enabled: true
10
+ EnforcedStyle: double_quotes
11
+
12
+ Layout/LineLength:
13
+ Max: 120
14
+
15
+ Style/Documentation:
16
+ Enabled: false
17
+
18
+ Metrics/CyclomaticComplexity:
19
+ Enabled: false
20
+
21
+ Metrics/MethodLength:
22
+ Enabled: false
23
+
24
+ Metrics/ClassLength:
25
+ Enabled: false
26
+
27
+ Metrics/AbcSize:
28
+ Enabled: false
29
+
30
+ Gemspec/RequiredRubyVersion:
31
+ Enabled: false
32
+
33
+ Metrics/PerceivedComplexity:
34
+ Enabled: false
data/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ ## [Unreleased]
2
+
3
+ ## [1.0.0] - 2023-02-15
4
+
5
+ - Initial release
@@ -0,0 +1,84 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
6
+
7
+ We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
8
+
9
+ ## Our Standards
10
+
11
+ Examples of behavior that contributes to a positive environment for our community include:
12
+
13
+ * Demonstrating empathy and kindness toward other people
14
+ * Being respectful of differing opinions, viewpoints, and experiences
15
+ * Giving and gracefully accepting constructive feedback
16
+ * Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
17
+ * Focusing on what is best not just for us as individuals, but for the overall community
18
+
19
+ Examples of unacceptable behavior include:
20
+
21
+ * The use of sexualized language or imagery, and sexual attention or
22
+ advances of any kind
23
+ * Trolling, insulting or derogatory comments, and personal or political attacks
24
+ * Public or private harassment
25
+ * Publishing others' private information, such as a physical or email
26
+ address, without their explicit permission
27
+ * Other conduct which could reasonably be considered inappropriate in a
28
+ professional setting
29
+
30
+ ## Enforcement Responsibilities
31
+
32
+ Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
33
+
34
+ Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
35
+
36
+ ## Scope
37
+
38
+ This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
39
+
40
+ ## Enforcement
41
+
42
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at thuc.phan@tomosia.com. All complaints will be reviewed and investigated promptly and fairly.
43
+
44
+ All community leaders are obligated to respect the privacy and security of the reporter of any incident.
45
+
46
+ ## Enforcement Guidelines
47
+
48
+ Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
49
+
50
+ ### 1. Correction
51
+
52
+ **Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
53
+
54
+ **Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
55
+
56
+ ### 2. Warning
57
+
58
+ **Community Impact**: A violation through a single incident or series of actions.
59
+
60
+ **Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
61
+
62
+ ### 3. Temporary Ban
63
+
64
+ **Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
65
+
66
+ **Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
67
+
68
+ ### 4. Permanent Ban
69
+
70
+ **Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
71
+
72
+ **Consequence**: A permanent ban from any sort of public interaction within the community.
73
+
74
+ ## Attribution
75
+
76
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0,
77
+ available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
78
+
79
+ Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
80
+
81
+ [homepage]: https://www.contributor-covenant.org
82
+
83
+ For answers to common questions about this code of conduct, see the FAQ at
84
+ https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.
data/Gemfile ADDED
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ # Specify your gem's dependencies in hmvc-rails.gemspec
6
+ gemspec
7
+
8
+ group :test do
9
+ # Ruby on Rails is a full-stack web framework optimized for programmer happiness and sustainable productivity
10
+ gem "rails", "7.0"
11
+
12
+ # Rake is a Make-like program implemented in Ruby
13
+ gem "rake", "13.0"
14
+
15
+ # RuboCop is a Ruby code style checking and code formatting tool
16
+ gem "rubocop", "1.21"
17
+
18
+ # Minitest provides a complete suite of testing facilities supporting TDD, BDD, mocking, and benchmarking
19
+ gem "minitest", "5.17"
20
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,172 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ hmvc-rails (1.0.0)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ actioncable (7.0.0)
10
+ actionpack (= 7.0.0)
11
+ activesupport (= 7.0.0)
12
+ nio4r (~> 2.0)
13
+ websocket-driver (>= 0.6.1)
14
+ actionmailbox (7.0.0)
15
+ actionpack (= 7.0.0)
16
+ activejob (= 7.0.0)
17
+ activerecord (= 7.0.0)
18
+ activestorage (= 7.0.0)
19
+ activesupport (= 7.0.0)
20
+ mail (>= 2.7.1)
21
+ actionmailer (7.0.0)
22
+ actionpack (= 7.0.0)
23
+ actionview (= 7.0.0)
24
+ activejob (= 7.0.0)
25
+ activesupport (= 7.0.0)
26
+ mail (~> 2.5, >= 2.5.4)
27
+ rails-dom-testing (~> 2.0)
28
+ actionpack (7.0.0)
29
+ actionview (= 7.0.0)
30
+ activesupport (= 7.0.0)
31
+ rack (~> 2.0, >= 2.2.0)
32
+ rack-test (>= 0.6.3)
33
+ rails-dom-testing (~> 2.0)
34
+ rails-html-sanitizer (~> 1.0, >= 1.2.0)
35
+ actiontext (7.0.0)
36
+ actionpack (= 7.0.0)
37
+ activerecord (= 7.0.0)
38
+ activestorage (= 7.0.0)
39
+ activesupport (= 7.0.0)
40
+ globalid (>= 0.6.0)
41
+ nokogiri (>= 1.8.5)
42
+ actionview (7.0.0)
43
+ activesupport (= 7.0.0)
44
+ builder (~> 3.1)
45
+ erubi (~> 1.4)
46
+ rails-dom-testing (~> 2.0)
47
+ rails-html-sanitizer (~> 1.1, >= 1.2.0)
48
+ activejob (7.0.0)
49
+ activesupport (= 7.0.0)
50
+ globalid (>= 0.3.6)
51
+ activemodel (7.0.0)
52
+ activesupport (= 7.0.0)
53
+ activerecord (7.0.0)
54
+ activemodel (= 7.0.0)
55
+ activesupport (= 7.0.0)
56
+ activestorage (7.0.0)
57
+ actionpack (= 7.0.0)
58
+ activejob (= 7.0.0)
59
+ activerecord (= 7.0.0)
60
+ activesupport (= 7.0.0)
61
+ marcel (~> 1.0)
62
+ mini_mime (>= 1.1.0)
63
+ activesupport (7.0.0)
64
+ concurrent-ruby (~> 1.0, >= 1.0.2)
65
+ i18n (>= 1.6, < 2)
66
+ minitest (>= 5.1)
67
+ tzinfo (~> 2.0)
68
+ ast (2.4.2)
69
+ builder (3.2.4)
70
+ concurrent-ruby (1.2.0)
71
+ crass (1.0.6)
72
+ date (3.3.3)
73
+ erubi (1.12.0)
74
+ globalid (1.1.0)
75
+ activesupport (>= 5.0)
76
+ i18n (1.12.0)
77
+ concurrent-ruby (~> 1.0)
78
+ loofah (2.19.1)
79
+ crass (~> 1.0.2)
80
+ nokogiri (>= 1.5.9)
81
+ mail (2.8.1)
82
+ mini_mime (>= 0.1.1)
83
+ net-imap
84
+ net-pop
85
+ net-smtp
86
+ marcel (1.0.2)
87
+ method_source (1.0.0)
88
+ mini_mime (1.1.2)
89
+ minitest (5.17.0)
90
+ net-imap (0.3.4)
91
+ date
92
+ net-protocol
93
+ net-pop (0.1.2)
94
+ net-protocol
95
+ net-protocol (0.2.1)
96
+ timeout
97
+ net-smtp (0.3.3)
98
+ net-protocol
99
+ nio4r (2.5.8)
100
+ nokogiri (1.14.2-x86_64-darwin)
101
+ racc (~> 1.4)
102
+ parallel (1.22.1)
103
+ parser (3.2.1.0)
104
+ ast (~> 2.4.1)
105
+ racc (1.6.2)
106
+ rack (2.2.6.2)
107
+ rack-test (2.0.2)
108
+ rack (>= 1.3)
109
+ rails (7.0.0)
110
+ actioncable (= 7.0.0)
111
+ actionmailbox (= 7.0.0)
112
+ actionmailer (= 7.0.0)
113
+ actionpack (= 7.0.0)
114
+ actiontext (= 7.0.0)
115
+ actionview (= 7.0.0)
116
+ activejob (= 7.0.0)
117
+ activemodel (= 7.0.0)
118
+ activerecord (= 7.0.0)
119
+ activestorage (= 7.0.0)
120
+ activesupport (= 7.0.0)
121
+ bundler (>= 1.15.0)
122
+ railties (= 7.0.0)
123
+ rails-dom-testing (2.0.3)
124
+ activesupport (>= 4.2.0)
125
+ nokogiri (>= 1.6)
126
+ rails-html-sanitizer (1.5.0)
127
+ loofah (~> 2.19, >= 2.19.1)
128
+ railties (7.0.0)
129
+ actionpack (= 7.0.0)
130
+ activesupport (= 7.0.0)
131
+ method_source
132
+ rake (>= 12.2)
133
+ thor (~> 1.0)
134
+ zeitwerk (~> 2.5)
135
+ rainbow (3.1.1)
136
+ rake (13.0.0)
137
+ regexp_parser (2.7.0)
138
+ rexml (3.2.5)
139
+ rubocop (1.21.0)
140
+ parallel (~> 1.10)
141
+ parser (>= 3.0.0.0)
142
+ rainbow (>= 2.2.2, < 4.0)
143
+ regexp_parser (>= 1.8, < 3.0)
144
+ rexml
145
+ rubocop-ast (>= 1.9.1, < 2.0)
146
+ ruby-progressbar (~> 1.7)
147
+ unicode-display_width (>= 1.4.0, < 3.0)
148
+ rubocop-ast (1.26.0)
149
+ parser (>= 3.2.1.0)
150
+ ruby-progressbar (1.11.0)
151
+ thor (1.2.1)
152
+ timeout (0.3.2)
153
+ tzinfo (2.0.6)
154
+ concurrent-ruby (~> 1.0)
155
+ unicode-display_width (2.4.2)
156
+ websocket-driver (0.7.5)
157
+ websocket-extensions (>= 0.1.0)
158
+ websocket-extensions (0.1.5)
159
+ zeitwerk (2.6.7)
160
+
161
+ PLATFORMS
162
+ x86_64-darwin-19
163
+
164
+ DEPENDENCIES
165
+ hmvc-rails!
166
+ minitest (= 5.17)
167
+ rails (= 7.0)
168
+ rake (= 13.0)
169
+ rubocop (= 1.21)
170
+
171
+ BUNDLED WITH
172
+ 2.3.25
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2023 thucpt
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,302 @@
1
+ # HMVC-RAILS
2
+
3
+ ## Summary
4
+
5
+ - hmvc-rails is the high-level model of MVC (MVC high-level structure)
6
+
7
+ - hmvc-rails makes it easy to manage source code and develop projects
8
+
9
+ ## Features
10
+
11
+ - Generate controller file
12
+ - Generate operations file
13
+ - Generate forms file
14
+ - Generate views file
15
+ - Add file creator and creation date
16
+
17
+ ## Installation
18
+
19
+ Add this line to your application's Gemfile
20
+
21
+ ```ruby
22
+ group :development do
23
+ gem 'hmvc-rails', git: 'git@github.com:TOMOSIA-VIETNAM/hmvc-rails.git'
24
+ end
25
+ ```
26
+
27
+ Then execute
28
+
29
+ ```
30
+ bundle install
31
+ ```
32
+
33
+ And run
34
+
35
+ ```
36
+ rails g hmvc_rails:install
37
+ ```
38
+
39
+ ```
40
+ create config/initializers/hmvc.rb
41
+ create app/operations/application_operation.rb
42
+ create app/forms/application_form.rb
43
+ create app/validators/uniqueness_validator.rb
44
+ create app/validators/email_validator.rb
45
+ ```
46
+
47
+ If it's an API project then you can run
48
+
49
+ ```
50
+ rails g hmvc_rails:install --api
51
+ ```
52
+
53
+ ```
54
+ create config/initializers/hmvc_rails.rb
55
+ create app/operations/application_operation.rb
56
+ create app/forms/application_form.rb
57
+ create app/validators/uniqueness_validator.rb
58
+ create app/validators/email_validator.rb
59
+ create lib/hmvc_rails/extras/exception.rb
60
+ create lib/hmvc_rails/extras/error_resource.rb
61
+ create lib/hmvc_rails/extras/error_response.rb
62
+ insert config/application.rb
63
+ insert app/controllers/application_controller.rb
64
+ ```
65
+
66
+ ## Usage
67
+
68
+ ### Default generator
69
+
70
+ ```
71
+ rails g hmvc_rails controller_name
72
+ ```
73
+
74
+ Example
75
+
76
+ ```
77
+ rails g hmvc_rails admin
78
+ ```
79
+
80
+ ```
81
+ create app/controllers/admin_controller.rb
82
+ create app/operations/admin/index_operation.rb
83
+ create app/operations/admin/show_operation.rb
84
+ create app/operations/admin/new_operation.rb
85
+ create app/operations/admin/create_operation.rb
86
+ create app/operations/admin/edit_operation.rb
87
+ create app/operations/admin/update_operation.rb
88
+ create app/operations/admin/destroy_operation.rb
89
+ create app/forms/admin/new_form.rb
90
+ create app/forms/admin/create_form.rb
91
+ create app/forms/admin/edit_form.rb
92
+ create app/forms/admin/update_form.rb
93
+ create app/views/admin/index.html.erb
94
+ create app/views/admin/show.html.erb
95
+ create app/views/admin/new.html.erb
96
+ create app/views/admin/edit.html.erb
97
+ ```
98
+
99
+ ### Options
100
+
101
+ ##### 1. If you want to create with action other than default. You can use option `--action`
102
+
103
+ ```
104
+ rails g hmvc_rails admin --action index show list detail selection
105
+ ```
106
+
107
+ ##### 2. If you want to create with form action other than default. You can use option `--form`
108
+
109
+ ```
110
+ rails g hmvc_rails admin --action index show list detail selection --form index show list
111
+ ```
112
+
113
+ ##### 3. If you want to create with parent controller other than default. You can use option `--parent-controller`
114
+
115
+ ```
116
+ rails g hmvc_rails admin --parent-controller PersonController
117
+ ```
118
+
119
+ ##### 4. If you want to skip creating the forms file when generate. You can use option `--skip-form`
120
+
121
+ ```
122
+ rails g hmvc_rails admin --skip-form
123
+ ```
124
+
125
+ Or change configuration `config.form = %w[]`
126
+
127
+ ##### 5. If you want to skip creating the views file when generate. You can use option `--skip-view`
128
+
129
+ ```
130
+ rails g hmvc_rails admin --skip-view
131
+ ```
132
+
133
+ Or change configuration `config.view = %w[]`
134
+
135
+ ## Configuration
136
+
137
+ If you want to change the default value when creating the file, please uncomment and update
138
+
139
+ _config/initializers/hmvc.rb_
140
+
141
+ ```ruby
142
+ # frozen_string_literal: true
143
+
144
+ # Created at: 2023-02-18 22:30 +0700
145
+ # Creator: thuc.phan@tomosia.com
146
+
147
+ if Rails.env.development?
148
+ Hmvc::Rails.configure do |config|
149
+ # The controller files's parent class of controller. Default is ApplicationController
150
+ # config.parent_controller = "ApplicationController"
151
+
152
+ # Method when creating the controller files. Default is %w[index show new create edit update destroy]
153
+ # config.action = %w[index show new create edit update destroy]
154
+
155
+ # Method when creating the view files. Default is %w[index show new edit]
156
+ # config.view = %w[index show new edit]
157
+
158
+ # The form files's parent class. Default is ApplicationForm
159
+ # config.parent_form = "ApplicationForm"
160
+
161
+ # Method when creating the form files. Default is %w[new create edit update]
162
+ # config.form = %w[new create edit update]
163
+
164
+ # The operation files's parent class. Default is ApplicationOperation
165
+ # config.parent_operation = "ApplicationOperation"
166
+
167
+ # Save author name and timestamp to file. Default is true
168
+ # config.file_traces = true
169
+ end
170
+ end
171
+ ```
172
+
173
+ ## Rollback generator
174
+
175
+ If you want to rollback the hmvc-rails generator. You can run command
176
+
177
+ ```
178
+ rails d hmvc_rails controller_name
179
+ ```
180
+
181
+ ## Test and debug gem on development environment
182
+
183
+ - Add gem and run `bundle` (link to gem hmvc-rails project)
184
+
185
+ ```ruby
186
+ group :development do
187
+ gem 'hmvc-rails', path: '../../Projects/hmvc-rails'
188
+ gem 'pry'
189
+ end
190
+ ```
191
+
192
+ - Add `binding.pry` to the line you want to test
193
+
194
+ ```ruby
195
+ require 'pry'
196
+ ...
197
+ def create_controller
198
+ binding.pry
199
+ template "controller.rb", File.join("app/controllers", class_path.join("/"), "#{file_name}_controller.rb")
200
+ end
201
+ ```
202
+
203
+ - Run command generator at Rails project terminal
204
+
205
+ ```
206
+ rails g hmvc_rails admin
207
+ ```
208
+
209
+ ```
210
+ 37: def create_controller
211
+ => 38: binding.pry
212
+ 39: template "controllers/controller.rb",
213
+ 40: File.join("app/controllers", class_path.join("/"), "#{file_name}_controller.rb")
214
+ 41: end
215
+
216
+ [1] pry(#<HmvcRailsGenerator>)> options[:action]
217
+ => ["index", "show", "new", "create", "edit", "update", "destroy"]
218
+ [2] pry(#<HmvcRailsGenerator>)>
219
+ ```
220
+
221
+ - Code convention check
222
+
223
+ ```
224
+ ➜ hmvc-rails git:(main) rubocop
225
+ Inspecting 14 files
226
+ ..............
227
+
228
+ 14 files inspected, no offenses detected
229
+ ```
230
+
231
+ - Run unit test
232
+
233
+ ```
234
+ ➜ hmvc-rails git:(main) ✗ rake test
235
+ Run options: --seed 9122
236
+
237
+ # Running:
238
+
239
+ .............
240
+
241
+ Finished in 0.721364s, 18.0214 runs/s, 166.3515 assertions/s.
242
+ 13 runs, 120 assertions, 0 failures, 0 errors, 0 skips
243
+ ```
244
+
245
+ ## Configure rubocop
246
+
247
+ If your project used rubocop for code convention. You can add the below configuration for some conventional hmvc-rails
248
+
249
+ _.rubocop.yml_
250
+
251
+ ```ruby
252
+ require: rubocop/cop/hmvc_rails_cops
253
+
254
+ HmvcRails/OperatingStyle:
255
+ Enabled: true
256
+ Include:
257
+ - app/operations/**/*.rb
258
+
259
+ HmvcRails/FormalStyle:
260
+ Enabled: true
261
+ Include:
262
+ - app/forms/**/*.rb
263
+ ```
264
+
265
+ Example hmvc-rails offenses
266
+
267
+ ```
268
+ ➜ demo git:(master) ✗ rubocop
269
+ Inspecting 48 files
270
+ ......C......C..................................
271
+
272
+ Offenses:
273
+
274
+ app/forms/admin/new_form.rb:6:1: C: HmvcRails/FormalStyle: The form filename does not match the desired format
275
+ class Admin::NewFormm < ApplicationForm ...
276
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
277
+ app/operations/admin/new_operation.rb:6:1: C: HmvcRails/OperatingStyle: The operation filename does not match the desired format
278
+ class Admin::NewOperationn < ApplicationOperation ...
279
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
280
+ app/operations/admin/new_operation.rb:7:3: C: HmvcRails/OperatingStyle: Method works in "call" without prefix "step_"
281
+ def call ...
282
+ ^^^^^^^^
283
+
284
+ 48 files inspected, 3 offenses detected
285
+ ```
286
+
287
+ ## License
288
+
289
+ The gem `hmvc-rails` is copyright TOMOSIA VIET NAM CO., LTD
290
+
291
+ ## Contributor
292
+
293
+ - Thuc Phan T. thuc.phan@tomosia.com
294
+ - Minh Tang Q. minh.tang@tomosia.com
295
+
296
+ ## About [TOMOSIA VIET NAM CO., LTD](https://www.tomosia.com/)
297
+
298
+ A company that creates new value together with customers and lights the light of happiness
299
+
300
+ 【一緒に】【ハッピー】【ライトアップ】
301
+
302
+ お客様と共に新たな価値を生み出し幸せの明かりを灯す会社、トモシア
data/Rakefile ADDED
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rubocop/rake_task"
5
+ require "rake/testtask"
6
+
7
+ RuboCop::RakeTask.new
8
+
9
+ Rake::TestTask.new do |t|
10
+ t.libs << "test"
11
+ end
12
+
13
+ task default: :rubocop
14
+ task default: :test