metacosm 0.3.1 → 0.3.2
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 +4 -4
- data/lib/metacosm/remote_simulation.rb +7 -1
- data/lib/metacosm/simulation.rb +14 -2
- data/lib/metacosm/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e645a9a08cbfe919ac910c227a009362cea85489
|
4
|
+
data.tar.gz: ddc00033d2b1753af206e7c94ce826a87a65d08e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 144418e13b1af3653d7bb6e8a41349f47c4c9dc4c2a13affac698a611cf00d7d97531348346e454d93a0aa1ba05fc85c248d086c15911714f99d7dfc0ae01aa0
|
7
|
+
data.tar.gz: a743ea6ca08471c22efd146b2d0b3698b101060eefab3a49b3d36382f384b4f4c8dddbe61ea94959ded1d85d79ff41e4fe9f6002e5c7f5f67c6e3dd4a5cc21ea
|
@@ -14,6 +14,10 @@ module Metacosm
|
|
14
14
|
redis.publish(@command_queue_name, Marshal.dump(command_dto))
|
15
15
|
end
|
16
16
|
|
17
|
+
def received_events
|
18
|
+
@events_received ||= []
|
19
|
+
end
|
20
|
+
|
17
21
|
def setup_connection
|
18
22
|
@remote_listener_thread = Thread.new do
|
19
23
|
begin
|
@@ -31,13 +35,15 @@ module Metacosm
|
|
31
35
|
module_name = "Object" if module_name.empty?
|
32
36
|
listener = (module_name.constantize).const_get(listener_class_name).new(self)
|
33
37
|
listener.receive(event)
|
38
|
+
|
39
|
+
received_events.push(event)
|
34
40
|
end
|
35
41
|
|
36
42
|
on.unsubscribe do |channel, subscriptions|
|
37
43
|
puts "Unsubscribed from remote simulation event stream ##{channel} (#{subscriptions} subscriptions)"
|
38
44
|
end
|
39
45
|
end
|
40
|
-
rescue Redis::BaseConnectionError => error
|
46
|
+
rescue ::Redis::BaseConnectionError => error
|
41
47
|
puts "#{error}, retrying in 1s"
|
42
48
|
sleep 1
|
43
49
|
retry
|
data/lib/metacosm/simulation.rb
CHANGED
@@ -5,6 +5,10 @@ module Metacosm
|
|
5
5
|
Redis.new
|
6
6
|
end
|
7
7
|
|
8
|
+
def params
|
9
|
+
@params ||= {}
|
10
|
+
end
|
11
|
+
|
8
12
|
def fire(command)
|
9
13
|
command_queue.push(command)
|
10
14
|
end
|
@@ -40,6 +44,8 @@ module Metacosm
|
|
40
44
|
|
41
45
|
def apply(command)
|
42
46
|
mutex.synchronize do
|
47
|
+
received_commands.push(command)
|
48
|
+
|
43
49
|
if command.is_a?(Hash)
|
44
50
|
handler_module_name = command.delete(:handler_module)
|
45
51
|
handler_class_name = command.delete(:handler_class_name)
|
@@ -54,6 +60,10 @@ module Metacosm
|
|
54
60
|
end
|
55
61
|
end
|
56
62
|
|
63
|
+
def received_commands
|
64
|
+
@commands_received ||= []
|
65
|
+
end
|
66
|
+
|
57
67
|
def apply_event(event)
|
58
68
|
if !@on_event_callback.nil?
|
59
69
|
event_dto = event.attrs.merge(listener_module: event.listener_module_name, listener_class_name: event.listener_class_name)
|
@@ -97,8 +107,10 @@ module Metacosm
|
|
97
107
|
end
|
98
108
|
|
99
109
|
on.message do |chan, message|
|
100
|
-
puts "##{chan}: #{message}"
|
101
|
-
|
110
|
+
# puts "##{chan}: #{message}"
|
111
|
+
command_data = Marshal.load(message)
|
112
|
+
p [ :got_message, command_data: command_data ]
|
113
|
+
apply(command_data)
|
102
114
|
end
|
103
115
|
|
104
116
|
on.unsubscribe do |chan, subscriptions|
|
data/lib/metacosm/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: metacosm
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joseph Weissman
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-04-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: passive_record
|
@@ -194,7 +194,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
194
194
|
version: '0'
|
195
195
|
requirements: []
|
196
196
|
rubyforge_project:
|
197
|
-
rubygems_version: 2.4.
|
197
|
+
rubygems_version: 2.4.8
|
198
198
|
signing_key:
|
199
199
|
specification_version: 4
|
200
200
|
summary: reactive simulation framework
|