evnt 3.2.5 → 3.2.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +11 -20
- data/lib/evnt/event.rb +4 -4
- data/lib/evnt/version.rb +1 -1
- data/lib/generators/evnt/event_generator.rb +1 -1
- data/lib/generators/evnt/initializer_generator.rb +11 -0
- data/lib/generators/evnt/templates/initializer/app/commands/application_command.rb +4 -0
- data/lib/generators/evnt/templates/initializer/app/events/application_event.rb +11 -0
- data/lib/generators/evnt/templates/initializer/test/commands/application_command_test.rb +0 -1
- data/lib/generators/evnt/templates/initializer/test/events/application_event_test.rb +0 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '0018c224758da691335945353b6168dfc983aa13d7bda8e1e1d08e0b7f23de51'
|
4
|
+
data.tar.gz: e8842f6d62ac1b78a1ca6db497702ba9c6bea6afed34e01f7e57ba57597246a7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 96fa1e160c588b1840a30405b4963cc302a6c5a83f4912bd3c114eba909a4d8ca95164beaab2432661147c95aafc927dd0c117701285472b48d9382b2ddb8cf2
|
7
|
+
data.tar.gz: 7b614dba5252f70d8f3106bd55de60278b8e541d47dadece24359d90f94d03b39db82f781a97358ede91aa154d9ed6efe667fb20072c3091413685f6ee34157c
|
data/README.md
CHANGED
@@ -1,16 +1,17 @@
|
|
1
1
|
# Evnt
|
2
2
|
|
3
|
+
[![Gem Version](https://badge.fury.io/rb/evnt.svg)](https://badge.fury.io/rb/evnt)
|
4
|
+
[![Inline docs](http://inch-ci.org/github/ideonetwork/evnt.svg?branch=master)](http://inch-ci.org/github/ideonetwork/evnt)
|
5
|
+
|
3
6
|
CQRS and Event Driven Development architecture for Ruby projects.
|
4
7
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
- [Rails integration](https://github.com/ideonetwork/evnt/blob/master/doc/RailsIntegration.md)
|
11
|
-
- [Development](#development)
|
8
|
+
Evnt is a Ruby gem used to design software following the CQRS and Event driven development pattern. The idea behind Evnt is to develop the business logic of the system using three different classes:
|
9
|
+
|
10
|
+
- **Commands**: actions executed by actors that can be completed or stopped by the system.
|
11
|
+
- **Events**: something that it's already happen and should be logged somewhere.
|
12
|
+
- **Handlers**: event listeners that perform specific tasks.
|
12
13
|
|
13
|
-
|
14
|
+
The full documentation of these classes can be found here: https://ideonetwork.github.io/evnt
|
14
15
|
|
15
16
|
## Installation
|
16
17
|
|
@@ -26,22 +27,12 @@ Legacy version
|
|
26
27
|
gem 'evnt'
|
27
28
|
```
|
28
29
|
|
29
|
-
## Structure
|
30
|
-
|
31
|
-
Evnt is developed to be used over all kinds of projects and frameworks (like Ruby on Rails or Sinatra), so it contains only three types of entities:
|
32
|
-
|
33
|
-
- [Command](https://github.com/ideonetwork/evnt/blob/master/doc/Command.md)
|
34
|
-
- [Event](https://github.com/ideonetwork/evnt/blob/master/doc/Event.md)
|
35
|
-
- [Handler](https://github.com/ideonetwork/evnt/blob/master/doc/Handler.md)
|
36
|
-
|
37
|
-
Every entity is a simple class that should be extended to structure your awesome project.
|
38
|
-
|
39
30
|
## Development
|
40
31
|
|
41
|
-
To update the documentation run:
|
32
|
+
To update the rdoc documentation run:
|
42
33
|
|
43
34
|
```console
|
44
35
|
|
45
|
-
rdoc --op
|
36
|
+
rdoc --op rdoc
|
46
37
|
|
47
38
|
```
|
data/lib/evnt/event.rb
CHANGED
@@ -86,6 +86,10 @@ module Evnt
|
|
86
86
|
@options = initial_options.merge(default_options)
|
87
87
|
.merge(params_options)
|
88
88
|
|
89
|
+
# set name and attributes
|
90
|
+
@name = _safe_name
|
91
|
+
@attributes = _safe_attributes
|
92
|
+
|
89
93
|
# set payload
|
90
94
|
payload = params.reject { |k, _v| k[0] == '_' }
|
91
95
|
@payload = @state[:reloaded] ? payload : _generate_payload(payload)
|
@@ -94,10 +98,6 @@ module Evnt
|
|
94
98
|
@extras = {}
|
95
99
|
extras = params.select { |k, _v| k[0] == '_' }
|
96
100
|
extras.each { |k, v| @extras[k[1..-1].to_sym] = v }
|
97
|
-
|
98
|
-
# set other datas
|
99
|
-
@name = _safe_name
|
100
|
-
@attributes = _safe_attributes
|
101
101
|
end
|
102
102
|
|
103
103
|
# This function generates the complete event payload.
|
data/lib/evnt/version.rb
CHANGED
@@ -15,7 +15,7 @@ module Evnt
|
|
15
15
|
path = informations.first.split('::')
|
16
16
|
@event_class = path.last.camelize
|
17
17
|
@event_modules = path - [path.last]
|
18
|
-
@event_name = path.map(&:underscore).join('_')
|
18
|
+
@event_name = path.map(&:underscore).join('_') # TODO: Remove "event" at the end of name if it's present.
|
19
19
|
@event_attributes = (informations - [informations.first]).map { |a| ":#{a}" }.join(', ')
|
20
20
|
|
21
21
|
template(
|
@@ -9,9 +9,14 @@ module Evnt
|
|
9
9
|
|
10
10
|
source_root File.expand_path('../templates', __FILE__)
|
11
11
|
|
12
|
+
class_option :migrated, type: :boolean, default: false,
|
13
|
+
desription: 'Include migration for a model used to save events.'
|
14
|
+
|
12
15
|
def create_initializer
|
13
16
|
directory './initializer', './'
|
14
17
|
update_config_application
|
18
|
+
|
19
|
+
manage_migrated_option
|
15
20
|
end
|
16
21
|
|
17
22
|
def update_config_application
|
@@ -20,6 +25,12 @@ module Evnt
|
|
20
25
|
application "config.autoload_paths += %W[\#{Rails.root}/app/handlers]"
|
21
26
|
end
|
22
27
|
|
28
|
+
def manage_migrated_option
|
29
|
+
return unless options[:migrated]
|
30
|
+
|
31
|
+
invoke 'model', ['EvntEvent', 'name:string', 'payload:text']
|
32
|
+
end
|
33
|
+
|
23
34
|
end
|
24
35
|
|
25
36
|
end
|
@@ -2,4 +2,15 @@
|
|
2
2
|
|
3
3
|
# ApplicationEvent.
|
4
4
|
class ApplicationEvent < Evnt::Event
|
5
|
+
|
6
|
+
default_options silent: false
|
7
|
+
|
8
|
+
# Change this block with what you want to do to save event!
|
9
|
+
to_write_event do
|
10
|
+
EvntEvent.create(
|
11
|
+
name: name,
|
12
|
+
payload: payload
|
13
|
+
)
|
14
|
+
end
|
15
|
+
|
5
16
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: evnt
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.2.
|
4
|
+
version: 3.2.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ideonetwork
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-03-
|
11
|
+
date: 2018-03-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|