operation_model_scaffold 0.1.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.
- checksums.yaml +7 -0
- data/.rspec +3 -0
- data/CHANGELOG.md +5 -0
- data/CODE_OF_CONDUCT.md +132 -0
- data/LICENSE.txt +21 -0
- data/README.md +79 -0
- data/Rakefile +8 -0
- data/lib/generators/operation_model/scaffold_generator.rb +35 -0
- data/lib/generators/operation_model/templates/README.md.tt +131 -0
- data/lib/generators/operation_model/templates/operation_model.rb.tt +4 -0
- data/lib/generators/operation_model/templates/utility.rb.tt +4 -0
- data/lib/operation_model_scaffold/version.rb +5 -0
- data/lib/operation_model_scaffold.rb +9 -0
- data/operation_model_scaffold.gemspec +38 -0
- data/sig/operation_model_scaffold.rbs +4 -0
- metadata +72 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: a64c450413451bdc2fcbc86bf0ca7c40fe7c2814356936aca49b3820f8ed3a7f
|
4
|
+
data.tar.gz: ef0dafa9c83887c8658320d9e29fe4ff78d17929434614dd9a98cccac04a5b75
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 9b04a2ae19780ec3525b0e65433516817614eece07112677b0ce7398508dac099884a09757cadd7ed6b3c07af88333a9944d2ec90b760cdeb854b88dce4539a6
|
7
|
+
data.tar.gz: 03fb04f46e91cc3ff4aff0cfb4590275ad7aaee909344b084563b6500ed5ab6f9b876e23b391a9fef6328ce2b37103630ddcda4c7d2cac76fb636e8d2fae0290
|
data/.rspec
ADDED
data/CHANGELOG.md
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,132 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
We as members, contributors, and leaders pledge to make participation in our
|
6
|
+
community a harassment-free experience for everyone, regardless of age, body
|
7
|
+
size, visible or invisible disability, ethnicity, sex characteristics, gender
|
8
|
+
identity and expression, level of experience, education, socio-economic status,
|
9
|
+
nationality, personal appearance, race, caste, color, religion, or sexual
|
10
|
+
identity and orientation.
|
11
|
+
|
12
|
+
We pledge to act and interact in ways that contribute to an open, welcoming,
|
13
|
+
diverse, inclusive, and healthy community.
|
14
|
+
|
15
|
+
## Our Standards
|
16
|
+
|
17
|
+
Examples of behavior that contributes to a positive environment for our
|
18
|
+
community include:
|
19
|
+
|
20
|
+
* Demonstrating empathy and kindness toward other people
|
21
|
+
* Being respectful of differing opinions, viewpoints, and experiences
|
22
|
+
* Giving and gracefully accepting constructive feedback
|
23
|
+
* Accepting responsibility and apologizing to those affected by our mistakes,
|
24
|
+
and learning from the experience
|
25
|
+
* Focusing on what is best not just for us as individuals, but for the overall
|
26
|
+
community
|
27
|
+
|
28
|
+
Examples of unacceptable behavior include:
|
29
|
+
|
30
|
+
* The use of sexualized language or imagery, and sexual attention or advances of
|
31
|
+
any kind
|
32
|
+
* Trolling, insulting or derogatory comments, and personal or political attacks
|
33
|
+
* Public or private harassment
|
34
|
+
* Publishing others' private information, such as a physical or email address,
|
35
|
+
without their explicit permission
|
36
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
37
|
+
professional setting
|
38
|
+
|
39
|
+
## Enforcement Responsibilities
|
40
|
+
|
41
|
+
Community leaders are responsible for clarifying and enforcing our standards of
|
42
|
+
acceptable behavior and will take appropriate and fair corrective action in
|
43
|
+
response to any behavior that they deem inappropriate, threatening, offensive,
|
44
|
+
or harmful.
|
45
|
+
|
46
|
+
Community leaders have the right and responsibility to remove, edit, or reject
|
47
|
+
comments, commits, code, wiki edits, issues, and other contributions that are
|
48
|
+
not aligned to this Code of Conduct, and will communicate reasons for moderation
|
49
|
+
decisions when appropriate.
|
50
|
+
|
51
|
+
## Scope
|
52
|
+
|
53
|
+
This Code of Conduct applies within all community spaces, and also applies when
|
54
|
+
an individual is officially representing the community in public spaces.
|
55
|
+
Examples of representing our community include using an official email address,
|
56
|
+
posting via an official social media account, or acting as an appointed
|
57
|
+
representative at an online or offline event.
|
58
|
+
|
59
|
+
## Enforcement
|
60
|
+
|
61
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
62
|
+
reported to the community leaders responsible for enforcement at
|
63
|
+
[INSERT CONTACT METHOD].
|
64
|
+
All complaints will be reviewed and investigated promptly and fairly.
|
65
|
+
|
66
|
+
All community leaders are obligated to respect the privacy and security of the
|
67
|
+
reporter of any incident.
|
68
|
+
|
69
|
+
## Enforcement Guidelines
|
70
|
+
|
71
|
+
Community leaders will follow these Community Impact Guidelines in determining
|
72
|
+
the consequences for any action they deem in violation of this Code of Conduct:
|
73
|
+
|
74
|
+
### 1. Correction
|
75
|
+
|
76
|
+
**Community Impact**: Use of inappropriate language or other behavior deemed
|
77
|
+
unprofessional or unwelcome in the community.
|
78
|
+
|
79
|
+
**Consequence**: A private, written warning from community leaders, providing
|
80
|
+
clarity around the nature of the violation and an explanation of why the
|
81
|
+
behavior was inappropriate. A public apology may be requested.
|
82
|
+
|
83
|
+
### 2. Warning
|
84
|
+
|
85
|
+
**Community Impact**: A violation through a single incident or series of
|
86
|
+
actions.
|
87
|
+
|
88
|
+
**Consequence**: A warning with consequences for continued behavior. No
|
89
|
+
interaction with the people involved, including unsolicited interaction with
|
90
|
+
those enforcing the Code of Conduct, for a specified period of time. This
|
91
|
+
includes avoiding interactions in community spaces as well as external channels
|
92
|
+
like social media. Violating these terms may lead to a temporary or permanent
|
93
|
+
ban.
|
94
|
+
|
95
|
+
### 3. Temporary Ban
|
96
|
+
|
97
|
+
**Community Impact**: A serious violation of community standards, including
|
98
|
+
sustained inappropriate behavior.
|
99
|
+
|
100
|
+
**Consequence**: A temporary ban from any sort of interaction or public
|
101
|
+
communication with the community for a specified period of time. No public or
|
102
|
+
private interaction with the people involved, including unsolicited interaction
|
103
|
+
with those enforcing the Code of Conduct, is allowed during this period.
|
104
|
+
Violating these terms may lead to a permanent ban.
|
105
|
+
|
106
|
+
### 4. Permanent Ban
|
107
|
+
|
108
|
+
**Community Impact**: Demonstrating a pattern of violation of community
|
109
|
+
standards, including sustained inappropriate behavior, harassment of an
|
110
|
+
individual, or aggression toward or disparagement of classes of individuals.
|
111
|
+
|
112
|
+
**Consequence**: A permanent ban from any sort of public interaction within the
|
113
|
+
community.
|
114
|
+
|
115
|
+
## Attribution
|
116
|
+
|
117
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
|
118
|
+
version 2.1, available at
|
119
|
+
[https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1].
|
120
|
+
|
121
|
+
Community Impact Guidelines were inspired by
|
122
|
+
[Mozilla's code of conduct enforcement ladder][Mozilla CoC].
|
123
|
+
|
124
|
+
For answers to common questions about this code of conduct, see the FAQ at
|
125
|
+
[https://www.contributor-covenant.org/faq][FAQ]. Translations are available at
|
126
|
+
[https://www.contributor-covenant.org/translations][translations].
|
127
|
+
|
128
|
+
[homepage]: https://www.contributor-covenant.org
|
129
|
+
[v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html
|
130
|
+
[Mozilla CoC]: https://github.com/mozilla/diversity
|
131
|
+
[FAQ]: https://www.contributor-covenant.org/faq
|
132
|
+
[translations]: https://www.contributor-covenant.org/translations
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2025 shu0115
|
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,79 @@
|
|
1
|
+
# Operation Model Scaffold
|
2
|
+
|
3
|
+
[](LICENSE.txt)
|
4
|
+
|
5
|
+
**Operation Model Scaffold** ใฏใRails ใขใใชใฑใผใทใงใณใซใใใ **Operations ใฌใคใคใผ** ใฎ Scaffold ใ็ๆใใใธใงใใฌใผใฟ Gem ใงใใ
|
6
|
+
|
7
|
+
ใใฎใใผใซใไฝฟ็จใใใใจใงใใใธใในใญใธใใฏใฎ่ฒฌๅใๆ็ขบใซๅ้ขใใไฟๅฎๆงใจๅๅฉ็จๆงใ้ซใใใใใฎใขใผใญใใฏใใฃๆง็ฏใใตใใผใใใพใใ
|
8
|
+
|
9
|
+
---
|
10
|
+
|
11
|
+
## ๐ ่ๆฏ
|
12
|
+
|
13
|
+
Rails ใงใฏใใตใผใในใฏใฉในใใขใใซใ่ฅๅคงๅใใใใใใใธใในใญใธใใฏใฎๆๅจใๆๆงใซใชใใใจใใใใพใใ
|
14
|
+
|
15
|
+
**Operation Model Scaffold** ใฏใ`Operations` ใฌใคใคใผใๅฐๅ
ฅใใใใจใงใๆไฝ๏ผOperation๏ผใใใขใใชใฑใผใทใงใณใฎๆง้ ใจใใฆๆ็คบ็ใซ่กจ็พใงใใใใใซใใไปฅไธใฎใใใชๅนๆใใใใใใพใ๏ผ
|
16
|
+
|
17
|
+
- ใใกใคใณใญใธใใฏใฎ่ฆ้ใใ่ฏใใชใ
|
18
|
+
- ้ขๅฟใฎๅ้ข๏ผSeparation of Concerns๏ผใๆ็ขบใซใชใ
|
19
|
+
- ใในใใใใใใชใ
|
20
|
+
|
21
|
+
---
|
22
|
+
|
23
|
+
## โจ ็นๅพด
|
24
|
+
|
25
|
+
- `bin/rails generate operation_model:scaffold` ใณใใณใใง `app/models/operations/` ใ่ชๅ็ๆ
|
26
|
+
- `README.md` ใ `utility.rb` ใชใฉใฎใใผในใใกใคใซใ็ๆ
|
27
|
+
- `app/models/` ้
ไธใซใใๅ
จใขใใซใซๅฏพๅฟใใ Operations ใขใธใฅใผใซใ่ชๅ็ๆ
|
28
|
+
- `application_record.rb` ใ `utility.rb` ใชใฉใ็นๅฎใใกใคใซใฏ่ชๅ็ๆๅฏพ่ฑกใใ้คๅค
|
29
|
+
|
30
|
+
---
|
31
|
+
|
32
|
+
## ๐ฆ ใคใณในใใผใซ
|
33
|
+
|
34
|
+
Gemfile ใซไปฅไธใ่ฟฝๅ ๏ผ
|
35
|
+
|
36
|
+
```ruby
|
37
|
+
gem 'operation_model_scaffold'
|
38
|
+
```
|
39
|
+
|
40
|
+
ใคใณในใใผใซ๏ผ
|
41
|
+
|
42
|
+
```bash
|
43
|
+
bundle install
|
44
|
+
```
|
45
|
+
|
46
|
+
---
|
47
|
+
|
48
|
+
## ๐ ไฝฟ็จๆนๆณ
|
49
|
+
|
50
|
+
ไปฅไธใฎใธใงใใฌใผใฟใๅฎ่ก๏ผ
|
51
|
+
|
52
|
+
```bash
|
53
|
+
bin/rails generate operation_model:scaffold
|
54
|
+
```
|
55
|
+
|
56
|
+
ใใฎใณใใณใใซใใใไปฅไธใฎใใใชๆง้ ใไฝๆใใใพใ๏ผ
|
57
|
+
|
58
|
+
```
|
59
|
+
app/models/operations/
|
60
|
+
โโโ README.md # Operations ใฌใคใคใผใฎใฌใคใใฉใคใณ
|
61
|
+
โโโ user.rb # Operations::User ใขใธใฅใผใซ๏ผapp/models/user.rb ใซๅฏพๅฟ๏ผ
|
62
|
+
โโโ post.rb # Operations::Post ใขใธใฅใผใซ๏ผapp/models/post.rb ใซๅฏพๅฟ๏ผ
|
63
|
+
โโโ use_cases/
|
64
|
+
โโโ utility.rb # ๅ
ฑ้ใฆใผในใฑใผในๅใใฆใผใใฃใชใใฃ
|
65
|
+
```
|
66
|
+
|
67
|
+
โป `application_record.rb` ใ `utility.rb` ใจใใฃใ็นๆฎ็จ้ใฎใขใใซใฏ่ชๅ็ๆใฎๅฏพ่ฑกๅคใงใใ
|
68
|
+
|
69
|
+
---
|
70
|
+
|
71
|
+
## ๐ ใฉใคใปใณใน
|
72
|
+
|
73
|
+
ใใฎใใญใธใงใฏใใฏ [MIT License](LICENSE.txt) ใฎใใจใงๅ
ฌ้ใใใฆใใพใใ
|
74
|
+
|
75
|
+
---
|
76
|
+
|
77
|
+
## ๐ค ไฝ่
|
78
|
+
|
79
|
+
- [@shu0115](https://github.com/shu0115)
|
data/Rakefile
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
require "rails/generators"
|
2
|
+
|
3
|
+
module OperationModel
|
4
|
+
class ScaffoldGenerator < Rails::Generators::Base
|
5
|
+
source_root File.expand_path("templates", __dir__)
|
6
|
+
|
7
|
+
def create_operations_readme
|
8
|
+
empty_directory "app/models/operations"
|
9
|
+
empty_directory "app/models/operations/use_cases"
|
10
|
+
|
11
|
+
operation_paths = [
|
12
|
+
{ template_name: "README.md", file_path: "app/models/operations/README.md" },
|
13
|
+
{ template_name: "utility.rb", file_path: "app/models/operations/use_cases/utility.rb" },
|
14
|
+
]
|
15
|
+
|
16
|
+
operation_paths.each do |operation_path|
|
17
|
+
File.exist?(operation_path[:file_path]) ? say_status("skip", operation_path[:file_path], :yellow) : template(operation_path[:template_name], operation_path[:file_path])
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def create_model_operations
|
22
|
+
skip_model_names = ['application_record', 'utility']
|
23
|
+
model_files = Dir.glob("app/models/*.rb")
|
24
|
+
|
25
|
+
model_files.each do |model_file|
|
26
|
+
@model_name = File.basename(model_file, ".rb")
|
27
|
+
|
28
|
+
template_name = "operation_model.rb.tt"
|
29
|
+
file_path = "app/models/operations/#{@model_name}.rb"
|
30
|
+
|
31
|
+
(File.exist?(file_path) || skip_model_names.include?(@model_name)) ? say_status("skip", file_path, :yellow) : template(template_name, file_path)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,131 @@
|
|
1
|
+
|
2
|
+
## Operations: ใขใใชใฑใผใทใงใณใฎๆไฝใๆ็คบ็ใซ่จ่ฟฐใใใฌใคใคใผ
|
3
|
+
|
4
|
+
- ใใฎใใฃใฌใฏใใชใซใฏใใใธใในใญใธใใฏใ่คๆฐใขใใซใซใพใใใๅฆ็ใชใฉใใขใใชใฑใผใทใงใณๅบๆใฎใๆไฝ๏ผOperation๏ผใใ่จ่ฟฐใใใขใธใฅใผใซใ้
็ฝฎใใพใใ
|
5
|
+
- ใตใผใในใฏใฉในใฎไนฑ็จใ้ฟใใ่ฒฌๅใจๆง้ ใๆ็ขบใซๅ้ขใใใใใฎๆๆณใจใใฆ่จญ่จใใใใฎใใใใฎ "ใชใใฌใผใทใงใณใขใใซ" ใงใใ
|
6
|
+
|
7
|
+
---
|
8
|
+
|
9
|
+
## ๐ ๅบๆฌใซใผใซ
|
10
|
+
|
11
|
+
- `Operations` ใฏ **ๅฟ
ใใขใธใฅใผใซใจใใฆๅฎ็พฉ**ใใพใ๏ผใฏใฉในใฏ็ฆๆญข๏ผใ
|
12
|
+
|
13
|
+
```ruby
|
14
|
+
module Operations::User
|
15
|
+
def self.promote_to_admin(user)
|
16
|
+
# ...
|
17
|
+
end
|
18
|
+
end
|
19
|
+
```
|
20
|
+
|
21
|
+
- **ใคใณในใฟใณในๅใฏ็ฆๆญข**๏ผ็ถๆ
ใๆใใชใๆ็คบ็ใช้ขๆฐๅในใฟใคใซใๆก็จใใพใใ
|
22
|
+
- **Mix-in๏ผinclude/extend๏ผใฏ็ฆๆญข**๏ผไพๅญ้ขไฟใ้ฟใใใขใธใฅใผใซใฎ็ฌ็ซๆงใไฟใกใพใใ
|
23
|
+
- **ใขใใซใฎใฏใฉในใกใฝใใใฎไปฃๆฟใจใใฆไฝฟ็จ**ใใพใใ
|
24
|
+
- ใขใใซใซใฏ็ถๆ
ๆไฝใๅ็ดใชๅใๅใใใ ใใๆฎใใพใใ
|
25
|
+
- **่คๆฐใฎใขใใซใซใพใใใๅฆ็**ใฏๅฟ
ใ `Operations` ใซๅใๅบใใฆใใ ใใใ
|
26
|
+
|
27
|
+
---
|
28
|
+
|
29
|
+
## ๐ ใใฃใฌใฏใใชๆงๆไพ
|
30
|
+
|
31
|
+
```
|
32
|
+
app/models/operations/
|
33
|
+
โโโ user.rb # Operations::User ใขใธใฅใผใซ
|
34
|
+
โโโ use_cases/
|
35
|
+
โโโ registration.rb # Operations::UseCases::Registration ใขใธใฅใผใซ
|
36
|
+
```
|
37
|
+
|
38
|
+
---
|
39
|
+
|
40
|
+
## ๐ก ใฉใใใใจใใซ Operations ใซๅใๅบใใ๏ผ
|
41
|
+
|
42
|
+
### โ
Operations ใซๆธใใใฎ
|
43
|
+
|
44
|
+
- ่คๆฐใฎใขใใซใๅค้จAPIใซใพใใใๅฆ็
|
45
|
+
- ใใธใในใซใผใซใป็ถๆ
้ท็งปใไผดใๆ็ถใ็ใชๅฆ็
|
46
|
+
- ใขใใซใใณใณใใญใผใฉใซๆธใใจ่ฅๅคงๅใใใใๆไฝ็ใญใธใใฏ
|
47
|
+
- ๆ็ขบใซใใใใใใใจ่จใใใฆใผในใฑใผใน๏ผไพ๏ผไผๅก็ป้ฒใ้ไผๅฆ็ใใใคใณใไปไธ ใชใฉ๏ผ
|
48
|
+
- ใขใใซใฎใฏใฉในใกใฝใใใ่ค้ใชใคใณในใฟใณในใกใฝใใใฎๅฆ็ใฏๅบๆฌ็ใซ Operations ใซๅใๅบใ
|
49
|
+
|
50
|
+
### โ
ใขใใซใซๆธใใใฎ
|
51
|
+
|
52
|
+
- ๅฎๆฐ
|
53
|
+
- `belongs_to`ใ`has_one`ใ`has_many`ใชใฉใฎใขใฝใทใจใผใทใงใณ
|
54
|
+
- enumใฎๅฎ็พฉ
|
55
|
+
- ใใชใใผใทใงใณ
|
56
|
+
- `before_save`ใ`after_destroy`ใชใฉใฎใณใผใซใใใฏ
|
57
|
+
- ่ค้ใชๅฆ็ใซใชใๅ ดๅใฏใใณใผใซใใใฏใฎไธญใงOperationsใฎใกใฝใใใๅผใถๅฝขใซใใใใจใๆค่จใใ
|
58
|
+
- ในใณใผใ
|
59
|
+
- ่ค้ใชๅฆ็ใซใชใๅ ดๅใฏใOperationsใฎใกใฝใใใซใใใใจใๆค่จใใ
|
60
|
+
- ใคใณในใฟใณในใกใฝใใ
|
61
|
+
- ่ค้ใชๅฆ็ใซใชใๅ ดๅใฏใใคใณในใฟใณในใกใฝใใใฎไธญใงOperationsใฎใกใฝใใใๅผใถใใใใใฏใคใณในใฟใณในใกใฝใใใงใฏใชใOperationsใฎใกใฝใใใซใใใใจใๆค่จใใ
|
62
|
+
|
63
|
+
---
|
64
|
+
|
65
|
+
## ๐งญ ๅฝๅ่ฆๅใจๅ้ก
|
66
|
+
|
67
|
+
- **ๆไฝใฎๅฏพ่ฑกใใจใซๅๅ็ฉบ้ใๅใใ**
|
68
|
+
- `Operations::User`๏ผใฆใผใถใผ้ข้ฃใฎๆไฝ
|
69
|
+
- `Operations::UseCases::Registration`๏ผไผๅก็ป้ฒใซ้ขใใไธ้ฃใฎๆไฝ
|
70
|
+
- `Operations::UseCases::Purchase`๏ผ่ณผๅ
ฅๅฆ็้ข้ฃใฎๆไฝ
|
71
|
+
- **ใกใฝใใๅใฏใไฝใใใใใใๆ็ขบใซไผใใใใใๅ่ฉใใผในใงๅฝๅใใ๏ผไพ: `promote_to_admin`, `reset_password`๏ผ**
|
72
|
+
|
73
|
+
```ruby
|
74
|
+
Operations::User.promote_to_admin(user)
|
75
|
+
Operations::User.reset_password(user, token)
|
76
|
+
Operations::UseCases::Registration.create_user(user_params)
|
77
|
+
```
|
78
|
+
|
79
|
+
- **่ค้ใชๅฆ็ใฏใในใใใใใขใธใฅใผใซใซๅๅฒใใฆใ่ฏใ**
|
80
|
+
- ใขใธใฅใผใซๅใจใใกใคใซใในใไธ่ดใใใใใจใงใ็บ่ฆๆงใไฟใกใพใใ
|
81
|
+
|
82
|
+
---
|
83
|
+
|
84
|
+
## ๐ ไฝฟ็จไพ
|
85
|
+
|
86
|
+
```ruby
|
87
|
+
# ็ฎก็่
ๆจฉ้ใฎไปไธ
|
88
|
+
Operations::User.promote_to_admin(user)
|
89
|
+
|
90
|
+
# ใในใฏใผใๅ่จญๅฎๅฆ็
|
91
|
+
Operations::User.reset_password(user, new_password)
|
92
|
+
|
93
|
+
# ไผๅก็ป้ฒๅฆ็
|
94
|
+
Operations::UseCases::Registration.create_user(user_params)
|
95
|
+
```
|
96
|
+
|
97
|
+
---
|
98
|
+
|
99
|
+
## ๐ฏ ็ฎ็ใจๅฉ็น
|
100
|
+
|
101
|
+
- ใณใผใใฎ่ฒฌๅใๆ็ขบใซๅ้ข๏ผใขใใซ่ฅๅคงๅใปใตใผใในใฏใฉในๆททไนฑใ้ฒๆญข๏ผ
|
102
|
+
- ใไฝใใใใใใใใกใคใซใในใจใกใฝใใๅใใ็ดๆ็ใซใใใ
|
103
|
+
- ใในใใใใใใๅๅฉ็จใใใใ
|
104
|
+
- ้ขๆฐๅในใฟใคใซใงๅฏไฝ็จใๆ็คบใป้ๅฎใงใใ
|
105
|
+
|
106
|
+
---
|
107
|
+
|
108
|
+
## ๐งช ใในใใซใคใใฆ
|
109
|
+
|
110
|
+
Operations ใขใธใฅใผใซใฏ็ถๆ
ใๆใใชใใใใRSpec ็ญใฎใฆใใใใในใใง็ดๆฅใกใฝใใใๅผใณๅบใใ ใใง็ฐกๅใซใในใใงใใพใใ
|
111
|
+
|
112
|
+
```ruby
|
113
|
+
describe Operations::User do
|
114
|
+
describe ".promote_to_admin" do
|
115
|
+
it "grants admin role to the user" do
|
116
|
+
user = create(:user)
|
117
|
+
expect {
|
118
|
+
Operations::User.promote_to_admin(user)
|
119
|
+
}.to change { user.reload.role }.to("admin")
|
120
|
+
end
|
121
|
+
end
|
122
|
+
end
|
123
|
+
```
|
124
|
+
|
125
|
+
---
|
126
|
+
|
127
|
+
## ๐ ่ฃ่ถณ
|
128
|
+
|
129
|
+
ใใฎใใฃใฌใฏใใชใฏใRailsใฎๅ
ฌๅผใชใฌใคใคใผๆง้ ๏ผMVC๏ผใซใฏๅญๅจใใพใใใใใขใใชใฑใผใทใงใณ่ฆๆจกใฎๆ้ทใซไผดใฃใฆๅฟ
่ฆใซใชใใใฆใผในใฑใผในๅฑคใใจใใฆไฝ็ฝฎใฅใใใใพใใ
|
130
|
+
|
131
|
+
ใใฎ `Operations` ๅฑคใซใใใใใธใในใญใธใใฏใจใใผใฟใขใใซใฎ่ฒฌๅใใใใใซๅ้ขใใ้ทๆ็ใชไฟๅฎๆงใจใในใๆงใๅไธใใใใใจใ็ฎ็ใงใใ
|
@@ -0,0 +1,38 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "lib/operation_model_scaffold/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "operation_model_scaffold"
|
7
|
+
spec.version = OperationModelScaffold::VERSION
|
8
|
+
spec.authors = ["shu0115"]
|
9
|
+
spec.email = ["s.matsumoto0115@gmail.com"]
|
10
|
+
|
11
|
+
spec.summary = "Rails generator for creating an Operations layer scaffold."
|
12
|
+
spec.description = "This gem provides a generator to scaffold an Operations layer in your Rails app, helping structure application logic in a modular and maintainable way."
|
13
|
+
|
14
|
+
spec.homepage = "https://github.com/shu0115/operation_model_scaffold"
|
15
|
+
spec.license = "MIT"
|
16
|
+
spec.required_ruby_version = ">= 3.1.0"
|
17
|
+
|
18
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
19
|
+
spec.metadata["source_code_uri"] = "https://github.com/shu0115/operation_model_scaffold"
|
20
|
+
spec.metadata["changelog_uri"] = "https://github.com/shu0115/operation_model_scaffold/releases"
|
21
|
+
|
22
|
+
# allowed_push_host is only needed if you push to a private gem server
|
23
|
+
# It is not required for public RubyGems.org
|
24
|
+
# spec.metadata["allowed_push_host"] = "https://rubygems.org"
|
25
|
+
|
26
|
+
spec.files = IO.popen(%w[git ls-files -z], chdir: __dir__, err: IO::NULL) do |ls|
|
27
|
+
ls.readlines("\x0", chomp: true).reject do |f|
|
28
|
+
f.start_with?(*%w[bin/ test/ spec/ features/ .git .github appveyor Gemfile])
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
spec.bindir = "exe"
|
33
|
+
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
34
|
+
spec.require_paths = ["lib"]
|
35
|
+
|
36
|
+
# Add runtime dependencies here, if any.
|
37
|
+
spec.add_dependency "rails"
|
38
|
+
end
|
metadata
ADDED
@@ -0,0 +1,72 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: operation_model_scaffold
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- shu0115
|
8
|
+
bindir: exe
|
9
|
+
cert_chain: []
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
11
|
+
dependencies:
|
12
|
+
- !ruby/object:Gem::Dependency
|
13
|
+
name: rails
|
14
|
+
requirement: !ruby/object:Gem::Requirement
|
15
|
+
requirements:
|
16
|
+
- - ">="
|
17
|
+
- !ruby/object:Gem::Version
|
18
|
+
version: '0'
|
19
|
+
type: :runtime
|
20
|
+
prerelease: false
|
21
|
+
version_requirements: !ruby/object:Gem::Requirement
|
22
|
+
requirements:
|
23
|
+
- - ">="
|
24
|
+
- !ruby/object:Gem::Version
|
25
|
+
version: '0'
|
26
|
+
description: This gem provides a generator to scaffold an Operations layer in your
|
27
|
+
Rails app, helping structure application logic in a modular and maintainable way.
|
28
|
+
email:
|
29
|
+
- s.matsumoto0115@gmail.com
|
30
|
+
executables: []
|
31
|
+
extensions: []
|
32
|
+
extra_rdoc_files: []
|
33
|
+
files:
|
34
|
+
- ".rspec"
|
35
|
+
- CHANGELOG.md
|
36
|
+
- CODE_OF_CONDUCT.md
|
37
|
+
- LICENSE.txt
|
38
|
+
- README.md
|
39
|
+
- Rakefile
|
40
|
+
- lib/generators/operation_model/scaffold_generator.rb
|
41
|
+
- lib/generators/operation_model/templates/README.md.tt
|
42
|
+
- lib/generators/operation_model/templates/operation_model.rb.tt
|
43
|
+
- lib/generators/operation_model/templates/utility.rb.tt
|
44
|
+
- lib/operation_model_scaffold.rb
|
45
|
+
- lib/operation_model_scaffold/version.rb
|
46
|
+
- operation_model_scaffold.gemspec
|
47
|
+
- sig/operation_model_scaffold.rbs
|
48
|
+
homepage: https://github.com/shu0115/operation_model_scaffold
|
49
|
+
licenses:
|
50
|
+
- MIT
|
51
|
+
metadata:
|
52
|
+
homepage_uri: https://github.com/shu0115/operation_model_scaffold
|
53
|
+
source_code_uri: https://github.com/shu0115/operation_model_scaffold
|
54
|
+
changelog_uri: https://github.com/shu0115/operation_model_scaffold/releases
|
55
|
+
rdoc_options: []
|
56
|
+
require_paths:
|
57
|
+
- lib
|
58
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - ">="
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: 3.1.0
|
63
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - ">="
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: '0'
|
68
|
+
requirements: []
|
69
|
+
rubygems_version: 3.6.9
|
70
|
+
specification_version: 4
|
71
|
+
summary: Rails generator for creating an Operations layer scaffold.
|
72
|
+
test_files: []
|