ionian 0.6.5 → 0.6.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -114,6 +114,101 @@
114
114
 
115
115
 
116
116
 
117
+ <h2>Instance Attribute Summary <small>(<a href="#" class="summary_toggle">collapse</a>)</small></h2>
118
+ <ul class="summary">
119
+
120
+ <li class="public ">
121
+ <span class="summary_signature">
122
+
123
+ <a href="#interface-instance_method" title="#interface (instance method)">- (Object) <strong>interface</strong> </a>
124
+
125
+
126
+
127
+ </span>
128
+
129
+
130
+
131
+
132
+ <span class="note title readonly">readonly</span>
133
+
134
+
135
+
136
+
137
+
138
+
139
+
140
+
141
+
142
+ <span class="summary_desc"><div class='inline'>
143
+ <p>Interface to listen for clients.</p>
144
+ </div></span>
145
+
146
+ </li>
147
+
148
+
149
+ <li class="public ">
150
+ <span class="summary_signature">
151
+
152
+ <a href="#port-instance_method" title="#port (instance method)">- (Object) <strong>port</strong> </a>
153
+
154
+
155
+
156
+ </span>
157
+
158
+
159
+
160
+
161
+ <span class="note title readonly">readonly</span>
162
+
163
+
164
+
165
+
166
+
167
+
168
+
169
+
170
+
171
+ <span class="summary_desc"><div class='inline'>
172
+ <p>Port number to listen for clients.</p>
173
+ </div></span>
174
+
175
+ </li>
176
+
177
+
178
+ <li class="public ">
179
+ <span class="summary_signature">
180
+
181
+ <a href="#protocol-instance_method" title="#protocol (instance method)">- (Object) <strong>protocol</strong> </a>
182
+
183
+
184
+
185
+ (also: #protocol?)
186
+
187
+ </span>
188
+
189
+
190
+
191
+
192
+ <span class="note title readonly">readonly</span>
193
+
194
+
195
+
196
+
197
+
198
+
199
+
200
+
201
+
202
+ <span class="summary_desc"><div class='inline'>
203
+ <p>Returns a symbol of the type of protocol this socket uses: :tcp, :udp,
204
+ :unix.</p>
205
+ </div></span>
206
+
207
+ </li>
208
+
209
+
210
+ </ul>
211
+
117
212
 
118
213
 
119
214
 
@@ -300,7 +395,8 @@ Server opens listening socket on instantiation if this block is provided.</p>
300
395
 
301
396
  <p>Args:</p>
302
397
 
303
- <pre class="code ruby"><code class="ruby">interface: The address of the network interface to bind to.
398
+ <pre class="code ruby"><code class="ruby">port: Port number to listen for clients.
399
+ interface: The address of the network interface to bind to.
304
400
  Defaults to all.
305
401
  protocol: :tcp, :unix. Default is :tcp.</code></pre>
306
402
 
@@ -316,19 +412,6 @@ protocol: :tcp, :unix. Default is :tcp.</code></pre>
316
412
  <pre class="lines">
317
413
 
318
414
 
319
- 19
320
- 20
321
- 21
322
- 22
323
- 23
324
- 24
325
- 25
326
- 26
327
- 27
328
- 28
329
- 29
330
- 30
331
- 31
332
415
  32
333
416
  33
334
417
  34
@@ -344,35 +427,86 @@ protocol: :tcp, :unix. Default is :tcp.</code></pre>
344
427
  44
345
428
  45
346
429
  46
347
- 47</pre>
430
+ 47
431
+ 48
432
+ 49
433
+ 50
434
+ 51
435
+ 52
436
+ 53
437
+ 54
438
+ 55
439
+ 56
440
+ 57
441
+ 58
442
+ 59
443
+ 60
444
+ 61
445
+ 62
446
+ 63
447
+ 64
448
+ 65
449
+ 66
450
+ 67
451
+ 68
452
+ 69
453
+ 70
454
+ 71
455
+ 72
456
+ 73
457
+ 74
458
+ 75
459
+ 76
460
+ 77
461
+ 78
462
+ 79</pre>
348
463
  </td>
349
464
  <td>
350
- <pre class="code"><span class="info file"># File 'lib/ionian/server.rb', line 19</span>
465
+ <pre class="code"><span class="info file"># File 'lib/ionian/server.rb', line 32</span>
351
466
 
352
467
  <span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</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>
353
468
  <span class='ivar'>@accept_listeners</span> <span class='op'>=</span> <span class='lbracket'>[</span><span class='rbracket'>]</span>
354
469
  <span class='id identifier rubyid_register_accept_listener'>register_accept_listener</span> <span class='op'>&amp;</span><span class='id identifier rubyid_block'>block</span> <span class='kw'>if</span> <span class='id identifier rubyid_block_given?'>block_given?</span>
355
470
 
356
- <span class='ivar'>@interface</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'>:interface</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_end'>&#39;</span></span>
471
+ <span class='comment'># @interface = kwargs.fetch :interface, nil
472
+ </span> <span class='ivar'>@interface</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'>:interface</span><span class='comma'>,</span> <span class='kw'>nil</span>
357
473
  <span class='ivar'>@port</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'>:port</span><span class='comma'>,</span> <span class='kw'>nil</span>
358
474
 
359
-
360
475
  <span class='comment'># Automatically select UDP for the multicast range. Otherwise default to TCP.
361
476
  </span> <span class='id identifier rubyid_default_protocol'>default_protocol</span> <span class='op'>=</span> <span class='symbol'>:tcp</span>
362
- <span class='comment'># TODO: This ivar may be incorrect for UDP -- bound interface is not destination.
363
- </span> <span class='id identifier rubyid_default_protocol'>default_protocol</span> <span class='op'>=</span> <span class='symbol'>:udp</span> <span class='kw'>if</span> <span class='const'>Ionian</span><span class='op'>::</span><span class='const'>Extension</span><span class='op'>::</span><span class='const'>Socket</span><span class='period'>.</span><span class='id identifier rubyid_multicast?'>multicast?</span> <span class='ivar'>@interface</span>
364
- <span class='id identifier rubyid_default_protocol'>default_protocol</span> <span class='op'>=</span> <span class='symbol'>:unix</span> <span class='kw'>if</span> <span class='ivar'>@interface</span><span class='period'>.</span><span class='id identifier rubyid_start_with?'>start_with?</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>/</span><span class='tstring_end'>&#39;</span></span>
477
+
478
+ <span class='kw'>if</span> <span class='ivar'>@interface</span>
479
+ <span class='comment'># TODO: This ivar may be incorrect for UDP -- bound interface is not destination.
480
+ </span> <span class='id identifier rubyid_default_protocol'>default_protocol</span> <span class='op'>=</span> <span class='symbol'>:udp</span> <span class='kw'>if</span> <span class='const'>Ionian</span><span class='op'>::</span><span class='const'>Extension</span><span class='op'>::</span><span class='const'>Socket</span><span class='period'>.</span><span class='id identifier rubyid_multicast?'>multicast?</span> <span class='ivar'>@interface</span>
481
+ <span class='id identifier rubyid_default_protocol'>default_protocol</span> <span class='op'>=</span> <span class='symbol'>:unix</span> <span class='kw'>if</span> <span class='ivar'>@interface</span><span class='period'>.</span><span class='id identifier rubyid_start_with?'>start_with?</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>/</span><span class='tstring_end'>&#39;</span></span>
482
+ <span class='kw'>end</span>
365
483
 
366
484
  <span class='ivar'>@protocol</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'>:protocol</span><span class='comma'>,</span> <span class='id identifier rubyid_default_protocol'>default_protocol</span>
367
485
 
486
+
368
487
  <span class='comment'># TODO: Move this to #listen.
369
488
  </span> <span class='kw'>case</span> <span class='ivar'>@protocol</span>
370
489
  <span class='kw'>when</span> <span class='symbol'>:tcp</span>
490
+ <span class='ivar'>@interface</span> <span class='op'>||=</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>0.0.0.0</span><span class='tstring_end'>&#39;</span></span> <span class='comment'># All interfaces.
491
+ </span>
492
+ <span class='comment'># Parse host out of &quot;host:port&quot; if specified.
493
+ </span> <span class='id identifier rubyid_host_port_ary'>host_port_ary</span> <span class='op'>=</span> <span class='ivar'>@interface</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span><span class='period'>.</span><span class='id identifier rubyid_split'>split</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>:</span><span class='tstring_end'>&#39;</span></span>
494
+ <span class='ivar'>@interface</span> <span class='op'>=</span> <span class='id identifier rubyid_host_port_ary'>host_port_ary</span><span class='lbracket'>[</span><span class='int'>0</span><span class='rbracket'>]</span>
495
+ <span class='ivar'>@port</span> <span class='op'>||=</span> <span class='id identifier rubyid_host_port_ary'>host_port_ary</span><span class='lbracket'>[</span><span class='int'>1</span><span class='rbracket'>]</span>
496
+
497
+ <span class='comment'># TODO: Parse port from interface if TCP.
498
+ </span> <span class='id identifier rubyid_raise'>raise</span> <span class='const'>ArgumentError</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Port not specified.</span><span class='tstring_end'>&quot;</span></span> <span class='kw'>unless</span> <span class='ivar'>@port</span>
499
+ <span class='ivar'>@port</span> <span class='op'>=</span> <span class='ivar'>@port</span><span class='period'>.</span><span class='id identifier rubyid_to_i'>to_i</span>
500
+
371
501
  <span class='ivar'>@server</span> <span class='op'>=</span> <span class='const'>TCPServer</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span> <span class='ivar'>@interface</span><span class='comma'>,</span> <span class='ivar'>@port</span>
372
502
  <span class='ivar'>@server</span><span class='period'>.</span><span class='id identifier rubyid_setsockopt'>setsockopt</span> <span class='op'>::</span><span class='const'>Socket</span><span class='op'>::</span><span class='const'>SOL_SOCKET</span><span class='comma'>,</span> <span class='op'>::</span><span class='const'>Socket</span><span class='op'>::</span><span class='const'>SO_REUSEADDR</span><span class='comma'>,</span> <span class='lbracket'>[</span><span class='int'>1</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_pack'>pack</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>i</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span>
503
+
373
504
  <span class='kw'>when</span> <span class='symbol'>:udp</span>
374
505
  <span class='id identifier rubyid_raise'>raise</span> <span class='const'>ArgumentError</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>UDP should be implemented with Ionian::Socket.</span><span class='tstring_end'>&quot;</span></span>
506
+
375
507
  <span class='kw'>when</span> <span class='symbol'>:unix</span>
508
+ <span class='id identifier rubyid_raise'>raise</span> <span class='const'>ArgumentError</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Path not specified.</span><span class='tstring_end'>&quot;</span></span> <span class='kw'>unless</span> <span class='ivar'>@interface</span>
509
+
376
510
  <span class='ivar'>@server</span> <span class='op'>=</span> <span class='const'>UNIXServer</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span> <span class='ivar'>@interface</span>
377
511
  <span class='kw'>end</span>
378
512
 
@@ -385,6 +519,145 @@ protocol: :tcp, :unix. Default is :tcp.</code></pre>
385
519
 
386
520
  </div>
387
521
 
522
+ <div id="instance_attr_details" class="attr_details">
523
+ <h2>Instance Attribute Details</h2>
524
+
525
+
526
+ <span id=""></span>
527
+ <div class="method_details first">
528
+ <h3 class="signature first" id="interface-instance_method">
529
+
530
+ - (<tt>Object</tt>) <strong>interface</strong> <span class="extras">(readonly)</span>
531
+
532
+
533
+
534
+
535
+
536
+ </h3><div class="docstring">
537
+ <div class="discussion">
538
+
539
+ <p>Interface to listen for clients.</p>
540
+
541
+
542
+ </div>
543
+ </div>
544
+ <div class="tags">
545
+
546
+
547
+ </div><table class="source_code">
548
+ <tr>
549
+ <td>
550
+ <pre class="lines">
551
+
552
+
553
+ 10
554
+ 11
555
+ 12</pre>
556
+ </td>
557
+ <td>
558
+ <pre class="code"><span class="info file"># File 'lib/ionian/server.rb', line 10</span>
559
+
560
+ <span class='kw'>def</span> <span class='id identifier rubyid_interface'>interface</span>
561
+ <span class='ivar'>@interface</span>
562
+ <span class='kw'>end</span></pre>
563
+ </td>
564
+ </tr>
565
+ </table>
566
+ </div>
567
+
568
+
569
+ <span id=""></span>
570
+ <div class="method_details ">
571
+ <h3 class="signature " id="port-instance_method">
572
+
573
+ - (<tt>Object</tt>) <strong>port</strong> <span class="extras">(readonly)</span>
574
+
575
+
576
+
577
+
578
+
579
+ </h3><div class="docstring">
580
+ <div class="discussion">
581
+
582
+ <p>Port number to listen for clients.</p>
583
+
584
+
585
+ </div>
586
+ </div>
587
+ <div class="tags">
588
+
589
+
590
+ </div><table class="source_code">
591
+ <tr>
592
+ <td>
593
+ <pre class="lines">
594
+
595
+
596
+ 13
597
+ 14
598
+ 15</pre>
599
+ </td>
600
+ <td>
601
+ <pre class="code"><span class="info file"># File 'lib/ionian/server.rb', line 13</span>
602
+
603
+ <span class='kw'>def</span> <span class='id identifier rubyid_port'>port</span>
604
+ <span class='ivar'>@port</span>
605
+ <span class='kw'>end</span></pre>
606
+ </td>
607
+ </tr>
608
+ </table>
609
+ </div>
610
+
611
+
612
+ <span id=""></span>
613
+ <div class="method_details ">
614
+ <h3 class="signature " id="protocol-instance_method">
615
+
616
+ - (<tt>Object</tt>) <strong>protocol</strong> <span class="extras">(readonly)</span>
617
+
618
+
619
+
620
+ <span class="aliases">Also known as:
621
+ <span class="names"><span id='protocol?-instance_method'>protocol?</span></span>
622
+ </span>
623
+
624
+
625
+
626
+ </h3><div class="docstring">
627
+ <div class="discussion">
628
+
629
+ <p>Returns a symbol of the type of protocol this socket uses: :tcp, :udp,
630
+ :unix</p>
631
+
632
+
633
+ </div>
634
+ </div>
635
+ <div class="tags">
636
+
637
+
638
+ </div><table class="source_code">
639
+ <tr>
640
+ <td>
641
+ <pre class="lines">
642
+
643
+
644
+ 17
645
+ 18
646
+ 19</pre>
647
+ </td>
648
+ <td>
649
+ <pre class="code"><span class="info file"># File 'lib/ionian/server.rb', line 17</span>
650
+
651
+ <span class='kw'>def</span> <span class='id identifier rubyid_protocol'>protocol</span>
652
+ <span class='ivar'>@protocol</span>
653
+ <span class='kw'>end</span></pre>
654
+ </td>
655
+ </tr>
656
+ </table>
657
+ </div>
658
+
659
+ </div>
660
+
388
661
 
389
662
  <div id="instance_method_details" class="method_details_list">
390
663
  <h2>Instance Method Details</h2>
@@ -416,14 +689,14 @@ protocol: :tcp, :unix. Default is :tcp.</code></pre>
416
689
  <pre class="lines">
417
690
 
418
691
 
419
- 74
420
- 75
421
- 76
422
- 77
423
- 78</pre>
692
+ 106
693
+ 107
694
+ 108
695
+ 109
696
+ 110</pre>
424
697
  </td>
425
698
  <td>
426
- <pre class="code"><span class="info file"># File 'lib/ionian/server.rb', line 74</span>
699
+ <pre class="code"><span class="info file"># File 'lib/ionian/server.rb', line 106</span>
427
700
 
428
701
  <span class='kw'>def</span> <span class='id identifier rubyid_close'>close</span>
429
702
  <span class='ivar'>@server</span><span class='period'>.</span><span class='id identifier rubyid_close'>close</span> <span class='kw'>if</span> <span class='ivar'>@server</span>
@@ -474,12 +747,12 @@ protocol: :tcp, :unix. Default is :tcp.</code></pre>
474
747
  <pre class="lines">
475
748
 
476
749
 
477
- 81
478
- 82
479
- 83</pre>
750
+ 113
751
+ 114
752
+ 115</pre>
480
753
  </td>
481
754
  <td>
482
- <pre class="code"><span class="info file"># File 'lib/ionian/server.rb', line 81</span>
755
+ <pre class="code"><span class="info file"># File 'lib/ionian/server.rb', line 113</span>
483
756
 
484
757
  <span class='kw'>def</span> <span class='id identifier rubyid_closed?'>closed?</span>
485
758
  <span class='ivar'>@server</span><span class='period'>.</span><span class='id identifier rubyid_closed?'>closed?</span>
@@ -516,29 +789,29 @@ protocol: :tcp, :unix. Default is :tcp.</code></pre>
516
789
  <pre class="lines">
517
790
 
518
791
 
519
- 52
520
- 53
521
- 54
522
- 55
523
- 56
524
- 57
525
- 58
526
- 59
527
- 60
528
- 61
529
- 62
530
- 63
531
- 64
532
- 65
533
- 66
534
- 67
535
- 68
536
- 69
537
- 70
538
- 71</pre>
792
+ 84
793
+ 85
794
+ 86
795
+ 87
796
+ 88
797
+ 89
798
+ 90
799
+ 91
800
+ 92
801
+ 93
802
+ 94
803
+ 95
804
+ 96
805
+ 97
806
+ 98
807
+ 99
808
+ 100
809
+ 101
810
+ 102
811
+ 103</pre>
539
812
  </td>
540
813
  <td>
541
- <pre class="code"><span class="info file"># File 'lib/ionian/server.rb', line 52</span>
814
+ <pre class="code"><span class="info file"># File 'lib/ionian/server.rb', line 84</span>
542
815
 
543
816
  <span class='kw'>def</span> <span class='id identifier rubyid_listen'>listen</span> <span class='op'>&amp;</span><span class='id identifier rubyid_block'>block</span>
544
817
  <span class='id identifier rubyid_register_accept_listener'>register_accept_listener</span> <span class='op'>&amp;</span><span class='id identifier rubyid_block'>block</span> <span class='kw'>if</span> <span class='id identifier rubyid_block_given?'>block_given?</span>
@@ -596,13 +869,13 @@ connected client is passed to the block as an Ionain::Client.</p>
596
869
  <pre class="lines">
597
870
 
598
871
 
599
- 87
600
- 88
601
- 89
602
- 90</pre>
872
+ 119
873
+ 120
874
+ 121
875
+ 122</pre>
603
876
  </td>
604
877
  <td>
605
- <pre class="code"><span class="info file"># File 'lib/ionian/server.rb', line 87</span>
878
+ <pre class="code"><span class="info file"># File 'lib/ionian/server.rb', line 119</span>
606
879
 
607
880
  <span class='kw'>def</span> <span class='id identifier rubyid_register_accept_listener'>register_accept_listener</span> <span class='op'>&amp;</span><span class='id identifier rubyid_block'>block</span>
608
881
  <span class='ivar'>@accept_listeners</span> <span class='op'>&lt;&lt;</span> <span class='id identifier rubyid_block'>block</span> <span class='kw'>unless</span> <span class='ivar'>@accept_listeners</span><span class='period'>.</span><span class='id identifier rubyid_include?'>include?</span> <span class='id identifier rubyid_block'>block</span>
@@ -639,16 +912,16 @@ connected client is passed to the block as an Ionain::Client.</p>
639
912
  <pre class="lines">
640
913
 
641
914
 
642
- 95
643
- 96
644
- 97
645
- 98</pre>
915
+ 127
916
+ 128
917
+ 129
918
+ 130</pre>
646
919
  </td>
647
920
  <td>
648
- <pre class="code"><span class="info file"># File 'lib/ionian/server.rb', line 95</span>
921
+ <pre class="code"><span class="info file"># File 'lib/ionian/server.rb', line 127</span>
649
922
 
650
923
  <span class='kw'>def</span> <span class='id identifier rubyid_unregister_accept_listener'>unregister_accept_listener</span> <span class='id identifier rubyid_proc'>proc</span>
651
- <span class='ivar'>@accept_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_proc'>proc</span><span class='rbrace'>}</span>
924
+ <span class='ivar'>@accept_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_proc'>proc</span> <span class='rbrace'>}</span>
652
925
  <span class='id identifier rubyid_proc'>proc</span>
653
926
  <span class='kw'>end</span></pre>
654
927
  </td>
@@ -661,7 +934,7 @@ connected client is passed to the block as an Ionain::Client.</p>
661
934
  </div>
662
935
 
663
936
  <div id="footer">
664
- Generated on Fri Apr 11 21:18:17 2014 by
937
+ Generated on Sat Apr 12 13:24:31 2014 by
665
938
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
666
939
  0.8.7.4 (ruby-2.1.1).
667
940
  </div>