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 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
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ ## [Unreleased]
2
+
3
+ ## [0.1.0] - 2025-05-23
4
+
5
+ - Initial release
@@ -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
+ [![MIT License](https://img.shields.io/badge/license-MIT-blue.svg)](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,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rspec/core/rake_task"
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ task default: :spec
@@ -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,4 @@
1
+ module Operations::<%= @model_name.camelize %>
2
+ class << self
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module Operations::Utility
2
+ class << self
3
+ end
4
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module OperationModelScaffold
4
+ VERSION = "0.1.0"
5
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "operation_model_scaffold/version"
4
+
5
+ module OperationModelScaffold
6
+ class Error < StandardError; end
7
+ end
8
+
9
+ require_relative "generators/operation_model/scaffold_generator"
@@ -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
@@ -0,0 +1,4 @@
1
+ module OperationModelScaffold
2
+ VERSION: String
3
+ # See the writing guide of rbs: https://github.com/ruby/rbs#guides
4
+ 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: []