metacosm 0.3.1 → 0.3.2

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: b791dadd34aa1c25af456378262af8bff854c1cd
4
- data.tar.gz: ad2e8bfc5761418c9d08d8a945d967387a45a2b6
3
+ metadata.gz: e645a9a08cbfe919ac910c227a009362cea85489
4
+ data.tar.gz: ddc00033d2b1753af206e7c94ce826a87a65d08e
5
5
  SHA512:
6
- metadata.gz: 294be92110a7e5ffad26a34d75d52ac1d15efffc2a053aeba53f6c61a4fb1fb2d05850217d9ee11d0dcb5d930b172ce9292ffffb80fdf123cc3699c2e70e32f3
7
- data.tar.gz: 39120b57afc4b8aed3b41fdefec15a0ae25123c03a7c5eb0040da216c5ab4cb392f8c54c46a7320782aeb648b73a1c8c0df57a7a8758c01d8061e9e4ad8091c8
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
@@ -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
- apply(Marshal.load(message))
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|
@@ -1,4 +1,4 @@
1
1
  module Metacosm
2
2
  # metacosm version
3
- VERSION = "0.3.1"
3
+ VERSION = "0.3.2"
4
4
  end
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.1
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-03-25 00:00:00.000000000 Z
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.6
197
+ rubygems_version: 2.4.8
198
198
  signing_key:
199
199
  specification_version: 4
200
200
  summary: reactive simulation framework