evnt 3.5.0 → 3.6.0

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: 1147304064293c3dfa71574a83935a8328b98f91f9ece384d9bf32c8bc4195c2
4
- data.tar.gz: 1b74795c01d50f1c00c3f45f6938a42493d5e9e5609c72b8df1a3bcce98e33d8
3
+ metadata.gz: 390c7cbf488240f3f1ba5caa1f1ca38d4b8f8aceb335a0c7e99ef52ddc2487b9
4
+ data.tar.gz: c46c2a712719b9640f25f1f3843f9470512b9b77b95a77caa1672e25dfb46a0d
5
5
  SHA512:
6
- metadata.gz: f54bfe9c4b7ffeeea71df3a393e932ac2d51d9c0d96928f9ee35ec478c264dc3608f65bf16e10bc81e916290ef1a51cfcaade7481d2abe075a8791d43c7add7d
7
- data.tar.gz: 8788243241cc12dc09edb4686d375bab113db99aa5bda599958f1c175153e1e72658757d8e1be1167781fb36e9a8c7a069ea333aa75d49d2c0704ea877690c13
6
+ metadata.gz: 66a63f9254bded1cfbd5211d0c54ebbe637911fd9b130145b968cbbc31f6e513794ba69871e7923b96ae388ede1a22c8f3be25849a70464aa3d6c678b29dfebc
7
+ data.tar.gz: 3e30a18058cde3b00148cf22826d554af206e2a19fd6812a4fa2b380ca85d399e0a748ff79d0efe820268f983c3428537daa8285933b5c0cd2c2352b6c6e736c
data/README.md CHANGED
@@ -5,12 +5,11 @@
5
5
 
6
6
  CQRS and Event Driven Development architecture for Ruby projects.
7
7
 
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 four different classes:
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
9
 
10
10
  - **Commands**: actions executed by actors that can be completed or stopped by the system.
11
11
  - **Events**: something that it's already happen and should be logged somewhere.
12
12
  - **Handlers**: event listeners that perform specific tasks.
13
- - **Queries**: list of queries used to read data from database.
14
13
 
15
14
  The full documentation of these classes can be found here: https://ideonetwork.github.io/evnt
16
15
 
data/lib/evnt.rb CHANGED
@@ -6,9 +6,6 @@ require 'evnt/event'
6
6
  require 'evnt/handler'
7
7
  require 'evnt/validator'
8
8
 
9
- require 'evnt/query'
10
- require 'evnt/query_activerecord'
11
-
12
9
  ##
13
10
  # Evnt is a gem developed to integrate a event driven development
14
11
  # and CQRS pattern inside a ruby project.
data/lib/evnt/event.rb CHANGED
@@ -213,6 +213,15 @@ module Evnt
213
213
  define_method('_attributes', -> { return event_attributes })
214
214
  end
215
215
 
216
+ # This function sets the list of handlers for the event.
217
+ def handlers_are(handlers)
218
+ @handlers ||= []
219
+ @handlers.concat(handlers)
220
+ event_handlers = @handlers
221
+
222
+ define_method('_handlers', -> { return event_handlers })
223
+ end
224
+
216
225
  # This function sets the write event function for the event.
217
226
  def to_write_event(&block)
218
227
  define_method('_write_event', &block)
@@ -229,17 +238,6 @@ module Evnt
229
238
 
230
239
  # DEPRECATED
231
240
 
232
- # This function sets the list of handlers for the event.
233
- def handlers_are(handlers)
234
- @handlers ||= []
235
- @handlers.concat(handlers)
236
- event_handlers = @handlers
237
-
238
- define_method('_handlers', -> { return event_handlers })
239
-
240
- warn '[DEPRECATION] `handlers_are` is deprecated. Please use handler `listen` instead.'
241
- end
242
-
243
241
  end
244
242
 
245
243
  end
data/lib/evnt/version.rb CHANGED
@@ -3,6 +3,6 @@
3
3
  # Evnt.
4
4
  module Evnt
5
5
 
6
- VERSION = '3.5.0'
6
+ VERSION = '3.6.0'
7
7
 
8
8
  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.5.0
4
+ version: 3.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ideonetwork
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-04-04 00:00:00.000000000 Z
11
+ date: 2018-04-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -65,27 +65,22 @@ files:
65
65
  - lib/evnt/command.rb
66
66
  - lib/evnt/event.rb
67
67
  - lib/evnt/handler.rb
68
- - lib/evnt/query.rb
69
- - lib/evnt/query_activerecord.rb
70
68
  - lib/evnt/validator.rb
71
69
  - lib/evnt/version.rb
72
70
  - lib/generators/evnt/command_generator.rb
73
71
  - lib/generators/evnt/event_generator.rb
74
72
  - lib/generators/evnt/handler_generator.rb
75
73
  - lib/generators/evnt/initializer_generator.rb
76
- - lib/generators/evnt/query_generator.rb
77
74
  - lib/generators/evnt/templates/command/command.rb.erb
78
75
  - lib/generators/evnt/templates/event/event.rb.erb
79
76
  - lib/generators/evnt/templates/handler/handler.rb.erb
80
77
  - lib/generators/evnt/templates/initializer/app/commands/application_command.rb
81
78
  - lib/generators/evnt/templates/initializer/app/events/application_event.rb
82
79
  - lib/generators/evnt/templates/initializer/app/handlers/application_handler.rb
83
- - lib/generators/evnt/templates/initializer/app/queries/application_query.rb
84
80
  - lib/generators/evnt/templates/initializer/config/initializers/evnt.rb
85
81
  - lib/generators/evnt/templates/initializer/test/commands/application_command_test.rb
86
82
  - lib/generators/evnt/templates/initializer/test/events/application_event_test.rb
87
83
  - lib/generators/evnt/templates/initializer/test/handlers/application_handler_test.rb
88
- - lib/generators/evnt/templates/query/query.rb.erb
89
84
  homepage: http://ideonetwork.it/
90
85
  licenses:
91
86
  - MIT
data/lib/evnt/query.rb DELETED
@@ -1,48 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Evnt
4
-
5
- ##
6
- # Queries are used to read and prepare data from the database
7
- # to the client.
8
- # The Query class should contain only helpers used to develop custom queries.
9
- ##
10
- class Query
11
-
12
- ##
13
- # The constructor should not be used. Use class method insthead.
14
- ##
15
- def initialize
16
- raise SystemCallError, 'Query can not be initialized'
17
- end
18
-
19
- def self.as_json(_query, _parameters = {})
20
- raise NotImplementedError, 'As json method should be implemented on Query subclasses'
21
- end
22
-
23
- def self.as_string(_query, _parameters = {})
24
- raise NotImplementedError, 'As string method should be implemented on Query subclasses'
25
- end
26
-
27
- def self.as_bytes(_query, _parameters = {})
28
- raise NotImplementedError, 'As bytes method should be implemented on Query subclasses'
29
- end
30
-
31
- # Helpers:
32
- ############################################################################
33
-
34
- def self.clean_unpermitted_attributes_from_json(obj, unpermitted_attributes)
35
- if obj.is_a?(Array)
36
- obj.map { |o| unpermitted_attributes.each { |attribute| o.delete(attribute.to_s) } }
37
- else
38
- unpermitted_attributes.each { |attribute| obj.delete(attribute.to_s) }
39
- end
40
-
41
- obj
42
- end
43
-
44
- private_class_method :clean_unpermitted_attributes_from_json
45
-
46
- end
47
-
48
- end
@@ -1,58 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Evnt
4
-
5
- ##
6
- # Queries are used to read and prepare data from the database
7
- # to the client.
8
- # The QueryActivercord class shuld contain helpers used to develop custom
9
- # queries based on activerecord.
10
- ##
11
- class QueryActiverecord < Evnt::Query
12
-
13
- ##
14
- # This function should run a query and return the result as a hash/json object.
15
- #
16
- # ==== Attributes
17
- #
18
- # * +query+ - The name of the query that should be executed.
19
- # * +parameters+ - An object containing the parameters for the query.
20
- ##
21
- def self.as_json(query, parameters = {})
22
- except = parameters[:_except] || []
23
- only = parameters[:_only] || []
24
-
25
- result = send(query, parameters).as_json
26
- return result unless except.length.positive? || only.length.positive?
27
-
28
- clean_unpermitted_attributes_from_json(result, except) if except.length.positive?
29
- clean_unpermitted_attributes_from_json(result, result.keys - only) if only.length.positive?
30
- end
31
-
32
- ##
33
- # This function should run a query and return the result as a string object.
34
- #
35
- # ==== Attributes
36
- #
37
- # * +query+ - The name of the query that should be executed.
38
- # * +parameters+ - An object containing the parameters for the query.
39
- ##
40
- def self.as_string(query, parameters = {})
41
- as_json(query, parameters).to_s
42
- end
43
-
44
- ##
45
- # This function should run a query and return the result as a bytes array.
46
- #
47
- # ==== Attributes
48
- #
49
- # * +query+ - The name of the query that should be executed.
50
- # * +parameters+ - An object containing the parameters for the query.
51
- ##
52
- def self.as_bytes(query, parameters = {})
53
- as_string(query, parameters).bytes.to_a
54
- end
55
-
56
- end
57
-
58
- end
@@ -1,35 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'rails/generators/base'
4
-
5
- module Evnt
6
-
7
- # QueryGenerator.
8
- class QueryGenerator < Rails::Generators::Base
9
-
10
- source_root File.expand_path('../templates', __FILE__)
11
-
12
- argument :informations, type: :array, optional: false
13
-
14
- def create_comand
15
- path = informations.first.split('::')
16
- @query_class = path.last.camelize
17
- @query_modules = path - [path.last]
18
- @query_params = informations - [informations.first]
19
-
20
- template(
21
- './query/query.rb.erb',
22
- query_path
23
- )
24
- end
25
-
26
- def query_path
27
- path = './app/queries'
28
- @query_modules.map { |m| path = "#{path}/#{m.underscore}" }
29
- path = "#{path}/#{@query_class.underscore}.rb"
30
- path
31
- end
32
-
33
- end
34
-
35
- end
@@ -1,6 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # ApplicationQuery.
4
- class ApplicationQuery < Evnt::QueryActiverecord
5
-
6
- end
@@ -1,13 +0,0 @@
1
- # frozen_string_literal: true
2
- <% @query_modules.each_with_index do |module_name, index| %>
3
- <%= ' ' * index %>module <%= module_name %>
4
- <% end %>
5
- <%= ' ' * @query_modules.length %># <%= @query_class %>
6
- <%= ' ' * @query_modules.length %>class <%= @query_class %> < ApplicationQuery
7
- <% @query_params.each do |param| %>
8
- <%= ' ' * (@query_modules.length + 1) %>def self.<%= param %>; end
9
- <% end %>
10
- <%= ' ' * @query_modules.length %>end
11
- <% @query_modules.each_with_index do |_module_name, index| %>
12
- <%= ' ' * (@query_modules.length - index - 1) %>end
13
- <% end %>