cqs 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 +4 -0
- data/.standard.yml +3 -0
- data/CHANGELOG.md +7 -0
- data/CODE_OF_CONDUCT.md +132 -0
- data/LICENSE.txt +21 -0
- data/README.md +149 -0
- data/Rakefile +10 -0
- data/lib/cqs/base.rb +19 -0
- data/lib/cqs/command.rb +22 -0
- data/lib/cqs/engine.rb +6 -0
- data/lib/cqs/query.rb +22 -0
- data/lib/cqs/version.rb +5 -0
- data/lib/cqs.rb +10 -0
- data/lib/generators/cqs/command/USAGE +9 -0
- data/lib/generators/cqs/command/command_generator.rb +19 -0
- data/lib/generators/cqs/command/templates/command.rb.tt +9 -0
- data/lib/generators/cqs/command/templates/command_spec.rb.tt +7 -0
- data/lib/generators/cqs/install/USAGE +8 -0
- data/lib/generators/cqs/install/install_generator.rb +14 -0
- data/lib/generators/cqs/install/templates/cqs.rb.erb +15 -0
- data/lib/generators/cqs/query/USAGE +9 -0
- data/lib/generators/cqs/query/query_generator.rb +19 -0
- data/lib/generators/cqs/query/templates/query.rb.tt +9 -0
- data/lib/generators/cqs/query/templates/query_spec.rb.tt +7 -0
- data/sig/cqs.rbs +4 -0
- metadata +89 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 25ead5f863f480be7c4142451b814639bdc679bb4b12d0403299405d61d43117
|
|
4
|
+
data.tar.gz: e523eaf75e002bf13514258722a6d9b69929792edb5cfd06bb170c1875a46f2c
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 6eb876b0f9a852087a7f02aef4d4cacff33fb42b2c28844c48dbbb6fffc2f3ba9636c27564fb94857db295438aec5e6fb91bb7640f3209aaddc4e1f2f63ba79c
|
|
7
|
+
data.tar.gz: 85ce856f0e5ccd0bf8c62398b30070e08ec97f9f33dcbd30945b0e260f9b32345530fd59aead7b4d6a6afc8c2299f2b40c0a491dbe4d007b3c5728ef888d3578
|
data/.rspec
ADDED
data/.standard.yml
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) 2024 Enrique Comba Riepenhausen
|
|
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,149 @@
|
|
|
1
|
+
# CQS - Command Query Separation for Ruby (and Rails)
|
|
2
|
+
|
|
3
|
+
⚠️ This gem (and readme) are still **Work In Progress** ⚠️
|
|
4
|
+
|
|
5
|
+
Unlike [CQRS](https://martinfowler.com/bliki/CQRS.html), this gem tries to give a framework that allows to separate _Commands_ from _Queries_ in your [Ruby](https://www.ruby-lang.org) programs.
|
|
6
|
+
|
|
7
|
+
Working on a [Ruby on Rails](http://rubyonrails.org/) application we got tired and frustrated about the `ApplicationService` pattern that is so prevalent in so many [Rails](http://rubyonrails.org/)
|
|
8
|
+
codebases.
|
|
9
|
+
|
|
10
|
+
Here are a few reasons we did and did not like the pattern:
|
|
11
|
+
|
|
12
|
+
- A Service can be almost anything
|
|
13
|
+
- We are never sure what the service _really_ does and we end up, if not careful, creating similar services
|
|
14
|
+
- The language got a little muddled
|
|
15
|
+
|
|
16
|
+
For these reasons we opted for creating a simpler language in our application.
|
|
17
|
+
|
|
18
|
+
> When requesting information use a **Query**
|
|
19
|
+
>
|
|
20
|
+
> When requesting a change use a **Command**
|
|
21
|
+
|
|
22
|
+
One thing we did not want to implement (_the reason this is not a [CQRS](https://martinfowler.com/bliki/CQRS.html) implementation_) is the strictness of a pure CQRS implementation (_meaning commands can,
|
|
23
|
+
and many times will, have return values, specially if you consider a #save action in a Rails app_).
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
## Usage
|
|
27
|
+
|
|
28
|
+
Most of the times we use this gem in a [Ruby on Rails](https://rubyonrails.org) project, so the usage examples will be for Rails. If you use it in plain Ruby projects it will still work, you just won't have
|
|
29
|
+
access to the generators.
|
|
30
|
+
|
|
31
|
+
We are opinionated with the use of [RSpec](https://rspec.info) to test drive our code. Let us know if you'd like to have other testing tools supported!
|
|
32
|
+
|
|
33
|
+
### General assumptions
|
|
34
|
+
|
|
35
|
+
Commands and Queries operate on a `subject`. The subject is passed into the action by the provided methods (`wtih` for commands, and `in` for queries):
|
|
36
|
+
|
|
37
|
+
```ruby
|
|
38
|
+
FindUser.in(email_address: "test@test.com")
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
You can register methods to change the way you call your action:
|
|
42
|
+
|
|
43
|
+
```ruby
|
|
44
|
+
class FindUser
|
|
45
|
+
include Query
|
|
46
|
+
register_method :by
|
|
47
|
+
...
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
And then call the action with the method registered:
|
|
51
|
+
|
|
52
|
+
```ruby
|
|
53
|
+
FindUser.by(email_address: "test@test.com")
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
This works for both, `Commands` and `Queries`.
|
|
57
|
+
|
|
58
|
+
The subject is what's passed into the calling method and can be anything you like (_see below to see how it's used_).
|
|
59
|
+
|
|
60
|
+
### Queries
|
|
61
|
+
|
|
62
|
+
Imagine you want to create a query to find a user by passing a hash with some of their attributes (`find_by` in Rails).
|
|
63
|
+
|
|
64
|
+
To save time and setup you'll run the provided generator:
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
rails generate cqs:query FindUser
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
This will create the following files:
|
|
71
|
+
|
|
72
|
+
```
|
|
73
|
+
- app/queries/query/find_user.rb
|
|
74
|
+
- spec/queries/query/find_user_spec.rb
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
The generated `Query` looks like so:
|
|
78
|
+
|
|
79
|
+
```ruby
|
|
80
|
+
module Query
|
|
81
|
+
class FindUser
|
|
82
|
+
include Query
|
|
83
|
+
|
|
84
|
+
def answer
|
|
85
|
+
raise AnswerUnknownApology.new "Please implement #answer"
|
|
86
|
+
end
|
|
87
|
+
end
|
|
88
|
+
end
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
And the corresponding spec:
|
|
92
|
+
|
|
93
|
+
```ruby
|
|
94
|
+
require "rails_helper"
|
|
95
|
+
|
|
96
|
+
describe Query::FindUser do
|
|
97
|
+
it "does something" do
|
|
98
|
+
pending "test your query"
|
|
99
|
+
end
|
|
100
|
+
end
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
First we'd write our spec to ensure our `Query` does what we'd like it to do:
|
|
104
|
+
|
|
105
|
+
```ruby
|
|
106
|
+
require "rails_helper"
|
|
107
|
+
|
|
108
|
+
describe Query::FindUser do
|
|
109
|
+
it "finds a user by their email address" do
|
|
110
|
+
email_address = { email_address: "test@test.com"}
|
|
111
|
+
expect(User).to receive(:find_by).with(email_address)
|
|
112
|
+
|
|
113
|
+
Query::FindUser.by(email_address)
|
|
114
|
+
end
|
|
115
|
+
end
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
and the code to make this pass:
|
|
119
|
+
|
|
120
|
+
```ruby
|
|
121
|
+
module Query
|
|
122
|
+
class FindUser
|
|
123
|
+
include Query
|
|
124
|
+
register_method :by
|
|
125
|
+
|
|
126
|
+
def answer
|
|
127
|
+
User.find_by(subject)
|
|
128
|
+
end
|
|
129
|
+
end
|
|
130
|
+
end
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
## Development
|
|
134
|
+
|
|
135
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `bundle execute rspec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
|
136
|
+
|
|
137
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
|
138
|
+
|
|
139
|
+
## Contributing
|
|
140
|
+
|
|
141
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/cqs. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/cqs/blob/main/CODE_OF_CONDUCT.md).
|
|
142
|
+
|
|
143
|
+
## License
|
|
144
|
+
|
|
145
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
|
146
|
+
|
|
147
|
+
## Code of Conduct
|
|
148
|
+
|
|
149
|
+
Everyone interacting in the CQS project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/cqs/blob/main/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
data/lib/cqs/base.rb
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
module Cqs
|
|
2
|
+
class Error < StandardError; end
|
|
3
|
+
|
|
4
|
+
module Base
|
|
5
|
+
def self.included(base)
|
|
6
|
+
base.prepend InstanceMethods
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
module InstanceMethods
|
|
10
|
+
def initialize(subject)
|
|
11
|
+
@subject = subject
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def subject
|
|
15
|
+
@subject
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
data/lib/cqs/command.rb
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
require "cqs/base"
|
|
2
|
+
|
|
3
|
+
module Command
|
|
4
|
+
include Cqs::Base
|
|
5
|
+
|
|
6
|
+
def self.included(base)
|
|
7
|
+
base.extend(ClassMethods)
|
|
8
|
+
base.register_method :with
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
module ClassMethods
|
|
12
|
+
def register_method(method_name)
|
|
13
|
+
define_singleton_method(method_name) do |subject|
|
|
14
|
+
new(subject).execute
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def execute
|
|
20
|
+
raise CommandNotFound.new "I'm really sorry, but that command doesn't exist."
|
|
21
|
+
end
|
|
22
|
+
end
|
data/lib/cqs/engine.rb
ADDED
data/lib/cqs/query.rb
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
require "cqs/base"
|
|
2
|
+
|
|
3
|
+
module Query
|
|
4
|
+
include Cqs::Base
|
|
5
|
+
|
|
6
|
+
def self.included(base)
|
|
7
|
+
base.extend(ClassMethods)
|
|
8
|
+
base.register_method :in
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
module ClassMethods
|
|
12
|
+
def register_method(method_name)
|
|
13
|
+
define_singleton_method(method_name) do |subject|
|
|
14
|
+
new(subject).answer
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def answer
|
|
20
|
+
raise AnswerUnknownApology.new "I'm really sorry, but I don't have any answer for you."
|
|
21
|
+
end
|
|
22
|
+
end
|
data/lib/cqs/version.rb
ADDED
data/lib/cqs.rb
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
module Cqs::Generators
|
|
2
|
+
class CommandGenerator < Rails::Generators::NamedBase
|
|
3
|
+
source_root File.expand_path("templates", __dir__)
|
|
4
|
+
|
|
5
|
+
def create_command_file
|
|
6
|
+
template "command.rb", File.join(
|
|
7
|
+
"app/commands/command",
|
|
8
|
+
"#{file_name}.rb"
|
|
9
|
+
)
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def create_command_spec_file
|
|
13
|
+
template "command_spec.rb", File.join(
|
|
14
|
+
"spec/commands/command",
|
|
15
|
+
"#{file_name}_spec.rb"
|
|
16
|
+
)
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
module Cqs::Generators
|
|
2
|
+
class InstallGenerator < ::Rails::Generators::Base
|
|
3
|
+
source_root File.expand_path("templates", __dir__)
|
|
4
|
+
|
|
5
|
+
def create_intializer
|
|
6
|
+
template "cqs.rb.erb", Rails.root.join("config/initializers/cqs.rb")
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
def create_directories
|
|
10
|
+
empty_directory Rails.root.join("app/commands/command")
|
|
11
|
+
empty_directory Rails.root.join("app/queries/query")
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Command
|
|
4
|
+
end
|
|
5
|
+
|
|
6
|
+
module Query
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
Rails.autoloaders.main.push_dir(
|
|
10
|
+
Rails.root.join("app/commands/command").to_s, namespace: Command
|
|
11
|
+
)
|
|
12
|
+
|
|
13
|
+
Rails.autoloaders.main.push_dir(
|
|
14
|
+
Rails.root.join("app/queries/query").to_s, namespace: Query
|
|
15
|
+
)
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
module Cqs::Generators
|
|
2
|
+
class QueryGenerator < Rails::Generators::NamedBase
|
|
3
|
+
source_root File.expand_path("templates", __dir__)
|
|
4
|
+
|
|
5
|
+
def create_query_file
|
|
6
|
+
template "query.rb", File.join(
|
|
7
|
+
"app/queries/query",
|
|
8
|
+
"#{file_name}.rb"
|
|
9
|
+
)
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def create_query_spec_file
|
|
13
|
+
template "query_spec.rb", File.join(
|
|
14
|
+
"spec/queries/query",
|
|
15
|
+
"#{file_name}_spec.rb"
|
|
16
|
+
)
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
data/sig/cqs.rbs
ADDED
metadata
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: cqs
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Enrique Comba Riepenhausen
|
|
8
|
+
bindir: exe
|
|
9
|
+
cert_chain: []
|
|
10
|
+
date: 2024-12-22 00:00:00.000000000 Z
|
|
11
|
+
dependencies:
|
|
12
|
+
- !ruby/object:Gem::Dependency
|
|
13
|
+
name: railties
|
|
14
|
+
requirement: !ruby/object:Gem::Requirement
|
|
15
|
+
requirements:
|
|
16
|
+
- - ">="
|
|
17
|
+
- !ruby/object:Gem::Version
|
|
18
|
+
version: '6.1'
|
|
19
|
+
- - "<"
|
|
20
|
+
- !ruby/object:Gem::Version
|
|
21
|
+
version: '9'
|
|
22
|
+
type: :runtime
|
|
23
|
+
prerelease: false
|
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
25
|
+
requirements:
|
|
26
|
+
- - ">="
|
|
27
|
+
- !ruby/object:Gem::Version
|
|
28
|
+
version: '6.1'
|
|
29
|
+
- - "<"
|
|
30
|
+
- !ruby/object:Gem::Version
|
|
31
|
+
version: '9'
|
|
32
|
+
description: cqs allows you to separate queries from commands for a better segregation
|
|
33
|
+
of concerns.
|
|
34
|
+
email:
|
|
35
|
+
- enrique@ecomba.pro
|
|
36
|
+
executables: []
|
|
37
|
+
extensions: []
|
|
38
|
+
extra_rdoc_files: []
|
|
39
|
+
files:
|
|
40
|
+
- ".rspec"
|
|
41
|
+
- ".standard.yml"
|
|
42
|
+
- CHANGELOG.md
|
|
43
|
+
- CODE_OF_CONDUCT.md
|
|
44
|
+
- LICENSE.txt
|
|
45
|
+
- README.md
|
|
46
|
+
- Rakefile
|
|
47
|
+
- lib/cqs.rb
|
|
48
|
+
- lib/cqs/base.rb
|
|
49
|
+
- lib/cqs/command.rb
|
|
50
|
+
- lib/cqs/engine.rb
|
|
51
|
+
- lib/cqs/query.rb
|
|
52
|
+
- lib/cqs/version.rb
|
|
53
|
+
- lib/generators/cqs/command/USAGE
|
|
54
|
+
- lib/generators/cqs/command/command_generator.rb
|
|
55
|
+
- lib/generators/cqs/command/templates/command.rb.tt
|
|
56
|
+
- lib/generators/cqs/command/templates/command_spec.rb.tt
|
|
57
|
+
- lib/generators/cqs/install/USAGE
|
|
58
|
+
- lib/generators/cqs/install/install_generator.rb
|
|
59
|
+
- lib/generators/cqs/install/templates/cqs.rb.erb
|
|
60
|
+
- lib/generators/cqs/query/USAGE
|
|
61
|
+
- lib/generators/cqs/query/query_generator.rb
|
|
62
|
+
- lib/generators/cqs/query/templates/query.rb.tt
|
|
63
|
+
- lib/generators/cqs/query/templates/query_spec.rb.tt
|
|
64
|
+
- sig/cqs.rbs
|
|
65
|
+
homepage: https://github.com/OurWeeSaas/cqs
|
|
66
|
+
licenses:
|
|
67
|
+
- MIT
|
|
68
|
+
metadata:
|
|
69
|
+
homepage_uri: https://github.com/OurWeeSaas/cqs
|
|
70
|
+
source_code_uri: https://github.com/OurWeeSaas/cqs
|
|
71
|
+
changelog_uri: https://github.com/OurWeeSaas/cqs/CHANGELOG.md
|
|
72
|
+
rdoc_options: []
|
|
73
|
+
require_paths:
|
|
74
|
+
- lib
|
|
75
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
76
|
+
requirements:
|
|
77
|
+
- - ">="
|
|
78
|
+
- !ruby/object:Gem::Version
|
|
79
|
+
version: 3.0.0
|
|
80
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
81
|
+
requirements:
|
|
82
|
+
- - ">="
|
|
83
|
+
- !ruby/object:Gem::Version
|
|
84
|
+
version: '0'
|
|
85
|
+
requirements: []
|
|
86
|
+
rubygems_version: 3.6.0
|
|
87
|
+
specification_version: 4
|
|
88
|
+
summary: Command Query Segregation simplified for ruby (and rails)
|
|
89
|
+
test_files: []
|