ionian 0.6.11 → 0.6.12

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: e26c23c377fd8040799e0402c9b158b349b1d214
4
- data.tar.gz: e14513b53b83104a714628e5c90858bc3a91107e
3
+ metadata.gz: e1530db96be4407d57fc89cc8046d9f92b97f54e
4
+ data.tar.gz: b180870567aa3ed43f417748e22a1082154b3fd9
5
5
  SHA512:
6
- metadata.gz: bc4340836f0686884445e7c27f213952fc3791b7d8aec7f508818fc3c8a02e786a1f0245ede4380b6b152848d3a28373467970718f0b15775116fce160588a06
7
- data.tar.gz: c9b71ce2de0646eddd164342ee6f84d156d603b58c0e882b79088e6fadf77f00126b716577ff75f80ba5574680f6dff3d8551a5723e6dd4c20e5884086b28908
6
+ metadata.gz: ee0d50045eca52b78c7ad2ddd7caacd31256555f6686517b25fff52c39a4dcc8f57232634820e201408a84b2efa6a518baac0605efc97b5075e75feff2eb3662
7
+ data.tar.gz: 2e715c46f0edd97eae342951a54106d4e0574e37af0fa94b5325e7bc674555fe0e1ebef79574718f8f5270d939c0dd5e7db3e7182a6ca1006d62fa4bcfc17e78
@@ -350,7 +350,33 @@ implement the standard library IO class. my_socket.extend Ionian::IO</p>
350
350
  <li class="public ">
351
351
  <span class="summary_signature">
352
352
 
353
- <a href="#register_observer-instance_method" title="#register_observer (instance method)">- (Object) <strong>register_observer</strong>(&amp;block) </a>
353
+ <a href="#register_error_handler-instance_method" title="#register_error_handler (instance method)">- (Block) <strong>register_error_handler</strong> {|Exception, self| ... }</a>
354
+
355
+
356
+
357
+ (also: #on_error)
358
+
359
+ </span>
360
+
361
+
362
+
363
+
364
+
365
+
366
+
367
+
368
+
369
+ <span class="summary_desc"><div class='inline'>
370
+ <p>Register a block to be called when <span class='object_link'><a href="#run_match-instance_method" title="Ionian::Extension::IO#run_match (method)">#run_match</a></span> raises an error.</p>
371
+ </div></span>
372
+
373
+ </li>
374
+
375
+
376
+ <li class="public ">
377
+ <span class="summary_signature">
378
+
379
+ <a href="#register_match_handler-instance_method" title="#register_match_handler (instance method)">- (Block) <strong>register_match_handler</strong> {|MatchData, self| ... }</a>
354
380
 
355
381
 
356
382
 
@@ -370,6 +396,30 @@ implement the standard library IO class. my_socket.extend Ionian::IO</p>
370
396
  <p>Register a block to be called when <span class='object_link'><a href="#run_match-instance_method" title="Ionian::Extension::IO#run_match (method)">#run_match</a></span> receives matched data.</p>
371
397
  </div></span>
372
398
 
399
+ </li>
400
+
401
+
402
+ <li class="public deprecated">
403
+ <span class="summary_signature">
404
+
405
+ <a href="#register_observer-instance_method" title="#register_observer (instance method)">- (Object) <strong>register_observer</strong>(&amp;block) </a>
406
+
407
+
408
+
409
+ </span>
410
+
411
+
412
+
413
+
414
+
415
+ <span class="deprecated note title">deprecated</span>
416
+
417
+
418
+
419
+ <span class="summary_desc"><strong>Deprecated.</strong> <div class='inline'>
420
+ <p>Use <span class='object_link'><a href="#register_match_handler-instance_method" title="Ionian::Extension::IO#register_match_handler (method)">#register_match_handler</a></span> instead.</p>
421
+ </div></span>
422
+
373
423
  </li>
374
424
 
375
425
 
@@ -391,8 +441,7 @@ implement the standard library IO class. my_socket.extend Ionian::IO</p>
391
441
 
392
442
 
393
443
  <span class="summary_desc"><div class='inline'>
394
- <p>Start a thread that checks for data and notifies listeners (do |match,
395
- socket|).</p>
444
+ <p>Start a thread that checks for data and notifies match and error handlers.</p>
396
445
  </div></span>
397
446
 
398
447
  </li>
@@ -401,7 +450,31 @@ socket|).</p>
401
450
  <li class="public ">
402
451
  <span class="summary_signature">
403
452
 
404
- <a href="#unregister_observer-instance_method" title="#unregister_observer (instance method)">- (Object) <strong>unregister_observer</strong>(&amp;block) </a>
453
+ <a href="#unregister_error_handler-instance_method" title="#unregister_error_handler (instance method)">- (Object) <strong>unregister_error_handler</strong>(&amp;block) </a>
454
+
455
+
456
+
457
+ </span>
458
+
459
+
460
+
461
+
462
+
463
+
464
+
465
+
466
+
467
+ <span class="summary_desc"><div class='inline'>
468
+ <p>Unregister a block from being called when a <span class='object_link'><a href="#run_match-instance_method" title="Ionian::Extension::IO#run_match (method)">#run_match</a></span> error is raised.</p>
469
+ </div></span>
470
+
471
+ </li>
472
+
473
+
474
+ <li class="public ">
475
+ <span class="summary_signature">
476
+
477
+ <a href="#unregister_match_handler-instance_method" title="#unregister_match_handler (instance method)">- (Object) <strong>unregister_match_handler</strong>(&amp;block) </a>
405
478
 
406
479
 
407
480
 
@@ -419,6 +492,30 @@ socket|).</p>
419
492
  <p>Unregister a block from being called when matched data is received.</p>
420
493
  </div></span>
421
494
 
495
+ </li>
496
+
497
+
498
+ <li class="public deprecated">
499
+ <span class="summary_signature">
500
+
501
+ <a href="#unregister_observer-instance_method" title="#unregister_observer (instance method)">- (Object) <strong>unregister_observer</strong>(&amp;block) </a>
502
+
503
+
504
+
505
+ </span>
506
+
507
+
508
+
509
+
510
+
511
+ <span class="deprecated note title">deprecated</span>
512
+
513
+
514
+
515
+ <span class="summary_desc"><strong>Deprecated.</strong> <div class='inline'>
516
+ <p>Use <span class='object_link'><a href="#unregister_match_handler-instance_method" title="Ionian::Extension::IO#unregister_match_handler (method)">#unregister_match_handler</a></span> instead.</p>
517
+ </div></span>
518
+
422
519
  </li>
423
520
 
424
521
 
@@ -553,12 +650,12 @@ standard library IO::select.</p>
553
650
  <pre class="lines">
554
651
 
555
652
 
556
- 42
557
653
  43
558
- 44</pre>
654
+ 44
655
+ 45</pre>
559
656
  </td>
560
657
  <td>
561
- <pre class="code"><span class="info file"># File 'lib/ionian/extension/io.rb', line 42</span>
658
+ <pre class="code"><span class="info file"># File 'lib/ionian/extension/io.rb', line 43</span>
562
659
 
563
660
  <span class='kw'>def</span> <span class='id identifier rubyid_expression'>expression</span>
564
661
  <span class='ivar'>@ionian_expression</span>
@@ -598,13 +695,13 @@ href=":parameter">match</a>.</p>
598
695
  <pre class="lines">
599
696
 
600
697
 
601
- 52
602
698
  53
603
699
  54
604
- 55</pre>
700
+ 55
701
+ 56</pre>
605
702
  </td>
606
703
  <td>
607
- <pre class="code"><span class="info file"># File 'lib/ionian/extension/io.rb', line 52</span>
704
+ <pre class="code"><span class="info file"># File 'lib/ionian/extension/io.rb', line 53</span>
608
705
 
609
706
  <span class='kw'>def</span> <span class='id identifier rubyid_expression='>expression=</span> <span class='id identifier rubyid_exp'>exp</span>
610
707
  <span class='ivar'>@ionian_expression</span> <span class='op'>=</span> <span class='id identifier rubyid_exp'>exp</span>
@@ -680,12 +777,12 @@ blocking.</p>
680
777
  <pre class="lines">
681
778
 
682
779
 
683
- 37
684
780
  38
685
- 39</pre>
781
+ 39
782
+ 40</pre>
686
783
  </td>
687
784
  <td>
688
- <pre class="code"><span class="info file"># File 'lib/ionian/extension/io.rb', line 37</span>
785
+ <pre class="code"><span class="info file"># File 'lib/ionian/extension/io.rb', line 38</span>
689
786
 
690
787
  <span class='kw'>def</span> <span class='id identifier rubyid_has_data?'>has_data?</span> <span class='label'>timeout:</span> <span class='int'>0</span>
691
788
  <span class='op'>::</span><span class='const'>IO</span><span class='period'>.</span><span class='id identifier rubyid_select'>select</span><span class='lparen'>(</span><span class='lbracket'>[</span><span class='kw'>self</span><span class='rbracket'>]</span><span class='comma'>,</span> <span class='kw'>nil</span><span class='comma'>,</span> <span class='kw'>nil</span><span class='comma'>,</span> <span class='id identifier rubyid_timeout'>timeout</span><span class='rparen'>)</span> <span class='op'>?</span> <span class='kw'>true</span> <span class='op'>:</span> <span class='kw'>false</span>
@@ -729,18 +826,20 @@ blocking.</p>
729
826
  27
730
827
  28
731
828
  29
732
- 30</pre>
829
+ 30
830
+ 31</pre>
733
831
  </td>
734
832
  <td>
735
833
  <pre class="code"><span class="info file"># File 'lib/ionian/extension/io.rb', line 23</span>
736
834
 
737
835
  <span class='kw'>def</span> <span class='id identifier rubyid_initialize_ionian'>initialize_ionian</span>
738
- <span class='ivar'>@ionian_listeners</span> <span class='op'>=</span> <span class='lbracket'>[</span><span class='rbracket'>]</span>
739
- <span class='ivar'>@ionian_buf</span> <span class='op'>=</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_end'>&#39;</span></span>
740
- <span class='ivar'>@ionian_expression</span> <span class='op'>=</span> <span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>(.*?)[\r\n]+</span><span class='regexp_end'>/</span></span>
741
- <span class='ivar'>@ionian_timeout</span> <span class='op'>=</span> <span class='kw'>nil</span>
742
- <span class='ivar'>@ionian_skip_select</span> <span class='op'>=</span> <span class='kw'>false</span>
743
- <span class='ivar'>@ionian_build_methods</span> <span class='op'>=</span> <span class='kw'>true</span>
836
+ <span class='ivar'>@ionian_match_handlers</span> <span class='op'>=</span> <span class='lbracket'>[</span><span class='rbracket'>]</span>
837
+ <span class='ivar'>@ionian_error_handlers</span> <span class='op'>=</span> <span class='lbracket'>[</span><span class='rbracket'>]</span>
838
+ <span class='ivar'>@ionian_buf</span> <span class='op'>=</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_end'>&#39;</span></span>
839
+ <span class='ivar'>@ionian_expression</span> <span class='op'>=</span> <span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>(.*?)[\r\n]+</span><span class='regexp_end'>/</span></span>
840
+ <span class='ivar'>@ionian_timeout</span> <span class='op'>=</span> <span class='kw'>nil</span>
841
+ <span class='ivar'>@ionian_skip_select</span> <span class='op'>=</span> <span class='kw'>false</span>
842
+ <span class='ivar'>@ionian_build_methods</span> <span class='op'>=</span> <span class='kw'>true</span>
744
843
  <span class='kw'>end</span></pre>
745
844
  </td>
746
845
  </tr>
@@ -774,14 +873,14 @@ automatically.</p>
774
873
  <pre class="lines">
775
874
 
776
875
 
777
- 172
778
876
  173
779
877
  174
780
878
  175
781
- 176</pre>
879
+ 176
880
+ 177</pre>
782
881
  </td>
783
882
  <td>
784
- <pre class="code"><span class="info file"># File 'lib/ionian/extension/io.rb', line 172</span>
883
+ <pre class="code"><span class="info file"># File 'lib/ionian/extension/io.rb', line 173</span>
785
884
 
786
885
  <span class='kw'>def</span> <span class='id identifier rubyid_purge'>purge</span>
787
886
  <span class='comment'># Erase IO buffer.
@@ -821,7 +920,6 @@ nonblocking, returns nil if no data available.</p>
821
920
  <pre class="lines">
822
921
 
823
922
 
824
- 61
825
923
  62
826
924
  63
827
925
  64
@@ -829,10 +927,11 @@ nonblocking, returns nil if no data available.</p>
829
927
  66
830
928
  67
831
929
  68
832
- 69</pre>
930
+ 69
931
+ 70</pre>
833
932
  </td>
834
933
  <td>
835
- <pre class="code"><span class="info file"># File 'lib/ionian/extension/io.rb', line 61</span>
934
+ <pre class="code"><span class="info file"># File 'lib/ionian/extension/io.rb', line 62</span>
836
935
 
837
936
  <span class='kw'>def</span> <span class='id identifier rubyid_read_all'>read_all</span> <span class='label'>nonblocking:</span> <span class='kw'>false</span>
838
937
  <span class='kw'>return</span> <span class='kw'>nil</span> <span class='kw'>if</span> <span class='id identifier rubyid_nonblocking'>nonblocking</span> <span class='kw'>and</span> <span class='kw'>not</span> <span class='id identifier rubyid_has_data?'>has_data?</span>
@@ -943,7 +1042,7 @@ Set to 0 for nonblocking.</p>
943
1042
  </span>
944
1043
 
945
1044
  &mdash; <div class='inline'>
946
- <p>Set to false to skip notifying match listener procs.</p>
1045
+ <p>Set to false to skip notifying match handler procs.</p>
947
1046
  </div>
948
1047
 
949
1048
  </li>
@@ -1030,7 +1129,6 @@ timeout period.</p>
1030
1129
  <pre class="lines">
1031
1130
 
1032
1131
 
1033
- 106
1034
1132
  107
1035
1133
  108
1036
1134
  109
@@ -1074,10 +1172,11 @@ timeout period.</p>
1074
1172
  147
1075
1173
  148
1076
1174
  149
1077
- 150</pre>
1175
+ 150
1176
+ 151</pre>
1078
1177
  </td>
1079
1178
  <td>
1080
- <pre class="code"><span class="info file"># File 'lib/ionian/extension/io.rb', line 106</span>
1179
+ <pre class="code"><span class="info file"># File 'lib/ionian/extension/io.rb', line 107</span>
1081
1180
 
1082
1181
  <span class='kw'>def</span> <span class='id identifier rubyid_read_match'>read_match</span> <span class='op'>**</span><span class='id identifier rubyid_kwargs'>kwargs</span><span class='comma'>,</span> <span class='op'>&amp;</span><span class='id identifier rubyid_block'>block</span>
1083
1182
  <span class='id identifier rubyid_timeout'>timeout</span> <span class='op'>=</span> <span class='id identifier rubyid_kwargs'>kwargs</span><span class='period'>.</span><span class='id identifier rubyid_fetch'>fetch</span> <span class='symbol'>:timeout</span><span class='comma'>,</span> <span class='ivar'>@ionian_timeout</span>
@@ -1118,9 +1217,9 @@ timeout period.</p>
1118
1217
  <span class='comment'># Pass each match to block.
1119
1218
  </span> <span class='ivar'>@matches</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_match'>match</span><span class='op'>|</span> <span class='kw'>yield</span> <span class='id identifier rubyid_match'>match</span> <span class='rbrace'>}</span> <span class='kw'>if</span> <span class='id identifier rubyid_block_given?'>block_given?</span>
1120
1219
 
1121
- <span class='comment'># Notify on_match listeners unless the #run_match thread is active.
1122
- </span> <span class='ivar'>@matches</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_match'>match</span><span class='op'>|</span> <span class='id identifier rubyid_notify_listeners'>notify_listeners</span> <span class='id identifier rubyid_match'>match</span> <span class='rbrace'>}</span> \
1123
- <span class='kw'>if</span> <span class='id identifier rubyid_notify'>notify</span> <span class='kw'>and</span> <span class='kw'>not</span> <span class='ivar'>@match_listener</span>
1220
+ <span class='comment'># Notify on_match handlers unless the #run_match thread is active.
1221
+ </span> <span class='ivar'>@matches</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_match'>match</span><span class='op'>|</span> <span class='id identifier rubyid_notify_match_handlers'>notify_match_handlers</span> <span class='id identifier rubyid_match'>match</span> <span class='rbrace'>}</span> \
1222
+ <span class='kw'>if</span> <span class='id identifier rubyid_notify'>notify</span> <span class='kw'>and</span> <span class='kw'>not</span> <span class='ivar'>@run_match_thread</span>
1124
1223
 
1125
1224
  <span class='ivar'>@matches</span>
1126
1225
  <span class='kw'>end</span></pre>
@@ -1130,9 +1229,88 @@ timeout period.</p>
1130
1229
  </div>
1131
1230
 
1132
1231
  <div class="method_details ">
1133
- <h3 class="signature " id="register_observer-instance_method">
1232
+ <h3 class="signature " id="register_error_handler-instance_method">
1134
1233
 
1135
- - (<tt>Object</tt>) <strong>register_observer</strong>(&amp;block)
1234
+ - (<tt>Block</tt>) <strong>register_error_handler</strong> {|Exception, self| ... }
1235
+
1236
+
1237
+
1238
+ <span class="aliases">Also known as:
1239
+ <span class="names"><span id='on_error-instance_method'>on_error</span></span>
1240
+ </span>
1241
+
1242
+
1243
+
1244
+ </h3><div class="docstring">
1245
+ <div class="discussion">
1246
+
1247
+ <p>Register a block to be called when <span class='object_link'><a href="#run_match-instance_method" title="Ionian::Extension::IO#run_match (method)">#run_match</a></span> raises an error. Method
1248
+ callbacks can be registered with &amp;object.method(:method).</p>
1249
+
1250
+
1251
+ </div>
1252
+ </div>
1253
+ <div class="tags">
1254
+
1255
+ <p class="tag_title">Yields:</p>
1256
+ <ul class="yield">
1257
+
1258
+ <li>
1259
+
1260
+
1261
+ <span class='type'>(<tt>Exception</tt>, <tt>self</tt>)</span>
1262
+
1263
+
1264
+
1265
+ </li>
1266
+
1267
+ </ul>
1268
+ <p class="tag_title">Returns:</p>
1269
+ <ul class="return">
1270
+
1271
+ <li>
1272
+
1273
+
1274
+ <span class='type'>(<tt>Block</tt>)</span>
1275
+
1276
+
1277
+
1278
+ &mdash;
1279
+ <div class='inline'>
1280
+ <p>a reference to the given block.</p>
1281
+ </div>
1282
+
1283
+ </li>
1284
+
1285
+ </ul>
1286
+
1287
+ </div><table class="source_code">
1288
+ <tr>
1289
+ <td>
1290
+ <pre class="lines">
1291
+
1292
+
1293
+ 216
1294
+ 217
1295
+ 218
1296
+ 219</pre>
1297
+ </td>
1298
+ <td>
1299
+ <pre class="code"><span class="info file"># File 'lib/ionian/extension/io.rb', line 216</span>
1300
+
1301
+ <span class='kw'>def</span> <span class='id identifier rubyid_register_error_handler'>register_error_handler</span> <span class='op'>&amp;</span><span class='id identifier rubyid_block'>block</span>
1302
+ <span class='ivar'>@ionian_error_handlers</span> <span class='op'>&lt;&lt;</span> <span class='id identifier rubyid_block'>block</span> <span class='kw'>unless</span> <span class='ivar'>@ionian_error_handlers</span><span class='period'>.</span><span class='id identifier rubyid_include?'>include?</span> <span class='id identifier rubyid_block'>block</span>
1303
+ <span class='id identifier rubyid_block'>block</span>
1304
+ <span class='kw'>end</span></pre>
1305
+ </td>
1306
+ </tr>
1307
+ </table>
1308
+ </div>
1309
+
1310
+ <div class="method_details ">
1311
+ <h3 class="signature " id="register_match_handler-instance_method">
1312
+
1313
+ - (<tt>Block</tt>) <strong>register_match_handler</strong> {|MatchData, self| ... }
1136
1314
 
1137
1315
 
1138
1316
 
@@ -1146,8 +1324,7 @@ timeout period.</p>
1146
1324
  <div class="discussion">
1147
1325
 
1148
1326
  <p>Register a block to be called when <span class='object_link'><a href="#run_match-instance_method" title="Ionian::Extension::IO#run_match (method)">#run_match</a></span> receives matched data.
1149
- Method callbacks can be registered with &amp;object.method(:method).
1150
- Returns a reference to the given block.</p>
1327
+ Method callbacks can be registered with &amp;object.method(:method).</p>
1151
1328
 
1152
1329
 
1153
1330
  </div>
@@ -1158,13 +1335,49 @@ Returns a reference to the given block.</p>
1158
1335
  <p class="tag_title">Examples:</p>
1159
1336
 
1160
1337
 
1161
- <pre class="example code"><code>registered_block = ionian_socket.register_observer { |match| ... }</code></pre>
1338
+ <pre class="example code"><code>registered_block = ionian_socket.register_match_handler { |match| ... }</code></pre>
1162
1339
 
1163
1340
 
1164
- <pre class="example code"><code><span class='id identifier rubyid_registered_block'>registered_block</span> <span class='op'>=</span> <span class='id identifier rubyid_ionian_socket'>ionian_socket</span><span class='period'>.</span><span class='id identifier rubyid_register_observer'>register_observer</span> <span class='op'>&amp;</span><span class='id identifier rubyid_my_object'>my_object</span><span class='period'>.</span><span class='id identifier rubyid_method'>method</span><span class='lparen'>(</span><span class='symbol'>:foo</span><span class='rparen'>)</span></code></pre>
1341
+ <pre class="example code"><code><span class='id identifier rubyid_registered_block'>registered_block</span> <span class='op'>=</span> <span class='id identifier rubyid_ionian_socket'>ionian_socket</span><span class='period'>.</span><span class='id identifier rubyid_register_match_handler'>register_match_handler</span> <span class='op'>&amp;</span><span class='id identifier rubyid_my_object'>my_object</span><span class='period'>.</span><span class='id identifier rubyid_method'>method</span><span class='lparen'>(</span><span class='symbol'>:foo</span><span class='rparen'>)</span></code></pre>
1165
1342
 
1166
1343
  </div>
1167
1344
 
1345
+ <p class="tag_title">Yields:</p>
1346
+ <ul class="yield">
1347
+
1348
+ <li>
1349
+
1350
+
1351
+ <span class='type'>(<tt>MatchData</tt>, <tt>self</tt>)</span>
1352
+
1353
+
1354
+
1355
+ &mdash;
1356
+ <div class='inline'>
1357
+ <p>Regex match.</p>
1358
+ </div>
1359
+
1360
+ </li>
1361
+
1362
+ </ul>
1363
+ <p class="tag_title">Returns:</p>
1364
+ <ul class="return">
1365
+
1366
+ <li>
1367
+
1368
+
1369
+ <span class='type'>(<tt>Block</tt>)</span>
1370
+
1371
+
1372
+
1373
+ &mdash;
1374
+ <div class='inline'>
1375
+ <p>a reference to the given block.</p>
1376
+ </div>
1377
+
1378
+ </li>
1379
+
1380
+ </ul>
1168
1381
 
1169
1382
  </div><table class="source_code">
1170
1383
  <tr>
@@ -1172,21 +1385,63 @@ Returns a reference to the given block.</p>
1172
1385
  <pre class="lines">
1173
1386
 
1174
1387
 
1175
- 187
1176
- 188
1177
1388
  189
1178
- 190</pre>
1389
+ 190
1390
+ 191
1391
+ 192</pre>
1179
1392
  </td>
1180
1393
  <td>
1181
- <pre class="code"><span class="info file"># File 'lib/ionian/extension/io.rb', line 187</span>
1394
+ <pre class="code"><span class="info file"># File 'lib/ionian/extension/io.rb', line 189</span>
1182
1395
 
1183
- <span class='kw'>def</span> <span class='id identifier rubyid_register_observer'>register_observer</span> <span class='op'>&amp;</span><span class='id identifier rubyid_block'>block</span>
1184
- <span class='ivar'>@ionian_listeners</span> <span class='op'>&lt;&lt;</span> <span class='id identifier rubyid_block'>block</span> <span class='kw'>unless</span> <span class='ivar'>@ionian_listeners</span><span class='period'>.</span><span class='id identifier rubyid_include?'>include?</span> <span class='id identifier rubyid_block'>block</span>
1396
+ <span class='kw'>def</span> <span class='id identifier rubyid_register_match_handler'>register_match_handler</span> <span class='op'>&amp;</span><span class='id identifier rubyid_block'>block</span>
1397
+ <span class='ivar'>@ionian_match_handlers</span> <span class='op'>&lt;&lt;</span> <span class='id identifier rubyid_block'>block</span> <span class='kw'>unless</span> <span class='ivar'>@ionian_match_handlers</span><span class='period'>.</span><span class='id identifier rubyid_include?'>include?</span> <span class='id identifier rubyid_block'>block</span>
1185
1398
  <span class='id identifier rubyid_block'>block</span>
1186
1399
  <span class='kw'>end</span></pre>
1187
1400
  </td>
1188
1401
  </tr>
1189
1402
  </table>
1403
+ </div>
1404
+
1405
+ <div class="method_details ">
1406
+ <h3 class="signature " id="register_observer-instance_method">
1407
+
1408
+ - (<tt>Object</tt>) <strong>register_observer</strong>(&amp;block)
1409
+
1410
+
1411
+
1412
+
1413
+
1414
+ </h3><div class="docstring">
1415
+ <div class="discussion">
1416
+ <div class="note deprecated"><strong>Deprecated.</strong> <div class='inline'>
1417
+ <p>Use <span class='object_link'><a href="#register_match_handler-instance_method" title="Ionian::Extension::IO#register_match_handler (method)">#register_match_handler</a></span> instead.</p>
1418
+ </div></div>
1419
+
1420
+
1421
+ </div>
1422
+ </div>
1423
+ <div class="tags">
1424
+
1425
+
1426
+ </div><table class="source_code">
1427
+ <tr>
1428
+ <td>
1429
+ <pre class="lines">
1430
+
1431
+
1432
+ 197
1433
+ 198
1434
+ 199</pre>
1435
+ </td>
1436
+ <td>
1437
+ <pre class="code"><span class="info file"># File 'lib/ionian/extension/io.rb', line 197</span>
1438
+
1439
+ <span class='kw'>def</span> <span class='id identifier rubyid_register_observer'>register_observer</span> <span class='op'>&amp;</span><span class='id identifier rubyid_block'>block</span>
1440
+ <span class='id identifier rubyid_register_match_handler'>register_match_handler</span> <span class='op'>&amp;</span><span class='id identifier rubyid_block'>block</span>
1441
+ <span class='kw'>end</span></pre>
1442
+ </td>
1443
+ </tr>
1444
+ </table>
1190
1445
  </div>
1191
1446
 
1192
1447
  <div class="method_details ">
@@ -1201,8 +1456,8 @@ Returns a reference to the given block.</p>
1201
1456
  </h3><div class="docstring">
1202
1457
  <div class="discussion">
1203
1458
 
1204
- <p>Start a thread that checks for data and notifies listeners (do |match,
1205
- socket|). Passes kwargs to <span class='object_link'><a href="#read_match-instance_method" title="Ionian::Extension::IO#read_match (method)">#read_match</a></span>. This method SHOULD NOT be used if
1459
+ <p>Start a thread that checks for data and notifies match and error handlers.
1460
+ Passes kwargs to <span class='object_link'><a href="#read_match-instance_method" title="Ionian::Extension::IO#read_match (method)">#read_match</a></span>. This method SHOULD NOT be used if
1206
1461
  <span class='object_link'><a href="#read_match-instance_method" title="Ionian::Extension::IO#read_match (method)">#read_match</a></span> is used.</p>
1207
1462
 
1208
1463
 
@@ -1217,7 +1472,6 @@ socket|). Passes kwargs to <span class='object_link'><a href="#read_match-instan
1217
1472
  <pre class="lines">
1218
1473
 
1219
1474
 
1220
- 155
1221
1475
  156
1222
1476
  157
1223
1477
  158
@@ -1230,22 +1484,23 @@ socket|). Passes kwargs to <span class='object_link'><a href="#read_match-instan
1230
1484
  165
1231
1485
  166
1232
1486
  167
1233
- 168</pre>
1487
+ 168
1488
+ 169</pre>
1234
1489
  </td>
1235
1490
  <td>
1236
- <pre class="code"><span class="info file"># File 'lib/ionian/extension/io.rb', line 155</span>
1491
+ <pre class="code"><span class="info file"># File 'lib/ionian/extension/io.rb', line 156</span>
1237
1492
 
1238
1493
  <span class='kw'>def</span> <span class='id identifier rubyid_run_match'>run_match</span> <span class='op'>**</span><span class='id identifier rubyid_kwargs'>kwargs</span>
1239
- <span class='ivar'>@match_listener</span> <span class='op'>||=</span> <span class='const'>Thread</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span> <span class='kw'>do</span>
1494
+ <span class='ivar'>@run_match_thread</span> <span class='op'>||=</span> <span class='const'>Thread</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span> <span class='kw'>do</span>
1240
1495
  <span class='kw'>begin</span>
1241
1496
  <span class='kw'>while</span> <span class='kw'>not</span> <span class='id identifier rubyid_closed?'>closed?</span> <span class='kw'>do</span>
1242
1497
  <span class='id identifier rubyid_matches'>matches</span> <span class='op'>=</span> <span class='id identifier rubyid_read_match'>read_match</span> <span class='op'>**</span><span class='id identifier rubyid_kwargs'>kwargs</span>
1243
- <span class='id identifier rubyid_matches'>matches</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_match'>match</span><span class='op'>|</span> <span class='id identifier rubyid_notify_listeners'>notify_listeners</span> <span class='id identifier rubyid_match'>match</span> <span class='rbrace'>}</span> <span class='kw'>if</span> <span class='id identifier rubyid_matches'>matches</span>
1498
+ <span class='id identifier rubyid_matches'>matches</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_match'>match</span><span class='op'>|</span> <span class='id identifier rubyid_notify_match_handlers'>notify_match_handlers</span> <span class='id identifier rubyid_match'>match</span> <span class='rbrace'>}</span> <span class='kw'>if</span> <span class='id identifier rubyid_matches'>matches</span>
1244
1499
  <span class='kw'>end</span>
1245
- <span class='kw'>rescue</span> <span class='const'>EOFError</span>
1246
- <span class='kw'>rescue</span> <span class='const'>IOError</span>
1500
+ <span class='kw'>rescue</span> <span class='const'>Exception</span> <span class='op'>=&gt;</span> <span class='id identifier rubyid_e'>e</span>
1501
+ <span class='id identifier rubyid_notify_error_handlers'>notify_error_handlers</span> <span class='id identifier rubyid_e'>e</span>
1247
1502
  <span class='kw'>ensure</span>
1248
- <span class='ivar'>@match_listener</span> <span class='op'>=</span> <span class='kw'>nil</span>
1503
+ <span class='ivar'>@run_match_thread</span> <span class='op'>=</span> <span class='kw'>nil</span>
1249
1504
  <span class='kw'>end</span>
1250
1505
  <span class='kw'>end</span>
1251
1506
  <span class='kw'>end</span></pre>
@@ -1255,9 +1510,52 @@ socket|). Passes kwargs to <span class='object_link'><a href="#read_match-instan
1255
1510
  </div>
1256
1511
 
1257
1512
  <div class="method_details ">
1258
- <h3 class="signature " id="unregister_observer-instance_method">
1513
+ <h3 class="signature " id="unregister_error_handler-instance_method">
1259
1514
 
1260
- - (<tt>Object</tt>) <strong>unregister_observer</strong>(&amp;block)
1515
+ - (<tt>Object</tt>) <strong>unregister_error_handler</strong>(&amp;block)
1516
+
1517
+
1518
+
1519
+
1520
+
1521
+ </h3><div class="docstring">
1522
+ <div class="discussion">
1523
+
1524
+ <p>Unregister a block from being called when a <span class='object_link'><a href="#run_match-instance_method" title="Ionian::Extension::IO#run_match (method)">#run_match</a></span> error is raised.</p>
1525
+
1526
+
1527
+ </div>
1528
+ </div>
1529
+ <div class="tags">
1530
+
1531
+
1532
+ </div><table class="source_code">
1533
+ <tr>
1534
+ <td>
1535
+ <pre class="lines">
1536
+
1537
+
1538
+ 224
1539
+ 225
1540
+ 226
1541
+ 227</pre>
1542
+ </td>
1543
+ <td>
1544
+ <pre class="code"><span class="info file"># File 'lib/ionian/extension/io.rb', line 224</span>
1545
+
1546
+ <span class='kw'>def</span> <span class='id identifier rubyid_unregister_error_handler'>unregister_error_handler</span> <span class='op'>&amp;</span><span class='id identifier rubyid_block'>block</span>
1547
+ <span class='ivar'>@ionian_error_handlers</span><span class='period'>.</span><span class='id identifier rubyid_delete_if'>delete_if</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_o'>o</span><span class='op'>|</span> <span class='id identifier rubyid_o'>o</span> <span class='op'>==</span> <span class='id identifier rubyid_block'>block</span> <span class='rbrace'>}</span>
1548
+ <span class='id identifier rubyid_block'>block</span>
1549
+ <span class='kw'>end</span></pre>
1550
+ </td>
1551
+ </tr>
1552
+ </table>
1553
+ </div>
1554
+
1555
+ <div class="method_details ">
1556
+ <h3 class="signature " id="unregister_match_handler-instance_method">
1557
+
1558
+ - (<tt>Object</tt>) <strong>unregister_match_handler</strong>(&amp;block)
1261
1559
 
1262
1560
 
1263
1561
 
@@ -1280,21 +1578,63 @@ socket|). Passes kwargs to <span class='object_link'><a href="#read_match-instan
1280
1578
  <pre class="lines">
1281
1579
 
1282
1580
 
1283
- 195
1284
- 196
1285
- 197
1286
- 198</pre>
1581
+ 202
1582
+ 203
1583
+ 204
1584
+ 205</pre>
1287
1585
  </td>
1288
1586
  <td>
1289
- <pre class="code"><span class="info file"># File 'lib/ionian/extension/io.rb', line 195</span>
1587
+ <pre class="code"><span class="info file"># File 'lib/ionian/extension/io.rb', line 202</span>
1290
1588
 
1291
- <span class='kw'>def</span> <span class='id identifier rubyid_unregister_observer'>unregister_observer</span> <span class='op'>&amp;</span><span class='id identifier rubyid_block'>block</span>
1292
- <span class='ivar'>@ionian_listeners</span><span class='period'>.</span><span class='id identifier rubyid_delete_if'>delete_if</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_o'>o</span><span class='op'>|</span> <span class='id identifier rubyid_o'>o</span> <span class='op'>==</span> <span class='id identifier rubyid_block'>block</span> <span class='rbrace'>}</span>
1589
+ <span class='kw'>def</span> <span class='id identifier rubyid_unregister_match_handler'>unregister_match_handler</span> <span class='op'>&amp;</span><span class='id identifier rubyid_block'>block</span>
1590
+ <span class='ivar'>@ionian_match_handlers</span><span class='period'>.</span><span class='id identifier rubyid_delete_if'>delete_if</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_o'>o</span><span class='op'>|</span> <span class='id identifier rubyid_o'>o</span> <span class='op'>==</span> <span class='id identifier rubyid_block'>block</span> <span class='rbrace'>}</span>
1293
1591
  <span class='id identifier rubyid_block'>block</span>
1294
1592
  <span class='kw'>end</span></pre>
1295
1593
  </td>
1296
1594
  </tr>
1297
1595
  </table>
1596
+ </div>
1597
+
1598
+ <div class="method_details ">
1599
+ <h3 class="signature " id="unregister_observer-instance_method">
1600
+
1601
+ - (<tt>Object</tt>) <strong>unregister_observer</strong>(&amp;block)
1602
+
1603
+
1604
+
1605
+
1606
+
1607
+ </h3><div class="docstring">
1608
+ <div class="discussion">
1609
+ <div class="note deprecated"><strong>Deprecated.</strong> <div class='inline'>
1610
+ <p>Use <span class='object_link'><a href="#unregister_match_handler-instance_method" title="Ionian::Extension::IO#unregister_match_handler (method)">#unregister_match_handler</a></span> instead.</p>
1611
+ </div></div>
1612
+
1613
+
1614
+ </div>
1615
+ </div>
1616
+ <div class="tags">
1617
+
1618
+
1619
+ </div><table class="source_code">
1620
+ <tr>
1621
+ <td>
1622
+ <pre class="lines">
1623
+
1624
+
1625
+ 208
1626
+ 209
1627
+ 210</pre>
1628
+ </td>
1629
+ <td>
1630
+ <pre class="code"><span class="info file"># File 'lib/ionian/extension/io.rb', line 208</span>
1631
+
1632
+ <span class='kw'>def</span> <span class='id identifier rubyid_unregister_observer'>unregister_observer</span> <span class='op'>&amp;</span><span class='id identifier rubyid_block'>block</span>
1633
+ <span class='id identifier rubyid_unregister_match_handler'>unregister_match_handler</span> <span class='op'>&amp;</span><span class='id identifier rubyid_block'>block</span>
1634
+ <span class='kw'>end</span></pre>
1635
+ </td>
1636
+ </tr>
1637
+ </table>
1298
1638
  </div>
1299
1639
 
1300
1640
  </div>
@@ -1302,7 +1642,7 @@ socket|). Passes kwargs to <span class='object_link'><a href="#read_match-instan
1302
1642
  </div>
1303
1643
 
1304
1644
  <div id="footer">
1305
- Generated on Fri Jan 23 20:34:48 2015 by
1645
+ Generated on Mon Jan 26 21:45:48 2015 by
1306
1646
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
1307
1647
  0.8.7.6 (ruby-2.1.5).
1308
1648
  </div>
@@ -2530,7 +2530,7 @@ true.</p>
2530
2530
  </div>
2531
2531
 
2532
2532
  <div id="footer">
2533
- Generated on Fri Jan 23 20:34:48 2015 by
2533
+ Generated on Mon Jan 26 21:45:48 2015 by
2534
2534
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
2535
2535
  0.8.7.6 (ruby-2.1.5).
2536
2536
  </div>
@@ -119,7 +119,7 @@
119
119
  </div>
120
120
 
121
121
  <div id="footer">
122
- Generated on Fri Jan 23 20:34:47 2015 by
122
+ Generated on Mon Jan 26 21:45:48 2015 by
123
123
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
124
124
  0.8.7.6 (ruby-2.1.5).
125
125
  </div>
@@ -930,7 +930,7 @@ connected client is passed to the block as an Ionain::Client.</p>
930
930
  </div>
931
931
 
932
932
  <div id="footer">
933
- Generated on Fri Jan 23 20:34:48 2015 by
933
+ Generated on Mon Jan 26 21:45:48 2015 by
934
934
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
935
935
  0.8.7.6 (ruby-2.1.5).
936
936
  </div>
@@ -1854,7 +1854,7 @@ reference to the given block. block = ionian_socket.register_observer { … }</p
1854
1854
  </div>
1855
1855
 
1856
1856
  <div id="footer">
1857
- Generated on Fri Jan 23 20:34:48 2015 by
1857
+ Generated on Mon Jan 26 21:45:48 2015 by
1858
1858
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
1859
1859
  0.8.7.6 (ruby-2.1.5).
1860
1860
  </div>
data/doc/Ionian.html CHANGED
@@ -123,7 +123,7 @@ Features regular expression matching and notification of received data.</p>
123
123
  </div>
124
124
 
125
125
  <div id="footer">
126
- Generated on Fri Jan 23 20:34:47 2015 by
126
+ Generated on Mon Jan 26 21:45:48 2015 by
127
127
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
128
128
  0.8.7.6 (ruby-2.1.5).
129
129
  </div>
data/doc/_index.html CHANGED
@@ -155,7 +155,7 @@
155
155
  </div>
156
156
 
157
157
  <div id="footer">
158
- Generated on Fri Jan 23 20:34:47 2015 by
158
+ Generated on Mon Jan 26 21:45:47 2015 by
159
159
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
160
160
  0.8.7.6 (ruby-2.1.5).
161
161
  </div>
data/doc/file.README.html CHANGED
@@ -139,7 +139,7 @@ data.</p>
139
139
  </div></div>
140
140
 
141
141
  <div id="footer">
142
- Generated on Fri Jan 23 20:34:47 2015 by
142
+ Generated on Mon Jan 26 21:45:48 2015 by
143
143
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
144
144
  0.8.7.6 (ruby-2.1.5).
145
145
  </div>
@@ -64,7 +64,7 @@
64
64
  <div id="content"><div id='filecontents'>The MIT License (MIT)<br/><br/>Copyright (c) 2013-2015 Alex McLain<br/><br/>Permission is hereby granted, free of charge, to any person obtaining a copy<br/>of this software and associated documentation files (the &quot;Software&quot;), to deal<br/>in the Software without restriction, including without limitation the rights<br/>to use, copy, modify, merge, publish, distribute, sublicense, and/or sell<br/>copies of the Software, and to permit persons to whom the Software is<br/>furnished to do so, subject to the following conditions:<br/><br/>The above copyright notice and this permission notice shall be included in<br/>all copies or substantial portions of the Software.<br/><br/>THE SOFTWARE IS PROVIDED &quot;AS IS&quot;, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR<br/>IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,<br/>FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE<br/>AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER<br/>LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,<br/>OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN<br/>THE SOFTWARE.
65
65
 
66
66
  <div id="footer">
67
- Generated on Fri Jan 23 20:34:47 2015 by
67
+ Generated on Mon Jan 26 21:45:48 2015 by
68
68
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
69
69
  0.8.7.6 (ruby-2.1.5).
70
70
  </div>
data/doc/index.html CHANGED
@@ -139,7 +139,7 @@ data.</p>
139
139
  </div></div>
140
140
 
141
141
  <div id="footer">
142
- Generated on Fri Jan 23 20:34:47 2015 by
142
+ Generated on Mon Jan 26 21:45:48 2015 by
143
143
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
144
144
  0.8.7.6 (ruby-2.1.5).
145
145
  </div>
data/doc/method_list.html CHANGED
@@ -76,14 +76,14 @@
76
76
 
77
77
 
78
78
  <li class="r1 ">
79
- <span class='object_link'><a href="Ionian/Server.html#closed%3F-instance_method" title="Ionian::Server#closed? (method)">#closed?</a></span>
80
- <small>Ionian::Server</small>
79
+ <span class='object_link'><a href="Ionian/Socket.html#closed%3F-instance_method" title="Ionian::Socket#closed? (method)">#closed?</a></span>
80
+ <small>Ionian::Socket</small>
81
81
  </li>
82
82
 
83
83
 
84
84
  <li class="r2 ">
85
- <span class='object_link'><a href="Ionian/Socket.html#closed%3F-instance_method" title="Ionian::Socket#closed? (method)">#closed?</a></span>
86
- <small>Ionian::Socket</small>
85
+ <span class='object_link'><a href="Ionian/Server.html#closed%3F-instance_method" title="Ionian::Server#closed? (method)">#closed?</a></span>
86
+ <small>Ionian::Server</small>
87
87
  </li>
88
88
 
89
89
 
@@ -118,14 +118,14 @@
118
118
 
119
119
 
120
120
  <li class="r2 ">
121
- <span class='object_link'><a href="Ionian/Extension/IO.html#expression%3D-instance_method" title="Ionian::Extension::IO#expression= (method)">#expression=</a></span>
122
- <small>Ionian::Extension::IO</small>
121
+ <span class='object_link'><a href="Ionian/Socket.html#expression%3D-instance_method" title="Ionian::Socket#expression= (method)">#expression=</a></span>
122
+ <small>Ionian::Socket</small>
123
123
  </li>
124
124
 
125
125
 
126
126
  <li class="r1 ">
127
- <span class='object_link'><a href="Ionian/Socket.html#expression%3D-instance_method" title="Ionian::Socket#expression= (method)">#expression=</a></span>
128
- <small>Ionian::Socket</small>
127
+ <span class='object_link'><a href="Ionian/Extension/IO.html#expression%3D-instance_method" title="Ionian::Extension::IO#expression= (method)">#expression=</a></span>
128
+ <small>Ionian::Extension::IO</small>
129
129
  </li>
130
130
 
131
131
 
@@ -148,14 +148,14 @@
148
148
 
149
149
 
150
150
  <li class="r1 ">
151
- <span class='object_link'><a href="Ionian/Socket.html#has_data%3F-instance_method" title="Ionian::Socket#has_data? (method)">#has_data?</a></span>
152
- <small>Ionian::Socket</small>
151
+ <span class='object_link'><a href="Ionian/Extension/IO.html#has_data%3F-instance_method" title="Ionian::Extension::IO#has_data? (method)">#has_data?</a></span>
152
+ <small>Ionian::Extension::IO</small>
153
153
  </li>
154
154
 
155
155
 
156
156
  <li class="r2 ">
157
- <span class='object_link'><a href="Ionian/Extension/IO.html#has_data%3F-instance_method" title="Ionian::Extension::IO#has_data? (method)">#has_data?</a></span>
158
- <small>Ionian::Extension::IO</small>
157
+ <span class='object_link'><a href="Ionian/Socket.html#has_data%3F-instance_method" title="Ionian::Socket#has_data? (method)">#has_data?</a></span>
158
+ <small>Ionian::Socket</small>
159
159
  </li>
160
160
 
161
161
 
@@ -352,26 +352,26 @@
352
352
 
353
353
 
354
354
  <li class="r1 ">
355
- <span class='object_link'><a href="Ionian/Socket.html#port-instance_method" title="Ionian::Socket#port (method)">#port</a></span>
356
- <small>Ionian::Socket</small>
355
+ <span class='object_link'><a href="Ionian/Server.html#port-instance_method" title="Ionian::Server#port (method)">#port</a></span>
356
+ <small>Ionian::Server</small>
357
357
  </li>
358
358
 
359
359
 
360
360
  <li class="r2 ">
361
- <span class='object_link'><a href="Ionian/Server.html#port-instance_method" title="Ionian::Server#port (method)">#port</a></span>
362
- <small>Ionian::Server</small>
361
+ <span class='object_link'><a href="Ionian/Socket.html#port-instance_method" title="Ionian::Socket#port (method)">#port</a></span>
362
+ <small>Ionian::Socket</small>
363
363
  </li>
364
364
 
365
365
 
366
366
  <li class="r1 ">
367
- <span class='object_link'><a href="Ionian/Server.html#protocol-instance_method" title="Ionian::Server#protocol (method)">#protocol</a></span>
368
- <small>Ionian::Server</small>
367
+ <span class='object_link'><a href="Ionian/Socket.html#protocol-instance_method" title="Ionian::Socket#protocol (method)">#protocol</a></span>
368
+ <small>Ionian::Socket</small>
369
369
  </li>
370
370
 
371
371
 
372
372
  <li class="r2 ">
373
- <span class='object_link'><a href="Ionian/Socket.html#protocol-instance_method" title="Ionian::Socket#protocol (method)">#protocol</a></span>
374
- <small>Ionian::Socket</small>
373
+ <span class='object_link'><a href="Ionian/Server.html#protocol-instance_method" title="Ionian::Server#protocol (method)">#protocol</a></span>
374
+ <small>Ionian::Server</small>
375
375
  </li>
376
376
 
377
377
 
@@ -412,6 +412,18 @@
412
412
 
413
413
 
414
414
  <li class="r1 ">
415
+ <span class='object_link'><a href="Ionian/Extension/IO.html#register_error_handler-instance_method" title="Ionian::Extension::IO#register_error_handler (method)">#register_error_handler</a></span>
416
+ <small>Ionian::Extension::IO</small>
417
+ </li>
418
+
419
+
420
+ <li class="r2 ">
421
+ <span class='object_link'><a href="Ionian/Extension/IO.html#register_match_handler-instance_method" title="Ionian::Extension::IO#register_match_handler (method)">#register_match_handler</a></span>
422
+ <small>Ionian::Extension::IO</small>
423
+ </li>
424
+
425
+
426
+ <li class="r1 deprecated">
415
427
  <span class='object_link'><a href="Ionian/Extension/IO.html#register_observer-instance_method" title="Ionian::Extension::IO#register_observer (method)">#register_observer</a></span>
416
428
  <small>Ionian::Extension::IO</small>
417
429
  </li>
@@ -460,6 +472,18 @@
460
472
 
461
473
 
462
474
  <li class="r1 ">
475
+ <span class='object_link'><a href="Ionian/Extension/IO.html#unregister_error_handler-instance_method" title="Ionian::Extension::IO#unregister_error_handler (method)">#unregister_error_handler</a></span>
476
+ <small>Ionian::Extension::IO</small>
477
+ </li>
478
+
479
+
480
+ <li class="r2 ">
481
+ <span class='object_link'><a href="Ionian/Extension/IO.html#unregister_match_handler-instance_method" title="Ionian::Extension::IO#unregister_match_handler (method)">#unregister_match_handler</a></span>
482
+ <small>Ionian::Extension::IO</small>
483
+ </li>
484
+
485
+
486
+ <li class="r1 deprecated">
463
487
  <span class='object_link'><a href="Ionian/Extension/IO.html#unregister_observer-instance_method" title="Ionian::Extension::IO#unregister_observer (method)">#unregister_observer</a></span>
464
488
  <small>Ionian::Extension::IO</small>
465
489
  </li>
@@ -103,7 +103,7 @@
103
103
  </div>
104
104
 
105
105
  <div id="footer">
106
- Generated on Fri Jan 23 20:34:47 2015 by
106
+ Generated on Mon Jan 26 21:45:48 2015 by
107
107
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
108
108
  0.8.7.6 (ruby-2.1.5).
109
109
  </div>
@@ -21,12 +21,13 @@ module Ionian
21
21
  # Initialize the Ionian instance variables.
22
22
  # This is called automatically if #extend is called on an object.
23
23
  def initialize_ionian
24
- @ionian_listeners = []
25
- @ionian_buf = ''
26
- @ionian_expression = /(.*?)[\r\n]+/
27
- @ionian_timeout = nil
28
- @ionian_skip_select = false
29
- @ionian_build_methods = true
24
+ @ionian_match_handlers = []
25
+ @ionian_error_handlers = []
26
+ @ionian_buf = ''
27
+ @ionian_expression = /(.*?)[\r\n]+/
28
+ @ionian_timeout = nil
29
+ @ionian_skip_select = false
30
+ @ionian_build_methods = true
30
31
  end
31
32
 
32
33
  # @return [Boolean] True if there is data in the receive buffer.
@@ -94,7 +95,7 @@ module Ionian
94
95
  # match for this single method call.
95
96
  #
96
97
  # @option kwargs [Boolean] :notify (true) Set to false to skip notifying
97
- # match listener procs.
98
+ # match handler procs.
98
99
  #
99
100
  # @option kwargs [Boolean] :skip_select (false) Skip over the
100
101
  # IO::select statement. Use if you are calling IO::select ahead of
@@ -142,27 +143,27 @@ module Ionian
142
143
  # Pass each match to block.
143
144
  @matches.each { |match| yield match } if block_given?
144
145
 
145
- # Notify on_match listeners unless the #run_match thread is active.
146
- @matches.each { |match| notify_listeners match } \
147
- if notify and not @match_listener
146
+ # Notify on_match handlers unless the #run_match thread is active.
147
+ @matches.each { |match| notify_match_handlers match } \
148
+ if notify and not @run_match_thread
148
149
 
149
150
  @matches
150
151
  end
151
152
 
152
- # Start a thread that checks for data and notifies listeners (do |match, socket|).
153
+ # Start a thread that checks for data and notifies match and error handlers.
153
154
  # Passes kwargs to {#read_match}.
154
155
  # This method SHOULD NOT be used if {#read_match} is used.
155
156
  def run_match **kwargs
156
- @match_listener ||= Thread.new do
157
+ @run_match_thread ||= Thread.new do
157
158
  begin
158
159
  while not closed? do
159
160
  matches = read_match **kwargs
160
- matches.each { |match| notify_listeners match } if matches
161
+ matches.each { |match| notify_match_handlers match } if matches
161
162
  end
162
- rescue EOFError
163
- rescue IOError
163
+ rescue Exception => e
164
+ notify_error_handlers e
164
165
  ensure
165
- @match_listener = nil
166
+ @run_match_thread = nil
166
167
  end
167
168
  end
168
169
  end
@@ -177,23 +178,51 @@ module Ionian
177
178
 
178
179
  # Register a block to be called when {#run_match} receives matched data.
179
180
  # Method callbacks can be registered with &object.method(:method).
180
- # Returns a reference to the given block.
181
+ # @return [Block] a reference to the given block.
182
+ # @yield [MatchData, self] Regex match.
181
183
  #
182
184
  # @example
183
- # registered_block = ionian_socket.register_observer { |match| ... }
185
+ # registered_block = ionian_socket.register_match_handler { |match| ... }
184
186
  #
185
187
  # @example
186
- # registered_block = ionian_socket.register_observer &my_object.method(:foo)
187
- def register_observer &block
188
- @ionian_listeners << block unless @ionian_listeners.include? block
188
+ # registered_block = ionian_socket.register_match_handler &my_object.method(:foo)
189
+ def register_match_handler &block
190
+ @ionian_match_handlers << block unless @ionian_match_handlers.include? block
189
191
  block
190
192
  end
191
193
 
192
- alias_method :on_match, :register_observer
194
+ alias_method :on_match, :register_match_handler
195
+
196
+ # @deprecated Use {#register_match_handler} instead.
197
+ def register_observer &block
198
+ register_match_handler &block
199
+ end
193
200
 
194
201
  # Unregister a block from being called when matched data is received.
202
+ def unregister_match_handler &block
203
+ @ionian_match_handlers.delete_if { |o| o == block }
204
+ block
205
+ end
206
+
207
+ # @deprecated Use {#unregister_match_handler} instead.
195
208
  def unregister_observer &block
196
- @ionian_listeners.delete_if { |o| o == block }
209
+ unregister_match_handler &block
210
+ end
211
+
212
+ # Register a block to be called when {#run_match} raises an error.
213
+ # Method callbacks can be registered with &object.method(:method).
214
+ # @return [Block] a reference to the given block.
215
+ # @yield [Exception, self]
216
+ def register_error_handler &block
217
+ @ionian_error_handlers << block unless @ionian_error_handlers.include? block
218
+ block
219
+ end
220
+
221
+ alias_method :on_error, :register_error_handler
222
+
223
+ # Unregister a block from being called when a {#run_match} error is raised.
224
+ def unregister_error_handler &block
225
+ @ionian_error_handlers.delete_if { |o| o == block }
197
226
  block
198
227
  end
199
228
 
@@ -202,8 +231,14 @@ module Ionian
202
231
 
203
232
  # Send match to each of the registered observers. Includes self
204
233
  # as the second block parameter.
205
- def notify_listeners match
206
- @ionian_listeners.each { |listener| listener.call match, self }
234
+ def notify_match_handlers match
235
+ @ionian_match_handlers.each { |handler| handler.call match, self }
236
+ end
237
+
238
+ # Send exception to each of the registered observers. Includes self
239
+ # as the second block parameter.
240
+ def notify_error_handlers exception
241
+ @ionian_error_handlers.each { |handler| handler.call exception, self }
207
242
  end
208
243
 
209
244
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ionian
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.11
4
+ version: 0.6.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alex McLain
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-01-23 00:00:00.000000000 Z
11
+ date: 2015-01-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake