evil_events 0.1.0rc9 → 0.1.1

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
  SHA1:
3
- metadata.gz: 427742fccaa575d930f2ae10f64ce3b31e2a511a
4
- data.tar.gz: be655b351661f875c958c86efa678d20fe8c4961
3
+ metadata.gz: ce935f449ea78c46b999cb78c539ebb0831ffe6c
4
+ data.tar.gz: d95c3b341243285c82c1955f2cf09f44d5d5cbe1
5
5
  SHA512:
6
- metadata.gz: c7e7e6683b298bcf27244e9b5abd34c27a5e33ecd31ce39bc94406cc4b69cdb7830e6c09bc073d8aec00599ad1a0a8157566150d3739b43b13114f88198347df
7
- data.tar.gz: c76f2a4ebfb393aea6aab83cf97fdede36e2298a841963a40e814969a1cfcd73cf19cb0ebcf95cf7ba7f0a2426afedb75e2df4e226584cfd4196aca58f55fcdf
6
+ metadata.gz: 722725a362de968307d9ff12b9b46f60b044110eafc404d77f1e9a96ff5e19c37d00853c2deb0a940021a8f6632ef17cdfba04791ba0c1ce4db3c95e7dfb1b10
7
+ data.tar.gz: 4bba1a00b98b3aa7f8ae62b5434698f8e71fa6ab6401ff167c73a5e8108a3fbd16beb06b698c54c26a4d82e7fafd62ebff2939cbe7c41fcc4b678d78fd947e38
data/.gitignore CHANGED
@@ -8,6 +8,3 @@
8
8
  /spec/reports/
9
9
  /tmp/
10
10
  .rspec_status
11
- .DS_Store
12
- .idea
13
- /.gtm/
data/CHANGELOG.md CHANGED
@@ -1,2 +1,6 @@
1
1
  # Changelog
2
2
  All notable changes to this project will be documented in this file.
3
+
4
+ ## [0.1.1] - 2017-10-29
5
+ ### [Added]
6
+ - Serialization of event ids: support for using :id key in JSON/Hash serialization/deserialization.
data/README.md CHANGED
@@ -1,5 +1,3 @@
1
- # EvilEvents - event subsystem for ruby applications (work in progress!)
1
+ # EvilEvents · [![Gem Version](https://badge.fury.io/rb/evil_events.svg)](https://badge.fury.io/rb/evil_events) [![Build Status](https://travis-ci.org/0exp/evil_events.svg?branch=master)](https://travis-ci.org/0exp/evil_events) [![Coverage Status](https://coveralls.io/repos/github/0exp/evil_events/badge.svg?branch=master)](https://coveralls.io/github/0exp/evil_events?branch=master)
2
2
 
3
- [![Gem Version](https://badge.fury.io/rb/evil_events.svg)](https://badge.fury.io/rb/evil_events)
4
- [![Build Status](https://travis-ci.org/ergosploit/evil_events.svg?branch=master)](https://travis-ci.org/ergosploit/evil_events)
5
- [![Coverage Status](https://coveralls.io/repos/github/ergosploit/evil_events/badge.svg?branch=master)](https://coveralls.io/github/ergosploit/evil_events?branch=master)
3
+ Coming soon... :smiling_imp:
data/evil_events.gemspec CHANGED
@@ -11,7 +11,7 @@ Gem::Specification.new do |spec|
11
11
  spec.version = EvilEvents::VERSION
12
12
  spec.authors = 'Rustam Ibragimov'
13
13
  spec.email = 'iamdaiver@icloud.com'
14
- spec.homepage = 'https://github.com/ergosploit/evil_events'
14
+ spec.homepage = 'https://github.com/0exp/evil_events'
15
15
  spec.license = 'MIT'
16
16
  spec.summary = 'Event subsystem for ruby applications'
17
17
  spec.description = 'Ultra simple, but very flexible and fully customizable event subsystem ' \
@@ -39,7 +39,7 @@ Gem::Specification.new do |spec|
39
39
  spec.add_development_dependency 'simplecov-json', '0.2'
40
40
  spec.add_development_dependency 'rubocop', '0.51.0'
41
41
  spec.add_development_dependency 'bundler', '1.15.4'
42
- spec.add_development_dependency 'rake', '12.1.0'
42
+ spec.add_development_dependency 'rake', '12.2.1'
43
43
  spec.add_development_dependency 'rspec', '3.7.0'
44
44
  spec.add_development_dependency 'rubocop-rspec', '1.19.0'
45
45
  end
@@ -16,7 +16,7 @@ module EvilEvents::Core::Broadcasting
16
16
  # @since 0.1.0
17
17
  def emit(event)
18
18
  raise IncorrectEventError unless event.is_a?(EvilEvents::Core::Events::AbstractEvent)
19
- log_emitter_activity(event)
19
+ log_activity(event)
20
20
  event.adapter.call(event)
21
21
  end
22
22
 
@@ -40,7 +40,7 @@ module EvilEvents::Core::Broadcasting
40
40
  # @return void
41
41
  #
42
42
  # @since 0.1.0
43
- def log_emitter_activity(event)
43
+ def log_activity(event)
44
44
  activity = "EventEmitted(#{event.adapter_name})"
45
45
  message = "ID: #{event.id} :: " \
46
46
  "TYPE: #{event.type} :: " \
@@ -34,8 +34,8 @@ module EvilEvents::Core::Events
34
34
  # @option metadata [Hash]
35
35
  #
36
36
  # @since 0.1.0
37
- def initialize(payload: {}, metadata: {})
38
- @id = EvilEvents::Shared::Crypto.uuid
37
+ def initialize(id: nil, payload: {}, metadata: {})
38
+ @id = id || EvilEvents::Shared::Crypto.uuid
39
39
  @payload = build_payload(**payload)
40
40
  @metadata = build_metadata(**metadata)
41
41
  end
@@ -0,0 +1,65 @@
1
+ # frozen_string_literal: true
2
+
3
+ module EvilEvents::Core::Events
4
+ # @api private
5
+ # @since 0.1.1
6
+ module EventFactory
7
+ # @since 0.1.1
8
+ UNDEFINED_EVENT_ID = 'unknown'
9
+
10
+ module_function
11
+
12
+ # @param event_type [String]
13
+ # @raise [EvilEvents::Core::Events::ManagerRegistry::AlreadyManagedEventClassError]
14
+ # @return [Class{EvilEvents::Core::Events::AbstractEvent}]
15
+ #
16
+ # @since 0.1.1
17
+ def create_abstract_class(event_type)
18
+ Class.new(AbstractEvent).tap do |klass|
19
+ klass.type(event_type)
20
+
21
+ class << klass
22
+ def inherited(child_class)
23
+ child_class.type(type)
24
+ child_class.manage!
25
+ rescue EvilEvents::Core::Events::ManagerRegistry::AlreadyManagedEventClassError
26
+ EvilEvents::Core::Bootstrap[:event_system].unregister_event_class(child_class)
27
+ raise
28
+ end
29
+ end
30
+ end
31
+ end
32
+
33
+ # @param event_type [String]
34
+ # @param event_class_definitions [Proc]
35
+ # @yield [AbstractEvent]
36
+ # @raise [EvilEvents::Core::Events::ManagerRegistry::AlreadyManagedEventClassError]
37
+ # @return [Class{EvilEvents::Core::Events::AbstractEvent}]
38
+ #
39
+ # @since 0.1.1
40
+ def create_class(event_type, &event_class_definitions)
41
+ Class.new(AbstractEvent).tap do |klass|
42
+ begin
43
+ klass.type(event_type)
44
+ klass.manage!
45
+ klass.evaluate(&event_class_definitions) if block_given?
46
+ rescue EvilEvents::Core::Events::ManagerRegistry::AlreadyManagedEventClassError
47
+ EvilEvents::Core::Bootstrap[:event_system].unregister_event_class(klass)
48
+ raise
49
+ end
50
+ end
51
+ end
52
+
53
+ # @param event_class [Class{EvilEvents::Core::Events::AbstractEvent}]
54
+ # @option id [String, Object]
55
+ # @option payload [Hash]
56
+ # @option metadata [Hash]
57
+ # @return [EvilEvents::Core::Events::AbstractEvent]
58
+ #
59
+ # @api private
60
+ # @since 0.1.1
61
+ def restore_instance(event_class, id: UNDEFINED_EVENT_ID, payload: {}, metadata: {})
62
+ event_class.new(id: id || UNDEFINED_EVENT_ID, payload: payload, metadata: metadata)
63
+ end
64
+ end
65
+ end
@@ -47,13 +47,32 @@ class EvilEvents::Core::Events::Manager
47
47
  manager.subscribers.each do |subscriber|
48
48
  begin
49
49
  subscriber.notify(event)
50
+ log_activity(event, subscriber, :successful)
50
51
  rescue StandardError => error
51
52
  errors_stack << error
53
+ log_activity(event, subscriber, :failed)
52
54
  end
53
55
  end
54
56
 
55
57
  raise errors_stack unless errors_stack.empty?
56
58
  end
59
+
60
+ private
61
+
62
+ # @param event [EvilEvents::Core::Events::AbstractEvent]
63
+ # @param subscriber [EvilEvents::Core::Events::Subscriber]
64
+ # @param status [String,Symbol]
65
+ # @return void
66
+ #
67
+ # @since 0.1.1
68
+ def log_activity(event, subscriber, status)
69
+ activity = "EventProcessed(#{event.type})"
70
+ message = "EVENT_ID: #{event.id} :: " \
71
+ "STATUS: #{status} :: " \
72
+ "SUBSCRIBER: #{subscriber.source_object}"
73
+
74
+ EvilEvents::Core::ActivityLogger.log(activity: activity, message: message)
75
+ end
57
76
  end
58
77
  end
59
78
  end
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ class EvilEvents::Core::Events::Serializers
4
+ # @api private
5
+ # @since 0.1.1
6
+ module Base
7
+ # @option type [String]
8
+ # @option id [String, Object]
9
+ # @option payload [Hash]
10
+ # @option metadata [Hash]
11
+ # @return [EvilEvents::Core::Events::AbstractEvent]
12
+ #
13
+ # @since 0.1.1
14
+ def restore_event_instance(type:, id:, payload:, metadata:)
15
+ event_class = EvilEvents::Core::Bootstrap[:event_system].resolve_event_class(type)
16
+
17
+ EvilEvents::Core::Events::EventFactory.restore_instance(
18
+ event_class, id: id, payload: payload, metadata: metadata
19
+ )
20
+ end
21
+ end
22
+ end
@@ -4,49 +4,70 @@ class EvilEvents::Core::Events::Serializers
4
4
  # @api public
5
5
  # @since 0.1.0
6
6
  module Hash
7
- module_function
7
+ # @since 0.1.1
8
+ extend Base
8
9
 
9
- # @param event [EvilEvents::Core::Events::AbstractEvent]
10
- # @raise [SerializationError]
11
- # @return [::Hash]
12
- #
13
- # @since 0.1.0
14
- def serialize(event)
15
- raise SerializationError unless event.is_a?(EvilEvents::Core::Events::AbstractEvent)
10
+ class << self
11
+ # @param event [EvilEvents::Core::Events::AbstractEvent]
12
+ # @raise [SerializationError]
13
+ # @return [::Hash]
14
+ #
15
+ # @since 0.1.0
16
+ def serialize(event)
17
+ raise SerializationError unless event.is_a?(EvilEvents::Core::Events::AbstractEvent)
16
18
 
17
- { type: event.type, payload: event.payload, metadata: event.metadata }
18
- end
19
+ {
20
+ id: event.id,
21
+ type: event.type,
22
+ payload: event.payload,
23
+ metadata: event.metadata
24
+ }
25
+ end
19
26
 
20
- # @param hash [::Hash]
21
- # @raise [DeserializationError]
22
- # @return [EvilEvents::Core::Events::AbstractEvent]
23
- #
24
- # @since 0.1.0
25
- def deserialize(hash) # rubocop:disable Metrics/AbcSize
26
- raise DeserializationError unless hash.is_a?(::Hash)
27
- event_type = hash[:type] || hash['type']
28
- event_payload = hash[:payload] || hash['payload']
29
- event_metadata = hash[:metadata] || hash['metadata']
30
- raise DeserializationError unless event_type && event_payload && event_metadata
31
- raise DeserializationError unless event_payload.is_a?(::Hash) && event_metadata.is_a?(::Hash)
32
-
33
- EvilEvents::Core::Bootstrap[:event_system].resolve_event_object(
34
- event_type,
35
- payload: symbolized_event_data(event_payload),
36
- metadata: symbolized_event_data(event_metadata)
37
- )
38
- end
27
+ # rubocop:disable Metrics/AbcSize
28
+ # rubocop:disable Metrics/CyclomaticComplexity
29
+ # rubocop:disable Metrics/PerceivedComplexity
30
+
31
+ # @param hash [::Hash]
32
+ # @raise [DeserializationError]
33
+ # @return [EvilEvents::Core::Events::AbstractEvent]
34
+ #
35
+ # @since 0.1.0
36
+ def deserialize(hash)
37
+ raise DeserializationError unless hash.is_a?(::Hash)
38
+
39
+ event_id = hash[:id] || hash['id']
40
+ event_type = hash[:type] || hash['type']
41
+ event_payload = hash[:payload] || hash['payload']
42
+ event_metadata = hash[:metadata] || hash['metadata']
43
+
44
+ raise DeserializationError unless event_type && event_payload && event_metadata
45
+ raise DeserializationError unless event_payload.is_a?(::Hash)
46
+ raise DeserializationError unless event_metadata.is_a?(::Hash)
47
+
48
+ restore_event_instance(
49
+ type: event_type,
50
+ id: event_id,
51
+ payload: symbolized_event_data(event_payload),
52
+ metadata: symbolized_event_data(event_metadata)
53
+ )
54
+ end
55
+ # rubocop:enable Metrics/AbcSize
56
+ # rubocop:enable Metrics/CyclomaticComplexity
57
+ # rubocop:enable Metrics/PerceivedComplexity
58
+
59
+ private
39
60
 
40
- # @param payload_hash [::Hash]
41
- # @return [::Hash]
42
- #
43
- # @since 0.1.0
44
- def symbolized_event_data(payload_hash)
45
- payload_hash.each_pair.each_with_object({}) do |(key, value), result_hash|
46
- result_hash[key.to_sym] = value
61
+ # @param payload_hash [::Hash]
62
+ # @return [::Hash]
63
+ #
64
+ # @since 0.1.0
65
+ def symbolized_event_data(payload_hash)
66
+ payload_hash.each_pair.each_with_object({}) do |(key, value), result_hash|
67
+ result_hash[key.to_sym] = value
68
+ end
47
69
  end
48
70
  end
49
- private_class_method :symbolized_event_data
50
71
  end
51
72
 
52
73
  # @since 0.1.0
@@ -4,40 +4,52 @@ class EvilEvents::Core::Events::Serializers
4
4
  # @api public
5
5
  # @since 0.1.0
6
6
  module JSON
7
- module_function
7
+ # @since 0.1.1
8
+ extend Base
8
9
 
9
- # @param event [EvilEvents::Core::Events::AbstractEvent]
10
- # @raise [SerializationError]
11
- # @return [::Hash]
12
- #
13
- # @since 0.1.0
14
- def serialize(event)
15
- raise SerializationError unless event.is_a?(EvilEvents::Core::Events::AbstractEvent)
10
+ class << self
11
+ # @param event [EvilEvents::Core::Events::AbstractEvent]
12
+ # @raise [SerializationError]
13
+ # @return [::Hash]
14
+ #
15
+ # @since 0.1.0
16
+ def serialize(event)
17
+ raise SerializationError unless event.is_a?(EvilEvents::Core::Events::AbstractEvent)
16
18
 
17
- ::JSON.generate(type: event.type, payload: event.payload, metadata: event.metadata)
18
- end
19
+ ::JSON.generate(
20
+ id: event.id,
21
+ type: event.type,
22
+ payload: event.payload,
23
+ metadata: event.metadata
24
+ )
25
+ end
19
26
 
20
- # @param json [String]
21
- # @raise [DeserializationError]
22
- # @return [EvilEvents::Core::Events::AbstractEvent]
23
- #
24
- # @since 0.1.0
25
- def deserialize(json)
26
- raise DeserializationError unless json.is_a?(String)
27
+ # @param json [String]
28
+ # @raise [DeserializationError]
29
+ # @return [EvilEvents::Core::Events::AbstractEvent]
30
+ #
31
+ # @since 0.1.0
32
+ def deserialize(json)
33
+ raise DeserializationError unless json.is_a?(String)
27
34
 
28
- begin
29
- json_hash = ::JSON.parse(json, symbolize_names: true)
30
- event_type = json_hash[:type]
31
- event_payload = json_hash[:payload]
32
- event_metadata = json_hash[:metadata]
33
- raise DeserializationError unless event_type && event_payload && event_metadata
34
- rescue ::JSON::ParserError
35
- raise DeserializationError
36
- end
35
+ begin
36
+ json_hash = ::JSON.parse(json, symbolize_names: true)
37
+ event_id = json_hash[:id]
38
+ event_type = json_hash[:type]
39
+ event_payload = json_hash[:payload]
40
+ event_metadata = json_hash[:metadata]
41
+ raise DeserializationError unless event_type && event_payload && event_metadata
42
+ rescue ::JSON::ParserError
43
+ raise DeserializationError
44
+ end
37
45
 
38
- EvilEvents::Core::Bootstrap[:event_system].resolve_event_object(
39
- event_type, payload: event_payload, metadata: event_metadata
40
- )
46
+ restore_event_instance(
47
+ type: event_type,
48
+ id: event_id,
49
+ payload: event_payload,
50
+ metadata: event_metadata
51
+ )
52
+ end
41
53
  end
42
54
  end
43
55
 
@@ -5,6 +5,7 @@ module EvilEvents::Core
5
5
  # @since 0.1.0
6
6
  module Events
7
7
  require_relative 'events/serializers'
8
+ require_relative 'events/serializers/base'
8
9
  require_relative 'events/serializers/hash'
9
10
  require_relative 'events/serializers/json'
10
11
  require_relative 'events/event_extensions/type_aliasing'
@@ -25,6 +26,6 @@ module EvilEvents::Core
25
26
  require_relative 'events/manager_registry'
26
27
  require_relative 'events/subscriber'
27
28
  require_relative 'events/subscriber/mixin'
28
- require_relative 'events/event_class_factory'
29
+ require_relative 'events/event_factory'
29
30
  end
30
31
  end
@@ -11,7 +11,7 @@ class EvilEvents::Core::System
11
11
  #
12
12
  # @since 0.1.0
13
13
  def define_event_class(event_type, &event_class_definitions)
14
- EvilEvents::Core::Events::EventClassFactory.create(event_type, &event_class_definitions)
14
+ EvilEvents::Core::Events::EventFactory.create_class(event_type, &event_class_definitions)
15
15
  end
16
16
 
17
17
  # @param event_type [String]
@@ -19,7 +19,7 @@ class EvilEvents::Core::System
19
19
  #
20
20
  # @since 0.1.0
21
21
  def define_abstract_event_class(event_type)
22
- EvilEvents::Core::Events::EventClassFactory.create_abstract(event_type)
22
+ EvilEvents::Core::Events::EventFactory.create_abstract_class(event_type)
23
23
  end
24
24
 
25
25
  # @param serialized_event [String]
@@ -27,7 +27,7 @@ class EvilEvents::Core::System
27
27
  #
28
28
  # @since 0.1.0
29
29
  def deserialize_from_json(serialized_event)
30
- EvilEvents::Core::Events::Serializers.resolve(:json).deserialize(serialized_event)
30
+ EvilEvents::Core::Events::Serializers[:json].deserialize(serialized_event)
31
31
  end
32
32
 
33
33
  # @param serialized_event [Hash]
@@ -35,7 +35,7 @@ class EvilEvents::Core::System
35
35
  #
36
36
  # @since 0.1.0
37
37
  def deserialize_from_hash(serialized_event)
38
- EvilEvents::Core::Events::Serializers.resolve(:hash).deserialize(serialized_event)
38
+ EvilEvents::Core::Events::Serializers[:hash].deserialize(serialized_event)
39
39
  end
40
40
  end
41
41
  end
@@ -81,8 +81,18 @@ class EvilEvents::Core::System
81
81
  # @return [EvilEvents::Core::Events::AbstractEvent]
82
82
  #
83
83
  # @since 0.1.0
84
- def resolve_event_object(event_type, payload: {}, metadata: {})
85
- manager_of_event_type(event_type).event_class.new(payload: payload, metadata: metadata)
84
+ def resolve_event_object(event_type, id: nil, payload: {}, metadata: {})
85
+ manager_of_event_type(event_type).event_class.new(
86
+ id: id, payload: payload, metadata: metadata
87
+ )
88
+ end
89
+
90
+ # @param event_type [String]
91
+ # @return [Class{EvilEvents::Core::Events::AbstractEvent}]
92
+ #
93
+ # @since 0.1.0
94
+ def resolve_event_class(event_type)
95
+ manager_of_event_type(event_type).event_class
86
96
  end
87
97
 
88
98
  # @param event_class [EvilEvents::Core::Events::AbstractEvent]
@@ -61,7 +61,11 @@ class EvilEvents::Core::System
61
61
 
62
62
  # @see EvilEvents::Core::System
63
63
  # @since 0.1.0
64
- def resolve_event_object(event_type, payload: {}, metadata: {}); end
64
+ def resolve_event_object(event_type, id: nil, payload: {}, metadata: {}); end
65
+
66
+ # @see EvilEvents::Core::System
67
+ # @since 0.1.0
68
+ def resolve_event_class(event_type); end
65
69
 
66
70
  # @see EvilEvents::Core::System
67
71
  # @since 0.1.0
@@ -33,6 +33,7 @@ module EvilEvents::Core
33
33
  :unregister_event_class,
34
34
  :manager_of_event,
35
35
  :manager_of_event_type,
36
+ :resolve_event_class,
36
37
  :resolve_event_object,
37
38
  :managed_event?
38
39
 
@@ -3,5 +3,5 @@
3
3
  module EvilEvents
4
4
  # @api public
5
5
  # @since 0.1.0
6
- VERSION = '0.1.0rc9'
6
+ VERSION = '0.1.1'
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: evil_events
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0rc9
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rustam Ibragimov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-10-28 00:00:00.000000000 Z
11
+ date: 2017-10-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dry-monads
@@ -184,14 +184,14 @@ dependencies:
184
184
  requirements:
185
185
  - - '='
186
186
  - !ruby/object:Gem::Version
187
- version: 12.1.0
187
+ version: 12.2.1
188
188
  type: :development
189
189
  prerelease: false
190
190
  version_requirements: !ruby/object:Gem::Requirement
191
191
  requirements:
192
192
  - - '='
193
193
  - !ruby/object:Gem::Version
194
- version: 12.1.0
194
+ version: 12.2.1
195
195
  - !ruby/object:Gem::Dependency
196
196
  name: rspec
197
197
  requirement: !ruby/object:Gem::Requirement
@@ -258,7 +258,6 @@ files:
258
258
  - lib/evil_events/core/config.rb
259
259
  - lib/evil_events/core/events.rb
260
260
  - lib/evil_events/core/events/abstract_event.rb
261
- - lib/evil_events/core/events/event_class_factory.rb
262
261
  - lib/evil_events/core/events/event_extensions/adapter_customizable.rb
263
262
  - lib/evil_events/core/events/event_extensions/emittable.rb
264
263
  - lib/evil_events/core/events/event_extensions/manageable.rb
@@ -269,12 +268,14 @@ files:
269
268
  - lib/evil_events/core/events/event_extensions/payloadable/abstract_payload.rb
270
269
  - lib/evil_events/core/events/event_extensions/serializable.rb
271
270
  - lib/evil_events/core/events/event_extensions/type_aliasing.rb
271
+ - lib/evil_events/core/events/event_factory.rb
272
272
  - lib/evil_events/core/events/manager.rb
273
273
  - lib/evil_events/core/events/manager/notifier.rb
274
274
  - lib/evil_events/core/events/manager/subscriber_list.rb
275
275
  - lib/evil_events/core/events/manager_factory.rb
276
276
  - lib/evil_events/core/events/manager_registry.rb
277
277
  - lib/evil_events/core/events/serializers.rb
278
+ - lib/evil_events/core/events/serializers/base.rb
278
279
  - lib/evil_events/core/events/serializers/hash.rb
279
280
  - lib/evil_events/core/events/serializers/json.rb
280
281
  - lib/evil_events/core/events/subscriber.rb
@@ -303,7 +304,7 @@ files:
303
304
  - lib/evil_events/subscriber_mixin.rb
304
305
  - lib/evil_events/types.rb
305
306
  - lib/evil_events/version.rb
306
- homepage: https://github.com/ergosploit/evil_events
307
+ homepage: https://github.com/0exp/evil_events
307
308
  licenses:
308
309
  - MIT
309
310
  metadata: {}
@@ -318,9 +319,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
318
319
  version: 2.2.7
319
320
  required_rubygems_version: !ruby/object:Gem::Requirement
320
321
  requirements:
321
- - - ">"
322
+ - - ">="
322
323
  - !ruby/object:Gem::Version
323
- version: 1.3.1
324
+ version: '0'
324
325
  requirements: []
325
326
  rubyforge_project:
326
327
  rubygems_version: 2.6.14
@@ -1,50 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module EvilEvents::Core::Events
4
- # @api private
5
- # @since 0.1.0
6
- module EventClassFactory
7
- class << self
8
- # @param event_type [String]
9
- # @raise [EvilEvents::Core::Events::ManagerRegistry::AlreadyManagedEventClassError]
10
- # @return [Class{EvilEvents::Core::Events::AbstractEvent}]
11
- #
12
- # @since 0.1.0
13
- def create_abstract(event_type)
14
- Class.new(AbstractEvent).tap do |klass|
15
- klass.type(event_type)
16
-
17
- class << klass
18
- def inherited(child_class)
19
- child_class.type(type)
20
- child_class.manage!
21
- rescue EvilEvents::Core::Events::ManagerRegistry::AlreadyManagedEventClassError
22
- EvilEvents::Core::Bootstrap[:event_system].unregister_event_class(child_class)
23
- raise
24
- end
25
- end
26
- end
27
- end
28
-
29
- # @param event_type [String]
30
- # @param event_class_definitions [Proc]
31
- # @yield [AbstractEvent]
32
- # @raise [EvilEvents::Core::Events::ManagerRegistry::AlreadyManagedEventClassError]
33
- # @return [Class{EvilEvents::Core::Events::AbstractEvent}]
34
- #
35
- # @since 0.1.0
36
- def create(event_type, &event_class_definitions)
37
- Class.new(AbstractEvent).tap do |klass|
38
- begin
39
- klass.type(event_type)
40
- klass.manage!
41
- klass.evaluate(&event_class_definitions) if block_given?
42
- rescue EvilEvents::Core::Events::ManagerRegistry::AlreadyManagedEventClassError
43
- EvilEvents::Core::Bootstrap[:event_system].unregister_event_class(klass)
44
- raise
45
- end
46
- end
47
- end
48
- end
49
- end
50
- end