ntl-actor 0.4.1 → 0.5.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
  SHA1:
3
- metadata.gz: ba3e71c91c282205936e4cc9bf199e6d80dcae8c
4
- data.tar.gz: d46dbe635f619d79c02ef1fc333c3504edeac9ac
3
+ metadata.gz: e81baca90d8dfc0b1138c86c5d447e746ee42b64
4
+ data.tar.gz: 07da40ca6364e24f1c3007b044736ca9a86e3cf3
5
5
  SHA512:
6
- metadata.gz: aeb1c9a814dbfb72de543631797c343960f5b357e9985f03a950282709293e142150c74e41e1ef5cc9141edd73c50168aa0eed0c372a699acba605d0157797d9
7
- data.tar.gz: 5f897414547a15bb858c8a0b4fbcfb07761c7c978ac18a202d449df8e17f0b65c2f9e16cd70f94eac5e6954c8e81fa05eb083fb53b4f20649f2de592e4b8edec
6
+ metadata.gz: 3e20176f4addb6bed555fadd4375104322866effb7425ad71e99db449048f620e7f87f3c6bb09dd893839bff1aa67ca73c27a69bd28c648db57d006f1041d3c3
7
+ data.tar.gz: 9f1b7a7008b80e475679154c840121a4dc212066422aca82f1d2907adaec6f2e841ad504139d06e3e436e36c5fc926e8d5f8b1e85943ed16d3733c135b58370f
data/lib/actor.rb CHANGED
@@ -19,7 +19,6 @@ require 'actor/messaging/write/substitute'
19
19
 
20
20
  require 'actor/messages'
21
21
 
22
- require 'actor/build'
23
22
  require 'actor/handle_macro'
24
23
  require 'actor/observers'
25
24
 
data/lib/actor/actor.rb CHANGED
@@ -12,11 +12,12 @@ module Actor
12
12
  module Module
13
13
  def self.included cls
14
14
  cls.class_exec do
15
- extend Build
16
15
  extend HandleMacro
17
16
  extend Start
18
17
 
19
18
  include Observers
19
+
20
+ prepend Configure
20
21
  end
21
22
  end
22
23
 
@@ -94,11 +95,41 @@ module Actor
94
95
  @writer ||= Messaging::Write::Substitute.new
95
96
  end
96
97
 
98
+ module Configure
99
+ def configure
100
+ super
101
+
102
+ self.reader = Messaging::Read.build address
103
+ self.writer = Messaging::Write.new
104
+ end
105
+ end
106
+
97
107
  module Start
98
108
  def start *positional_arguments, address: nil, supervisor_address: nil, include: nil, **keyword_arguments, &block
99
109
  address ||= Address.build
100
110
 
101
- instance = build address, *positional_arguments, **keyword_arguments, &block
111
+ if respond_to? :build
112
+ constructor = method :build
113
+ else
114
+ constructor = method :new
115
+ end
116
+
117
+ if keyword_arguments.empty?
118
+ instance = constructor.(
119
+ *positional_arguments,
120
+ &block
121
+ )
122
+ else
123
+ instance = constructor.(
124
+ *positional_arguments,
125
+ **keyword_arguments,
126
+ &block
127
+ )
128
+ end
129
+
130
+ instance.address = address
131
+
132
+ instance.configure
102
133
 
103
134
  thread = Actor::Start.(
104
135
  instance,
@@ -18,9 +18,8 @@ module Actor
18
18
  def run &assembly
19
19
  self.address = Address.build
20
20
 
21
- instance = build address, &assembly
21
+ _, thread = start address: address, include: %i(thread), &assembly
22
22
 
23
- thread = Start.(instance, address)
24
23
  thread.join
25
24
  end
26
25
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ntl-actor
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nathan Ladd
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-09-17 00:00:00.000000000 Z
11
+ date: 2016-10-20 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Implementation of actor pattern for ruby designed for simplicity and
14
14
  frugality
@@ -20,7 +20,6 @@ files:
20
20
  - lib/actor.rb
21
21
  - lib/actor/actor.rb
22
22
  - lib/actor/address.rb
23
- - lib/actor/build.rb
24
23
  - lib/actor/controls.rb
25
24
  - lib/actor/controls/actor.rb
26
25
  - lib/actor/controls/address.rb
data/lib/actor/build.rb DELETED
@@ -1,19 +0,0 @@
1
- module Actor
2
- module Build
3
- def build address, *positional_arguments, **keyword_arguments, &block
4
- if keyword_arguments.empty?
5
- instance = new *positional_arguments, &block
6
- else
7
- instance = new *positional_arguments, **keyword_arguments, &block
8
- end
9
-
10
- instance.address = address
11
- instance.reader = Messaging::Read.build address
12
- instance.writer = Messaging::Write.new
13
-
14
- instance.configure
15
-
16
- instance
17
- end
18
- end
19
- end