low_event 0.7.1 → 0.8.0

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: 4286eb914a5d502cc8315b14d25f22351e4fc4085cccc199a274608716326598
4
- data.tar.gz: 72c748af66c4d677428620ae5f45657af50ad306240a3e9a861497dfa988b0ef
3
+ metadata.gz: 4bab872cc67259d94e7b3041b857c97eebf605a98ef4d7ec8150183e355ec1c7
4
+ data.tar.gz: c8b168ef52bc18c0cddf69f92e35f8d5d52ed9c3d7a939987e88bf7c878a7faf
5
5
  SHA512:
6
- metadata.gz: 86b141101160881806cac94ff1691b110f49d6e59d7c07e97bee200bc879ba027b7aa0a4a0c6c48fc8ab0290184c03a3605527dad39abc84150d13e5b0263fb5
7
- data.tar.gz: 8a26413485f1456924f62af3fe36451d481861e05a7d2355dd03c5467e785b031b127b36ad83a699ea85d4d2c0a6acf9e71ed4a389cca04c4dec804656a2c89c
6
+ metadata.gz: 3583d5c6da3494dc0f437b9b0aea7cb4eb17e52ede03a5cb88ae404e770939c65d231681ec48b2513f82a3e74711ca54ebdeebfb56b667a900eb166bc6490a18
7
+ data.tar.gz: afbcfea6a595fe2f97ca188bca772947fe441f85d0d061b17d7cd1e2b6be1ad9d9f97181a0d3af4e2a2dcc64eeb10e8904f7bb1e0a03a08eda32fa8bfa70f3e3
@@ -7,7 +7,7 @@ module Low
7
7
  class RequestEvent < Event
8
8
  attr_reader :request
9
9
 
10
- def initialize(request:, action: :handle)
10
+ def initialize(request:, action: :request)
11
11
  super(key: self.class, action:)
12
12
 
13
13
  @request = request
@@ -8,7 +8,7 @@ module Low
8
8
  class << self
9
9
  def response(body:)
10
10
  headers = Protocol::HTTP::Headers.new(['content-type', 'text/html'])
11
- body = Protocol::HTTP::Body::Buffered.wrap(body)
11
+ body = Protocol::HTTP::Body::Buffered.wrap(body.strip)
12
12
 
13
13
  Protocol::HTTP::Response.new('http/1.1', 200, headers, body)
14
14
  end
@@ -6,30 +6,32 @@ require_relative 'definable'
6
6
  require_relative '../support/value_object'
7
7
 
8
8
  module Low
9
- # An event represents what is currently happening in your application.
9
+ # An event represents what is currently happening; the past, present and future.
10
10
  #
11
- # Events are mutable in most cases (except for RenderEvent). They are action-driven, representing inputs and outputs
12
- # that are currently happening in a linear pipeline-like flow. They are present-tense and one-to-many with one return value.
13
- # The result of the previous event is made available to the next event. [UNRELEASED]
11
+ # They are action-driven, representing inputs and outputs in a linear pipeline-like flow,
12
+ # which end up as children of the event... which is why events are mutable (except for RenderEvent).
13
+ # They are one-to-many with a return value.
14
14
  #
15
15
  # Integrations:
16
16
  # - Observers for observer pattern which we wrap in an event-centric API
17
- # - EventPool for a tree of events and their child events
18
- # - LowState for state machines to trigger multiple actions [UNLRELEASED]
17
+ # - EventPool for a tree of events and their child events (defined in this gem)
18
+ # - LowState for state machines to trigger multiple ordered actions [UNLRELEASED]
19
19
  class Event
20
20
  include LowType
21
21
  include Observers
22
22
  include Events::Definable
23
23
  include Support::ValueObject
24
24
 
25
- attr_reader :key, :action, :created_at
25
+ attr_reader :key, :action, :actions, :created_at
26
26
  attr_accessor :children
27
27
 
28
- # The subclass will provide the key, usually "self.class".
29
- def initialize(key:, action: nil, children: [])
28
+ # Subclass provides a key such as "self.class".
29
+ def initialize(key:, action: nil, actions: [], children: [])
30
30
  @key = key
31
31
  @action = action
32
+ @actions = actions
32
33
  @children = children
34
+
33
35
  @created_at = Process.clock_gettime(Process::CLOCK_MONOTONIC, :millisecond)
34
36
  end
35
37
 
@@ -62,7 +64,6 @@ module Low
62
64
 
63
65
  def inherited(child)
64
66
  child.include LowType
65
-
66
67
  increase_count
67
68
  add_event(child)
68
69
  end
@@ -14,23 +14,23 @@ module Low
14
14
  BUFFER_SIZE = 100
15
15
 
16
16
  def initialize
17
- @pool = Support::PoolHash.new(BUFFER_SIZE)
17
+ @event_trees = Support::PoolHash.new(BUFFER_SIZE)
18
18
  @request_counts = Support::PoolHash.new(BUFFER_SIZE)
19
19
  end
20
20
 
21
21
  def current_event_tree(event:)
22
22
  request_id = request_id(event:)
23
23
 
24
- return @pool[request_id] if @pool[request_id]
24
+ return @event_trees[request_id] if @event_trees[request_id]
25
25
 
26
- event_tree = @pool.add(request_id, EventTree.new(request_id:))
26
+ event_tree = @event_trees.add(request_id, EventTree.new(request_id:))
27
27
  trigger action: :new_event_tree, event: event_tree
28
28
 
29
29
  event_tree
30
30
  end
31
31
 
32
32
  def event_trees
33
- @pool
33
+ @event_trees
34
34
  end
35
35
 
36
36
  private
data/lib/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Low
4
- EVENT_VERSION = '0.7.1'
4
+ EVENT_VERSION = '0.8.0'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: low_event
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.1
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - maedi
@@ -106,7 +106,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
106
106
  - !ruby/object:Gem::Version
107
107
  version: '0'
108
108
  requirements: []
109
- rubygems_version: 4.0.10
109
+ rubygems_version: 4.0.6
110
110
  specification_version: 4
111
111
  summary: Observable events
112
112
  test_files: []