symphony 0.7.0 → 0.8.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: 27cfb2845ca71c3af5596979ce84fb19c9a3ba6e
4
- data.tar.gz: f475feb878e9abf0be8f4fc16fd90f86d7d04193
3
+ metadata.gz: f77d5c29817bfb9b9a524045e2a09dce3f07f469
4
+ data.tar.gz: ff3c97b9eab7dfdc1528cd766f6018b508c36698
5
5
  SHA512:
6
- metadata.gz: 75fcf22eea9e1f738eeb502fe7bd31f5ae0c8b845857cd5610404f9943f89303fa2d84713174bda7c753f82e893604325de89fa9594292630d0e70180d781d43
7
- data.tar.gz: 550773eda18d10aa46e7bdc1f9a3a14b1e483a9aec9268e65b0c530ae1d19f02972facb0252cb7316f2bb689cca7d21fbbf68809909a152bd5e4c9ace43171d1
6
+ metadata.gz: fe1f7745132368e2b7414fa27ac34a8be01a40af388655041dd61718fc6b8dbcf9db44ed9337b60df4ab72150a925dfafbd64b518ecabf9642e89a050d17d6bd
7
+ data.tar.gz: 119c5a6aebb5d52341f1b901ac29457d6dcb9d810745c59d50b678bd0aec5c0bdafbdaabef506662d78338d7c0a94124c39e3ce4de96c289b4db06349622f74c
checksums.yaml.gz.sig CHANGED
Binary file
data.tar.gz.sig CHANGED
Binary file
data/ChangeLog CHANGED
@@ -1,8 +1,67 @@
1
+ 2014-09-01 Michael Granger <ged@FaerieMUD.org>
2
+
3
+ * lib/symphony/routing.rb, spec/symphony/routing_spec.rb:
4
+ Add route options to routing mixin
5
+ [328bc1fbb538] [qbase, qtip, route-options.patch, tip]
6
+
7
+ 2014-05-10 Michael Granger <ged@FaerieMUD.org>
8
+
9
+ * bin/symphony-task:
10
+ Use the config env stuff already in Symphony.load_config, and keep
11
+ the config file argument optional for symphony-task.
12
+ [0d91a148cacd] [qparent]
13
+
14
+ 2014-05-09 Mahlon E. Smith <mahlon@laika.com>
15
+
16
+ * bin/symphony-task:
17
+ Don't hardcode the path to the config file, letting it instead be
18
+ set on the command line or via the environment.
19
+ [e2cc9f8c064e]
20
+
21
+ 2014-05-05 Michael Granger <ged@FaerieMUD.org>
22
+
23
+ * .hgtags:
24
+ Added tag v0.7.0 for changeset 204a5921a6c7
25
+ [a40a8a3d1e83]
26
+
27
+ * .hgsigs:
28
+ Added signature for changeset 52300e72d138
29
+ [204a5921a6c7] [v0.7.0]
30
+
31
+ * History.rdoc, lib/symphony.rb:
32
+ Bump the minor version, update history.
33
+ [52300e72d138]
34
+
35
+ 2014-04-25 Michael Granger <ged@FaerieMUD.org>
36
+
37
+ * lib/symphony/daemon.rb, lib/symphony/task.rb:
38
+ Add a 'before_fork' hook to Symphony::Task.
39
+ [e9d2ed1b68ae]
40
+
41
+ 2014-04-23 Michael Granger <ged@FaerieMUD.org>
42
+
43
+ * .hgtags:
44
+ Added tag v0.6.1 for changeset 6be0640d1a6a
45
+ [d06ac2e417e2]
46
+
47
+ * .hgsigs:
48
+ Added signature for changeset d6ea48d772f3
49
+ [6be0640d1a6a] [v0.6.1]
50
+
51
+ * History.rdoc, lib/symphony.rb:
52
+ Bump the patch version, update history.
53
+ [d6ea48d772f3]
54
+
55
+ * lib/symphony/daemon.rb, lib/symphony/signal_handling.rb,
56
+ spec/symphony/daemon_spec.rb:
57
+ Handle SIGQUIT the same as SIGINT and SIGTERM in the daemon.
58
+ [42785d57eec9]
59
+
1
60
  2014-04-14 Mahlon E. Smith <mahlon@laika.com>
2
61
 
3
62
  * Rakefile:
4
63
  Add configurability to the dependencies list.
5
- [f73d3ee81d17] [tip]
64
+ [f73d3ee81d17]
6
65
 
7
66
  2014-04-14 Michael Granger <ged@FaerieMUD.org>
8
67
 
data/History.rdoc CHANGED
@@ -1,3 +1,10 @@
1
+ == v0.8.0 [2014-09-01] Michael Granger <ged@FaerieMUD.org>
2
+
3
+ - Add route options to routing mixin
4
+ - Don't hardcode the path to the config file, letting it instead be
5
+ set on the command line or via the environment.
6
+
7
+
1
8
  == v0.7.0 [2014-05-05] Michael Granger <ged@FaerieMUD.org>
2
9
 
3
10
  Add a 'before_fork' hook to Symphony::Task.
data/Manifest.txt CHANGED
@@ -24,5 +24,6 @@ spec/helpers.rb
24
24
  spec/symphony/daemon_spec.rb
25
25
  spec/symphony/mixins_spec.rb
26
26
  spec/symphony/queue_spec.rb
27
+ spec/symphony/routing_spec.rb
27
28
  spec/symphony/task_spec.rb
28
29
  spec/symphony_spec.rb
data/bin/symphony-task CHANGED
@@ -3,8 +3,11 @@
3
3
  require 'symphony'
4
4
  require 'symphony/task'
5
5
 
6
- taskname = ARGV.shift or raise "no task name given"
6
+ taskname = ARGV.shift
7
+ config = ARGV.shift
7
8
 
8
- Symphony.load_config( 'etc/config.yml' )
9
+ abort "symphony-task taskname [config.yml]" unless taskname
10
+
11
+ Symphony.load_config( config )
9
12
  Symphony::Task.get_subclass( taskname ).run
10
13
 
data/lib/symphony.rb CHANGED
@@ -12,10 +12,10 @@ module Symphony
12
12
  Configurability
13
13
 
14
14
  # Library version constant
15
- VERSION = '0.7.0'
15
+ VERSION = '0.8.0'
16
16
 
17
17
  # Version-control revision constant
18
- REVISION = %q$Revision: 52300e72d138 $
18
+ REVISION = %q$Revision: 68352ad02888 $
19
19
 
20
20
 
21
21
  # The name of the environment variable to check for config file overrides
@@ -18,8 +18,9 @@ module Symphony::Routing
18
18
  super
19
19
  mod.extend( Symphony::MethodUtilities )
20
20
  mod.extend( Symphony::Routing::ClassMethods )
21
- mod.singleton_attr_accessor( :routes )
21
+ mod.singleton_attr_accessor( :routes, :route_options )
22
22
  mod.routes = Hash.new {|h,k| h[k] = [] }
23
+ mod.route_options = Hash.new {|h,k| h[k] = {} }
23
24
  end
24
25
 
25
26
 
@@ -29,12 +30,15 @@ module Symphony::Routing
29
30
  ### Register an event pattern and a block to execute when an event
30
31
  ### matching that pattern is received.
31
32
  def on( *route_patterns, &block )
33
+ raise LocalJumpError, "no block given" unless block
34
+ options = route_patterns.pop if route_patterns.last.is_a?( Hash )
32
35
  route_patterns.each do |pattern|
33
36
  methodobj = self.make_handler_method( pattern, &block )
34
37
  self.routing_keys << pattern
35
38
 
36
39
  pattern_re = self.make_routing_pattern( pattern )
37
40
  self.routes[ pattern_re ] << methodobj
41
+ self.route_options[ pattern ].merge!( options ) if options
38
42
  end
39
43
  end
40
44
 
@@ -81,10 +85,7 @@ module Symphony::Routing
81
85
  key = metadata[:delivery_info].routing_key
82
86
  self.log.debug "Routing a %s message..." % [ key ]
83
87
 
84
- blocks = self.class.routes.inject([]) do |accum, (re, re_blocks)|
85
- accum += re_blocks if re.match( key )
86
- accum
87
- end
88
+ blocks = self.find_matching_blocks( key )
88
89
 
89
90
  self.log.debug " calling %d block/s" % [ blocks.length ]
90
91
  return blocks.all? do |block|
@@ -93,6 +94,14 @@ module Symphony::Routing
93
94
  end
94
95
 
95
96
 
97
+ ### Return routing block whose patterns match the specified +key+.
98
+ def find_matching_blocks( key )
99
+ return self.class.routes.inject([]) do |accum, (re, re_blocks)|
100
+ accum += re_blocks if re.match( key )
101
+ accum
102
+ end
103
+ end
104
+
96
105
  end # module Symphony::Routing
97
106
 
98
107
 
@@ -0,0 +1,67 @@
1
+ #!/usr/bin/env rspec -cfd
2
+
3
+ require_relative '../helpers'
4
+
5
+ require 'symphony'
6
+ require 'symphony/routing'
7
+
8
+
9
+ describe Symphony::Routing do
10
+
11
+ let( :task_class ) do
12
+ Class.new( Symphony::Task ) do
13
+ include Symphony::Routing
14
+ def self::name; 'ACME::TestingTask'; end
15
+ end
16
+ end
17
+
18
+
19
+ it "allows registration of message handlers by event name" do
20
+ called = false
21
+ delivery_info = double( "AMQP delivery_info", routing_key: 'test.event.received' )
22
+
23
+ task_class.on 'test.event.received' do |payload, metadata|
24
+ called = true
25
+ end
26
+
27
+ expect( task_class.routing_keys ).to include( 'test.event.received' )
28
+
29
+ instance = task_class.new( :queue )
30
+ expect( instance.work([], delivery_info: delivery_info) ).to be_truthy
31
+ expect( called ).to be_truthy
32
+ end
33
+
34
+
35
+ it "allows the same message handler for multiple events" do
36
+ called_count = 0
37
+ di1 = double( "AMQP delivery_info", routing_key: 'test.event.received' )
38
+ di2 = double( "AMQP delivery_info", routing_key: 'another.event.received' )
39
+
40
+ task_class.on 'test.event.received', 'another.event.received' do |payload, metadata|
41
+ called_count += 1
42
+ end
43
+
44
+ expect(
45
+ task_class.routing_keys
46
+ ).to include( 'test.event.received', 'another.event.received' )
47
+
48
+ instance = task_class.new( :queue )
49
+ expect( instance.work([], delivery_info: di1) ).to be_truthy
50
+ expect( instance.work([], delivery_info: di2) ).to be_truthy
51
+
52
+ expect( called_count ).to eq( 2 )
53
+ end
54
+
55
+
56
+ it "allows a Hash of options to be included with an event handler" do
57
+ task_class.on 'test.event.with_options', scheduled: '2 times an hour' do |payload, metadata|
58
+ end
59
+
60
+ expect( task_class.routing_keys ).to include( 'test.event.with_options' )
61
+ expect(
62
+ task_class.route_options['test.event.with_options']
63
+ ).to include( scheduled: '2 times an hour' )
64
+ end
65
+
66
+ end
67
+
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: symphony
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Granger
@@ -31,232 +31,232 @@ cert_chain:
31
31
  c7ZKPJcWBv0sm81+FCZXNACn2f9jfF8OQinxVs0O052KbGuEQaaiGIYeuuwQE2q6
32
32
  ggcrPfcYeTwWlfZPu2LrBg==
33
33
  -----END CERTIFICATE-----
34
- date: 2014-05-05 00:00:00.000000000 Z
34
+ date: 2014-09-03 00:00:00.000000000 Z
35
35
  dependencies:
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: configurability
38
38
  requirement: !ruby/object:Gem::Requirement
39
39
  requirements:
40
- - - ~>
40
+ - - "~>"
41
41
  - !ruby/object:Gem::Version
42
42
  version: '2.1'
43
43
  type: :runtime
44
44
  prerelease: false
45
45
  version_requirements: !ruby/object:Gem::Requirement
46
46
  requirements:
47
- - - ~>
47
+ - - "~>"
48
48
  - !ruby/object:Gem::Version
49
49
  version: '2.1'
50
50
  - !ruby/object:Gem::Dependency
51
51
  name: loggability
52
52
  requirement: !ruby/object:Gem::Requirement
53
53
  requirements:
54
- - - ~>
54
+ - - "~>"
55
55
  - !ruby/object:Gem::Version
56
56
  version: '0.10'
57
57
  type: :runtime
58
58
  prerelease: false
59
59
  version_requirements: !ruby/object:Gem::Requirement
60
60
  requirements:
61
- - - ~>
61
+ - - "~>"
62
62
  - !ruby/object:Gem::Version
63
63
  version: '0.10'
64
64
  - !ruby/object:Gem::Dependency
65
65
  name: pluggability
66
66
  requirement: !ruby/object:Gem::Requirement
67
67
  requirements:
68
- - - ~>
68
+ - - "~>"
69
69
  - !ruby/object:Gem::Version
70
70
  version: '0.4'
71
71
  type: :runtime
72
72
  prerelease: false
73
73
  version_requirements: !ruby/object:Gem::Requirement
74
74
  requirements:
75
- - - ~>
75
+ - - "~>"
76
76
  - !ruby/object:Gem::Version
77
77
  version: '0.4'
78
78
  - !ruby/object:Gem::Dependency
79
79
  name: bunny
80
80
  requirement: !ruby/object:Gem::Requirement
81
81
  requirements:
82
- - - ~>
82
+ - - "~>"
83
83
  - !ruby/object:Gem::Version
84
84
  version: '1.1'
85
85
  type: :runtime
86
86
  prerelease: false
87
87
  version_requirements: !ruby/object:Gem::Requirement
88
88
  requirements:
89
- - - ~>
89
+ - - "~>"
90
90
  - !ruby/object:Gem::Version
91
91
  version: '1.1'
92
92
  - !ruby/object:Gem::Dependency
93
93
  name: sysexits
94
94
  requirement: !ruby/object:Gem::Requirement
95
95
  requirements:
96
- - - ~>
96
+ - - "~>"
97
97
  - !ruby/object:Gem::Version
98
98
  version: '1.1'
99
99
  type: :runtime
100
100
  prerelease: false
101
101
  version_requirements: !ruby/object:Gem::Requirement
102
102
  requirements:
103
- - - ~>
103
+ - - "~>"
104
104
  - !ruby/object:Gem::Version
105
105
  version: '1.1'
106
106
  - !ruby/object:Gem::Dependency
107
107
  name: yajl-ruby
108
108
  requirement: !ruby/object:Gem::Requirement
109
109
  requirements:
110
- - - ~>
110
+ - - "~>"
111
111
  - !ruby/object:Gem::Version
112
112
  version: '1.2'
113
113
  type: :runtime
114
114
  prerelease: false
115
115
  version_requirements: !ruby/object:Gem::Requirement
116
116
  requirements:
117
- - - ~>
117
+ - - "~>"
118
118
  - !ruby/object:Gem::Version
119
119
  version: '1.2'
120
120
  - !ruby/object:Gem::Dependency
121
121
  name: msgpack
122
122
  requirement: !ruby/object:Gem::Requirement
123
123
  requirements:
124
- - - ~>
124
+ - - "~>"
125
125
  - !ruby/object:Gem::Version
126
126
  version: '0.5'
127
127
  type: :runtime
128
128
  prerelease: false
129
129
  version_requirements: !ruby/object:Gem::Requirement
130
130
  requirements:
131
- - - ~>
131
+ - - "~>"
132
132
  - !ruby/object:Gem::Version
133
133
  version: '0.5'
134
134
  - !ruby/object:Gem::Dependency
135
135
  name: metriks
136
136
  requirement: !ruby/object:Gem::Requirement
137
137
  requirements:
138
- - - ~>
138
+ - - "~>"
139
139
  - !ruby/object:Gem::Version
140
140
  version: '0.9'
141
141
  type: :runtime
142
142
  prerelease: false
143
143
  version_requirements: !ruby/object:Gem::Requirement
144
144
  requirements:
145
- - - ~>
145
+ - - "~>"
146
146
  - !ruby/object:Gem::Version
147
147
  version: '0.9'
148
148
  - !ruby/object:Gem::Dependency
149
149
  name: rusage
150
150
  requirement: !ruby/object:Gem::Requirement
151
151
  requirements:
152
- - - ~>
152
+ - - "~>"
153
153
  - !ruby/object:Gem::Version
154
154
  version: '0.2'
155
155
  type: :runtime
156
156
  prerelease: false
157
157
  version_requirements: !ruby/object:Gem::Requirement
158
158
  requirements:
159
- - - ~>
159
+ - - "~>"
160
160
  - !ruby/object:Gem::Version
161
161
  version: '0.2'
162
162
  - !ruby/object:Gem::Dependency
163
163
  name: hoe-mercurial
164
164
  requirement: !ruby/object:Gem::Requirement
165
165
  requirements:
166
- - - ~>
166
+ - - "~>"
167
167
  - !ruby/object:Gem::Version
168
- version: 1.4.0
168
+ version: '1.4'
169
169
  type: :development
170
170
  prerelease: false
171
171
  version_requirements: !ruby/object:Gem::Requirement
172
172
  requirements:
173
- - - ~>
173
+ - - "~>"
174
174
  - !ruby/object:Gem::Version
175
- version: 1.4.0
175
+ version: '1.4'
176
176
  - !ruby/object:Gem::Dependency
177
177
  name: hoe-deveiate
178
178
  requirement: !ruby/object:Gem::Requirement
179
179
  requirements:
180
- - - ~>
180
+ - - "~>"
181
181
  - !ruby/object:Gem::Version
182
- version: '0.5'
182
+ version: '0.6'
183
183
  type: :development
184
184
  prerelease: false
185
185
  version_requirements: !ruby/object:Gem::Requirement
186
186
  requirements:
187
- - - ~>
187
+ - - "~>"
188
188
  - !ruby/object:Gem::Version
189
- version: '0.5'
189
+ version: '0.6'
190
190
  - !ruby/object:Gem::Dependency
191
191
  name: hoe-highline
192
192
  requirement: !ruby/object:Gem::Requirement
193
193
  requirements:
194
- - - ~>
194
+ - - "~>"
195
195
  - !ruby/object:Gem::Version
196
196
  version: '0.2'
197
197
  type: :development
198
198
  prerelease: false
199
199
  version_requirements: !ruby/object:Gem::Requirement
200
200
  requirements:
201
- - - ~>
201
+ - - "~>"
202
202
  - !ruby/object:Gem::Version
203
203
  version: '0.2'
204
204
  - !ruby/object:Gem::Dependency
205
205
  name: rdoc
206
206
  requirement: !ruby/object:Gem::Requirement
207
207
  requirements:
208
- - - ~>
208
+ - - "~>"
209
209
  - !ruby/object:Gem::Version
210
210
  version: '4.0'
211
211
  type: :development
212
212
  prerelease: false
213
213
  version_requirements: !ruby/object:Gem::Requirement
214
214
  requirements:
215
- - - ~>
215
+ - - "~>"
216
216
  - !ruby/object:Gem::Version
217
217
  version: '4.0'
218
218
  - !ruby/object:Gem::Dependency
219
219
  name: rspec
220
220
  requirement: !ruby/object:Gem::Requirement
221
221
  requirements:
222
- - - ~>
222
+ - - "~>"
223
223
  - !ruby/object:Gem::Version
224
224
  version: '3.0'
225
225
  type: :development
226
226
  prerelease: false
227
227
  version_requirements: !ruby/object:Gem::Requirement
228
228
  requirements:
229
- - - ~>
229
+ - - "~>"
230
230
  - !ruby/object:Gem::Version
231
231
  version: '3.0'
232
232
  - !ruby/object:Gem::Dependency
233
233
  name: simplecov
234
234
  requirement: !ruby/object:Gem::Requirement
235
235
  requirements:
236
- - - ~>
236
+ - - "~>"
237
237
  - !ruby/object:Gem::Version
238
238
  version: '0.8'
239
239
  type: :development
240
240
  prerelease: false
241
241
  version_requirements: !ruby/object:Gem::Requirement
242
242
  requirements:
243
- - - ~>
243
+ - - "~>"
244
244
  - !ruby/object:Gem::Version
245
245
  version: '0.8'
246
246
  - !ruby/object:Gem::Dependency
247
247
  name: hoe
248
248
  requirement: !ruby/object:Gem::Requirement
249
249
  requirements:
250
- - - ~>
250
+ - - "~>"
251
251
  - !ruby/object:Gem::Version
252
- version: '3.11'
252
+ version: '3.12'
253
253
  type: :development
254
254
  prerelease: false
255
255
  version_requirements: !ruby/object:Gem::Requirement
256
256
  requirements:
257
- - - ~>
257
+ - - "~>"
258
258
  - !ruby/object:Gem::Version
259
- version: '3.11'
259
+ version: '3.12'
260
260
  description: |-
261
261
  Symphony is a subscription-based asynchronous job system. It
262
262
  allows you to define jobs that watch for lightweight events from a
@@ -285,7 +285,7 @@ extra_rdoc_files:
285
285
  - TODO.md
286
286
  - USAGE.rdoc
287
287
  files:
288
- - .simplecov
288
+ - ".simplecov"
289
289
  - ChangeLog
290
290
  - History.rdoc
291
291
  - Manifest.txt
@@ -311,6 +311,7 @@ files:
311
311
  - spec/symphony/daemon_spec.rb
312
312
  - spec/symphony/mixins_spec.rb
313
313
  - spec/symphony/queue_spec.rb
314
+ - spec/symphony/routing_spec.rb
314
315
  - spec/symphony/task_spec.rb
315
316
  - spec/symphony_spec.rb
316
317
  homepage: http://bitbucket.org/ged/symphony
@@ -319,20 +320,20 @@ licenses:
319
320
  metadata: {}
320
321
  post_install_message:
321
322
  rdoc_options:
322
- - -f
323
+ - "-f"
323
324
  - fivefish
324
- - -t
325
+ - "-t"
325
326
  - Symphony
326
327
  require_paths:
327
328
  - lib
328
329
  required_ruby_version: !ruby/object:Gem::Requirement
329
330
  requirements:
330
- - - '>='
331
+ - - ">="
331
332
  - !ruby/object:Gem::Version
332
333
  version: 2.0.0
333
334
  required_rubygems_version: !ruby/object:Gem::Requirement
334
335
  requirements:
335
- - - '>='
336
+ - - ">="
336
337
  - !ruby/object:Gem::Version
337
338
  version: 2.0.3
338
339
  requirements: []
metadata.gz.sig CHANGED
Binary file