ezmq 0.1.2 → 0.2.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: 53f27cf838fcd7f6dfe55aa2876eca322e4d1771
4
- data.tar.gz: 29a2a8f41c6de6f0302ef8492ddda546a6b6702b
3
+ metadata.gz: acd34ba3fc6400948cb525260fffeb2c537f9efa
4
+ data.tar.gz: f62399fa0d1b808429b8c18cf17bd38f709bac47
5
5
  SHA512:
6
- metadata.gz: 67e6d18714294b269610295c0f279175e848678ac8521f86d745e9105490b057ba2f491172ac7eaf611894c66b566279a7b7bd67547e8b2241934a3e86e887d9
7
- data.tar.gz: 9d4abe01a0061edd3b441749759ced76f3f558b351c65e49c377225e671d71089408c014a1c98e95c293fb0a8da3f591df27d2dc25ff5227de4cd397d540a405
6
+ metadata.gz: 9340fc6c1f9a1df80f29446e56cd69d49eeadd44336e4ef5201a91cc7f76c797aac653dc9046766d419ed60d4c53fe5192e75b926895db2c2255ea3c80299bfb
7
+ data.tar.gz: f6f2a361fcbb633dc8d1373d77dec5ebe415f3bec465eb91c2b75496ce2c7fb8bd58f2e379ef22a83186921469663d835eeea1983db82a5f7bcb666e7dcc72e6
data/README.md CHANGED
@@ -1,12 +1,106 @@
1
- EZMQ (Effortless ZeroMQ)
1
+ [EZMQ (Effortless ZeroMQ)](https://colstrom.github.io/ezmq/)
2
2
  ========================
3
3
 
4
+ Overview
5
+ --------
6
+
4
7
  EZMQ is a wrapper around the wonderful `ffi-rzmq` gem, which (as the name suggests) uses FFI, and exposes a fairly raw C-like interface. As elegant as 0MQ is, C doesn't feel like Ruby, and FFI bindings feel like C. EZMQ makes some reasonable assumptions to help you focus on what makes your code special, and not worry about setting up 0MQ.
5
8
 
6
9
  Any of the magical hand-wavey bits (contexts, sockets, etc) are still exposed for tinkering, EZMQ just starts you off with some sane defaults.
7
10
 
11
+ Examples
12
+ ========
13
+
14
+ Most of these examples are trivial, because ZMQ is just the fabric of your networked application(s).
15
+
16
+ Echo Server
17
+ -----------
18
+ Waits for a request, replies with the same request.
19
+
20
+ ```
21
+ require 'ezmq'
22
+
23
+ server = EZMQ::Server.new
24
+ server.listen
25
+ ```
26
+
27
+ Synchronous Client Request
28
+ --------------------------
29
+ Sends a message, prints the reply when it arrives.
30
+
31
+ ```
32
+ require 'ezmq'
33
+
34
+ client = EZMQ::Client.new
35
+ puts client.request 'test'
36
+ ```
37
+
38
+ Confirming Logging Server
39
+ -------------------------
40
+ Waits for a request, prints it to STDOUT, and thanks the client for it.
41
+
42
+ ```
43
+ require 'ezmq'
44
+
45
+ server = EZMQ::Server.new
46
+ server.listen do |message|
47
+ puts message
48
+ 'Thanks for the message!' # The return of the block is sent to the client.
49
+ end
50
+
51
+ JSON Echo Server
52
+ ----------------
53
+ Waits for JSON message, decodes it, re-encodes it, and sends it back.
54
+
55
+ ```
56
+ require 'ezmq'
57
+ require 'json'
58
+
59
+ server = EZMQ::Server.new encode: -> m { JSON.dump m }, decode: -> m { JSON.load m }
60
+ server.listen
61
+ ```
62
+
63
+ JSON Synchronous Client Request
64
+ -------------------------------
65
+ Encodes a message in JSON, sends it twice, prints the first one raw, and decodes the second.
66
+
67
+ ```
68
+ require 'ezmq'
69
+ require 'json'
70
+
71
+ client = EZMQ::Client.new encode: -> m { JSON.dump m }
72
+ puts client.request 'test'
73
+ client.decode = -> m { JSON.load m }
74
+ puts client.request 'test'
75
+ ```
76
+
77
+ 'foorever' Publisher
78
+ --------------------
79
+ Publishes an endless stream of 'foo's with a topic of 'foorever'.
80
+
81
+ ```
82
+ require 'ezmq'
83
+
84
+ publisher = EZMQ.Publisher.new topic: 'foorever'
85
+
86
+ loop do
87
+ publisher.send 'foo'
88
+ end
89
+ ```
90
+
91
+ 'foorever' Subscriber
92
+ ---------------------
93
+ Subscribes to topic 'foorever', prints any messages it receives.
94
+
95
+ ```
96
+ require 'ezmq'
97
+
98
+ subscriber = EZMQ.Subscriber.new topic: 'foorever'
99
+ subscriber.listen
100
+ ````
101
+
8
102
  Operating System Notes
9
- ----------------------
103
+ ======================
10
104
 
11
105
  As this relies on [ffi-rzmq](https://github.com/chuckremes/ffi-rzmq), you will need to have the zeromq libraries available.
12
106
 
@@ -0,0 +1,12 @@
1
+ Upgrading from 0.1.x to 0.2+
2
+ ----------------------------
3
+
4
+ Initializing a socket now allows `protocol`, `address`, and `port` as optional parameters.
5
+
6
+ If you were passing `address` in as a string containing all three, this is no longer required, and will fail.
7
+
8
+ `provides` and `action` removed from `Server` and `Subscriber` respectively. `handler` removed from #listen.
9
+
10
+ Server#listen and Subscriber#listen now yield received messages to a block, if given. The return of the block will be send as the response.
11
+
12
+ Client#request now yields the response message to the block.
@@ -117,7 +117,7 @@
117
117
  </div>
118
118
 
119
119
  <div id="footer">
120
- Generated on Tue Jan 6 12:58:18 2015 by
120
+ Generated on Fri Jan 9 13:06:26 2015 by
121
121
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
122
122
  0.8.7.6 (ruby-2.0.0).
123
123
  </div>
@@ -161,7 +161,7 @@
161
161
  <li class="public ">
162
162
  <span class="summary_signature">
163
163
 
164
- <a href="#request-instance_method" title="#request (instance method)">- (void) <strong>request</strong>(message = &#39;&#39;, encode: @encode, decode: @decode) </a>
164
+ <a href="#request-instance_method" title="#request (instance method)">- (void) <strong>request</strong>(message = &#39;&#39;, **options) </a>
165
165
 
166
166
 
167
167
 
@@ -231,7 +231,7 @@
231
231
 
232
232
  &mdash;
233
233
  <div class='inline'>
234
- <p>optional parameters</p>
234
+ <p>optional parameters.</p>
235
235
  </div>
236
236
 
237
237
  </li>
@@ -242,7 +242,7 @@
242
242
  <p class="tag_title">See Also:</p>
243
243
  <ul class="see">
244
244
 
245
- <li><span class='object_link'><a href="Socket.html" title="EZMQ::Socket (class)">EZMQ::Socket for a list of optional parameters.</a></span></li>
245
+ <li><span class='object_link'><a href="Socket.html" title="EZMQ::Socket (class)">EZMQ::Socket for optional parameters.</a></span></li>
246
246
 
247
247
  </ul>
248
248
 
@@ -252,12 +252,12 @@
252
252
  <pre class="lines">
253
253
 
254
254
 
255
- 125
256
- 126
257
- 127</pre>
255
+ 119
256
+ 120
257
+ 121</pre>
258
258
  </td>
259
259
  <td>
260
- <pre class="code"><span class="info file"># File 'lib/ezmq.rb', line 125</span>
260
+ <pre class="code"><span class="info file"># File 'lib/ezmq.rb', line 119</span>
261
261
 
262
262
  <span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span><span class='lparen'>(</span><span class='op'>**</span><span class='id identifier rubyid_options'>options</span><span class='rparen'>)</span>
263
263
  <span class='kw'>super</span> <span class='symbol'>:connect</span><span class='comma'>,</span> <span class='const'>ZMQ</span><span class='op'>::</span><span class='const'>REQ</span><span class='comma'>,</span> <span class='id identifier rubyid_options'>options</span>
@@ -277,7 +277,7 @@
277
277
  <div class="method_details first">
278
278
  <h3 class="signature first" id="request-instance_method">
279
279
 
280
- - (<tt>void</tt>) <strong>request</strong>(message = &#39;&#39;, encode: @encode, decode: @decode)
280
+ - (<tt>void</tt>) <strong>request</strong>(message = &#39;&#39;, **options)
281
281
 
282
282
 
283
283
 
@@ -315,37 +315,58 @@
315
315
 
316
316
  <li>
317
317
 
318
- <span class='name'>encode</span>
318
+ <span class='name'>options</span>
319
319
 
320
320
 
321
- <span class='type'>(<tt>lambda</tt>)</span>
321
+ <span class='type'>(<tt>Hash</tt>)</span>
322
322
 
323
323
 
324
324
 
325
325
  &mdash;
326
326
  <div class='inline'>
327
- <p>how to encode the message.</p>
327
+ <p>optional parameters.</p>
328
328
  </div>
329
329
 
330
330
  </li>
331
331
 
332
- <li>
333
-
334
- <span class='name'>decode</span>
335
-
336
-
337
- <span class='type'>(<tt>lambda</tt>)</span>
338
-
339
-
340
-
341
- &mdash;
342
- <div class='inline'>
332
+ </ul>
333
+
334
+
335
+
336
+
337
+
338
+
339
+ <p class="tag_title">Options Hash (<tt>**options</tt>):</p>
340
+ <ul class="option">
341
+
342
+ <li>
343
+ <span class="name">encode</span>
344
+ <span class="type">(<tt>lambda</tt>)</span>
345
+ <span class="default">
346
+
347
+ </span>
348
+
349
+ &mdash; <div class='inline'>
350
+ <p>how to encode the message.</p>
351
+ </div>
352
+
353
+ </li>
354
+
355
+ <li>
356
+ <span class="name">decode</span>
357
+ <span class="type">(<tt>lambda</tt>)</span>
358
+ <span class="default">
359
+
360
+ </span>
361
+
362
+ &mdash; <div class='inline'>
343
363
  <p>how to decode the message.</p>
344
364
  </div>
365
+
366
+ </li>
345
367
 
346
- </li>
368
+ </ul>
347
369
 
348
- </ul>
349
370
 
350
371
 
351
372
  </div><table class="source_code">
@@ -354,17 +375,25 @@
354
375
  <pre class="lines">
355
376
 
356
377
 
378
+ 132
379
+ 133
380
+ 134
381
+ 135
382
+ 136
357
383
  137
358
384
  138
359
- 139
360
- 140</pre>
385
+ 139</pre>
361
386
  </td>
362
387
  <td>
363
- <pre class="code"><span class="info file"># File 'lib/ezmq.rb', line 137</span>
364
-
365
- <span class='kw'>def</span> <span class='id identifier rubyid_request'>request</span><span class='lparen'>(</span><span class='id identifier rubyid_message'>message</span> <span class='op'>=</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_end'>&#39;</span></span><span class='comma'>,</span> <span class='label'>encode:</span> <span class='ivar'>@encode</span><span class='comma'>,</span> <span class='label'>decode:</span> <span class='ivar'>@decode</span><span class='rparen'>)</span>
366
- <span class='id identifier rubyid_send'>send</span> <span class='id identifier rubyid_message'>message</span><span class='comma'>,</span> <span class='label'>encode:</span> <span class='id identifier rubyid_encode'>encode</span>
367
- <span class='id identifier rubyid_receive'>receive</span> <span class='label'>decode:</span> <span class='id identifier rubyid_decode'>decode</span>
388
+ <pre class="code"><span class="info file"># File 'lib/ezmq.rb', line 132</span>
389
+
390
+ <span class='kw'>def</span> <span class='id identifier rubyid_request'>request</span><span class='lparen'>(</span><span class='id identifier rubyid_message'>message</span> <span class='op'>=</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_end'>&#39;</span></span><span class='comma'>,</span> <span class='op'>**</span><span class='id identifier rubyid_options'>options</span><span class='rparen'>)</span>
391
+ <span class='id identifier rubyid_send'>send</span> <span class='id identifier rubyid_message'>message</span><span class='comma'>,</span> <span class='id identifier rubyid_options'>options</span>
392
+ <span class='kw'>if</span> <span class='id identifier rubyid_block_given?'>block_given?</span>
393
+ <span class='kw'>yield</span> <span class='id identifier rubyid_receive'>receive</span> <span class='id identifier rubyid_options'>options</span>
394
+ <span class='kw'>else</span>
395
+ <span class='id identifier rubyid_receive'>receive</span> <span class='id identifier rubyid_options'>options</span>
396
+ <span class='kw'>end</span>
368
397
  <span class='kw'>end</span></pre>
369
398
  </td>
370
399
  </tr>
@@ -376,7 +405,7 @@
376
405
  </div>
377
406
 
378
407
  <div id="footer">
379
- Generated on Tue Jan 6 12:58:18 2015 by
408
+ Generated on Fri Jan 9 13:06:26 2015 by
380
409
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
381
410
  0.8.7.6 (ruby-2.0.0).
382
411
  </div>
@@ -161,7 +161,7 @@
161
161
  <li class="public ">
162
162
  <span class="summary_signature">
163
163
 
164
- <a href="#send-instance_method" title="#send (instance method)">- (Fixnum) <strong>send</strong>(message = &#39;&#39;, topic: &#39;&#39;, encode: @encode) </a>
164
+ <a href="#send-instance_method" title="#send (instance method)">- (Fixnum) <strong>send</strong>(message = &#39;&#39;, topic: &#39;&#39;, **options) </a>
165
165
 
166
166
 
167
167
 
@@ -231,7 +231,7 @@
231
231
 
232
232
  &mdash;
233
233
  <div class='inline'>
234
- <p>optional parameters</p>
234
+ <p>optional parameters.</p>
235
235
  </div>
236
236
 
237
237
  </li>
@@ -242,7 +242,7 @@
242
242
  <p class="tag_title">See Also:</p>
243
243
  <ul class="see">
244
244
 
245
- <li><span class='object_link'><a href="Socket.html" title="EZMQ::Socket (class)">EZMQ::Socket for a list of optional parameters.</a></span></li>
245
+ <li><span class='object_link'><a href="Socket.html" title="EZMQ::Socket (class)">EZMQ::Socket for optional parameters.</a></span></li>
246
246
 
247
247
  </ul>
248
248
 
@@ -252,12 +252,12 @@
252
252
  <pre class="lines">
253
253
 
254
254
 
255
- 153
256
- 154
257
- 155</pre>
255
+ 186
256
+ 187
257
+ 188</pre>
258
258
  </td>
259
259
  <td>
260
- <pre class="code"><span class="info file"># File 'lib/ezmq.rb', line 153</span>
260
+ <pre class="code"><span class="info file"># File 'lib/ezmq.rb', line 186</span>
261
261
 
262
262
  <span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span><span class='lparen'>(</span><span class='op'>**</span><span class='id identifier rubyid_options'>options</span><span class='rparen'>)</span>
263
263
  <span class='kw'>super</span> <span class='symbol'>:bind</span><span class='comma'>,</span> <span class='const'>ZMQ</span><span class='op'>::</span><span class='const'>PUB</span><span class='comma'>,</span> <span class='id identifier rubyid_options'>options</span>
@@ -277,7 +277,7 @@
277
277
  <div class="method_details first">
278
278
  <h3 class="signature first" id="send-instance_method">
279
279
 
280
- - (<tt>Fixnum</tt>) <strong>send</strong>(message = &#39;&#39;, topic: &#39;&#39;, encode: @encode)
280
+ - (<tt>Fixnum</tt>) <strong>send</strong>(message = &#39;&#39;, topic: &#39;&#39;, **options)
281
281
 
282
282
 
283
283
 
@@ -331,22 +331,48 @@
331
331
 
332
332
  <li>
333
333
 
334
- <span class='name'>encode</span>
334
+ <span class='name'>options</span>
335
335
 
336
336
 
337
- <span class='type'>(<tt>lambda</tt>)</span>
337
+ <span class='type'>(<tt>Hash</tt>)</span>
338
338
 
339
339
 
340
340
 
341
341
  &mdash;
342
342
  <div class='inline'>
343
- <p>how to encode the message.</p>
343
+ <p>optional parameters.</p>
344
344
  </div>
345
345
 
346
346
  </li>
347
347
 
348
348
  </ul>
349
349
 
350
+
351
+
352
+
353
+
354
+
355
+
356
+
357
+ <p class="tag_title">Options Hash (<tt>**options</tt>):</p>
358
+ <ul class="option">
359
+
360
+ <li>
361
+ <span class="name">encode</span>
362
+ <span class="type">(<tt>lambda</tt>)</span>
363
+ <span class="default">
364
+
365
+ </span>
366
+
367
+ &mdash; <div class='inline'>
368
+ <p>how to encode the message.</p>
369
+ </div>
370
+
371
+ </li>
372
+
373
+ </ul>
374
+
375
+
350
376
  <p class="tag_title">Returns:</p>
351
377
  <ul class="return">
352
378
 
@@ -372,15 +398,15 @@
372
398
  <pre class="lines">
373
399
 
374
400
 
375
- 165
376
- 166
377
- 167</pre>
401
+ 199
402
+ 200
403
+ 201</pre>
378
404
  </td>
379
405
  <td>
380
- <pre class="code"><span class="info file"># File 'lib/ezmq.rb', line 165</span>
406
+ <pre class="code"><span class="info file"># File 'lib/ezmq.rb', line 199</span>
381
407
 
382
- <span class='kw'>def</span> <span class='id identifier rubyid_send'>send</span><span class='lparen'>(</span><span class='id identifier rubyid_message'>message</span> <span class='op'>=</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_end'>&#39;</span></span><span class='comma'>,</span> <span class='label'>topic:</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_end'>&#39;</span></span><span class='comma'>,</span> <span class='label'>encode:</span> <span class='ivar'>@encode</span><span class='rparen'>)</span>
383
- <span class='ivar'>@socket</span><span class='period'>.</span><span class='id identifier rubyid_send_string'>send_string</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='embexpr_beg'>#{</span> <span class='id identifier rubyid_topic'>topic</span> <span class='embexpr_end'>}</span><span class='tstring_content'> </span><span class='embexpr_beg'>#{</span> <span class='id identifier rubyid_encode'>encode</span><span class='period'>.</span><span class='id identifier rubyid_call'>call</span> <span class='id identifier rubyid_message'>message</span> <span class='embexpr_end'>}</span><span class='tstring_end'>&quot;</span></span>
408
+ <span class='kw'>def</span> <span class='id identifier rubyid_send'>send</span><span class='lparen'>(</span><span class='id identifier rubyid_message'>message</span> <span class='op'>=</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_end'>&#39;</span></span><span class='comma'>,</span> <span class='label'>topic:</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_end'>&#39;</span></span><span class='comma'>,</span> <span class='op'>**</span><span class='id identifier rubyid_options'>options</span><span class='rparen'>)</span>
409
+ <span class='ivar'>@socket</span><span class='period'>.</span><span class='id identifier rubyid_send_string'>send_string</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='embexpr_beg'>#{</span> <span class='id identifier rubyid_topic'>topic</span> <span class='embexpr_end'>}</span><span class='tstring_content'> </span><span class='embexpr_beg'>#{</span> <span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span><span class='lbracket'>[</span><span class='symbol'>:encode</span><span class='rbracket'>]</span> <span class='op'>||</span> <span class='ivar'>@encode</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_call'>call</span> <span class='id identifier rubyid_message'>message</span> <span class='embexpr_end'>}</span><span class='tstring_end'>&quot;</span></span>
384
410
  <span class='kw'>end</span></pre>
385
411
  </td>
386
412
  </tr>
@@ -392,7 +418,7 @@
392
418
  </div>
393
419
 
394
420
  <div id="footer">
395
- Generated on Tue Jan 6 12:58:18 2015 by
421
+ Generated on Fri Jan 9 13:06:26 2015 by
396
422
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
397
423
  0.8.7.6 (ruby-2.0.0).
398
424
  </div>
@@ -116,41 +116,9 @@
116
116
 
117
117
 
118
118
 
119
- <h2>Instance Attribute Summary <small>(<a href="#" class="summary_toggle">collapse</a>)</small></h2>
120
- <ul class="summary">
121
-
122
- <li class="public ">
123
- <span class="summary_signature">
124
-
125
- <a href="#provides-instance_method" title="#provides (instance method)">- (Object) <strong>provides</strong> </a>
126
-
127
-
128
-
129
- </span>
130
-
131
-
132
-
133
-
134
-
135
-
136
-
137
-
138
-
139
-
140
-
141
-
142
- <span class="summary_desc"><div class='inline'>
143
- <p>Returns the value of attribute provides.</p>
144
- </div></span>
145
-
146
- </li>
147
119
 
148
-
149
- </ul>
150
120
 
151
-
152
-
153
-
121
+ <h2>Instance Attribute Summary</h2>
154
122
 
155
123
  <h3 class="inherited">Attributes inherited from <span class='object_link'><a href="Socket.html" title="EZMQ::Socket (class)">Socket</a></span></h3>
156
124
  <p class="inherited"><span class='object_link'><a href="Socket.html#context-instance_method" title="EZMQ::Socket#context (method)">#context</a></span>, <span class='object_link'><a href="Socket.html#decode-instance_method" title="EZMQ::Socket#decode (method)">#decode</a></span>, <span class='object_link'><a href="Socket.html#encode-instance_method" title="EZMQ::Socket#encode (method)">#encode</a></span>, <span class='object_link'><a href="Socket.html#socket-instance_method" title="EZMQ::Socket#socket (method)">#socket</a></span></p>
@@ -167,7 +135,7 @@
167
135
  <li class="public ">
168
136
  <span class="summary_signature">
169
137
 
170
- <a href="#initialize-instance_method" title="#initialize (instance method)">- (Server) <strong>initialize</strong>(provides: -&gt; m { m }, **options) </a>
138
+ <a href="#initialize-instance_method" title="#initialize (instance method)">- (Server) <strong>initialize</strong>(**options) </a>
171
139
 
172
140
 
173
141
 
@@ -193,7 +161,7 @@
193
161
  <li class="public ">
194
162
  <span class="summary_signature">
195
163
 
196
- <a href="#listen-instance_method" title="#listen (instance method)">- (void) <strong>listen</strong>(handler: -&gt; { send @provides.call(receive) }) </a>
164
+ <a href="#listen-instance_method" title="#listen (instance method)">- (void) <strong>listen</strong> {|message| ... }</a>
197
165
 
198
166
 
199
167
 
@@ -208,8 +176,7 @@
208
176
 
209
177
 
210
178
  <span class="summary_desc"><div class='inline'>
211
- <p>By default, waits to receive a message, calls @action with it, replies with
212
- the result, then loops.</p>
179
+ <p>Listens for a request, and responds to it.</p>
213
180
  </div></span>
214
181
 
215
182
  </li>
@@ -235,7 +202,7 @@ the result, then loops.</p>
235
202
  <div class="method_details first">
236
203
  <h3 class="signature first" id="initialize-instance_method">
237
204
 
238
- - (<tt><span class='object_link'><a href="" title="EZMQ::Server (class)">Server</a></span></tt>) <strong>initialize</strong>(provides: -&gt; m { m }, **options)
205
+ - (<tt><span class='object_link'><a href="" title="EZMQ::Server (class)">Server</a></span></tt>) <strong>initialize</strong>(**options)
239
206
 
240
207
 
241
208
 
@@ -253,22 +220,6 @@ the result, then loops.</p>
253
220
  <p class="tag_title">Parameters:</p>
254
221
  <ul class="param">
255
222
 
256
- <li>
257
-
258
- <span class='name'>provides</span>
259
-
260
-
261
- <span class='type'>(<tt>lambda</tt>)</span>
262
-
263
-
264
-
265
- &mdash;
266
- <div class='inline'>
267
- <p>the service provided by this server.</p>
268
- </div>
269
-
270
- </li>
271
-
272
223
  <li>
273
224
 
274
225
  <span class='name'>options</span>
@@ -291,7 +242,7 @@ the result, then loops.</p>
291
242
  <p class="tag_title">See Also:</p>
292
243
  <ul class="see">
293
244
 
294
- <li><span class='object_link'><a href="Socket.html" title="EZMQ::Socket (class)">EZMQ::Socket for a list of optional parameters.</a></span></li>
245
+ <li><span class='object_link'><a href="Socket.html" title="EZMQ::Socket (class)">EZMQ::Socket for optional parameters.</a></span></li>
295
246
 
296
247
  </ul>
297
248
 
@@ -301,16 +252,14 @@ the result, then loops.</p>
301
252
  <pre class="lines">
302
253
 
303
254
 
304
- 98
305
- 99
306
- 100
307
- 101</pre>
255
+ 152
256
+ 153
257
+ 154</pre>
308
258
  </td>
309
259
  <td>
310
- <pre class="code"><span class="info file"># File 'lib/ezmq.rb', line 98</span>
260
+ <pre class="code"><span class="info file"># File 'lib/ezmq.rb', line 152</span>
311
261
 
312
- <span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span><span class='lparen'>(</span><span class='label'>provides:</span> <span class='tlambda'>-&gt;</span> <span class='id identifier rubyid_m'>m</span> <span class='tlambeg'>{</span> <span class='id identifier rubyid_m'>m</span> <span class='rbrace'>}</span><span class='comma'>,</span> <span class='op'>**</span><span class='id identifier rubyid_options'>options</span><span class='rparen'>)</span>
313
- <span class='ivar'>@provides</span> <span class='op'>=</span> <span class='id identifier rubyid_provides'>provides</span>
262
+ <span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span><span class='lparen'>(</span><span class='op'>**</span><span class='id identifier rubyid_options'>options</span><span class='rparen'>)</span>
314
263
  <span class='kw'>super</span> <span class='symbol'>:bind</span><span class='comma'>,</span> <span class='const'>ZMQ</span><span class='op'>::</span><span class='const'>REP</span><span class='comma'>,</span> <span class='id identifier rubyid_options'>options</span>
315
264
  <span class='kw'>end</span></pre>
316
265
  </td>
@@ -320,54 +269,6 @@ the result, then loops.</p>
320
269
 
321
270
  </div>
322
271
 
323
- <div id="instance_attr_details" class="attr_details">
324
- <h2>Instance Attribute Details</h2>
325
-
326
-
327
- <span id="provides=-instance_method"></span>
328
- <div class="method_details first">
329
- <h3 class="signature first" id="provides-instance_method">
330
-
331
- - (<tt>Object</tt>) <strong>provides</strong>
332
-
333
-
334
-
335
-
336
-
337
- </h3><div class="docstring">
338
- <div class="discussion">
339
-
340
- <p>Returns the value of attribute provides</p>
341
-
342
-
343
- </div>
344
- </div>
345
- <div class="tags">
346
-
347
-
348
- </div><table class="source_code">
349
- <tr>
350
- <td>
351
- <pre class="lines">
352
-
353
-
354
- 87
355
- 88
356
- 89</pre>
357
- </td>
358
- <td>
359
- <pre class="code"><span class="info file"># File 'lib/ezmq.rb', line 87</span>
360
-
361
- <span class='kw'>def</span> <span class='id identifier rubyid_provides'>provides</span>
362
- <span class='ivar'>@provides</span>
363
- <span class='kw'>end</span></pre>
364
- </td>
365
- </tr>
366
- </table>
367
- </div>
368
-
369
- </div>
370
-
371
272
 
372
273
  <div id="instance_method_details" class="method_details_list">
373
274
  <h2>Instance Method Details</h2>
@@ -376,7 +277,7 @@ the result, then loops.</p>
376
277
  <div class="method_details first">
377
278
  <h3 class="signature first" id="listen-instance_method">
378
279
 
379
- - (<tt>void</tt>) <strong>listen</strong>(handler: -&gt; { send @provides.call(receive) })
280
+ - (<tt>void</tt>) <strong>listen</strong> {|message| ... }
380
281
 
381
282
 
382
283
 
@@ -385,34 +286,71 @@ the result, then loops.</p>
385
286
  </h3><div class="docstring">
386
287
  <div class="discussion">
387
288
  <p class="note returns_void">This method returns an undefined value.</p>
388
- <p>By default, waits to receive a message, calls @action with it, replies with
389
- the result, then loops.</p>
289
+ <p>Listens for a request, and responds to it.</p>
290
+
291
+ <p>If no block is given, responds with the request message.</p>
390
292
 
391
293
 
392
294
  </div>
393
295
  </div>
394
296
  <div class="tags">
395
- <p class="tag_title">Parameters:</p>
396
- <ul class="param">
297
+
298
+ <p class="tag_title">Yields:</p>
299
+ <ul class="yield">
397
300
 
398
301
  <li>
399
302
 
400
- <span class='name'>handler</span>
401
303
 
304
+ <span class='type'></span>
402
305
 
403
- <span class='type'>(<tt>lambda</tt>)</span>
306
+
307
+
308
+
309
+ <div class='inline'>
310
+ <p>message passes the message received to the block.</p>
311
+ </div>
312
+
313
+ </li>
314
+
315
+ </ul>
316
+ <p class="tag_title">Yield Parameters:</p>
317
+ <ul class="yieldparam">
318
+
319
+ <li>
320
+
321
+ <span class='name'>message</span>
322
+
323
+
324
+ <span class='type'>(<tt>String</tt>)</span>
404
325
 
405
326
 
406
327
 
407
328
  &mdash;
408
329
  <div class='inline'>
409
- <p>how requests are handled.</p>
330
+ <p>the message received.</p>
331
+ </div>
332
+
333
+ </li>
334
+
335
+ </ul>
336
+ <p class="tag_title">Yield Returns:</p>
337
+ <ul class="yieldreturn">
338
+
339
+ <li>
340
+
341
+
342
+ <span class='type'>(<tt>void</tt>)</span>
343
+
344
+
345
+
346
+ &mdash;
347
+ <div class='inline'>
348
+ <p>the message to reply with.</p>
410
349
  </div>
411
350
 
412
351
  </li>
413
352
 
414
353
  </ul>
415
-
416
354
 
417
355
  </div><table class="source_code">
418
356
  <tr>
@@ -420,15 +358,27 @@ the result, then loops.</p>
420
358
  <pre class="lines">
421
359
 
422
360
 
423
- 110
424
- 111
425
- 112</pre>
361
+ 166
362
+ 167
363
+ 168
364
+ 169
365
+ 170
366
+ 171
367
+ 172
368
+ 173
369
+ 174</pre>
426
370
  </td>
427
371
  <td>
428
- <pre class="code"><span class="info file"># File 'lib/ezmq.rb', line 110</span>
429
-
430
- <span class='kw'>def</span> <span class='id identifier rubyid_listen'>listen</span><span class='lparen'>(</span><span class='label'>handler:</span> <span class='tlambda'>-&gt;</span> <span class='tlambeg'>{</span> <span class='id identifier rubyid_send'>send</span> <span class='ivar'>@provides</span><span class='period'>.</span><span class='id identifier rubyid_call'>call</span><span class='lparen'>(</span><span class='id identifier rubyid_receive'>receive</span><span class='rparen'>)</span> <span class='rbrace'>}</span><span class='rparen'>)</span>
431
- <span class='id identifier rubyid_loop'>loop</span> <span class='lbrace'>{</span> <span class='id identifier rubyid_handler'>handler</span><span class='period'>.</span><span class='id identifier rubyid_call'>call</span> <span class='rbrace'>}</span>
372
+ <pre class="code"><span class="info file"># File 'lib/ezmq.rb', line 166</span>
373
+
374
+ <span class='kw'>def</span> <span class='id identifier rubyid_listen'>listen</span>
375
+ <span class='id identifier rubyid_loop'>loop</span> <span class='kw'>do</span>
376
+ <span class='kw'>if</span> <span class='id identifier rubyid_block_given?'>block_given?</span>
377
+ <span class='id identifier rubyid_send'>send</span> <span class='kw'>yield</span> <span class='id identifier rubyid_receive'>receive</span>
378
+ <span class='kw'>else</span>
379
+ <span class='id identifier rubyid_send'>send</span> <span class='id identifier rubyid_receive'>receive</span>
380
+ <span class='kw'>end</span>
381
+ <span class='kw'>end</span>
432
382
  <span class='kw'>end</span></pre>
433
383
  </td>
434
384
  </tr>
@@ -440,7 +390,7 @@ the result, then loops.</p>
440
390
  </div>
441
391
 
442
392
  <div id="footer">
443
- Generated on Tue Jan 6 12:58:18 2015 by
393
+ Generated on Fri Jan 9 13:06:26 2015 by
444
394
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
445
395
  0.8.7.6 (ruby-2.0.0).
446
396
  </div>