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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 31e331c91b6b97338b9583587d74b8a3da99c861b9ee46b584f7029185cd25db
4
- data.tar.gz: ce5fadcd4669d194b13a2840ff2e5c311da73f6149c0c7c628cb0bfe6872a641
3
+ metadata.gz: '0018c224758da691335945353b6168dfc983aa13d7bda8e1e1d08e0b7f23de51'
4
+ data.tar.gz: e8842f6d62ac1b78a1ca6db497702ba9c6bea6afed34e01f7e57ba57597246a7
5
5
  SHA512:
6
- metadata.gz: 138fcfc99e148ac1665b0f317ab4f9efe53dae0ef220774defc067e7c7f8e2f79174d19ff81cf17509a4eb1a26169237751e9b8117335d98b094fbd7abcaa0a6
7
- data.tar.gz: 944820d7276892bc245167d0340ed2098f0c5bb9d70cc3b3db3e231dfb0abb39288cfae3c96b7132c1cdbed59b9dec35d10ad61d3909b66508dcdb268abc6c36
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
- - [Installation](#installation)
6
- - [Structure](#structure)
7
- - [Command](https://github.com/ideonetwork/evnt/blob/master/doc/Command.md)
8
- - [Event](https://github.com/ideonetwork/evnt/blob/master/doc/Event.md)
9
- - [Handler](https://github.com/ideonetwork/evnt/blob/master/doc/Handler.md)
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
- Full class documentation here: https://ideonetwork.github.io/evnt/
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 docs
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
@@ -3,6 +3,6 @@
3
3
  # Evnt.
4
4
  module Evnt
5
5
 
6
- VERSION = '3.2.5'
6
+ VERSION = '3.2.6'
7
7
 
8
8
  end
@@ -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,8 @@
2
2
 
3
3
  # ApplicationCommand.
4
4
  class ApplicationCommand < Evnt::Command
5
+
6
+ default_options exceptions: false,
7
+ nullify_empty_params: false
8
+
5
9
  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
@@ -8,7 +8,6 @@ class ApplicationCommandTest < ActiveSupport::TestCase
8
8
  test 'it should be initialized' do
9
9
  command = ApplicationCommand.new
10
10
  assert_not_nil command
11
- assert command.completed?
12
11
  end
13
12
 
14
13
  end
@@ -8,8 +8,6 @@ class ApplicationEventTest < ActiveSupport::TestCase
8
8
  test 'it should be initialized' do
9
9
  event = ApplicationEvent.new
10
10
  assert_not_nil event
11
- assert_not_nil event.payload
12
- assert_not_nil event.payload[:evnt]
13
11
  end
14
12
 
15
13
  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.5
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-01 00:00:00.000000000 Z
11
+ date: 2018-03-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler