evil_events 0.1.0rc7 → 0.1.0rc8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (41) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +3 -0
  3. data/README.md +3 -0
  4. data/evil_events.gemspec +4 -4
  5. data/lib/evil_events/adapters.rb +24 -0
  6. data/lib/evil_events/config.rb +11 -42
  7. data/lib/evil_events/core/activity_logger.rb +1 -1
  8. data/lib/evil_events/core/bootstrap.rb +13 -0
  9. data/lib/evil_events/core/broadcasting/dispatcher.rb +1 -1
  10. data/lib/evil_events/core/broadcasting/emitter.rb +1 -1
  11. data/lib/evil_events/core/config.rb +54 -0
  12. data/lib/evil_events/core/events/abstract_event.rb +1 -1
  13. data/lib/evil_events/core/events/event_class_factory.rb +2 -2
  14. data/lib/evil_events/core/events/event_extensions/adapter_customizable.rb +2 -2
  15. data/lib/evil_events/core/events/event_extensions/emittable.rb +1 -1
  16. data/lib/evil_events/core/events/event_extensions/manageable.rb +1 -1
  17. data/lib/evil_events/core/events/event_extensions/observable.rb +3 -3
  18. data/lib/evil_events/core/events/serializers/hash.rb +1 -1
  19. data/lib/evil_events/core/events/serializers/json.rb +1 -1
  20. data/lib/evil_events/core/events/subscriber/mixin.rb +2 -2
  21. data/lib/evil_events/core/events/subscriber.rb +1 -1
  22. data/lib/evil_events/{system → core/system}/broadcaster.rb +1 -1
  23. data/lib/evil_events/{system → core/system}/event_builder.rb +1 -1
  24. data/lib/evil_events/{system → core/system}/event_manager.rb +1 -1
  25. data/lib/evil_events/{system → core/system}/mock.rb +21 -21
  26. data/lib/evil_events/{system → core/system}/mocking.rb +4 -4
  27. data/lib/evil_events/core/system.rb +63 -0
  28. data/lib/evil_events/core.rb +3 -0
  29. data/lib/evil_events/dispatcher_mixin.rb +7 -0
  30. data/lib/evil_events/emitter.rb +16 -0
  31. data/lib/evil_events/event.rb +25 -0
  32. data/lib/evil_events/serializer.rb +23 -0
  33. data/lib/evil_events/shared/{combined_context_mixin.rb → combined_context/mixin.rb} +5 -7
  34. data/lib/evil_events/shared.rb +1 -1
  35. data/lib/evil_events/subscriber_mixin.rb +7 -0
  36. data/lib/evil_events/types.rb +7 -0
  37. data/lib/evil_events/version.rb +1 -1
  38. data/lib/evil_events.rb +8 -118
  39. metadata +26 -18
  40. data/lib/evil_events/boot_point.rb +0 -13
  41. data/lib/evil_events/system.rb +0 -61
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cf1e64c53bc5c1613fb5ffdaf34e4295f8f5b939
4
- data.tar.gz: ccf595e35d013c7cf818efbf2cfaee9d3ad9b164
3
+ metadata.gz: d2dad67c5dd7b7585546efb878dc82d17d9d1d50
4
+ data.tar.gz: 9c9f991e7bfcc3b0e9f43507af7f16c40191a191
5
5
  SHA512:
6
- metadata.gz: 12fbb4762dc0eb9369c5f2c1d3adadc061ce2874db08c73b1c516ec0832fc76d396f6e107d77e762b16ad51815b7628eb83db3acf1f8b8a19209b83bfcef05ab
7
- data.tar.gz: 53dcc4384319e73053a32a9e294d72f61dd34065b62ad1d75a23536a6f85f9dea56a6e710d76eed059f231fb8529277c8e86787a6b338ec32fa51420fe649a14
6
+ metadata.gz: 554291095dc5c7f6677d9db008711f10659d86b050b1e261496dd5600c31354c494f245238f2a88978fa5ae39a298f87c37fe660007b3a8d365642a708ef719a
7
+ data.tar.gz: 46a1d122aecb3517469d68365316507041b35ba10171c16973a5fbf2c3c3256dd1df141df981dde42f8114a746c3e7e76e3a481ea56a788fa79d1c6960ce0e08
data/.rubocop.yml CHANGED
@@ -40,6 +40,9 @@ Style/FrozenStringLiteralComment:
40
40
  Style/ParallelAssignment:
41
41
  Enabled: false
42
42
 
43
+ Style/CommentedKeyword:
44
+ Enabled: false
45
+
43
46
  Naming/FileName:
44
47
  Enabled: false
45
48
 
data/README.md CHANGED
@@ -11,3 +11,6 @@
11
11
  - Event sourcing (0.3.0)
12
12
  - Concrete error messages for exceptions (0.1.1)
13
13
  - Hooks (0.2.0)
14
+ - Custom logger formatters (0.2.0)
15
+ - Logger colorization (0.2.0)
16
+ - DRY specs (0.1.1)
data/evil_events.gemspec CHANGED
@@ -34,12 +34,12 @@ Gem::Specification.new do |spec|
34
34
  spec.add_dependency 'concurrent-ruby', '1.0.5'
35
35
 
36
36
  spec.add_development_dependency 'coveralls', '0.8.21'
37
- spec.add_development_dependency 'pry', '0.11.1'
37
+ spec.add_development_dependency 'pry', '0.11.2'
38
38
  spec.add_development_dependency 'simplecov', '0.14.1'
39
39
  spec.add_development_dependency 'simplecov-json', '0.2'
40
- spec.add_development_dependency 'rubocop', '0.50.0'
40
+ spec.add_development_dependency 'rubocop', '0.51.0'
41
41
  spec.add_development_dependency 'bundler', '1.15.4'
42
42
  spec.add_development_dependency 'rake', '12.1.0'
43
- spec.add_development_dependency 'rspec', '3.6.0'
44
- spec.add_development_dependency 'rubocop-rspec', '1.18.0'
43
+ spec.add_development_dependency 'rspec', '3.7.0'
44
+ spec.add_development_dependency 'rubocop-rspec', '1.19.0'
45
45
  end
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+
3
+ module EvilEvents
4
+ # @api public
5
+ # @since 0.1.0
6
+ module Adapters
7
+ class << self
8
+ # @see EvilEvents::Core::System
9
+ # @api public
10
+ # @since 0.1.0
11
+ def register(adapter_name, adapter_object)
12
+ EvilEvents::Core::Bootstrap[:event_system].register_adapter(adapter_name, adapter_object)
13
+ end
14
+
15
+ # @see EvilEvents::Core::System
16
+ # @api public
17
+ # @since 0.1.0
18
+ def resolve(adapter_name)
19
+ EvilEvents::Core::Bootstrap[:event_system].resolve_adapter(adapter_name)
20
+ end
21
+ alias_method :[], :resolve
22
+ end
23
+ end
24
+ end
@@ -1,54 +1,23 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EvilEvents
4
- # @api private
4
+ # @api public
5
5
  # @since 0.1.0
6
- class Config
6
+ module Config
7
7
  class << self
8
- # @api private
8
+ # @see EvilEvents::Config
9
+ # @api public
9
10
  # @since 0.1.0
10
- def build_stub
11
- new
11
+ def configure
12
+ config.configure { |conf| yield(conf) if block_given? }
12
13
  end
13
- end
14
-
15
- # @api private
16
- # @since 0.1.0
17
- def initialize
18
- @config = Module.new do
19
- extend EvilEvents::Shared::Configurable
20
-
21
- setting :adapter, reader: true do
22
- setting :default, :memory_sync
23
- end
24
14
 
25
- setting :subscriber, reader: true do
26
- setting :default_delegator, :call
27
- end
28
-
29
- setting :logger, EvilEvents::Shared::Logger.new(STDOUT), reader: true
15
+ # @see EvilEvents::Config
16
+ # @api public
17
+ # @since 0.1.0
18
+ def config
19
+ EvilEvents::Core::Bootstrap[:config]
30
20
  end
31
21
  end
32
-
33
- private
34
-
35
- # @return [Module{EvilEvents::Shared::Configurable}]
36
- #
37
- # @api private
38
- # @since 0.1.0
39
- attr_reader :config
40
-
41
- # @api private
42
- # @since 0.1.0
43
- def method_missing(method_name, *attributes, &block)
44
- return super unless config.respond_to?(method_name)
45
- config.public_send(method_name, *attributes, &block)
46
- end
47
-
48
- # @api private
49
- # @since 0.1.0
50
- def respond_to_missing?(method_name, include_private = false)
51
- config.respond_to_missing?(method_name, include_private) || super
52
- end
53
22
  end
54
23
  end
@@ -21,7 +21,7 @@ module EvilEvents::Core
21
21
  #
22
22
  # @since 0.1.0
23
23
  def logger
24
- EvilEvents::BootPoint[:config].logger
24
+ EvilEvents::Core::Bootstrap[:config].logger
25
25
  end
26
26
  end
27
27
  end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module EvilEvents::Core
4
+ # @api private
5
+ # @since 0.1.0
6
+ class Bootstrap
7
+ # @since 0.1.0
8
+ extend EvilEvents::Shared::DependencyContainer::Mixin
9
+
10
+ register(:event_system, memoize: true) { EvilEvents::Core::System.new }
11
+ register(:config, memoize: true) { EvilEvents::Config.new }
12
+ end
13
+ end
@@ -10,7 +10,7 @@ module EvilEvents::Core::Broadcasting
10
10
  #
11
11
  # @since 0.1.0
12
12
  def dispatch(event) # Broadcast
13
- EvilEvents::BootPoint[:event_system].manager_of_event(event).notify(event)
13
+ EvilEvents::Core::Bootstrap[:event_system].manager_of_event(event).notify(event)
14
14
  end
15
15
  end
16
16
  end
@@ -26,7 +26,7 @@ module EvilEvents::Core::Broadcasting
26
26
  #
27
27
  # @since 0.1.0
28
28
  def raw_emit(event_type, **event_attributes)
29
- event_object = EvilEvents::BootPoint[:event_system].resolve_event_object(
29
+ event_object = EvilEvents::Core::Bootstrap[:event_system].resolve_event_object(
30
30
  event_type,
31
31
  **event_attributes
32
32
  )
@@ -0,0 +1,54 @@
1
+ # frozen_string_literal: true
2
+
3
+ module EvilEvents::Core
4
+ # @api private
5
+ # @since 0.1.0
6
+ class Config
7
+ class << self
8
+ # @api private
9
+ # @since 0.1.0
10
+ def build_stub
11
+ new
12
+ end
13
+ end
14
+
15
+ # @api private
16
+ # @since 0.1.0
17
+ def initialize
18
+ @config = Module.new do
19
+ extend EvilEvents::Shared::Configurable
20
+
21
+ setting :adapter, reader: true do
22
+ setting :default, :memory_sync
23
+ end
24
+
25
+ setting :subscriber, reader: true do
26
+ setting :default_delegator, :call
27
+ end
28
+
29
+ setting :logger, EvilEvents::Shared::Logger.new(STDOUT), reader: true
30
+ end
31
+ end
32
+
33
+ private
34
+
35
+ # @return [Module{EvilEvents::Shared::Configurable}]
36
+ #
37
+ # @api private
38
+ # @since 0.1.0
39
+ attr_reader :config
40
+
41
+ # @api private
42
+ # @since 0.1.0
43
+ def method_missing(method_name, *attributes, &block)
44
+ return super unless config.respond_to?(method_name)
45
+ config.public_send(method_name, *attributes, &block)
46
+ end
47
+
48
+ # @api private
49
+ # @since 0.1.0
50
+ def respond_to_missing?(method_name, include_private = false)
51
+ config.respond_to?(method_name, include_private) || super
52
+ end
53
+ end
54
+ end
@@ -22,7 +22,7 @@ module EvilEvents::Core::Events
22
22
  # @since 0.1.0
23
23
  include EventExtensions::MetadataExtendable
24
24
  # @since 0.1.0
25
- extend EvilEvents::Shared::CombinedContextMixin
25
+ extend EvilEvents::Shared::CombinedContext::Mixin
26
26
 
27
27
  # @option payload [Hash]
28
28
  # @option metadata [Hash]
@@ -19,7 +19,7 @@ module EvilEvents::Core::Events
19
19
  child_class.type(type)
20
20
  child_class.manage!
21
21
  rescue EvilEvents::Core::Events::ManagerRegistry::AlreadyManagedEventClassError
22
- EvilEvents::BootPoint[:event_system].unregister_event_class(child_class)
22
+ EvilEvents::Core::Bootstrap[:event_system].unregister_event_class(child_class)
23
23
  raise
24
24
  end
25
25
  end
@@ -40,7 +40,7 @@ module EvilEvents::Core::Events
40
40
  klass.manage!
41
41
  klass.evaluate(&event_class_definitions) if block_given?
42
42
  rescue EvilEvents::Core::Events::ManagerRegistry::AlreadyManagedEventClassError
43
- EvilEvents::BootPoint[:event_system].unregister_event_class(klass)
43
+ EvilEvents::Core::Bootstrap[:event_system].unregister_event_class(klass)
44
44
  raise
45
45
  end
46
46
  end
@@ -35,14 +35,14 @@ module EvilEvents::Core::Events::EventExtensions
35
35
  # @since 0.1.0
36
36
  def adapter(identifier = nil)
37
37
  @adapter_identifier = identifier if identifier
38
- EvilEvents::BootPoint[:event_system].resolve_adapter(adapter_name)
38
+ EvilEvents::Core::Bootstrap[:event_system].resolve_adapter(adapter_name)
39
39
  end
40
40
 
41
41
  # @return [Symbol, String]
42
42
  #
43
43
  # @since 0.1.0
44
44
  def adapter_name
45
- @adapter_identifier || EvilEvents::BootPoint[:config].adapter.default
45
+ @adapter_identifier || EvilEvents::Core::Bootstrap[:config].adapter.default
46
46
  end
47
47
  end
48
48
  end
@@ -6,7 +6,7 @@ module EvilEvents::Core::Events::EventExtensions
6
6
  module Emittable
7
7
  # @since 0.1.0
8
8
  def emit!
9
- EvilEvents::BootPoint[:event_system].emit(self)
9
+ EvilEvents::Core::Bootstrap[:event_system].emit(self)
10
10
  end
11
11
  end
12
12
  end
@@ -19,7 +19,7 @@ module EvilEvents::Core::Events::EventExtensions
19
19
  #
20
20
  # @since 0.1.0
21
21
  def manage!
22
- EvilEvents::BootPoint[:event_system].register_event_class(self)
22
+ EvilEvents::Core::Bootstrap[:event_system].register_event_class(self)
23
23
  end
24
24
  end
25
25
  end
@@ -27,7 +27,7 @@ module EvilEvents::Core::Events::EventExtensions
27
27
  #
28
28
  # @since 0.1.0
29
29
  def observe(raw_subscriber, delegator: nil)
30
- EvilEvents::BootPoint[:event_system].observe(self, raw_subscriber, delegator)
30
+ EvilEvents::Core::Bootstrap[:event_system].observe(self, raw_subscriber, delegator)
31
31
  end
32
32
 
33
33
  # @param delegator [Symbol, String, NilClass]
@@ -35,14 +35,14 @@ module EvilEvents::Core::Events::EventExtensions
35
35
  # @since 0.1.0
36
36
  def default_delegator(delegator = nil)
37
37
  @default_delegator = delegator if delegator
38
- @default_delegator || EvilEvents::BootPoint[:config].subscriber.default_delegator
38
+ @default_delegator || EvilEvents::Core::Bootstrap[:config].subscriber.default_delegator
39
39
  end
40
40
 
41
41
  # @return [Array]
42
42
  #
43
43
  # @since 0.1.0
44
44
  def observers
45
- EvilEvents::BootPoint[:event_system].observers(self)
45
+ EvilEvents::Core::Bootstrap[:event_system].observers(self)
46
46
  end
47
47
  end
48
48
  end
@@ -30,7 +30,7 @@ class EvilEvents::Core::Events::Serializers
30
30
  raise DeserializationError unless event_type && event_payload && event_metadata
31
31
  raise DeserializationError unless event_payload.is_a?(::Hash) && event_metadata.is_a?(::Hash)
32
32
 
33
- EvilEvents::BootPoint[:event_system].resolve_event_object(
33
+ EvilEvents::Core::Bootstrap[:event_system].resolve_event_object(
34
34
  event_type,
35
35
  payload: symbolized_event_data(event_payload),
36
36
  metadata: symbolized_event_data(event_metadata)
@@ -35,7 +35,7 @@ class EvilEvents::Core::Events::Serializers
35
35
  raise DeserializationError
36
36
  end
37
37
 
38
- EvilEvents::BootPoint[:event_system].resolve_event_object(
38
+ EvilEvents::Core::Bootstrap[:event_system].resolve_event_object(
39
39
  event_type, payload: event_payload, metadata: event_metadata
40
40
  )
41
41
  end
@@ -12,9 +12,9 @@ class EvilEvents::Core::Events::Subscriber
12
12
  def subscribe_to(event_type, delegator: nil)
13
13
  case event_type
14
14
  when Class
15
- EvilEvents::BootPoint[:event_system].observe(event_type, self, delegator)
15
+ EvilEvents::Core::Bootstrap[:event_system].observe(event_type, self, delegator)
16
16
  when String
17
- EvilEvents::BootPoint[:event_system].raw_observe(event_type, self, delegator)
17
+ EvilEvents::Core::Bootstrap[:event_system].raw_observe(event_type, self, delegator)
18
18
  else
19
19
  raise ArgumentError
20
20
  end
@@ -46,7 +46,7 @@ module EvilEvents::Core::Events
46
46
  #
47
47
  # @since 0.1.0
48
48
  def default_resolver
49
- delegation = -> { EvilEvents::BootPoint[:config].subscriber.default_delegator }
49
+ delegation = -> { EvilEvents::Core::Bootstrap[:config].subscriber.default_delegator }
50
50
  EvilEvents::Shared::DelegatorResolver.new(delegation)
51
51
  end
52
52
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- class EvilEvents::System
3
+ class EvilEvents::Core::System
4
4
  # @api private
5
5
  # @since 0.1.0
6
6
  class Broadcaster
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- class EvilEvents::System
3
+ class EvilEvents::Core::System
4
4
  # @api private
5
5
  # @since 0.1.0
6
6
  module EventBuilder
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- class EvilEvents::System
3
+ class EvilEvents::Core::System
4
4
  # @api private
5
5
  # @since 0.1.0
6
6
  class EventManager
@@ -2,84 +2,84 @@
2
2
 
3
3
  # @api public
4
4
  # @since 0.1.0
5
- class EvilEvents::System
6
- # @see EvilEvents::System
5
+ class EvilEvents::Core::System
6
+ # @see EvilEvents::Core::System
7
7
  # @api public
8
8
  # @since 0.1.0
9
9
  class Mock
10
- # @see EvilEvents::System
10
+ # @see EvilEvents::Core::System
11
11
  # @since 0.1.0
12
12
  attr_reader :broadcaster
13
13
 
14
- # @see EvilEvents::System
14
+ # @see EvilEvents::Core::System
15
15
  # @since 0.1.0
16
16
  attr_reader :event_manager
17
17
 
18
- # @see EvilEvents::System
18
+ # @see EvilEvents::Core::System
19
19
  # @since 0.1.0
20
20
  def observe(event_class, raw_subscriber, delegator); end
21
21
 
22
- # @see EvilEvents::System
22
+ # @see EvilEvents::Core::System
23
23
  # @since 0.1.0
24
24
  def raw_observe(event_type, raw_subscriber, delegator); end
25
25
 
26
- # @see EvilEvents::System
26
+ # @see EvilEvents::Core::System
27
27
  # @since 0.1.0
28
28
  def observers(event_class); end
29
29
 
30
- # @see EvilEvents::System
30
+ # @see EvilEvents::Core::System
31
31
  # @since 0.1.0
32
32
  def emit(event); end
33
33
 
34
- # @see EvilEvents::System
34
+ # @see EvilEvents::Core::System
35
35
  # @since 0.1.0
36
36
  def raw_emit(event_type, **event_attributes); end
37
37
 
38
- # @see EvilEvents::System
38
+ # @see EvilEvents::Core::System
39
39
  # @since 0.1.0
40
40
  def resolve_adapter(adapter_name); end
41
41
 
42
- # @see EvilEvents::System
42
+ # @see EvilEvents::Core::System
43
43
  # @since 0.1.0
44
44
  def register_adapter(adapter_name, adapter_object); end
45
45
 
46
- # @see EvilEvents::System
46
+ # @see EvilEvents::Core::System
47
47
  # @since 0.1.0
48
48
  def register_event_class(event_class); end
49
49
 
50
- # @see EvilEvents::System
50
+ # @see EvilEvents::Core::System
51
51
  # @since 0.1.0
52
52
  def unregister_event_class(event_class); end
53
53
 
54
- # @see EvilEvents::System
54
+ # @see EvilEvents::Core::System
55
55
  # @since 0.1.0
56
56
  def manager_of_event(event); end
57
57
 
58
- # @see EvilEvents::System
58
+ # @see EvilEvents::Core::System
59
59
  # @since 0.1.0
60
60
  def manager_of_event_type(event_type); end
61
61
 
62
- # @see EvilEvents::System
62
+ # @see EvilEvents::Core::System
63
63
  # @since 0.1.0
64
64
  def resolve_event_object(event_type, payload: {}, metadata: {}); end
65
65
 
66
- # @see EvilEvents::System
66
+ # @see EvilEvents::Core::System
67
67
  # @since 0.1.0
68
68
  def define_event_class(event_type, &event_class_definitions); end
69
69
 
70
- # @see EvilEvents::System
70
+ # @see EvilEvents::Core::System
71
71
  # @since 0.1.0
72
72
  def define_abstract_event_class(event_type); end
73
73
 
74
- # @see EvilEvents::System
74
+ # @see EvilEvents::Core::System
75
75
  # @since 0.1.0
76
76
  def deserialize_from_json(serialized_event); end
77
77
 
78
- # @see EvilEvents::System
78
+ # @see EvilEvents::Core::System
79
79
  # @since 0.1.0
80
80
  def deserialize_from_hash(serialized_event); end
81
81
 
82
- # @see EvilEvents::System
82
+ # @see EvilEvents::Core::System
83
83
  # @since 0.1.0
84
84
  def managed_event?(event_class); end
85
85
  end
@@ -1,11 +1,11 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- class EvilEvents::System
3
+ class EvilEvents::Core::System
4
4
  # @api private
5
5
  # @since 0.1.0
6
6
  module Mocking
7
7
  class << self
8
- # @param base_class [EvilEvents::System]
8
+ # @param base_class [EvilEvents::Core::System]
9
9
  #
10
10
  # @since 0.1.0
11
11
  def included(base_class)
@@ -15,14 +15,14 @@ class EvilEvents::System
15
15
 
16
16
  # @since 0.1.0
17
17
  module ClassMethods
18
- # @return [EvilEvents::System::Mock]
18
+ # @return [EvilEvents::Core::System::Mock]
19
19
  #
20
20
  # @since 0.1.0
21
21
  def build_mock
22
22
  Mock.new
23
23
  end
24
24
 
25
- # @return [EvilEvents::System]
25
+ # @return [EvilEvents::Core::System]
26
26
  #
27
27
  # @since 0.1.0
28
28
  def build_stub
@@ -0,0 +1,63 @@
1
+ # frozen_string_literal: true
2
+
3
+ module EvilEvents::Core
4
+ # @api private
5
+ # @since 0.1.0
6
+ class System
7
+ require_relative 'system/mock'
8
+ require_relative 'system/mocking'
9
+ require_relative 'system/broadcaster'
10
+ require_relative 'system/event_builder'
11
+ require_relative 'system/event_manager'
12
+
13
+ # @since 0.1.0
14
+ extend Forwardable
15
+ # @since 0.1.0
16
+ include Mocking
17
+
18
+ # @see EvilEvents::Core::System::Broadcaster
19
+ # @since 0.1.0
20
+ def_delegators :broadcaster,
21
+ :emit,
22
+ :raw_emit,
23
+ :resolve_adapter,
24
+ :register_adapter
25
+
26
+ # @see EvilEvents::Core::System::EventManager
27
+ # @since 0.1.0
28
+ def_delegators :event_manager,
29
+ :observe,
30
+ :raw_observe,
31
+ :observers,
32
+ :register_event_class,
33
+ :unregister_event_class,
34
+ :manager_of_event,
35
+ :manager_of_event_type,
36
+ :resolve_event_object,
37
+ :managed_event?
38
+
39
+ # @see EvilEvents::Core::System::EventBuilder
40
+ # @since 0.1.0
41
+ def_delegators 'EvilEvents::Core::System::EventBuilder',
42
+ :define_event_class,
43
+ :define_abstract_event_class,
44
+ :deserialize_from_json,
45
+ :deserialize_from_hash
46
+
47
+ # @return [EvilEvents::Core::System::Broadcaster]
48
+ #
49
+ # @since 0.1.0
50
+ attr_reader :broadcaster
51
+
52
+ # @return [EvilEvents::Core::System::EventManager]
53
+ #
54
+ # @since 0.1.0
55
+ attr_reader :event_manager
56
+
57
+ # @since 0.1.0
58
+ def initialize
59
+ @broadcaster = Broadcaster.new
60
+ @event_manager = EventManager.new
61
+ end
62
+ end
63
+ end
@@ -7,5 +7,8 @@ module EvilEvents
7
7
  require_relative 'core/activity_logger'
8
8
  require_relative 'core/broadcasting'
9
9
  require_relative 'core/events'
10
+ require_relative 'core/config'
11
+ require_relative 'core/system'
12
+ require_relative 'core/bootstrap'
10
13
  end
11
14
  end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ module EvilEvents
4
+ # @api public
5
+ # @since 0.1.0
6
+ DispatcherMixin = EvilEvents::Core::Broadcasting::Dispatcher::Mixin.module_clone
7
+ end
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ module EvilEvents
4
+ # @api public
5
+ # @since 0.1.0
6
+ module Emitter
7
+ class << self
8
+ # @see EvilEvents::Core::System
9
+ # @api public
10
+ # @since 0.1.0
11
+ def emit(event_type, **event_attributes)
12
+ EvilEvents::Core::Bootstrap[:event_system].raw_emit(event_type, **event_attributes)
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ module EvilEvents
4
+ # @api public
5
+ # @since 0.1.0
6
+ module Event
7
+ class << self
8
+ # @see EvilEvents::Core::System
9
+ # @api public
10
+ # @since 0.1.0
11
+ def [](event_type)
12
+ EvilEvents::Core::Bootstrap[:event_system].define_abstract_event_class(event_type)
13
+ end
14
+
15
+ # @see EvilEvents::Core::System
16
+ # @api public
17
+ # @since 0.1.0
18
+ def define(event_type, &event_class_definitions)
19
+ EvilEvents::Core::Bootstrap[:event_system].define_event_class(
20
+ event_type, &event_class_definitions
21
+ )
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ module EvilEvents
4
+ # @api public
5
+ # @since 0.1.0
6
+ module Serializer
7
+ class << self
8
+ # @see EvilEvents::Core::System
9
+ # @api public
10
+ # @since 0.1.0
11
+ def load_from_json(serialized_event)
12
+ EvilEvents::Core::Bootstrap[:event_system].deserialize_from_json(serialized_event)
13
+ end
14
+
15
+ # @see EvilEvents::Core::System
16
+ # @api public
17
+ # @since 0.1.0
18
+ def load_from_hash(serialized_event)
19
+ EvilEvents::Core::Bootstrap[:event_system].deserialize_from_hash(serialized_event)
20
+ end
21
+ end
22
+ end
23
+ end
@@ -1,14 +1,12 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module EvilEvents
4
- module Shared
5
- # TODO: переместить это в неймспейс CombinedContext чтобы было CombinedContext::Mixin
6
-
3
+ module EvilEvents::Shared
4
+ class CombinedContext
7
5
  # @example
8
6
  # require 'securerandom'
9
7
  #
10
8
  # class Event
11
- # extend EvilEvents::Shared::CombinedContextMixin
9
+ # extend EvilEvents::Shared::CombinedContext::Mixin
12
10
  #
13
11
  # class << self
14
12
  # def type(type = nil)
@@ -28,9 +26,9 @@ module EvilEvents
28
26
  #
29
27
  # @see EvilEvents::Shared::CombinedContext
30
28
  #
31
- # @since 0.1.0
32
29
  # @api public
33
- module CombinedContextMixin
30
+ # @since 0.1.0
31
+ module Mixin
34
32
  # @param clojure [Proc]
35
33
  # @return [Object] Clojure evaluation result
36
34
  #
@@ -9,9 +9,9 @@ module EvilEvents
9
9
  require_relative 'shared/structure'
10
10
  require_relative 'shared/configurable'
11
11
  require_relative 'shared/combined_context'
12
+ require_relative 'shared/combined_context/mixin'
12
13
  require_relative 'shared/delegator_resolver'
13
14
  require_relative 'shared/dependency_container'
14
- require_relative 'shared/combined_context_mixin'
15
15
  require_relative 'shared/clonable_module_builder'
16
16
  end
17
17
  end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ module EvilEvents
4
+ # @api piblic
5
+ # @since 0.1.0
6
+ SubscriberMixin = EvilEvents::Core::Events::Subscriber::Mixin.module_clone
7
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ module EvilEvents
4
+ # @api public
5
+ # @since 0.1.0
6
+ Types = Shared::Types
7
+ end
@@ -3,5 +3,5 @@
3
3
  module EvilEvents
4
4
  # @api public
5
5
  # @since 0.1.0
6
- VERSION = '0.1.0rc7'
6
+ VERSION = '0.1.0rc8'
7
7
  end
data/lib/evil_events.rb CHANGED
@@ -12,125 +12,15 @@ require 'json'
12
12
  # @api public
13
13
  # @since 0.1.0
14
14
  module EvilEvents
15
+ require_relative 'evil_events/version'
15
16
  require_relative 'evil_events/shared'
17
+ require_relative 'evil_events/types'
16
18
  require_relative 'evil_events/core'
17
- require_relative 'evil_events/system'
18
19
  require_relative 'evil_events/config'
19
- require_relative 'evil_events/boot_point'
20
- require_relative 'evil_events/version'
21
-
22
- # @api public
23
- # @since 0.1.0
24
- Types = Shared::Types
25
-
26
- # @api public
27
- # @since 0.1.0
28
- DispatcherMixin = EvilEvents::Core::Broadcasting::Dispatcher::Mixin.module_clone
29
-
30
- # @api piblic
31
- # @since 0.1.0
32
- SubscriberMixin = EvilEvents::Core::Events::Subscriber::Mixin.module_clone
33
-
34
- class << self
35
- # @see EvilEvents::Config
36
- # @api public
37
- # @since 0.1.0
38
- def configure
39
- config.configure { |conf| yield(conf) if block_given? }
40
- end
41
-
42
- # @see EvilEvents::Config
43
- # @api public
44
- # @since 0.1.0
45
- def config
46
- EvilEvents::BootPoint[:config]
47
- end
48
- end
49
-
50
- # @api public
51
- # @since 0.1.0
52
- module Adapters
53
- class << self
54
- # @params adapter_name [String, Symbol]
55
- # @params adapter_object [Class{EvilEvents::DispatcherMixin}]
56
- # @raise Dry::Container::Error
57
- # @return void
58
- #
59
- # @see EvilEvents::System
60
- #
61
- # @api public
62
- # @since 0.1.0
63
- def register(adapter_name, adapter_object)
64
- EvilEvents::BootPoint[:event_system].register_adapter(adapter_name, adapter_object)
65
- end
66
-
67
- # @param adapter_name [String, Symbol]
68
- # @raise Dry::Container::Error
69
- # @return [Class{EvilEvents::DispatcherMixin}]
70
- #
71
- # @see EvilEvents::System
72
- #
73
- # @api public
74
- # @since 0.1.0
75
- def resolve(adapter_name)
76
- EvilEvents::BootPoint[:event_system].resolve_adapter(adapter_name)
77
- end
78
- alias_method :[], :resolve
79
- end
80
- end
81
-
82
- # @api public
83
- # @since 0.1.0
84
- module Serializer
85
- class << self
86
- # @see EvilEvents::System
87
- # @api public
88
- # @since 0.1.0
89
- def load_from_json(serialized_event)
90
- EvilEvents::BootPoint[:event_system].deserialize_from_json(serialized_event)
91
- end
92
-
93
- # @see EvilEvents::System
94
- # @api public
95
- # @since 0.1.0
96
- def load_from_hash(serialized_event)
97
- EvilEvents::BootPoint[:event_system].deserialize_from_hash(serialized_event)
98
- end
99
- end
100
- end
101
-
102
- # @api public
103
- # @since 0.1.0
104
- module Emitter
105
- class << self
106
- # @see EvilEvents::System
107
- # @api public
108
- # @since 0.1.0
109
- def emit(event_type, **event_attributes)
110
- EvilEvents::BootPoint[:event_system].raw_emit(event_type, **event_attributes)
111
- end
112
- end
113
- end
114
-
115
- # @api public
116
- # @since 0.1.0
117
- module Event
118
- class << self
119
- # @see EvilEvents::System
120
- # @api public
121
- # @since 0.1.0
122
- def [](event_type)
123
- EvilEvents::BootPoint[:event_system].define_abstract_event_class(event_type)
124
- end
125
-
126
- # @see EvilEvents::System
127
- # @api public
128
- # @since 0.1.0
129
- def define(event_type, &event_class_definitions)
130
- EvilEvents::BootPoint[:event_system].define_event_class(
131
- event_type, &event_class_definitions
132
- )
133
- end
134
- end
135
- end
20
+ require_relative 'evil_events/event'
21
+ require_relative 'evil_events/serializer'
22
+ require_relative 'evil_events/adapters'
23
+ require_relative 'evil_events/emitter'
24
+ require_relative 'evil_events/subscriber_mixin'
25
+ require_relative 'evil_events/dispatcher_mixin'
136
26
  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.0rc7
4
+ version: 0.1.0rc8
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-24 00:00:00.000000000 Z
11
+ date: 2017-10-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dry-monads
@@ -114,14 +114,14 @@ dependencies:
114
114
  requirements:
115
115
  - - '='
116
116
  - !ruby/object:Gem::Version
117
- version: 0.11.1
117
+ version: 0.11.2
118
118
  type: :development
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
122
  - - '='
123
123
  - !ruby/object:Gem::Version
124
- version: 0.11.1
124
+ version: 0.11.2
125
125
  - !ruby/object:Gem::Dependency
126
126
  name: simplecov
127
127
  requirement: !ruby/object:Gem::Requirement
@@ -156,14 +156,14 @@ dependencies:
156
156
  requirements:
157
157
  - - '='
158
158
  - !ruby/object:Gem::Version
159
- version: 0.50.0
159
+ version: 0.51.0
160
160
  type: :development
161
161
  prerelease: false
162
162
  version_requirements: !ruby/object:Gem::Requirement
163
163
  requirements:
164
164
  - - '='
165
165
  - !ruby/object:Gem::Version
166
- version: 0.50.0
166
+ version: 0.51.0
167
167
  - !ruby/object:Gem::Dependency
168
168
  name: bundler
169
169
  requirement: !ruby/object:Gem::Requirement
@@ -198,28 +198,28 @@ dependencies:
198
198
  requirements:
199
199
  - - '='
200
200
  - !ruby/object:Gem::Version
201
- version: 3.6.0
201
+ version: 3.7.0
202
202
  type: :development
203
203
  prerelease: false
204
204
  version_requirements: !ruby/object:Gem::Requirement
205
205
  requirements:
206
206
  - - '='
207
207
  - !ruby/object:Gem::Version
208
- version: 3.6.0
208
+ version: 3.7.0
209
209
  - !ruby/object:Gem::Dependency
210
210
  name: rubocop-rspec
211
211
  requirement: !ruby/object:Gem::Requirement
212
212
  requirements:
213
213
  - - '='
214
214
  - !ruby/object:Gem::Version
215
- version: 1.18.0
215
+ version: 1.19.0
216
216
  type: :development
217
217
  prerelease: false
218
218
  version_requirements: !ruby/object:Gem::Requirement
219
219
  requirements:
220
220
  - - '='
221
221
  - !ruby/object:Gem::Version
222
- version: 1.18.0
222
+ version: 1.19.0
223
223
  description: Ultra simple, but very flexible and fully customizable event subsystem
224
224
  for ruby applications with a wide set of customization interfaces and smart event
225
225
  definition DSL.
@@ -243,10 +243,11 @@ files:
243
243
  - bin/setup
244
244
  - evil_events.gemspec
245
245
  - lib/evil_events.rb
246
- - lib/evil_events/boot_point.rb
246
+ - lib/evil_events/adapters.rb
247
247
  - lib/evil_events/config.rb
248
248
  - lib/evil_events/core.rb
249
249
  - lib/evil_events/core/activity_logger.rb
250
+ - lib/evil_events/core/bootstrap.rb
250
251
  - lib/evil_events/core/broadcasting.rb
251
252
  - lib/evil_events/core/broadcasting/adapters.rb
252
253
  - lib/evil_events/core/broadcasting/adapters/memory_async.rb
@@ -254,6 +255,7 @@ files:
254
255
  - lib/evil_events/core/broadcasting/dispatcher.rb
255
256
  - lib/evil_events/core/broadcasting/dispatcher/mixin.rb
256
257
  - lib/evil_events/core/broadcasting/emitter.rb
258
+ - lib/evil_events/core/config.rb
257
259
  - lib/evil_events/core/events.rb
258
260
  - lib/evil_events/core/events/abstract_event.rb
259
261
  - lib/evil_events/core/events/event_class_factory.rb
@@ -276,22 +278,28 @@ files:
276
278
  - lib/evil_events/core/events/serializers/json.rb
277
279
  - lib/evil_events/core/events/subscriber.rb
278
280
  - lib/evil_events/core/events/subscriber/mixin.rb
281
+ - lib/evil_events/core/system.rb
282
+ - lib/evil_events/core/system/broadcaster.rb
283
+ - lib/evil_events/core/system/event_builder.rb
284
+ - lib/evil_events/core/system/event_manager.rb
285
+ - lib/evil_events/core/system/mock.rb
286
+ - lib/evil_events/core/system/mocking.rb
287
+ - lib/evil_events/dispatcher_mixin.rb
288
+ - lib/evil_events/emitter.rb
289
+ - lib/evil_events/event.rb
290
+ - lib/evil_events/serializer.rb
279
291
  - lib/evil_events/shared.rb
280
292
  - lib/evil_events/shared/clonable_module_builder.rb
281
293
  - lib/evil_events/shared/combined_context.rb
282
- - lib/evil_events/shared/combined_context_mixin.rb
294
+ - lib/evil_events/shared/combined_context/mixin.rb
283
295
  - lib/evil_events/shared/configurable.rb
284
296
  - lib/evil_events/shared/delegator_resolver.rb
285
297
  - lib/evil_events/shared/dependency_container.rb
286
298
  - lib/evil_events/shared/logger.rb
287
299
  - lib/evil_events/shared/structure.rb
288
300
  - lib/evil_events/shared/types.rb
289
- - lib/evil_events/system.rb
290
- - lib/evil_events/system/broadcaster.rb
291
- - lib/evil_events/system/event_builder.rb
292
- - lib/evil_events/system/event_manager.rb
293
- - lib/evil_events/system/mock.rb
294
- - lib/evil_events/system/mocking.rb
301
+ - lib/evil_events/subscriber_mixin.rb
302
+ - lib/evil_events/types.rb
295
303
  - lib/evil_events/version.rb
296
304
  homepage: https://github.com/ergosploit/evil_events
297
305
  licenses:
@@ -1,13 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module EvilEvents
4
- # @api private
5
- # @since 0.1.0
6
- class BootPoint
7
- # @since 0.1.0
8
- extend Shared::DependencyContainer::Mixin
9
-
10
- register(:event_system, memoize: true) { EvilEvents::System.new }
11
- register(:config, memoize: true) { EvilEvents::Config.new }
12
- end
13
- end
@@ -1,61 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # @api private
4
- # @since 0.1.0
5
- class EvilEvents::System
6
- require_relative 'system/mock'
7
- require_relative 'system/mocking'
8
- require_relative 'system/broadcaster'
9
- require_relative 'system/event_builder'
10
- require_relative 'system/event_manager'
11
-
12
- # @since 0.1.0
13
- extend Forwardable
14
- # @since 0.1.0
15
- include Mocking
16
-
17
- # @see EvilEvents::System::Broadcaster
18
- # @since 0.1.0
19
- def_delegators :broadcaster,
20
- :emit,
21
- :raw_emit,
22
- :resolve_adapter,
23
- :register_adapter
24
-
25
- # @see EvilEvents::System::EventManager
26
- # @since 0.1.0
27
- def_delegators :event_manager,
28
- :observe,
29
- :raw_observe,
30
- :observers,
31
- :register_event_class,
32
- :unregister_event_class,
33
- :manager_of_event,
34
- :manager_of_event_type,
35
- :resolve_event_object,
36
- :managed_event?
37
-
38
- # @see EvilEvents::System::EventBuilder
39
- # @since 0.1.0
40
- def_delegators 'EvilEvents::System::EventBuilder',
41
- :define_event_class,
42
- :define_abstract_event_class,
43
- :deserialize_from_json,
44
- :deserialize_from_hash
45
-
46
- # @return [EvilEvents::System::Broadcaster]
47
- #
48
- # @since 0.1.0
49
- attr_reader :broadcaster
50
-
51
- # @return [EvilEvents::System::EventManager]
52
- #
53
- # @since 0.1.0
54
- attr_reader :event_manager
55
-
56
- # @since 0.1.0
57
- def initialize
58
- @broadcaster = Broadcaster.new
59
- @event_manager = EventManager.new
60
- end
61
- end