ionian 0.6.0 → 0.6.1

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: 964e038d726e1d4df50ee1d0bc9a12efcc48ddfe
4
- data.tar.gz: f277619e42d62b1fbd764cb3ed2130fd69f4edd4
3
+ metadata.gz: 5bf6ad6b7843ed3ef7ebc1fd83e43f4b33f3d167
4
+ data.tar.gz: b76ab62698c36c925283444132a9bd568b63ae22
5
5
  SHA512:
6
- metadata.gz: 7a3eabd8146f2317a6594ea9260232bb49664ddcb50d38ad2f4b9d0e96025b58c7f974c67594323ea9ad7e4f66faf8bad5e31e55162f905efeb54b6c40558b80
7
- data.tar.gz: df0226142d2dbd26ecceb16628745a66d4f31a0c5c6bd0125dc42b93138fbb415b986a59471cb11d891f6c14b7ef79d67094f88247ac1768b6ec7c91c5c65bd8
6
+ metadata.gz: e6cf447c0f1858c87397ac08b6dffe363fa9c5714607351c032b38b1b5461d36c0ef7708e8abddb8e31111a53ede9bacd577b1d0ed4449f88f4d248942972fcf
7
+ data.tar.gz: f0623d616b5232ffc8c01a8f32ddc488c7892d90266f03b91e728b6b74159638d8c2d1b035005eb1dda981037763c5688aedb44280eb2c3ba914155d1e9955b0
@@ -390,7 +390,7 @@ automatically.</p>
390
390
 
391
391
 
392
392
  <div class="method-source-code" id="purge-source">
393
- <pre><span class="ruby-comment"># File lib/ionian/extension/io.rb, line 143</span>
393
+ <pre><span class="ruby-comment"># File lib/ionian/extension/io.rb, line 151</span>
394
394
  <span class="ruby-keyword">def</span> <span class="ruby-identifier">purge</span>
395
395
  <span class="ruby-comment"># Erase IO buffer.</span>
396
396
  <span class="ruby-keyword">while</span> <span class="ruby-operator">::</span><span class="ruby-constant">IO</span>.<span class="ruby-identifier">select</span> [<span class="ruby-keyword">self</span>], <span class="ruby-keyword">nil</span>, <span class="ruby-keyword">nil</span>, <span class="ruby-value">0</span>
@@ -476,6 +476,9 @@ helpful for protocols like RS232 that do not have packet boundries.</p>
476
476
  <p>kwargs:</p>
477
477
 
478
478
  <pre>timeout: Timeout in seconds IO::select will block.
479
+ expression: Override the expression match for this single
480
+ method call.
481
+ notify: Set to false to skip notifying match listener procs.
479
482
  skip_select: Skip over the IO::select statement. Use if you
480
483
  are calling IO::select ahead of this method.
481
484
  build_methods: Build accessor methods from named capture groups.
@@ -485,11 +488,15 @@ build_methods: Build accessor methods from named capture groups.
485
488
 
486
489
 
487
490
  <div class="method-source-code" id="read_match-source">
488
- <pre><span class="ruby-comment"># File lib/ionian/extension/io.rb, line 83</span>
491
+ <pre><span class="ruby-comment"># File lib/ionian/extension/io.rb, line 86</span>
489
492
  <span class="ruby-keyword">def</span> <span class="ruby-identifier">read_match</span>(<span class="ruby-operator">**</span><span class="ruby-identifier">kwargs</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>)
490
- <span class="ruby-identifier">timeout</span> = <span class="ruby-identifier">kwargs</span>.<span class="ruby-identifier">fetch</span> <span class="ruby-value">:timeout</span>, <span class="ruby-ivar">@ionian_timeout</span>
491
- <span class="ruby-identifier">skip_select</span> = <span class="ruby-identifier">kwargs</span>.<span class="ruby-identifier">fetch</span> <span class="ruby-value">:skip_select</span>, <span class="ruby-ivar">@ionian_skip_select</span>
492
- <span class="ruby-identifier">build_methods</span> = <span class="ruby-identifier">kwargs</span>.<span class="ruby-identifier">fetch</span> <span class="ruby-value">:build_methods</span>, <span class="ruby-ivar">@ionian_build_methods</span>
493
+ <span class="ruby-identifier">timeout</span> = <span class="ruby-identifier">kwargs</span>.<span class="ruby-identifier">fetch</span> <span class="ruby-value">:timeout</span>, <span class="ruby-ivar">@ionian_timeout</span>
494
+ <span class="ruby-identifier">notify</span> = <span class="ruby-identifier">kwargs</span>.<span class="ruby-identifier">fetch</span> <span class="ruby-value">:notify</span>, <span class="ruby-keyword">true</span>
495
+ <span class="ruby-identifier">skip_select</span> = <span class="ruby-identifier">kwargs</span>.<span class="ruby-identifier">fetch</span> <span class="ruby-value">:skip_select</span>, <span class="ruby-ivar">@ionian_skip_select</span>
496
+ <span class="ruby-identifier">build_methods</span> = <span class="ruby-identifier">kwargs</span>.<span class="ruby-identifier">fetch</span> <span class="ruby-value">:build_methods</span>, <span class="ruby-ivar">@ionian_build_methods</span>
497
+
498
+ <span class="ruby-identifier">exp</span> = <span class="ruby-identifier">kwargs</span>.<span class="ruby-identifier">fetch</span> <span class="ruby-value">:expression</span>, <span class="ruby-ivar">@ionian_expression</span>
499
+ <span class="ruby-identifier">exp</span> = <span class="ruby-constant">Regexp</span>.<span class="ruby-identifier">new</span> <span class="ruby-node">&quot;(.*?)#{exp}&quot;</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">exp</span>.<span class="ruby-identifier">is_a?</span> <span class="ruby-constant">String</span>
493
500
 
494
501
  <span class="ruby-keyword">unless</span> <span class="ruby-identifier">skip_select</span>
495
502
  <span class="ruby-keyword">return</span> <span class="ruby-keyword">nil</span> <span class="ruby-keyword">unless</span> <span class="ruby-operator">::</span><span class="ruby-constant">IO</span>.<span class="ruby-identifier">select</span> [<span class="ruby-keyword">self</span>], <span class="ruby-keyword">nil</span>, <span class="ruby-keyword">nil</span>, <span class="ruby-identifier">timeout</span>
@@ -503,7 +510,7 @@ build_methods: Build accessor methods from named capture groups.
503
510
 
504
511
  <span class="ruby-ivar">@matches</span> = []
505
512
 
506
- <span class="ruby-keyword">while</span> <span class="ruby-ivar">@ionian_buf</span> <span class="ruby-operator">=~</span> <span class="ruby-ivar">@ionian_expression</span>
513
+ <span class="ruby-keyword">while</span> <span class="ruby-ivar">@ionian_buf</span> <span class="ruby-operator">=~</span> <span class="ruby-identifier">exp</span>
507
514
  <span class="ruby-ivar">@matches</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">$~</span> <span class="ruby-comment"># Match data.</span>
508
515
  <span class="ruby-keyword">yield</span> <span class="ruby-identifier">$~</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">block_given?</span>
509
516
  <span class="ruby-ivar">@ionian_buf</span> = <span class="ruby-node">$&#39;</span> <span class="ruby-comment"># Leave post match data in the buffer.</span>
@@ -520,6 +527,9 @@ build_methods: Build accessor methods from named capture groups.
520
527
  <span class="ruby-keyword">end</span>
521
528
  <span class="ruby-keyword">end</span>
522
529
 
530
+ <span class="ruby-comment"># Notify on_match listeners.</span>
531
+ <span class="ruby-ivar">@matches</span>.<span class="ruby-identifier">each</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">match</span><span class="ruby-operator">|</span> <span class="ruby-identifier">notify_listeners</span> <span class="ruby-identifier">match</span>} <span class="ruby-keyword">if</span> <span class="ruby-identifier">notify</span>
532
+
523
533
  <span class="ruby-ivar">@matches</span>
524
534
  <span class="ruby-keyword">end</span></pre>
525
535
  </div>
@@ -555,7 +565,7 @@ ionian_socket.register_observer {…}</p>
555
565
 
556
566
 
557
567
  <div class="method-source-code" id="register_observer-source">
558
- <pre><span class="ruby-comment"># File lib/ionian/extension/io.rb, line 156</span>
568
+ <pre><span class="ruby-comment"># File lib/ionian/extension/io.rb, line 164</span>
559
569
  <span class="ruby-keyword">def</span> <span class="ruby-identifier">register_observer</span>(<span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>)
560
570
  <span class="ruby-ivar">@ionian_listeners</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">block</span> <span class="ruby-keyword">unless</span> <span class="ruby-ivar">@ionian_listeners</span>.<span class="ruby-identifier">include?</span> <span class="ruby-identifier">block</span>
561
571
  <span class="ruby-identifier">block</span>
@@ -596,15 +606,13 @@ be used if <a href="IO.html#method-i-read_match">read_match</a> is used.</p>
596
606
 
597
607
 
598
608
  <div class="method-source-code" id="run_match-source">
599
- <pre><span class="ruby-comment"># File lib/ionian/extension/io.rb, line 124</span>
609
+ <pre><span class="ruby-comment"># File lib/ionian/extension/io.rb, line 134</span>
600
610
  <span class="ruby-keyword">def</span> <span class="ruby-identifier">run_match</span>(<span class="ruby-operator">**</span><span class="ruby-identifier">kwargs</span>)
601
611
  <span class="ruby-ivar">@match_listener</span> <span class="ruby-operator">||=</span> <span class="ruby-constant">Thread</span>.<span class="ruby-identifier">new</span> <span class="ruby-keyword">do</span>
602
612
  <span class="ruby-keyword">begin</span>
603
613
  <span class="ruby-keyword">while</span> <span class="ruby-keyword">not</span> <span class="ruby-identifier">closed?</span> <span class="ruby-keyword">do</span>
604
- <span class="ruby-identifier">matches</span> = <span class="ruby-identifier">read_match</span> <span class="ruby-identifier">kwargs</span>
605
- <span class="ruby-identifier">matches</span>.<span class="ruby-identifier">each</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">match</span><span class="ruby-operator">|</span>
606
- <span class="ruby-ivar">@ionian_listeners</span>.<span class="ruby-identifier">each</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">listener</span><span class="ruby-operator">|</span> <span class="ruby-identifier">listener</span>.<span class="ruby-identifier">call</span> <span class="ruby-identifier">match</span>, <span class="ruby-keyword">self</span>}
607
- } <span class="ruby-keyword">if</span> <span class="ruby-identifier">matches</span>
614
+ <span class="ruby-identifier">matches</span> = <span class="ruby-identifier">read_match</span> <span class="ruby-operator">**</span><span class="ruby-identifier">kwargs</span>
615
+ <span class="ruby-identifier">matches</span>.<span class="ruby-identifier">each</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">match</span><span class="ruby-operator">|</span> <span class="ruby-identifier">notify_listeners</span> <span class="ruby-identifier">match</span> } <span class="ruby-keyword">if</span> <span class="ruby-identifier">matches</span>
608
616
  <span class="ruby-keyword">end</span>
609
617
  <span class="ruby-keyword">rescue</span> <span class="ruby-constant">EOFError</span>
610
618
  <span class="ruby-keyword">rescue</span> <span class="ruby-constant">IOError</span>
@@ -642,7 +650,7 @@ be used if <a href="IO.html#method-i-read_match">read_match</a> is used.</p>
642
650
 
643
651
 
644
652
  <div class="method-source-code" id="unregister_observer-source">
645
- <pre><span class="ruby-comment"># File lib/ionian/extension/io.rb, line 164</span>
653
+ <pre><span class="ruby-comment"># File lib/ionian/extension/io.rb, line 172</span>
646
654
  <span class="ruby-keyword">def</span> <span class="ruby-identifier">unregister_observer</span>(<span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>)
647
655
  <span class="ruby-ivar">@ionian_listeners</span>.<span class="ruby-identifier">delete_if</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">o</span><span class="ruby-operator">|</span> <span class="ruby-identifier">o</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">block</span>}
648
656
  <span class="ruby-identifier">block</span>
@@ -708,13 +708,13 @@ IP_MULTICAST_TTL )</p>
708
708
 
709
709
  <div class="method-description">
710
710
 
711
-
711
+ <p>Not yet implemented.</p>
712
712
 
713
713
 
714
714
 
715
715
 
716
716
  <div class="method-source-code" id="ipv6_add_membership-source">
717
- <pre><span class="ruby-comment"># File lib/ionian/extension/socket.rb, line 188</span>
717
+ <pre><span class="ruby-comment"># File lib/ionian/extension/socket.rb, line 189</span>
718
718
  <span class="ruby-keyword">def</span> <span class="ruby-identifier">ipv6_add_membership</span>
719
719
  <span class="ruby-comment"># TODO: Implement</span>
720
720
  <span class="ruby-keyword">false</span>
@@ -742,13 +742,13 @@ IP_MULTICAST_TTL )</p>
742
742
 
743
743
  <div class="method-description">
744
744
 
745
-
745
+ <p>Not yet implemented.</p>
746
746
 
747
747
 
748
748
 
749
749
 
750
750
  <div class="method-source-code" id="ipv6_drop_membership-source">
751
- <pre><span class="ruby-comment"># File lib/ionian/extension/socket.rb, line 193</span>
751
+ <pre><span class="ruby-comment"># File lib/ionian/extension/socket.rb, line 195</span>
752
752
  <span class="ruby-keyword">def</span> <span class="ruby-identifier">ipv6_drop_membership</span>
753
753
  <span class="ruby-comment"># TODO: Implement</span>
754
754
  <span class="ruby-keyword">false</span>
@@ -776,13 +776,13 @@ IP_MULTICAST_TTL )</p>
776
776
 
777
777
  <div class="method-description">
778
778
 
779
-
779
+ <p>Not yet implemented.</p>
780
780
 
781
781
 
782
782
 
783
783
 
784
784
  <div class="method-source-code" id="ipv6_multicast_hops-source">
785
- <pre><span class="ruby-comment"># File lib/ionian/extension/socket.rb, line 207</span>
785
+ <pre><span class="ruby-comment"># File lib/ionian/extension/socket.rb, line 212</span>
786
786
  <span class="ruby-keyword">def</span> <span class="ruby-identifier">ipv6_multicast_hops</span>
787
787
  <span class="ruby-comment"># TODO: Implement</span>
788
788
  <span class="ruby-keyword">false</span>
@@ -810,13 +810,13 @@ IP_MULTICAST_TTL )</p>
810
810
 
811
811
  <div class="method-description">
812
812
 
813
-
813
+ <p>Not yet implemented.</p>
814
814
 
815
815
 
816
816
 
817
817
 
818
818
  <div class="method-source-code" id="ipv6_multicast_hops-3D-source">
819
- <pre><span class="ruby-comment"># File lib/ionian/extension/socket.rb, line 212</span>
819
+ <pre><span class="ruby-comment"># File lib/ionian/extension/socket.rb, line 218</span>
820
820
  <span class="ruby-keyword">def</span> <span class="ruby-identifier">ipv6_multicast_hops=</span>(<span class="ruby-identifier">value</span>)
821
821
  <span class="ruby-comment"># TODO: Implement</span>
822
822
  <span class="ruby-keyword">end</span></pre>
@@ -843,13 +843,13 @@ IP_MULTICAST_TTL )</p>
843
843
 
844
844
  <div class="method-description">
845
845
 
846
-
846
+ <p>Not yet implemented.</p>
847
847
 
848
848
 
849
849
 
850
850
 
851
851
  <div class="method-source-code" id="ipv6_multicast_if-source">
852
- <pre><span class="ruby-comment"># File lib/ionian/extension/socket.rb, line 198</span>
852
+ <pre><span class="ruby-comment"># File lib/ionian/extension/socket.rb, line 201</span>
853
853
  <span class="ruby-keyword">def</span> <span class="ruby-identifier">ipv6_multicast_if</span>
854
854
  <span class="ruby-comment"># TODO: Implement</span>
855
855
  <span class="ruby-keyword">false</span>
@@ -877,13 +877,13 @@ IP_MULTICAST_TTL )</p>
877
877
 
878
878
  <div class="method-description">
879
879
 
880
-
880
+ <p>Not yet implemented.</p>
881
881
 
882
882
 
883
883
 
884
884
 
885
885
  <div class="method-source-code" id="ipv6_multicast_if-3D-source">
886
- <pre><span class="ruby-comment"># File lib/ionian/extension/socket.rb, line 203</span>
886
+ <pre><span class="ruby-comment"># File lib/ionian/extension/socket.rb, line 207</span>
887
887
  <span class="ruby-keyword">def</span> <span class="ruby-identifier">ipv6_multicast_if=</span>(<span class="ruby-identifier">value</span>)
888
888
  <span class="ruby-comment"># TODO: Implement</span>
889
889
  <span class="ruby-keyword">end</span></pre>
@@ -910,13 +910,13 @@ IP_MULTICAST_TTL )</p>
910
910
 
911
911
  <div class="method-description">
912
912
 
913
-
913
+ <p>Not yet implemented.</p>
914
914
 
915
915
 
916
916
 
917
917
 
918
918
  <div class="method-source-code" id="ipv6_multicast_loop-source">
919
- <pre><span class="ruby-comment"># File lib/ionian/extension/socket.rb, line 216</span>
919
+ <pre><span class="ruby-comment"># File lib/ionian/extension/socket.rb, line 223</span>
920
920
  <span class="ruby-keyword">def</span> <span class="ruby-identifier">ipv6_multicast_loop</span>
921
921
  <span class="ruby-comment"># TODO: Implement</span>
922
922
  <span class="ruby-keyword">false</span>
@@ -948,13 +948,13 @@ IP_MULTICAST_TTL )</p>
948
948
 
949
949
  <div class="method-description">
950
950
 
951
-
951
+ <p>Not yet implemented.</p>
952
952
 
953
953
 
954
954
 
955
955
 
956
956
  <div class="method-source-code" id="ipv6_multicast_loop-3D-source">
957
- <pre><span class="ruby-comment"># File lib/ionian/extension/socket.rb, line 223</span>
957
+ <pre><span class="ruby-comment"># File lib/ionian/extension/socket.rb, line 231</span>
958
958
  <span class="ruby-keyword">def</span> <span class="ruby-identifier">ipv6_multicast_loop=</span>(<span class="ruby-identifier">value</span>)
959
959
  <span class="ruby-comment"># TODO: Implement</span>
960
960
  <span class="ruby-keyword">end</span></pre>
@@ -1015,7 +1015,7 @@ IP_MULTICAST_TTL )</p>
1015
1015
 
1016
1016
 
1017
1017
  <div class="method-source-code" id="multicast-source">
1018
- <pre><span class="ruby-comment"># File lib/ionian/extension/socket.rb, line 230</span>
1018
+ <pre><span class="ruby-comment"># File lib/ionian/extension/socket.rb, line 238</span>
1019
1019
  <span class="ruby-keyword">def</span> <span class="ruby-identifier">multicast</span>(<span class="ruby-identifier">address</span>)
1020
1020
  <span class="ruby-identifier">address</span> <span class="ruby-operator">&gt;=</span> <span class="ruby-string">&#39;224.0.0.0&#39;</span> <span class="ruby-keyword">and</span> <span class="ruby-identifier">address</span> <span class="ruby-operator">&lt;=</span> <span class="ruby-string">&#39;239.255.255.255&#39;</span> <span class="ruby-operator">?</span> <span class="ruby-keyword">true</span> <span class="ruby-operator">:</span> <span class="ruby-keyword">false</span>
1021
1021
  <span class="ruby-keyword">end</span></pre>
@@ -134,13 +134,23 @@
134
134
 
135
135
  <div class="method-description">
136
136
 
137
-
137
+ <p>A convenient wrapper for TCP and Unix server sockets (UDP doesn&#39;t use a
138
+ server).</p>
139
+
140
+ <p>Accepts an optional block that is passed to <a
141
+ href="Server.html#method-i-register_accept_listener">register_accept_listener</a>.</p>
142
+
143
+ <p>Args:</p>
144
+
145
+ <pre>interface: The address of the network interface to bind to.
146
+ Defaults to all.
147
+ protocol: :tcp, :unix. Default is :tcp.</pre>
138
148
 
139
149
 
140
150
 
141
151
 
142
152
  <div class="method-source-code" id="new-source">
143
- <pre><span class="ruby-comment"># File lib/ionian/server.rb, line 9</span>
153
+ <pre><span class="ruby-comment"># File lib/ionian/server.rb, line 18</span>
144
154
  <span class="ruby-keyword">def</span> <span class="ruby-identifier">initialize</span> <span class="ruby-operator">**</span><span class="ruby-identifier">kwargs</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>
145
155
  <span class="ruby-ivar">@accept_listeners</span> = []
146
156
  <span class="ruby-identifier">register_accept_listener</span> <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">block_given?</span>
@@ -163,7 +173,7 @@
163
173
  <span class="ruby-ivar">@server</span> = <span class="ruby-constant">TCPServer</span>.<span class="ruby-identifier">new</span> <span class="ruby-ivar">@interface</span>, <span class="ruby-ivar">@port</span>
164
174
  <span class="ruby-ivar">@server</span>.<span class="ruby-identifier">setsockopt</span> <span class="ruby-operator">::</span><span class="ruby-constant">Socket</span><span class="ruby-operator">::</span><span class="ruby-constant">SOL_SOCKET</span>, <span class="ruby-operator">::</span><span class="ruby-constant">Socket</span><span class="ruby-operator">::</span><span class="ruby-constant">SO_REUSEADDR</span>, [<span class="ruby-value">1</span>].<span class="ruby-identifier">pack</span>(<span class="ruby-string">&#39;i&#39;</span>)
165
175
  <span class="ruby-keyword">when</span> <span class="ruby-value">:udp</span>
166
- <span class="ruby-ivar">@server</span> = <span class="ruby-constant">Ionian</span><span class="ruby-operator">::</span><span class="ruby-constant">Socket</span>.<span class="ruby-identifier">new</span> <span class="ruby-identifier">host</span><span class="ruby-operator">:</span> <span class="ruby-ivar">@interface</span>, <span class="ruby-identifier">port</span><span class="ruby-operator">:</span> <span class="ruby-ivar">@port</span>, <span class="ruby-identifier">protocol</span><span class="ruby-operator">:</span> <span class="ruby-value">:udp</span>
176
+ <span class="ruby-identifier">raise</span> <span class="ruby-constant">ArgumentError</span>, <span class="ruby-string">&quot;UDP should be implemented with Ionian::Socket.&quot;</span>
167
177
  <span class="ruby-keyword">when</span> <span class="ruby-value">:unix</span>
168
178
  <span class="ruby-ivar">@server</span> = <span class="ruby-constant">UNIXServer</span>.<span class="ruby-identifier">new</span> <span class="ruby-ivar">@interface</span>
169
179
  <span class="ruby-keyword">end</span>
@@ -205,7 +215,7 @@
205
215
 
206
216
 
207
217
  <div class="method-source-code" id="close-source">
208
- <pre><span class="ruby-comment"># File lib/ionian/server.rb, line 62</span>
218
+ <pre><span class="ruby-comment"># File lib/ionian/server.rb, line 71</span>
209
219
  <span class="ruby-keyword">def</span> <span class="ruby-identifier">close</span>
210
220
  <span class="ruby-ivar">@server</span>.<span class="ruby-identifier">close</span> <span class="ruby-keyword">if</span> <span class="ruby-ivar">@server</span>
211
221
  <span class="ruby-ivar">@accept_thread</span>.<span class="ruby-identifier">join</span> <span class="ruby-keyword">if</span> <span class="ruby-ivar">@accept_thread</span>
@@ -243,7 +253,7 @@ will be run when a connection is accepted.</p>
243
253
 
244
254
 
245
255
  <div class="method-source-code" id="listen-source">
246
- <pre><span class="ruby-comment"># File lib/ionian/server.rb, line 40</span>
256
+ <pre><span class="ruby-comment"># File lib/ionian/server.rb, line 49</span>
247
257
  <span class="ruby-keyword">def</span> <span class="ruby-identifier">listen</span> <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>
248
258
  <span class="ruby-identifier">register_accept_listener</span> <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">block_given?</span>
249
259
 
@@ -322,7 +332,7 @@ connected client is passed to the block as an Ionain::Client.</p>
322
332
 
323
333
 
324
334
  <div class="method-source-code" id="register_accept_listener-source">
325
- <pre><span class="ruby-comment"># File lib/ionian/server.rb, line 70</span>
335
+ <pre><span class="ruby-comment"># File lib/ionian/server.rb, line 79</span>
326
336
  <span class="ruby-keyword">def</span> <span class="ruby-identifier">register_accept_listener</span> <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>
327
337
  <span class="ruby-ivar">@accept_listeners</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">block</span> <span class="ruby-keyword">unless</span> <span class="ruby-ivar">@accept_listeners</span>.<span class="ruby-identifier">include?</span> <span class="ruby-identifier">block</span>
328
338
  <span class="ruby-identifier">block</span>
@@ -360,7 +370,7 @@ connected client is passed to the block as an Ionain::Client.</p>
360
370
 
361
371
 
362
372
  <div class="method-source-code" id="unregister_accept_listener-source">
363
- <pre><span class="ruby-comment"># File lib/ionian/server.rb, line 78</span>
373
+ <pre><span class="ruby-comment"># File lib/ionian/server.rb, line 87</span>
364
374
  <span class="ruby-keyword">def</span> <span class="ruby-identifier">unregister_accept_listener</span> <span class="ruby-identifier">proc</span>
365
375
  <span class="ruby-ivar">@accept_listeners</span>.<span class="ruby-identifier">delete_if</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">o</span><span class="ruby-operator">|</span> <span class="ruby-identifier">o</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">proc</span>}
366
376
  <span class="ruby-identifier">proc</span>
@@ -166,7 +166,7 @@
166
166
 
167
167
  <div class="method-description">
168
168
 
169
-
169
+ <p>Returns the regular expression used to match incoming data.</p>
170
170
 
171
171
  </div>
172
172
  </div>
@@ -245,7 +245,7 @@ expression: Overrides the #read_match regular expression for received data.</pre
245
245
 
246
246
 
247
247
  <div class="method-source-code" id="new-source">
248
- <pre><span class="ruby-comment"># File lib/ionian/socket.rb, line 26</span>
248
+ <pre><span class="ruby-comment"># File lib/ionian/socket.rb, line 27</span>
249
249
  <span class="ruby-keyword">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">existing_socket</span> = <span class="ruby-keyword">nil</span>, <span class="ruby-operator">**</span><span class="ruby-identifier">kwargs</span>)
250
250
  <span class="ruby-ivar">@socket</span> = <span class="ruby-identifier">existing_socket</span>
251
251
 
@@ -296,6 +296,7 @@ expression: Overrides the #read_match regular expression for received data.</pre
296
296
 
297
297
  <span class="ruby-ivar">@protocol</span> = <span class="ruby-identifier">kwargs</span>.<span class="ruby-identifier">fetch</span> <span class="ruby-value">:protocol</span>, <span class="ruby-identifier">default_protocol</span>
298
298
  <span class="ruby-ivar">@persistent</span> = <span class="ruby-identifier">kwargs</span>.<span class="ruby-identifier">fetch</span> <span class="ruby-value">:persistent</span>, <span class="ruby-keyword">true</span>
299
+ <span class="ruby-ivar">@persistent</span> = <span class="ruby-keyword">true</span> <span class="ruby-keyword">if</span> <span class="ruby-ivar">@protocol</span> <span class="ruby-operator">==</span> <span class="ruby-value">:udp</span>
299
300
 
300
301
  <span class="ruby-ivar">@reuse_addr</span> = <span class="ruby-identifier">kwargs</span>.<span class="ruby-identifier">fetch</span> <span class="ruby-value">:reuse_addr</span>, <span class="ruby-keyword">false</span>
301
302
  <span class="ruby-ivar">@no_delay</span> = <span class="ruby-identifier">kwargs</span>.<span class="ruby-identifier">fetch</span> <span class="ruby-value">:no_delay</span>, <span class="ruby-keyword">false</span>
@@ -370,7 +371,7 @@ expression: Overrides the #read_match regular expression for received data.</pre
370
371
 
371
372
 
372
373
  <div class="method-source-code" id="closed-3F-source">
373
- <pre><span class="ruby-comment"># File lib/ionian/socket.rb, line 148</span>
374
+ <pre><span class="ruby-comment"># File lib/ionian/socket.rb, line 150</span>
374
375
  <span class="ruby-keyword">def</span> <span class="ruby-identifier">closed?</span>
375
376
  <span class="ruby-keyword">return</span> <span class="ruby-keyword">true</span> <span class="ruby-keyword">unless</span> <span class="ruby-ivar">@socket</span>
376
377
  <span class="ruby-ivar">@socket</span>.<span class="ruby-identifier">closed?</span>
@@ -406,7 +407,7 @@ href="Extension/IO.html#method-i-read_match">Ionian::Extension::IO#read_match</a
406
407
 
407
408
 
408
409
  <div class="method-source-code" id="cmd-source">
409
- <pre><span class="ruby-comment"># File lib/ionian/socket.rb, line 100</span>
410
+ <pre><span class="ruby-comment"># File lib/ionian/socket.rb, line 102</span>
410
411
  <span class="ruby-keyword">def</span> <span class="ruby-identifier">cmd</span>(<span class="ruby-identifier">string</span>, <span class="ruby-operator">**</span><span class="ruby-identifier">kwargs</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>)
411
412
  <span class="ruby-identifier">create_socket</span> <span class="ruby-keyword">unless</span> <span class="ruby-ivar">@persistent</span>
412
413
 
@@ -453,7 +454,7 @@ non-persistent sockets.</p>
453
454
 
454
455
 
455
456
  <div class="method-source-code" id="flush-source">
456
- <pre><span class="ruby-comment"># File lib/ionian/socket.rb, line 155</span>
457
+ <pre><span class="ruby-comment"># File lib/ionian/socket.rb, line 157</span>
457
458
  <span class="ruby-keyword">def</span> <span class="ruby-identifier">flush</span>
458
459
  <span class="ruby-ivar">@socket</span>.<span class="ruby-identifier">flush</span> <span class="ruby-keyword">if</span> <span class="ruby-ivar">@persistent</span>
459
460
  <span class="ruby-keyword">end</span></pre>
@@ -489,7 +490,7 @@ non-persistent sockets.</p>
489
490
 
490
491
 
491
492
  <div class="method-source-code" id="has_data-3F-source">
492
- <pre><span class="ruby-comment"># File lib/ionian/socket.rb, line 142</span>
493
+ <pre><span class="ruby-comment"># File lib/ionian/socket.rb, line 144</span>
493
494
  <span class="ruby-keyword">def</span> <span class="ruby-identifier">has_data?</span>(<span class="ruby-operator">**</span><span class="ruby-identifier">kwargs</span>)
494
495
  <span class="ruby-keyword">return</span> <span class="ruby-keyword">false</span> <span class="ruby-keyword">unless</span> <span class="ruby-ivar">@socket</span>
495
496
  <span class="ruby-ivar">@socket</span>.<span class="ruby-identifier">has_data?</span> <span class="ruby-identifier">kwargs</span>
@@ -551,7 +552,7 @@ non-persistent sockets.</p>
551
552
 
552
553
 
553
554
  <div class="method-source-code" id="persistent-3F-source">
554
- <pre><span class="ruby-comment"># File lib/ionian/socket.rb, line 92</span>
555
+ <pre><span class="ruby-comment"># File lib/ionian/socket.rb, line 94</span>
555
556
  <span class="ruby-keyword">def</span> <span class="ruby-identifier">persistent?</span>
556
557
  <span class="ruby-ivar">@persistent</span> <span class="ruby-operator">==</span> <span class="ruby-keyword">false</span> <span class="ruby-operator">||</span> <span class="ruby-ivar">@persistent</span> <span class="ruby-operator">==</span> <span class="ruby-keyword">nil</span> <span class="ruby-operator">?</span> <span class="ruby-keyword">false</span> <span class="ruby-operator">:</span> <span class="ruby-keyword">true</span>
557
558
  <span class="ruby-keyword">end</span></pre>
@@ -585,7 +586,7 @@ any string not already ending with one.</p>
585
586
 
586
587
 
587
588
  <div class="method-source-code" id="puts-source">
588
- <pre><span class="ruby-comment"># File lib/ionian/socket.rb, line 161</span>
589
+ <pre><span class="ruby-comment"># File lib/ionian/socket.rb, line 163</span>
589
590
  <span class="ruby-keyword">def</span> <span class="ruby-identifier">puts</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">string</span>)
590
591
  <span class="ruby-keyword">self</span>.<span class="ruby-identifier">write</span> <span class="ruby-identifier">string</span>.<span class="ruby-identifier">map</span>{<span class="ruby-operator">|</span><span class="ruby-identifier">s</span><span class="ruby-operator">|</span> <span class="ruby-identifier">s</span>.<span class="ruby-identifier">chomp</span>}.<span class="ruby-identifier">join</span>(<span class="ruby-string">&quot;\n&quot;</span>) <span class="ruby-operator">+</span> <span class="ruby-string">&quot;\n&quot;</span>
591
592
  <span class="ruby-keyword">end</span></pre>
@@ -620,7 +621,7 @@ reference to the given block. block = ionian_socket.register_observer {…}</p>
620
621
 
621
622
 
622
623
  <div class="method-source-code" id="register_observer-source">
623
- <pre><span class="ruby-comment"># File lib/ionian/socket.rb, line 121</span>
624
+ <pre><span class="ruby-comment"># File lib/ionian/socket.rb, line 123</span>
624
625
  <span class="ruby-keyword">def</span> <span class="ruby-identifier">register_observer</span> <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>
625
626
  <span class="ruby-ivar">@ionian_listeners</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">block</span> <span class="ruby-keyword">unless</span> <span class="ruby-ivar">@ionian_listeners</span>.<span class="ruby-identifier">include?</span> <span class="ruby-identifier">block</span>
626
627
  <span class="ruby-ivar">@socket</span>.<span class="ruby-identifier">register_observer</span> <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span> <span class="ruby-keyword">if</span> <span class="ruby-ivar">@socket</span>
@@ -659,7 +660,7 @@ reference to the given block. block = ionian_socket.register_observer {…}</p>
659
660
 
660
661
 
661
662
  <div class="method-source-code" id="unregister_observer-source">
662
- <pre><span class="ruby-comment"># File lib/ionian/socket.rb, line 130</span>
663
+ <pre><span class="ruby-comment"># File lib/ionian/socket.rb, line 132</span>
663
664
  <span class="ruby-keyword">def</span> <span class="ruby-identifier">unregister_observer</span>(<span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>)
664
665
  <span class="ruby-ivar">@ionian_listeners</span>.<span class="ruby-identifier">delete_if</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">o</span><span class="ruby-operator">|</span> <span class="ruby-identifier">o</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">block</span>}
665
666
  <span class="ruby-ivar">@socket</span>.<span class="ruby-identifier">unregister_observer</span> <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span> <span class="ruby-keyword">if</span> <span class="ruby-ivar">@socket</span>
@@ -694,7 +695,7 @@ reference to the given block. block = ionian_socket.register_observer {…}</p>
694
695
 
695
696
 
696
697
  <div class="method-source-code" id="write-source">
697
- <pre><span class="ruby-comment"># File lib/ionian/socket.rb, line 167</span>
698
+ <pre><span class="ruby-comment"># File lib/ionian/socket.rb, line 169</span>
698
699
  <span class="ruby-keyword">def</span> <span class="ruby-identifier">write</span>(<span class="ruby-identifier">string</span>)
699
700
  <span class="ruby-identifier">create_socket</span> <span class="ruby-keyword">unless</span> <span class="ruby-ivar">@persistent</span>
700
701
 
data/doc/created.rid CHANGED
@@ -1,6 +1,6 @@
1
- Wed, 22 Jan 2014 18:32:41 -0800
2
- lib/ionian.rb Sun, 19 Jan 2014 22:25:27 -0800
3
- lib/ionian/extension/io.rb Thu, 16 Jan 2014 19:10:20 -0800
4
- lib/ionian/extension/socket.rb Sat, 07 Dec 2013 14:02:46 -0800
5
- lib/ionian/server.rb Wed, 22 Jan 2014 18:31:59 -0800
6
- lib/ionian/socket.rb Wed, 22 Jan 2014 18:14:29 -0800
1
+ Fri, 24 Jan 2014 22:04:49 -0800
2
+ lib/ionian.rb Mon, 20 Jan 2014 16:23:59 -0800
3
+ lib/ionian/extension/io.rb Fri, 24 Jan 2014 15:44:42 -0800
4
+ lib/ionian/extension/socket.rb Fri, 24 Jan 2014 22:04:33 -0800
5
+ lib/ionian/server.rb Fri, 24 Jan 2014 22:03:08 -0800
6
+ lib/ionian/socket.rb Fri, 24 Jan 2014 22:03:54 -0800
@@ -1 +1 @@
1
- var search_data = {"index":{"searchIndex":["ionian","extension","io","socket","server","socket","<<()","close()","closed?()","cmd()","cork()","cork=()","cork?()","expression()","expression=()","extended()","extended()","flush()","has_data?()","has_data?()","initialize_ionian()","initialize_ionian_socket()","ip_add_membership()","ip_drop_membership()","ip_multicast_if()","ip_multicast_if=()","ip_multicast_loop()","ip_multicast_loop=()","ip_multicast_loop?()","ip_multicast_ttl()","ip_multicast_ttl=()","ipv6_add_membership()","ipv6_drop_membership()","ipv6_multicast_hops()","ipv6_multicast_hops=()","ipv6_multicast_if()","ipv6_multicast_if=()","ipv6_multicast_loop()","ipv6_multicast_loop=()","ipv6_multicast_loop?()","listen()","multicast()","multicast?()","new()","new()","no_delay()","no_delay=()","no_delay?()","on_accept()","on_match()","on_match()","persistent?()","purge()","puts()","read_all()","read_match()","recork()","register_accept_listener()","register_observer()","register_observer()","reuse_addr()","reuse_addr=()","reuse_addr?()","run_match()","ttl()","ttl=()","ttl?()","unregister_accept_listener()","unregister_observer()","unregister_observer()","write()"],"longSearchIndex":["ionian","ionian::extension","ionian::extension::io","ionian::extension::socket","ionian::server","ionian::socket","ionian::socket#<<()","ionian::server#close()","ionian::socket#closed?()","ionian::socket#cmd()","ionian::extension::socket#cork()","ionian::extension::socket#cork=()","ionian::extension::socket#cork?()","ionian::extension::io#expression()","ionian::extension::io#expression=()","ionian::extension::io::extended()","ionian::extension::socket::extended()","ionian::socket#flush()","ionian::extension::io#has_data?()","ionian::socket#has_data?()","ionian::extension::io#initialize_ionian()","ionian::extension::socket#initialize_ionian_socket()","ionian::extension::socket#ip_add_membership()","ionian::extension::socket#ip_drop_membership()","ionian::extension::socket#ip_multicast_if()","ionian::extension::socket#ip_multicast_if=()","ionian::extension::socket#ip_multicast_loop()","ionian::extension::socket#ip_multicast_loop=()","ionian::extension::socket#ip_multicast_loop?()","ionian::extension::socket#ip_multicast_ttl()","ionian::extension::socket#ip_multicast_ttl=()","ionian::extension::socket#ipv6_add_membership()","ionian::extension::socket#ipv6_drop_membership()","ionian::extension::socket#ipv6_multicast_hops()","ionian::extension::socket#ipv6_multicast_hops=()","ionian::extension::socket#ipv6_multicast_if()","ionian::extension::socket#ipv6_multicast_if=()","ionian::extension::socket#ipv6_multicast_loop()","ionian::extension::socket#ipv6_multicast_loop=()","ionian::extension::socket#ipv6_multicast_loop?()","ionian::server#listen()","ionian::extension::socket#multicast()","ionian::extension::socket#multicast?()","ionian::server::new()","ionian::socket::new()","ionian::extension::socket#no_delay()","ionian::extension::socket#no_delay=()","ionian::extension::socket#no_delay?()","ionian::server#on_accept()","ionian::extension::io#on_match()","ionian::socket#on_match()","ionian::socket#persistent?()","ionian::extension::io#purge()","ionian::socket#puts()","ionian::extension::io#read_all()","ionian::extension::io#read_match()","ionian::extension::socket#recork()","ionian::server#register_accept_listener()","ionian::extension::io#register_observer()","ionian::socket#register_observer()","ionian::extension::socket#reuse_addr()","ionian::extension::socket#reuse_addr=()","ionian::extension::socket#reuse_addr?()","ionian::extension::io#run_match()","ionian::extension::socket#ttl()","ionian::extension::socket#ttl=()","ionian::extension::socket#ttl?()","ionian::server#unregister_accept_listener()","ionian::extension::io#unregister_observer()","ionian::socket#unregister_observer()","ionian::socket#write()"],"info":[["Ionian","","Ionian.html","","<p>A library to simplify interaction with IO streams. This includes network\nsockets, file sockets, and serial …\n"],["Ionian::Extension","","Ionian/Extension.html","","<p>A collection of mixins.\n"],["Ionian::Extension::IO","","Ionian/Extension/IO.html","","<p>A mixin for IO objects that allows regular expression matching and\nconvenient notification of received …\n"],["Ionian::Extension::Socket","","Ionian/Extension/Socket.html","","<p>A mixin for Socket objects.\n<p>This module was designed to be extended by instantiated objects that\nimplement …\n"],["Ionian::Server","","Ionian/Server.html","","<p>A convenient wrapper for TCP, UDP, and Unix server sockets.\n"],["Ionian::Socket","","Ionian/Socket.html","","<p>A convenient wrapper for TCP, UDP, and Unix client sockets.\n"],["<<","Ionian::Socket","Ionian/Socket.html#method-i-3C-3C","(string)",""],["close","Ionian::Server","Ionian/Server.html#method-i-close","()","<p>Shutdown the server socket and stop listening for connections.\n"],["closed?","Ionian::Socket","Ionian/Socket.html#method-i-closed-3F","()","<p>Returns true if the socket is closed.\n"],["cmd","Ionian::Socket","Ionian/Socket.html#method-i-cmd","(string, **kwargs, &block)","<p>Send a command (data) to the socket. Returns an array of received matches.\nBlock yields received match. …\n"],["cork","Ionian::Extension::Socket","Ionian/Extension/Socket.html#method-i-cork","()","<p>Returns true if multiple writes are buffered into a single segment. See\n#recork. Linux only. ( TCP_CORK …\n"],["cork=","Ionian::Extension::Socket","Ionian/Extension/Socket.html#method-i-cork-3D","(value)","<p>Buffers multiple writes into a single segment if true. The segment is sent\nonce the cork flag is disabled, …\n"],["cork?","Ionian::Extension::Socket","Ionian/Extension/Socket.html#method-i-cork-3F","()",""],["expression","Ionian::Extension::IO","Ionian/Extension/IO.html#method-i-expression","()","<p>Returns the regular expression used for #read_match.\n"],["expression=","Ionian::Extension::IO","Ionian/Extension/IO.html#method-i-expression-3D","(exp)","<p>Set the expression to match against the read buffer. Can be a regular\nexpression specifying capture groups, …\n"],["extended","Ionian::Extension::IO","Ionian/Extension/IO.html#method-c-extended","(obj)","<p>Called automaticallly when the object is extended with #extend.\n"],["extended","Ionian::Extension::Socket","Ionian/Extension/Socket.html#method-c-extended","(obj)","<p>Called automaticallly when the object is extended with #extend.\n"],["flush","Ionian::Socket","Ionian/Socket.html#method-i-flush","()","<p>Flushes buffered data to the operating system. This method has no effect on\nnon-persistent sockets.\n"],["has_data?","Ionian::Extension::IO","Ionian/Extension/IO.html#method-i-has_data-3F","(timeout: 0)","<p>Returns true if there is data in the receive buffer. Args:\n\n<pre>Timeout: Number of seconds to wait for data ...</pre>\n"],["has_data?","Ionian::Socket","Ionian/Socket.html#method-i-has_data-3F","(**kwargs)","<p>Returns true if there is data in the receive buffer. Args:\n\n<pre>Timeout: Number of seconds to wait for data ...</pre>\n"],["initialize_ionian","Ionian::Extension::IO","Ionian/Extension/IO.html#method-i-initialize_ionian","()","<p>Initialize the Ionian instance variables. This is called automatically if\n#extend is called on an object. …\n"],["initialize_ionian_socket","Ionian::Extension::Socket","Ionian/Extension/Socket.html#method-i-initialize_ionian_socket","()","<p>Initialize the Ionian Socket variables. This is called automatically if\n#extend is called on an object. …\n"],["ip_add_membership","Ionian::Extension::Socket","Ionian/Extension/Socket.html#method-i-ip_add_membership","(address = nil, interface = nil)","<p>Join a multicast group. Address is the class D multicast address (uses\nremote address if not specified). …\n"],["ip_drop_membership","Ionian::Extension::Socket","Ionian/Extension/Socket.html#method-i-ip_drop_membership","(address = nil, interface = nil)","<p>Leave a multicast group. Address is the class D multicast address (uses\nremote address if not specified). …\n"],["ip_multicast_if","Ionian::Extension::Socket","Ionian/Extension/Socket.html#method-i-ip_multicast_if","()","<p>Returns the default interface for outgoing multicasts. ( IP_MULTICAST_IF )\n"],["ip_multicast_if=","Ionian::Extension::Socket","Ionian/Extension/Socket.html#method-i-ip_multicast_if-3D","(interface = nil)","<p>Specify default interface for outgoing multicasts. ( IP_MULTICAST_IF )\n"],["ip_multicast_loop","Ionian::Extension::Socket","Ionian/Extension/Socket.html#method-i-ip_multicast_loop","()","<p>Returns true if loopback of outgoing multicasts is enabled. (\nIP_MULTICAST_LOOP )\n"],["ip_multicast_loop=","Ionian::Extension::Socket","Ionian/Extension/Socket.html#method-i-ip_multicast_loop-3D","(value)","<p>Enables loopback of outgoing multicasts if true. ( IP_MULTICAST_LOOP )\n"],["ip_multicast_loop?","Ionian::Extension::Socket","Ionian/Extension/Socket.html#method-i-ip_multicast_loop-3F","()",""],["ip_multicast_ttl","Ionian::Extension::Socket","Ionian/Extension/Socket.html#method-i-ip_multicast_ttl","()","<p>Returns the time to live (hop limit) for outgoing multicasts. (\nIP_MULTICAST_TTL )\n"],["ip_multicast_ttl=","Ionian::Extension::Socket","Ionian/Extension/Socket.html#method-i-ip_multicast_ttl-3D","(value)","<p>Set the time to live (hop limit) for outgoing multicasts. (\nIP_MULTICAST_TTL )\n"],["ipv6_add_membership","Ionian::Extension::Socket","Ionian/Extension/Socket.html#method-i-ipv6_add_membership","()",""],["ipv6_drop_membership","Ionian::Extension::Socket","Ionian/Extension/Socket.html#method-i-ipv6_drop_membership","()",""],["ipv6_multicast_hops","Ionian::Extension::Socket","Ionian/Extension/Socket.html#method-i-ipv6_multicast_hops","()",""],["ipv6_multicast_hops=","Ionian::Extension::Socket","Ionian/Extension/Socket.html#method-i-ipv6_multicast_hops-3D","(value)",""],["ipv6_multicast_if","Ionian::Extension::Socket","Ionian/Extension/Socket.html#method-i-ipv6_multicast_if","()",""],["ipv6_multicast_if=","Ionian::Extension::Socket","Ionian/Extension/Socket.html#method-i-ipv6_multicast_if-3D","(value)",""],["ipv6_multicast_loop","Ionian::Extension::Socket","Ionian/Extension/Socket.html#method-i-ipv6_multicast_loop","()",""],["ipv6_multicast_loop=","Ionian::Extension::Socket","Ionian/Extension/Socket.html#method-i-ipv6_multicast_loop-3D","(value)",""],["ipv6_multicast_loop?","Ionian::Extension::Socket","Ionian/Extension/Socket.html#method-i-ipv6_multicast_loop-3F","()",""],["listen","Ionian::Server","Ionian/Server.html#method-i-listen","(&block)","<p>Starts the socket server listening for connections. Blocks registered with\n#register_accept_listener …\n"],["multicast","Ionian::Extension::Socket","Ionian/Extension/Socket.html#method-i-multicast","(address)","<p>Returns true if the given address is within the multicast range.\n"],["multicast?","Ionian::Extension::Socket","Ionian/Extension/Socket.html#method-i-multicast-3F","(address)",""],["new","Ionian::Server","Ionian/Server.html#method-c-new","(**kwargs, &block)",""],["new","Ionian::Socket","Ionian/Socket.html#method-c-new","(existing_socket = nil, **kwargs)","<p>Creates a new socket or wraps an existing socket.\n<p>Args:\n\n<pre>host: IP or hostname to connect to.\nport: ...</pre>\n"],["no_delay","Ionian::Extension::Socket","Ionian/Extension/Socket.html#method-i-no_delay","()","<p>Returns true if the Nagle algorithm is disabled. ( TCP_NODELAY )\n"],["no_delay=","Ionian::Extension::Socket","Ionian/Extension/Socket.html#method-i-no_delay-3D","(value)","<p>Disables the Nagle algorithm if true. ( TCP_NODELAY )\n"],["no_delay?","Ionian::Extension::Socket","Ionian/Extension/Socket.html#method-i-no_delay-3F","()",""],["on_accept","Ionian::Server","Ionian/Server.html#method-i-on_accept","(&block)",""],["on_match","Ionian::Extension::IO","Ionian/Extension/IO.html#method-i-on_match","(&block)",""],["on_match","Ionian::Socket","Ionian/Socket.html#method-i-on_match","(&block)",""],["persistent?","Ionian::Socket","Ionian/Socket.html#method-i-persistent-3F","()","<p>Returns true if the socket remains open after writing data.\n"],["purge","Ionian::Extension::IO","Ionian/Extension/IO.html#method-i-purge","()","<p>Erase the data in the IO and Ionian buffers. This is typically handled\nautomatically.\n"],["puts","Ionian::Socket","Ionian/Socket.html#method-i-puts","(*string)","<p>Writes the given string(s) to the socket and appends a newline character to\nany string not already ending …\n"],["read_all","Ionian::Extension::IO","Ionian/Extension/IO.html#method-i-read_all","()","<p>Read all data in the buffer. An alternative to using #readpartial with a\nlarge length.\n"],["read_match","Ionian::Extension::IO","Ionian/Extension/IO.html#method-i-read_match","(**kwargs, &block)","<p>Read matched data from the buffer. This method SHOULD NOT be used if\n#run_match is used.\n<p>Passes matches …\n"],["recork","Ionian::Extension::Socket","Ionian/Extension/Socket.html#method-i-recork","()","<p>Unsets cork to transmit data, then reapplies cork. ( TCP_CORK )\n"],["register_accept_listener","Ionian::Server","Ionian/Server.html#method-i-register_accept_listener","(&block)","<p>Register a block to be run when server accepts a client connection. The\nconnected client is passed to …\n"],["register_observer","Ionian::Extension::IO","Ionian/Extension/IO.html#method-i-register_observer","(&block)","<p>Register a block to be called when #run_match receives matched data. Method\ncallbacks can be registered …\n"],["register_observer","Ionian::Socket","Ionian/Socket.html#method-i-register_observer","(&block)","<p>Register a block to be called when #run_match receives matched data. Method\ncallbacks can be registered …\n"],["reuse_addr","Ionian::Extension::Socket","Ionian/Extension/Socket.html#method-i-reuse_addr","()","<p>Returns true if local address reuse is allowed. ( SO_REUSEADDR )\n"],["reuse_addr=","Ionian::Extension::Socket","Ionian/Extension/Socket.html#method-i-reuse_addr-3D","(value)","<p>Allows local address reuse if true. ( SO_REUSEADDR )\n"],["reuse_addr?","Ionian::Extension::Socket","Ionian/Extension/Socket.html#method-i-reuse_addr-3F","()",""],["run_match","Ionian::Extension::IO","Ionian/Extension/IO.html#method-i-run_match","(**kwargs)","<p>Start a thread that checks for data and notifies listeners (do |match,\nsocket|). Passes kwargs to #read_match …\n"],["ttl","Ionian::Extension::Socket","Ionian/Extension/Socket.html#method-i-ttl","()","<p>Returns the time to live (hop limit). ( IP_TTL )\n"],["ttl=","Ionian::Extension::Socket","Ionian/Extension/Socket.html#method-i-ttl-3D","(value)","<p>Sets the time to live (hop limit). ( IP_TTL )\n"],["ttl?","Ionian::Extension::Socket","Ionian/Extension/Socket.html#method-i-ttl-3F","()",""],["unregister_accept_listener","Ionian::Server","Ionian/Server.html#method-i-unregister_accept_listener","(proc)","<p>Unregisters a socket accept notifier block.\n"],["unregister_observer","Ionian::Extension::IO","Ionian/Extension/IO.html#method-i-unregister_observer","(&block)","<p>Unregister a block from being called when matched data is received.\n"],["unregister_observer","Ionian::Socket","Ionian/Socket.html#method-i-unregister_observer","(&block)","<p>Unregister a block from being called when matched data is received.\n"],["write","Ionian::Socket","Ionian/Socket.html#method-i-write","(string)","<p>Writes the given string to the socket. Returns the number of bytes written.\n"]]}}
1
+ var search_data = {"index":{"searchIndex":["ionian","extension","io","socket","server","socket","<<()","close()","closed?()","cmd()","cork()","cork=()","cork?()","expression()","expression=()","extended()","extended()","flush()","has_data?()","has_data?()","initialize_ionian()","initialize_ionian_socket()","ip_add_membership()","ip_drop_membership()","ip_multicast_if()","ip_multicast_if=()","ip_multicast_loop()","ip_multicast_loop=()","ip_multicast_loop?()","ip_multicast_ttl()","ip_multicast_ttl=()","ipv6_add_membership()","ipv6_drop_membership()","ipv6_multicast_hops()","ipv6_multicast_hops=()","ipv6_multicast_if()","ipv6_multicast_if=()","ipv6_multicast_loop()","ipv6_multicast_loop=()","ipv6_multicast_loop?()","listen()","multicast()","multicast?()","new()","new()","no_delay()","no_delay=()","no_delay?()","on_accept()","on_match()","on_match()","persistent?()","purge()","puts()","read_all()","read_match()","recork()","register_accept_listener()","register_observer()","register_observer()","reuse_addr()","reuse_addr=()","reuse_addr?()","run_match()","ttl()","ttl=()","ttl?()","unregister_accept_listener()","unregister_observer()","unregister_observer()","write()"],"longSearchIndex":["ionian","ionian::extension","ionian::extension::io","ionian::extension::socket","ionian::server","ionian::socket","ionian::socket#<<()","ionian::server#close()","ionian::socket#closed?()","ionian::socket#cmd()","ionian::extension::socket#cork()","ionian::extension::socket#cork=()","ionian::extension::socket#cork?()","ionian::extension::io#expression()","ionian::extension::io#expression=()","ionian::extension::io::extended()","ionian::extension::socket::extended()","ionian::socket#flush()","ionian::extension::io#has_data?()","ionian::socket#has_data?()","ionian::extension::io#initialize_ionian()","ionian::extension::socket#initialize_ionian_socket()","ionian::extension::socket#ip_add_membership()","ionian::extension::socket#ip_drop_membership()","ionian::extension::socket#ip_multicast_if()","ionian::extension::socket#ip_multicast_if=()","ionian::extension::socket#ip_multicast_loop()","ionian::extension::socket#ip_multicast_loop=()","ionian::extension::socket#ip_multicast_loop?()","ionian::extension::socket#ip_multicast_ttl()","ionian::extension::socket#ip_multicast_ttl=()","ionian::extension::socket#ipv6_add_membership()","ionian::extension::socket#ipv6_drop_membership()","ionian::extension::socket#ipv6_multicast_hops()","ionian::extension::socket#ipv6_multicast_hops=()","ionian::extension::socket#ipv6_multicast_if()","ionian::extension::socket#ipv6_multicast_if=()","ionian::extension::socket#ipv6_multicast_loop()","ionian::extension::socket#ipv6_multicast_loop=()","ionian::extension::socket#ipv6_multicast_loop?()","ionian::server#listen()","ionian::extension::socket#multicast()","ionian::extension::socket#multicast?()","ionian::server::new()","ionian::socket::new()","ionian::extension::socket#no_delay()","ionian::extension::socket#no_delay=()","ionian::extension::socket#no_delay?()","ionian::server#on_accept()","ionian::extension::io#on_match()","ionian::socket#on_match()","ionian::socket#persistent?()","ionian::extension::io#purge()","ionian::socket#puts()","ionian::extension::io#read_all()","ionian::extension::io#read_match()","ionian::extension::socket#recork()","ionian::server#register_accept_listener()","ionian::extension::io#register_observer()","ionian::socket#register_observer()","ionian::extension::socket#reuse_addr()","ionian::extension::socket#reuse_addr=()","ionian::extension::socket#reuse_addr?()","ionian::extension::io#run_match()","ionian::extension::socket#ttl()","ionian::extension::socket#ttl=()","ionian::extension::socket#ttl?()","ionian::server#unregister_accept_listener()","ionian::extension::io#unregister_observer()","ionian::socket#unregister_observer()","ionian::socket#write()"],"info":[["Ionian","","Ionian.html","","<p>A library to simplify interaction with IO streams. This includes network\nsockets, file sockets, and serial …\n"],["Ionian::Extension","","Ionian/Extension.html","","<p>A collection of mixins.\n"],["Ionian::Extension::IO","","Ionian/Extension/IO.html","","<p>A mixin for IO objects that allows regular expression matching and\nconvenient notification of received …\n"],["Ionian::Extension::Socket","","Ionian/Extension/Socket.html","","<p>A mixin for Socket objects.\n<p>This module was designed to be extended by instantiated objects that\nimplement …\n"],["Ionian::Server","","Ionian/Server.html","","<p>A convenient wrapper for TCP, UDP, and Unix server sockets.\n"],["Ionian::Socket","","Ionian/Socket.html","","<p>A convenient wrapper for TCP, UDP, and Unix client sockets.\n"],["<<","Ionian::Socket","Ionian/Socket.html#method-i-3C-3C","(string)",""],["close","Ionian::Server","Ionian/Server.html#method-i-close","()","<p>Shutdown the server socket and stop listening for connections.\n"],["closed?","Ionian::Socket","Ionian/Socket.html#method-i-closed-3F","()","<p>Returns true if the socket is closed.\n"],["cmd","Ionian::Socket","Ionian/Socket.html#method-i-cmd","(string, **kwargs, &block)","<p>Send a command (data) to the socket. Returns an array of received matches.\nBlock yields received match. …\n"],["cork","Ionian::Extension::Socket","Ionian/Extension/Socket.html#method-i-cork","()","<p>Returns true if multiple writes are buffered into a single segment. See\n#recork. Linux only. ( TCP_CORK …\n"],["cork=","Ionian::Extension::Socket","Ionian/Extension/Socket.html#method-i-cork-3D","(value)","<p>Buffers multiple writes into a single segment if true. The segment is sent\nonce the cork flag is disabled, …\n"],["cork?","Ionian::Extension::Socket","Ionian/Extension/Socket.html#method-i-cork-3F","()",""],["expression","Ionian::Extension::IO","Ionian/Extension/IO.html#method-i-expression","()","<p>Returns the regular expression used for #read_match.\n"],["expression=","Ionian::Extension::IO","Ionian/Extension/IO.html#method-i-expression-3D","(exp)","<p>Set the expression to match against the read buffer. Can be a regular\nexpression specifying capture groups, …\n"],["extended","Ionian::Extension::IO","Ionian/Extension/IO.html#method-c-extended","(obj)","<p>Called automaticallly when the object is extended with #extend.\n"],["extended","Ionian::Extension::Socket","Ionian/Extension/Socket.html#method-c-extended","(obj)","<p>Called automaticallly when the object is extended with #extend.\n"],["flush","Ionian::Socket","Ionian/Socket.html#method-i-flush","()","<p>Flushes buffered data to the operating system. This method has no effect on\nnon-persistent sockets.\n"],["has_data?","Ionian::Extension::IO","Ionian/Extension/IO.html#method-i-has_data-3F","(timeout: 0)","<p>Returns true if there is data in the receive buffer. Args:\n\n<pre>Timeout: Number of seconds to wait for data ...</pre>\n"],["has_data?","Ionian::Socket","Ionian/Socket.html#method-i-has_data-3F","(**kwargs)","<p>Returns true if there is data in the receive buffer. Args:\n\n<pre>Timeout: Number of seconds to wait for data ...</pre>\n"],["initialize_ionian","Ionian::Extension::IO","Ionian/Extension/IO.html#method-i-initialize_ionian","()","<p>Initialize the Ionian instance variables. This is called automatically if\n#extend is called on an object. …\n"],["initialize_ionian_socket","Ionian::Extension::Socket","Ionian/Extension/Socket.html#method-i-initialize_ionian_socket","()","<p>Initialize the Ionian Socket variables. This is called automatically if\n#extend is called on an object. …\n"],["ip_add_membership","Ionian::Extension::Socket","Ionian/Extension/Socket.html#method-i-ip_add_membership","(address = nil, interface = nil)","<p>Join a multicast group. Address is the class D multicast address (uses\nremote address if not specified). …\n"],["ip_drop_membership","Ionian::Extension::Socket","Ionian/Extension/Socket.html#method-i-ip_drop_membership","(address = nil, interface = nil)","<p>Leave a multicast group. Address is the class D multicast address (uses\nremote address if not specified). …\n"],["ip_multicast_if","Ionian::Extension::Socket","Ionian/Extension/Socket.html#method-i-ip_multicast_if","()","<p>Returns the default interface for outgoing multicasts. ( IP_MULTICAST_IF )\n"],["ip_multicast_if=","Ionian::Extension::Socket","Ionian/Extension/Socket.html#method-i-ip_multicast_if-3D","(interface = nil)","<p>Specify default interface for outgoing multicasts. ( IP_MULTICAST_IF )\n"],["ip_multicast_loop","Ionian::Extension::Socket","Ionian/Extension/Socket.html#method-i-ip_multicast_loop","()","<p>Returns true if loopback of outgoing multicasts is enabled. (\nIP_MULTICAST_LOOP )\n"],["ip_multicast_loop=","Ionian::Extension::Socket","Ionian/Extension/Socket.html#method-i-ip_multicast_loop-3D","(value)","<p>Enables loopback of outgoing multicasts if true. ( IP_MULTICAST_LOOP )\n"],["ip_multicast_loop?","Ionian::Extension::Socket","Ionian/Extension/Socket.html#method-i-ip_multicast_loop-3F","()",""],["ip_multicast_ttl","Ionian::Extension::Socket","Ionian/Extension/Socket.html#method-i-ip_multicast_ttl","()","<p>Returns the time to live (hop limit) for outgoing multicasts. (\nIP_MULTICAST_TTL )\n"],["ip_multicast_ttl=","Ionian::Extension::Socket","Ionian/Extension/Socket.html#method-i-ip_multicast_ttl-3D","(value)","<p>Set the time to live (hop limit) for outgoing multicasts. (\nIP_MULTICAST_TTL )\n"],["ipv6_add_membership","Ionian::Extension::Socket","Ionian/Extension/Socket.html#method-i-ipv6_add_membership","()","<p>Not yet implemented.\n"],["ipv6_drop_membership","Ionian::Extension::Socket","Ionian/Extension/Socket.html#method-i-ipv6_drop_membership","()","<p>Not yet implemented.\n"],["ipv6_multicast_hops","Ionian::Extension::Socket","Ionian/Extension/Socket.html#method-i-ipv6_multicast_hops","()","<p>Not yet implemented.\n"],["ipv6_multicast_hops=","Ionian::Extension::Socket","Ionian/Extension/Socket.html#method-i-ipv6_multicast_hops-3D","(value)","<p>Not yet implemented.\n"],["ipv6_multicast_if","Ionian::Extension::Socket","Ionian/Extension/Socket.html#method-i-ipv6_multicast_if","()","<p>Not yet implemented.\n"],["ipv6_multicast_if=","Ionian::Extension::Socket","Ionian/Extension/Socket.html#method-i-ipv6_multicast_if-3D","(value)","<p>Not yet implemented.\n"],["ipv6_multicast_loop","Ionian::Extension::Socket","Ionian/Extension/Socket.html#method-i-ipv6_multicast_loop","()","<p>Not yet implemented.\n"],["ipv6_multicast_loop=","Ionian::Extension::Socket","Ionian/Extension/Socket.html#method-i-ipv6_multicast_loop-3D","(value)","<p>Not yet implemented.\n"],["ipv6_multicast_loop?","Ionian::Extension::Socket","Ionian/Extension/Socket.html#method-i-ipv6_multicast_loop-3F","()",""],["listen","Ionian::Server","Ionian/Server.html#method-i-listen","(&block)","<p>Starts the socket server listening for connections. Blocks registered with\n#register_accept_listener …\n"],["multicast","Ionian::Extension::Socket","Ionian/Extension/Socket.html#method-i-multicast","(address)","<p>Returns true if the given address is within the multicast range.\n"],["multicast?","Ionian::Extension::Socket","Ionian/Extension/Socket.html#method-i-multicast-3F","(address)",""],["new","Ionian::Server","Ionian/Server.html#method-c-new","(**kwargs, &block)","<p>A convenient wrapper for TCP and Unix server sockets (UDP doesn&#39;t use a\nserver).\n<p>Accepts an optional …\n"],["new","Ionian::Socket","Ionian/Socket.html#method-c-new","(existing_socket = nil, **kwargs)","<p>Creates a new socket or wraps an existing socket.\n<p>Args:\n\n<pre>host: IP or hostname to connect to.\nport: ...</pre>\n"],["no_delay","Ionian::Extension::Socket","Ionian/Extension/Socket.html#method-i-no_delay","()","<p>Returns true if the Nagle algorithm is disabled. ( TCP_NODELAY )\n"],["no_delay=","Ionian::Extension::Socket","Ionian/Extension/Socket.html#method-i-no_delay-3D","(value)","<p>Disables the Nagle algorithm if true. ( TCP_NODELAY )\n"],["no_delay?","Ionian::Extension::Socket","Ionian/Extension/Socket.html#method-i-no_delay-3F","()",""],["on_accept","Ionian::Server","Ionian/Server.html#method-i-on_accept","(&block)",""],["on_match","Ionian::Extension::IO","Ionian/Extension/IO.html#method-i-on_match","(&block)",""],["on_match","Ionian::Socket","Ionian/Socket.html#method-i-on_match","(&block)",""],["persistent?","Ionian::Socket","Ionian/Socket.html#method-i-persistent-3F","()","<p>Returns true if the socket remains open after writing data.\n"],["purge","Ionian::Extension::IO","Ionian/Extension/IO.html#method-i-purge","()","<p>Erase the data in the IO and Ionian buffers. This is typically handled\nautomatically.\n"],["puts","Ionian::Socket","Ionian/Socket.html#method-i-puts","(*string)","<p>Writes the given string(s) to the socket and appends a newline character to\nany string not already ending …\n"],["read_all","Ionian::Extension::IO","Ionian/Extension/IO.html#method-i-read_all","()","<p>Read all data in the buffer. An alternative to using #readpartial with a\nlarge length.\n"],["read_match","Ionian::Extension::IO","Ionian/Extension/IO.html#method-i-read_match","(**kwargs, &block)","<p>Read matched data from the buffer. This method SHOULD NOT be used if\n#run_match is used.\n<p>Passes matches …\n"],["recork","Ionian::Extension::Socket","Ionian/Extension/Socket.html#method-i-recork","()","<p>Unsets cork to transmit data, then reapplies cork. ( TCP_CORK )\n"],["register_accept_listener","Ionian::Server","Ionian/Server.html#method-i-register_accept_listener","(&block)","<p>Register a block to be run when server accepts a client connection. The\nconnected client is passed to …\n"],["register_observer","Ionian::Extension::IO","Ionian/Extension/IO.html#method-i-register_observer","(&block)","<p>Register a block to be called when #run_match receives matched data. Method\ncallbacks can be registered …\n"],["register_observer","Ionian::Socket","Ionian/Socket.html#method-i-register_observer","(&block)","<p>Register a block to be called when #run_match receives matched data. Method\ncallbacks can be registered …\n"],["reuse_addr","Ionian::Extension::Socket","Ionian/Extension/Socket.html#method-i-reuse_addr","()","<p>Returns true if local address reuse is allowed. ( SO_REUSEADDR )\n"],["reuse_addr=","Ionian::Extension::Socket","Ionian/Extension/Socket.html#method-i-reuse_addr-3D","(value)","<p>Allows local address reuse if true. ( SO_REUSEADDR )\n"],["reuse_addr?","Ionian::Extension::Socket","Ionian/Extension/Socket.html#method-i-reuse_addr-3F","()",""],["run_match","Ionian::Extension::IO","Ionian/Extension/IO.html#method-i-run_match","(**kwargs)","<p>Start a thread that checks for data and notifies listeners (do |match,\nsocket|). Passes kwargs to #read_match …\n"],["ttl","Ionian::Extension::Socket","Ionian/Extension/Socket.html#method-i-ttl","()","<p>Returns the time to live (hop limit). ( IP_TTL )\n"],["ttl=","Ionian::Extension::Socket","Ionian/Extension/Socket.html#method-i-ttl-3D","(value)","<p>Sets the time to live (hop limit). ( IP_TTL )\n"],["ttl?","Ionian::Extension::Socket","Ionian/Extension/Socket.html#method-i-ttl-3F","()",""],["unregister_accept_listener","Ionian::Server","Ionian/Server.html#method-i-unregister_accept_listener","(proc)","<p>Unregisters a socket accept notifier block.\n"],["unregister_observer","Ionian::Extension::IO","Ionian/Extension/IO.html#method-i-unregister_observer","(&block)","<p>Unregister a block from being called when matched data is received.\n"],["unregister_observer","Ionian::Socket","Ionian/Socket.html#method-i-unregister_observer","(&block)","<p>Unregister a block from being called when matched data is received.\n"],["write","Ionian::Socket","Ionian/Socket.html#method-i-write","(string)","<p>Writes the given string to the socket. Returns the number of bytes written.\n"]]}}
@@ -76,14 +76,21 @@ module Ionian
76
76
  #
77
77
  # kwargs:
78
78
  # timeout: Timeout in seconds IO::select will block.
79
+ # expression: Override the expression match for this single
80
+ # method call.
81
+ # notify: Set to false to skip notifying match listener procs.
79
82
  # skip_select: Skip over the IO::select statement. Use if you
80
83
  # are calling IO::select ahead of this method.
81
84
  # build_methods: Build accessor methods from named capture groups.
82
85
  # Enabled by default.
83
86
  def read_match(**kwargs, &block)
84
- timeout = kwargs.fetch :timeout, @ionian_timeout
85
- skip_select = kwargs.fetch :skip_select, @ionian_skip_select
86
- build_methods = kwargs.fetch :build_methods, @ionian_build_methods
87
+ timeout = kwargs.fetch :timeout, @ionian_timeout
88
+ notify = kwargs.fetch :notify, true
89
+ skip_select = kwargs.fetch :skip_select, @ionian_skip_select
90
+ build_methods = kwargs.fetch :build_methods, @ionian_build_methods
91
+
92
+ exp = kwargs.fetch :expression, @ionian_expression
93
+ exp = Regexp.new "(.*?)#{exp}" if exp.is_a? String
87
94
 
88
95
  unless skip_select
89
96
  return nil unless ::IO.select [self], nil, nil, timeout
@@ -97,7 +104,7 @@ module Ionian
97
104
 
98
105
  @matches = []
99
106
 
100
- while @ionian_buf =~ @ionian_expression
107
+ while @ionian_buf =~ exp
101
108
  @matches << $~ # Match data.
102
109
  yield $~ if block_given?
103
110
  @ionian_buf = $' # Leave post match data in the buffer.
@@ -115,6 +122,9 @@ module Ionian
115
122
  end
116
123
  end
117
124
 
125
+ # Notify on_match listeners.
126
+ @matches.each {|match| notify_listeners match} if notify
127
+
118
128
  @matches
119
129
  end
120
130
 
@@ -125,10 +135,8 @@ module Ionian
125
135
  @match_listener ||= Thread.new do
126
136
  begin
127
137
  while not closed? do
128
- matches = read_match kwargs
129
- matches.each {|match|
130
- @ionian_listeners.each {|listener| listener.call match, self}
131
- } if matches
138
+ matches = read_match **kwargs
139
+ matches.each {|match| notify_listeners match } if matches
132
140
  end
133
141
  rescue EOFError
134
142
  rescue IOError
@@ -165,6 +173,15 @@ module Ionian
165
173
  @ionian_listeners.delete_if {|o| o == block}
166
174
  block
167
175
  end
176
+
177
+
178
+ private
179
+
180
+ # Send match to each of the registered observers. Includes self
181
+ # as the second block parameter.
182
+ def notify_listeners match
183
+ @ionian_listeners.each {|listener| listener.call match, self}
184
+ end
168
185
 
169
186
  end
170
187
  end
@@ -185,34 +185,41 @@ module Ionian
185
185
  self.setsockopt ::Socket::IPPROTO_IP, ::Socket::IP_MULTICAST_LOOP, [param].pack('C')
186
186
  end
187
187
 
188
+ # Not yet implemented.
188
189
  def ipv6_add_membership
189
190
  # TODO: Implement
190
191
  false
191
192
  end
192
193
 
194
+ # Not yet implemented.
193
195
  def ipv6_drop_membership
194
196
  # TODO: Implement
195
197
  false
196
198
  end
197
199
 
200
+ # Not yet implemented.
198
201
  def ipv6_multicast_if
199
202
  # TODO: Implement
200
203
  false
201
204
  end
202
205
 
206
+ # Not yet implemented.
203
207
  def ipv6_multicast_if=(value)
204
208
  # TODO: Implement
205
209
  end
206
210
 
211
+ # Not yet implemented.
207
212
  def ipv6_multicast_hops
208
213
  # TODO: Implement
209
214
  false
210
215
  end
211
216
 
217
+ # Not yet implemented.
212
218
  def ipv6_multicast_hops=(value)
213
219
  # TODO: Implement
214
220
  end
215
221
 
222
+ # Not yet implemented.
216
223
  def ipv6_multicast_loop
217
224
  # TODO: Implement
218
225
  false
@@ -220,6 +227,7 @@ module Ionian
220
227
 
221
228
  alias_method :ipv6_multicast_loop?, :ipv6_multicast_loop
222
229
 
230
+ # Not yet implemented.
223
231
  def ipv6_multicast_loop=(value)
224
232
  # TODO: Implement
225
233
  end
data/lib/ionian/server.rb CHANGED
@@ -6,6 +6,15 @@ module Ionian
6
6
  # A convenient wrapper for TCP, UDP, and Unix server sockets.
7
7
  class Server
8
8
 
9
+ # A convenient wrapper for TCP and Unix server sockets (UDP doesn't use
10
+ # a server).
11
+ #
12
+ # Accepts an optional block that is passed to #register_accept_listener.
13
+ #
14
+ # Args:
15
+ # interface: The address of the network interface to bind to.
16
+ # Defaults to all.
17
+ # protocol: :tcp, :unix. Default is :tcp.
9
18
  def initialize **kwargs, &block
10
19
  @accept_listeners = []
11
20
  register_accept_listener &block if block_given?
@@ -28,7 +37,7 @@ module Ionian
28
37
  @server = TCPServer.new @interface, @port
29
38
  @server.setsockopt ::Socket::SOL_SOCKET, ::Socket::SO_REUSEADDR, [1].pack('i')
30
39
  when :udp
31
- @server = Ionian::Socket.new host: @interface, port: @port, protocol: :udp
40
+ raise ArgumentError, "UDP should be implemented with Ionian::Socket."
32
41
  when :unix
33
42
  @server = UNIXServer.new @interface
34
43
  end
data/lib/ionian/socket.rb CHANGED
@@ -4,6 +4,7 @@ module Ionian
4
4
 
5
5
  # A convenient wrapper for TCP, UDP, and Unix client sockets.
6
6
  class Socket
7
+ # Returns the regular expression used to match incoming data.
7
8
  attr_accessor :expression
8
9
 
9
10
  # Creates a new socket or wraps an existing socket.
@@ -73,6 +74,7 @@ module Ionian
73
74
 
74
75
  @protocol = kwargs.fetch :protocol, default_protocol
75
76
  @persistent = kwargs.fetch :persistent, true
77
+ @persistent = true if @protocol == :udp
76
78
 
77
79
  @reuse_addr = kwargs.fetch :reuse_addr, false
78
80
  @no_delay = kwargs.fetch :no_delay, false
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.0
4
+ version: 0.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alex McLain
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-01-22 00:00:00.000000000 Z
11
+ date: 2014-01-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake