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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a48e55844b50d4c411b90b137fe6d01e8ccfdf2ea6ed6c6cf6a4e6c1fa61858d
4
- data.tar.gz: f4c2ff39479cd2c39c76948ca82f0adbd7cf033e3cbc80aebb3829870782661e
3
+ metadata.gz: 23232c3a36bb0ede0c8c8ae56e8b777575f34b962e98063781ad9b7dc8ff149b
4
+ data.tar.gz: 58dce58ad6aba69fe1bea815c6f8d3ff64cf8aaf0e487653aa3ba93013f4f589
5
5
  SHA512:
6
- metadata.gz: efa2e26984fa7e44fa0460af1eb8e7a61f310090b4f433a117debf927cac25422a7e6a289ddf19f02acfe2efb34fa947b9f6521441ca7ae6f8535bf788e47c15
7
- data.tar.gz: 611679a3f465a77f9bc5c2c464df2b3b691cd0b417fa97c0b61d80e401ddea683ad57d093d5a15c9baf40f998134b9dad4d001891b9fb2beac53f0b8ee820948
6
+ metadata.gz: 52b2d3824bb3a20f97195b8a9f327a03805c5ca20e3cfdaf14f2ee5f2e730991065e4480c42d4cd34a8b111576778d97e1415cb4f33fd443646eea9ddb62c9ef
7
+ data.tar.gz: 9967a9ccfd94e85648fa59f32b05d706c5985c0f7cff6328dd931f3fae7677e4a7ced4fda3fa24f4bf631bbc537b2929e002a90aef166f7dfc03b75b25f61ba9
data/README.md CHANGED
@@ -1,8 +1,8 @@
1
- # Eztek::MediatR
1
+ # Eztek MediatR
2
2
 
3
- 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.
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
- TODO: Delete this and the text above, and describe your gem
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
- TODO: Write usage instructions here
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/[USERNAME]/eztek-mediat_r.
96
+ Bug reports and pull requests are welcome on GitHub at https://github.com/yeucon02vn/eztek-mediat_r.
@@ -2,6 +2,6 @@
2
2
 
3
3
  module EZ
4
4
  module MediatR
5
- VERSION = "1.0.2"
5
+ VERSION = "1.1.1"
6
6
  end
7
7
  end
@@ -2,7 +2,7 @@ Description:
2
2
  Creates the command model structure for you.
3
3
 
4
4
  Example:
5
- rails generate commands user create_user
5
+ rails generate command user create_user
6
6
 
7
7
  This will create:
8
8
  app/cqrs/user/commands/create_user_command.rb
@@ -1,4 +1,4 @@
1
- class CommandsGenerator < Rails::Generators::Base
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 'commands_template.template', "app/cqrs/#{model.underscore}/commands/#{name.underscore}_command.rb"
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 'commands_validator_template.template', "app/cqrs/#{model.underscore}/commands/validators/#{name.underscore}_command_validator.rb"
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 'commands_handler_template.template', "app/cqrs/#{model.underscore}/commands/handlers/#{name.underscore}_command_handler.rb"
28
+ template 'command_handler_template.template', "app/cqrs/#{model.underscore}/commands/handlers/#{name.underscore}_command_handler.rb"
30
29
  end
31
30
  end
@@ -2,7 +2,7 @@ Description:
2
2
  Creates the query model structure for you.
3
3
 
4
4
  Example:
5
- rails generate queries user get_all_user
5
+ rails generate query user get_all_user
6
6
 
7
7
  This will create:
8
8
  app/cqrs/user/queries/get_all_user_query.rb
@@ -1,4 +1,4 @@
1
- class QueriesGenerator < Rails::Generators::Base
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 'queries_template.template', "app/cqrs/#{model.underscore}/queries/#{name.underscore}_query.rb"
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 'queries_validator_template.template', "app/cqrs/#{model.underscore}/queries/validators/#{name.underscore}_query_validator.rb"
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 'queries_handler_template.template', "app/cqrs/#{model.underscore}/queries/handlers/#{name.underscore}_query_handler.rb"
28
+ template 'query_handler_template.template', "app/cqrs/#{model.underscore}/queries/handlers/#{name.underscore}_query_handler.rb"
29
29
  end
30
30
  end
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.0.2
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-08 00:00:00.000000000 Z
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/commands/USAGE
83
- - lib/generators/commands/commands_generator.rb
84
- - lib/generators/commands/templates/command_handler_template.template
85
- - lib/generators/commands/templates/command_template.template
86
- - lib/generators/commands/templates/command_validator_template.template
87
- - lib/generators/queries/USAGE
88
- - lib/generators/queries/queries_generator.rb
89
- - lib/generators/queries/templates/queries_handler_template.template
90
- - lib/generators/queries/templates/queries_template.template
91
- - lib/generators/queries/templates/queries_validator_template.template
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: