metacosm 0.2.14 → 0.3.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: 68f1b5dd4218a10775dfe6aae1afc0b4db1e295d
4
- data.tar.gz: b6d7707b7b226b4d30a8f1d3a89e275aee2973b2
3
+ metadata.gz: 66827fd4b46abafb5968f2e5edfbc81fb0d0bf6a
4
+ data.tar.gz: be2c788d20092c47e8ce694f301a35c02c7fbf3b
5
5
  SHA512:
6
- metadata.gz: f6aaa059326435c46219c6205a21892b999980d9fc40d1108e1ec7ed47052206698098f94b8e7ce40c5a009002f38ce15c081337b2eb4f08a95b67d119e05d42
7
- data.tar.gz: 8653b0c85c98fa87b1e09036ecc01e7e5ede20696b56e57ba660843951bba77c63ad7ce48ed150c494185ffb3a339514f72b18ed4983cff08fd12675c072a1e6
6
+ metadata.gz: 0f4b1ed809a9ae97e6912ac49e53c27994b5931d7931037ce5c99ceff02587bf0d3acef582005664bf421c6ae97919ea5f36255fe4d474650c54df1c28e3bbdf
7
+ data.tar.gz: 744ddc7537917dd4b691076c33cc8bc07b2ad142c309148e903c3635eee8125cbe555d461fcb889a7239e60c42f7595944261ec1f8b61d43489e1044c67097b4
data/Gemfile CHANGED
@@ -1,6 +1,6 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
- ruby '2.3.0'
3
+ ruby '2.2.1'
4
4
 
5
5
  gemspec
6
6
 
data/gemspec.yml CHANGED
@@ -6,7 +6,7 @@ authors: Joseph Weissman
6
6
  email: jweissman1986@gmail.com
7
7
  homepage: https://rubygems.org/gems/metacosm
8
8
  dependencies:
9
- passive_record: ~> 0.3
9
+ passive_record: ~> 0.4
10
10
  redis: ~> 3.2
11
11
  development_dependencies:
12
12
  bundler: ~> 1.10
@@ -10,6 +10,8 @@ module Metacosm
10
10
  Redis.new
11
11
  end
12
12
 
13
+ def apply(command); fire command end
14
+
13
15
  def fire(command)
14
16
  command_dto = command.attrs.merge(handler_module: command.handler_module_name, handler_class_name: command.handler_class_name)
15
17
  redis = redis_connection
@@ -20,7 +20,6 @@ module Metacosm
20
20
  while true
21
21
  if (command=command_queue.pop)
22
22
  apply(command)
23
- sleep 0.01
24
23
  end
25
24
  Thread.pass
26
25
  end
@@ -84,26 +83,28 @@ module Metacosm
84
83
 
85
84
  def subscribe_for_commands(channel:)
86
85
  p [ :subscribe_to_command_channel, channel: channel ]
87
- redis = Redis.new
88
- begin
89
- redis.subscribe(channel) do |on|
90
- on.subscribe do |chan, subscriptions|
91
- puts "Subscribed to ##{chan} (#{subscriptions} subscriptions)"
92
- end
93
-
94
- on.message do |chan, message|
95
- puts "##{chan}: #{message}"
96
- apply(Marshal.load(message))
97
- end
98
-
99
- on.unsubscribe do |chan, subscriptions|
100
- puts "Unsubscribed from ##{chan} (#{subscriptions} subscriptions)"
101
- end
102
- end
103
- rescue Redis::BaseConnectionError => error
104
- puts "#{error}, retrying in 1s"
105
- sleep 1
106
- retry
86
+ @command_subscription_thread = Thread.new do
87
+ redis = Redis.new
88
+ begin
89
+ redis.subscribe(channel) do |on|
90
+ on.subscribe do |chan, subscriptions|
91
+ puts "Subscribed to ##{chan} (#{subscriptions} subscriptions)"
92
+ end
93
+
94
+ on.message do |chan, message|
95
+ puts "##{chan}: #{message}"
96
+ apply(Marshal.load(message))
97
+ end
98
+
99
+ on.unsubscribe do |chan, subscriptions|
100
+ puts "Unsubscribed from ##{chan} (#{subscriptions} subscriptions)"
101
+ end
102
+ end
103
+ rescue Redis::BaseConnectionError => error
104
+ puts "#{error}, retrying in 1s"
105
+ sleep 1
106
+ retry
107
+ end
107
108
  end
108
109
  end
109
110
 
@@ -130,7 +131,7 @@ module Metacosm
130
131
 
131
132
  def clear!
132
133
  @events = []
133
- @command_queue&.clear
134
+ @command_queue && @command_queue.clear
134
135
  end
135
136
 
136
137
  protected
@@ -1,4 +1,4 @@
1
1
  module Metacosm
2
2
  # metacosm version
3
- VERSION = "0.2.14"
3
+ VERSION = "0.3.0"
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.2.14
4
+ version: 0.3.0
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-19 00:00:00.000000000 Z
11
+ date: 2016-03-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: passive_record
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '0.3'
19
+ version: '0.4'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '0.3'
26
+ version: '0.4'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: redis
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -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.5.1
197
+ rubygems_version: 2.4.6
198
198
  signing_key:
199
199
  specification_version: 4
200
200
  summary: reactive simulation framework