evnt 3.6.2 → 3.6.3

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: 534a7e52f3d1e1e0639241b4576f13ddf3d84f5d27661653a7f54b8ab6282b87
4
- data.tar.gz: 269c77c39c3475b5514f6bb72b6d0177bb6d0e7707de349ad40613feb2bae9ec
3
+ metadata.gz: d6914876f490b7f506f0bd135ac831e8acffb9e5fb43415f58058caabd247b89
4
+ data.tar.gz: bccddfbc82d68e6b0a4799dd1db223cb8eb29c53b74b2ce59cfbcbd208d15ad5
5
5
  SHA512:
6
- metadata.gz: c5ba0c448849c4d6b6288b7158c8ce32ac2a532829257207f371567fc39e070495ad25e69d2ad2c9d1d5e222d3b6d5ce9b2cd9a430c0a87680675b692ab9913e
7
- data.tar.gz: 000fb5ac286e63df864ddbad79759e12829b02f627bb2fab61b8631a75db1f43dc127b9637dc3183988b961a6d100345303c1fd4b66cee0cea3c45768029a462
6
+ metadata.gz: c66d8707ed27a203347788861f27f7acdb6220bae5fe6288ce63b4b162dafc19ace35fe0e4e077274e743f908f1c0ca2acd379cdc02441cf1aeb2956ba502ddf
7
+ data.tar.gz: 7e01984cd1ae84b961ff41fad33e0fd518c5543c172eb821a5315936767637615e81efb3d215e408fa824e79c087d11e4daeceba8d76c8f57f17c97fc76aff08
data/README.md CHANGED
@@ -42,7 +42,7 @@ rdoc --op rdoc
42
42
  Install docsify as global node dependency
43
43
 
44
44
  ```shell
45
- npm install -g docsify
45
+ npm install -g docsify-cli
46
46
  ```
47
47
 
48
48
  See documentation on local machine
@@ -213,11 +213,10 @@ module Evnt
213
213
 
214
214
  # This function sets the single validation request for a command parameter.
215
215
  def validates(param, options)
216
- @validations ||= []
217
- @validations.push(param: param, options: options)
218
- command_validations = @validations
216
+ @@validations ||= []
217
+ @@validations.push(param: param, options: options)
219
218
 
220
- define_method('_validations', -> { return command_validations })
219
+ define_method('_validations', -> { @@validations })
221
220
  end
222
221
 
223
222
  # This function sets the normalize params function for the command.
@@ -16,7 +16,17 @@ module Evnt
16
16
  attr_reader :name
17
17
 
18
18
  ##
19
- # Attribute containings the list of attributes of the event.
19
+ # Attribute containings the list of payload attributes of the event.
20
+ ##
21
+ attr_reader :payload_attributes
22
+
23
+ ##
24
+ # Attribute containings the list of extras attributes of the event.
25
+ ##
26
+ attr_reader :extras_attributes
27
+
28
+ ##
29
+ # DEPRECATED: Attribute containings the list of attributes of the event.
20
30
  ##
21
31
  attr_reader :attributes
22
32
 
@@ -49,6 +59,7 @@ module Evnt
49
59
  def initialize(params = {})
50
60
  _init_event_data(params)
51
61
  _validate_payload
62
+ _validate_extras
52
63
  _run_event_steps
53
64
  _notify_handlers if @state[:saved]
54
65
  end
@@ -111,7 +122,9 @@ module Evnt
111
122
 
112
123
  # set name and attributes
113
124
  @name = _safe_name
114
- @attributes = _safe_attributes
125
+ @payload_attributes = _safe_payload_attributes
126
+ @extras_attributes = _safe_extras_attributes
127
+ @attributes = _safe_payload_attributes # DEPRECATED
115
128
 
116
129
  # set payload
117
130
  payload = params.reject { |k, _v| k[0] == '_' }
@@ -137,10 +150,17 @@ module Evnt
137
150
  # This function validates all payload and check they are completed.
138
151
  def _validate_payload
139
152
  # check all attributes are present
140
- check_attr = (@payload.keys - [:evnt]) == @attributes
153
+ check_attr = (@payload.keys - [:evnt]).sort == @payload_attributes.sort
141
154
  raise 'Event parameters are not correct' unless check_attr
142
155
  end
143
156
 
157
+ # This function validates all extras and check they are completed.
158
+ def _validate_extras
159
+ # check all attributes are present
160
+ check_attr = @extras.keys.sort == @extras_attributes.sort
161
+ puts 'Event extras are not correct; in future releases they will be required' unless check_attr
162
+ end
163
+
144
164
  # This function calls requested steps for the event.
145
165
  def _run_event_steps
146
166
  _safe_write_event
@@ -169,8 +189,13 @@ module Evnt
169
189
  ''
170
190
  end
171
191
 
172
- def _safe_attributes
173
- return _attributes if defined?(_attributes)
192
+ def _safe_payload_attributes
193
+ return _payload_attributes if defined?(_payload_attributes)
194
+ []
195
+ end
196
+
197
+ def _safe_extras_attributes
198
+ return _extras_attributes if defined?(_extras_attributes)
174
199
  []
175
200
  end
176
201
 
@@ -192,11 +217,10 @@ module Evnt
192
217
 
193
218
  # This function sets the default options that should be used by the event.
194
219
  def default_options(options)
195
- @options ||= {}
196
- @options.merge!(options)
197
- event_options = @options
220
+ @@options ||= {}
221
+ @@options.merge!(options)
198
222
 
199
- define_method('_default_options', -> { return event_options })
223
+ define_method('_default_options', -> { @@options })
200
224
  end
201
225
 
202
226
  # This function sets the name for the event.
@@ -204,22 +228,36 @@ module Evnt
204
228
  define_method('_name', -> { return name })
205
229
  end
206
230
 
207
- # This function sets the list of attributes for the event.
231
+ # This function sets the list of payload attributes for the event.
232
+ def payload_attributes_are(*attributes)
233
+ @@payload_attributes ||= []
234
+ @@payload_attributes.concat(attributes).uniq!
235
+
236
+ define_method('_payload_attributes', -> { @@payload_attributes })
237
+ end
238
+
239
+ # This function sets the list of extras attributes for the event.
240
+ def extras_attributes_are(*attributes)
241
+ @@extras_attributes ||= []
242
+ @@extras_attributes.concat(attributes).uniq!
243
+
244
+ define_method('_extras_attributes', -> { @@extras_attributes })
245
+ end
246
+
247
+ # DEPRECATED: This function sets the list of attributes for the event.
208
248
  def attributes_are(*attributes)
209
- @attributes ||= []
210
- @attributes.concat(attributes).uniq!
211
- event_attributes = @attributes
249
+ @@payload_attributes ||= []
250
+ @@payload_attributes.concat(attributes).uniq!
212
251
 
213
- define_method('_attributes', -> { return event_attributes })
252
+ define_method('_payload_attributes', -> { @@payload_attributes })
214
253
  end
215
254
 
216
255
  # This function sets the list of handlers for the event.
217
256
  def handlers_are(handlers)
218
- @handlers ||= []
219
- @handlers.concat(handlers)
220
- event_handlers = @handlers
257
+ @@handlers ||= []
258
+ @@handlers.concat(handlers)
221
259
 
222
- define_method('_handlers', -> { return event_handlers })
260
+ define_method('_handlers', -> { @@handlers })
223
261
  end
224
262
 
225
263
  # This function sets the write event function for the event.
@@ -229,11 +267,10 @@ module Evnt
229
267
 
230
268
  # This function is used to add a new handler to the event from the external.
231
269
  def add_handler(handler)
232
- @handlers ||= []
233
- @handlers.push(handler)
234
- event_handlers = @handlers
270
+ @@handlers ||= []
271
+ @@handlers.push(handler)
235
272
 
236
- define_method('_handlers', -> { return event_handlers })
273
+ define_method('_handlers', -> { @@handlers })
237
274
  end
238
275
 
239
276
  end
@@ -3,6 +3,6 @@
3
3
  # Evnt.
4
4
  module Evnt
5
5
 
6
- VERSION = '3.6.2'
6
+ VERSION = '3.6.3'
7
7
 
8
8
  end
@@ -7,7 +7,7 @@
7
7
 
8
8
  <%= ' ' * (@event_modules.length + 1) %>name_is :<%= @event_name %>
9
9
  <% unless @event_attributes.blank? %>
10
- <%= ' ' * (@event_modules.length + 1) %>attributes_are <%= @event_attributes %>
10
+ <%= ' ' * (@event_modules.length + 1) %>payload_attributes_are <%= @event_attributes %>
11
11
  <% end %>
12
12
  <%= ' ' * @event_modules.length %>end
13
13
  <% @event_modules.each_with_index do |_module_name, index| %>
@@ -3,7 +3,8 @@
3
3
  # ApplicationEvent.
4
4
  class ApplicationEvent < Evnt::Event
5
5
 
6
- default_options silent: false
6
+ default_options silent: false,
7
+ exceptions: false
7
8
 
8
9
  # Change this block with what you want to do to save event!
9
10
  to_write_event do
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.6.2
4
+ version: 3.6.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ideonetwork
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-12-24 00:00:00.000000000 Z
11
+ date: 2019-11-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -100,8 +100,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
100
100
  - !ruby/object:Gem::Version
101
101
  version: '0'
102
102
  requirements: []
103
- rubyforge_project:
104
- rubygems_version: 2.7.3
103
+ rubygems_version: 3.0.6
105
104
  signing_key:
106
105
  specification_version: 4
107
106
  summary: CQRS and Event Driven Development architecture for Ruby