eztek-mediat_r 1.0.2 → 1.1.1
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 +4 -4
- data/README.md +66 -5
- data/lib/ez/mediat_r/version.rb +1 -1
- data/lib/generators/{commands → command}/USAGE +1 -1
- data/lib/generators/{commands/commands_generator.rb → command/command_generator.rb} +4 -5
- data/lib/generators/{commands → command}/templates/command_handler_template.template +0 -0
- data/lib/generators/{commands → command}/templates/command_template.template +0 -0
- data/lib/generators/{commands → command}/templates/command_validator_template.template +0 -0
- data/lib/generators/{queries → query}/USAGE +1 -1
- data/lib/generators/{queries/queries_generator.rb → query/query_generator.rb} +4 -4
- data/lib/generators/{queries/templates/queries_handler_template.template → query/templates/query_handler_template.template} +0 -0
- data/lib/generators/{queries/templates/queries_template.template → query/templates/query_template.template} +0 -0
- data/lib/generators/{queries/templates/queries_validator_template.template → query/templates/query_validator_template.template} +0 -0
- metadata +12 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 23232c3a36bb0ede0c8c8ae56e8b777575f34b962e98063781ad9b7dc8ff149b
|
4
|
+
data.tar.gz: 58dce58ad6aba69fe1bea815c6f8d3ff64cf8aaf0e487653aa3ba93013f4f589
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 52b2d3824bb3a20f97195b8a9f327a03805c5ca20e3cfdaf14f2ee5f2e730991065e4480c42d4cd34a8b111576778d97e1415cb4f33fd443646eea9ddb62c9ef
|
7
|
+
data.tar.gz: 9967a9ccfd94e85648fa59f32b05d706c5985c0f7cff6328dd931f3fae7677e4a7ced4fda3fa24f4bf631bbc537b2929e002a90aef166f7dfc03b75b25f61ba9
|
data/README.md
CHANGED
@@ -1,8 +1,8 @@
|
|
1
|
-
# Eztek
|
1
|
+
# Eztek MediatR
|
2
2
|
|
3
|
-
|
3
|
+
<a href="https://www.buymeacoffee.com/phunguyen" target="_blank"><img src="https://www.buymeacoffee.com/assets/img/custom_images/orange_img.png" alt="Buy Me A Coffee" style="height: 41px !important;width: 174px !important;box-shadow: 0px 3px 2px 0px rgba(190, 190, 190, 0.5) !important;-webkit-box-shadow: 0px 3px 2px 0px rgba(190, 190, 190, 0.5) !important;" ></a>
|
4
4
|
|
5
|
-
|
5
|
+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/eztek/mediat_r`. To experiment with that code, run `bin/console` for an interactive prompt.
|
6
6
|
|
7
7
|
## Installation
|
8
8
|
|
@@ -21,8 +21,69 @@ Or install it yourself as:
|
|
21
21
|
$ gem install eztek-mediat_r
|
22
22
|
|
23
23
|
## Usage
|
24
|
+
### Initialize mediatR
|
25
|
+
Add new file config/initializers/mediat_r.rb to initializer mediatR
|
26
|
+
```ruby
|
27
|
+
require 'ez/mediat_r'
|
28
|
+
|
29
|
+
mediator = EZ::MediatR.new
|
30
|
+
Rails.configuration.to_prepare do
|
31
|
+
Rails.configuration.bus = Bus.new
|
32
|
+
Rails.configuration.bus.tap do |bus|
|
33
|
+
# Register command - handler
|
34
|
+
bus.register(Auth::Commands::LoginCommand, Auth::Commands::Handlers::LoginCommandHandler.new)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
```
|
39
|
+
|
40
|
+
### Declare mediatR in controller
|
41
|
+
```ruby
|
42
|
+
def initialize
|
43
|
+
@mediator = Rails.configuration.bus
|
44
|
+
end
|
45
|
+
|
46
|
+
```
|
47
|
+
|
48
|
+
or dependency with dry-container, dry-auto_inject:
|
49
|
+
|
50
|
+
### Register mediaR in container
|
51
|
+
Use file dependency.rb to register mediatR
|
52
|
+
```ruby
|
53
|
+
require 'ez/mediat_r'
|
54
|
+
|
55
|
+
dependency_container = Dry::Container.new
|
56
|
+
dependency_container.register('mediator', -> { EZ::MediatR.new })
|
57
|
+
AutoInject = Dry::AutoInject(dependency_container)
|
58
|
+
|
59
|
+
```
|
60
|
+
|
61
|
+
### Define mediatR in controller
|
62
|
+
```ruby
|
63
|
+
include AutoInject['mediator']
|
64
|
+
|
65
|
+
```
|
66
|
+
|
67
|
+
### Run mediator
|
68
|
+
```ruby
|
69
|
+
command = Auth::Commands::LoginCommand.new(username, password)
|
70
|
+
mediator.execute(command)
|
71
|
+
|
72
|
+
```
|
73
|
+
|
74
|
+
## Generator structure with rails
|
75
|
+
```ruby
|
76
|
+
$ rails generate command feature command_name
|
77
|
+
```
|
78
|
+
Example:
|
79
|
+
```ruby
|
80
|
+
$ rails generate command auth login
|
81
|
+
```
|
24
82
|
|
25
|
-
|
83
|
+
This will create:
|
84
|
+
app/cqrs/auth/commands/login_command.rb
|
85
|
+
app/cqrs/auth/commands/validators/login_command_validator.rb
|
86
|
+
app/cqrs/auth/commands/handlers/login_command_handler.rb
|
26
87
|
|
27
88
|
## Development
|
28
89
|
|
@@ -32,4 +93,4 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
32
93
|
|
33
94
|
## Contributing
|
34
95
|
|
35
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
96
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/yeucon02vn/eztek-mediat_r.
|
data/lib/ez/mediat_r/version.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
class
|
1
|
+
class CommandGenerator < Rails::Generators::Base
|
2
2
|
source_root File.expand_path('../templates', __FILE__)
|
3
3
|
argument :model, type: :string
|
4
4
|
argument :name, type: :string
|
@@ -14,18 +14,17 @@ class CommandsGenerator < Rails::Generators::Base
|
|
14
14
|
generate_command_validator if options.validator?
|
15
15
|
end
|
16
16
|
|
17
|
-
|
18
17
|
private
|
19
18
|
|
20
19
|
def generate_command
|
21
|
-
template '
|
20
|
+
template 'command_template.template', "app/cqrs/#{model.underscore}/commands/#{name.underscore}_command.rb"
|
22
21
|
end
|
23
22
|
|
24
23
|
def generate_command_validator
|
25
|
-
template '
|
24
|
+
template 'command_validator_template.template', "app/cqrs/#{model.underscore}/commands/validators/#{name.underscore}_command_validator.rb"
|
26
25
|
end
|
27
26
|
|
28
27
|
def generate_command_handler
|
29
|
-
template '
|
28
|
+
template 'command_handler_template.template', "app/cqrs/#{model.underscore}/commands/handlers/#{name.underscore}_command_handler.rb"
|
30
29
|
end
|
31
30
|
end
|
File without changes
|
File without changes
|
File without changes
|
@@ -1,4 +1,4 @@
|
|
1
|
-
class
|
1
|
+
class QueryGenerator < Rails::Generators::Base
|
2
2
|
source_root File.expand_path('../templates', __FILE__)
|
3
3
|
argument :model, type: :string
|
4
4
|
argument :name, type: :string
|
@@ -17,14 +17,14 @@ class QueriesGenerator < Rails::Generators::Base
|
|
17
17
|
private
|
18
18
|
|
19
19
|
def generate_query
|
20
|
-
template '
|
20
|
+
template 'query_template.template', "app/cqrs/#{model.underscore}/queries/#{name.underscore}_query.rb"
|
21
21
|
end
|
22
22
|
|
23
23
|
def generate_query_validator
|
24
|
-
template '
|
24
|
+
template 'query_validator_template.template', "app/cqrs/#{model.underscore}/queries/validators/#{name.underscore}_query_validator.rb"
|
25
25
|
end
|
26
26
|
|
27
27
|
def generate_query_handler
|
28
|
-
template '
|
28
|
+
template 'query_handler_template.template', "app/cqrs/#{model.underscore}/queries/handlers/#{name.underscore}_query_handler.rb"
|
29
29
|
end
|
30
30
|
end
|
File without changes
|
File without changes
|
File without changes
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: eztek-mediat_r
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- yeucon02vn
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-09-
|
11
|
+
date: 2022-09-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: concurrent-ruby
|
@@ -79,16 +79,16 @@ files:
|
|
79
79
|
- lib/ez/mediat_r.rb
|
80
80
|
- lib/ez/mediat_r/alias.rb
|
81
81
|
- lib/ez/mediat_r/version.rb
|
82
|
-
- lib/generators/
|
83
|
-
- lib/generators/
|
84
|
-
- lib/generators/
|
85
|
-
- lib/generators/
|
86
|
-
- lib/generators/
|
87
|
-
- lib/generators/
|
88
|
-
- lib/generators/
|
89
|
-
- lib/generators/
|
90
|
-
- lib/generators/
|
91
|
-
- lib/generators/
|
82
|
+
- lib/generators/command/USAGE
|
83
|
+
- lib/generators/command/command_generator.rb
|
84
|
+
- lib/generators/command/templates/command_handler_template.template
|
85
|
+
- lib/generators/command/templates/command_template.template
|
86
|
+
- lib/generators/command/templates/command_validator_template.template
|
87
|
+
- lib/generators/query/USAGE
|
88
|
+
- lib/generators/query/query_generator.rb
|
89
|
+
- lib/generators/query/templates/query_handler_template.template
|
90
|
+
- lib/generators/query/templates/query_template.template
|
91
|
+
- lib/generators/query/templates/query_validator_template.template
|
92
92
|
- sig/ez/mediat_r.rbs
|
93
93
|
homepage: https://github.com/yeucon02vn/eztek-mediat_r
|
94
94
|
licenses:
|