doc/Safubot/Twitter/Bot.html in safubot-0.0.2 vs doc/Safubot/Twitter/Bot.html in safubot-0.0.3
- old
+ new
@@ -173,10 +173,64 @@
<li class="public ">
<span class="summary_signature">
+ <a href="#pid-instance_method" title="#pid (instance method)">- (Object) <strong>pid</strong> </a>
+
+
+
+ </span>
+
+
+ <span class="note title readonly">readonly</span>
+
+
+
+
+
+
+
+
+ <span class="summary_desc"><div class='inline'><p>
+Returns the value of attribute pid.
+</p>
+</div></span>
+
+</li>
+
+
+ <li class="public ">
+ <span class="summary_signature">
+
+ <a href="#stream-instance_method" title="#stream (instance method)">- (Object) <strong>stream</strong> </a>
+
+
+
+ </span>
+
+
+ <span class="note title readonly">readonly</span>
+
+
+
+
+
+
+
+
+ <span class="summary_desc"><div class='inline'><p>
+Returns the value of attribute stream.
+</p>
+</div></span>
+
+</li>
+
+
+ <li class="public ">
+ <span class="summary_signature">
+
<a href="#username-instance_method" title="#username (instance method)">- (Object) <strong>username</strong> </a>
</span>
@@ -288,10 +342,34 @@
<li class="public ">
<span class="summary_signature">
+ <a href="#init_stream-instance_method" title="#init_stream (instance method)">- (Object) <strong>init_stream</strong> </a>
+
+
+
+ </span>
+
+
+
+
+
+
+
+
+ <span class="summary_desc"><div class='inline'><p>
+Initializes the TweetStream client.
+</p>
+</div></span>
+
+</li>
+
+
+ <li class="public ">
+ <span class="summary_signature">
+
<a href="#initialize-instance_method" title="#initialize (instance method)">- (Bot) <strong>initialize</strong>(options = {}) </a>
</span>
@@ -401,20 +479,44 @@
<span class="summary_desc"><div class='inline'><p>
-Starts our TweetStream client running.
+Starts our TweetStream client running in a new process.
</p>
</div></span>
</li>
<li class="public ">
<span class="summary_signature">
+ <a href="#run_stream-instance_method" title="#run_stream (instance method)">- (Object) <strong>run_stream</strong> </a>
+
+
+
+ </span>
+
+
+
+
+
+
+
+
+ <span class="summary_desc"><div class='inline'><p>
+Runs the TweetStream client.
+</p>
+</div></span>
+
+</li>
+
+
+ <li class="public ">
+ <span class="summary_signature">
+
<a href="#send-instance_method" title="#send (instance method)">- (Object) <strong>send</strong>(resp) </a>
</span>
@@ -432,10 +534,34 @@
</div></span>
</li>
+ <li class="public ">
+ <span class="summary_signature">
+
+ <a href="#stop-instance_method" title="#stop (instance method)">- (Object) <strong>stop</strong> </a>
+
+
+
+ </span>
+
+
+
+
+
+
+
+
+ <span class="summary_desc"><div class='inline'><p>
+Shut down the TweetStream client.
+</p>
+</div></span>
+
+</li>
+
+
</ul>
@@ -474,25 +600,25 @@
<tr>
<td>
<pre class="lines">
-265
-266
-267
-268
-269
-270
-271
-272
-273
-274
-275
-276</pre>
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294</pre>
</td>
<td>
- <pre class="code"><span class="info file"># File 'lib/safubot/twitter.rb', line 265</span>
+ <pre class="code"><span class="info file"># File 'lib/safubot/twitter.rb', line 283</span>
<span class='kw'>def</span> <span class='id initialize'>initialize</span><span class='lparen'>(</span><span class='id options'>options</span><span class='op'>=</span><span class='lbrace'>{</span><span class='rbrace'>}</span><span class='rparen'>)</span>
<span class='id defaults'>defaults</span> <span class='op'>=</span> <span class='lbrace'>{</span> <span class='symbol'>:username</span> <span class='op'>=></span> <span class='kw'>nil</span><span class='comma'>,</span>
<span class='symbol'>:consumer_key</span> <span class='op'>=></span> <span class='kw'>nil</span><span class='comma'>,</span> <span class='symbol'>:consumer_secret</span> <span class='op'>=></span> <span class='kw'>nil</span><span class='comma'>,</span>
<span class='symbol'>:oauth_token</span> <span class='op'>=></span> <span class='kw'>nil</span><span class='comma'>,</span> <span class='symbol'>:oauth_token_secret</span> <span class='op'>=></span> <span class='kw'>nil</span><span class='comma'>,</span>
@@ -540,16 +666,16 @@
<tr>
<td>
<pre class="lines">
-159
160
-161</pre>
+161
+162</pre>
</td>
<td>
- <pre class="code"><span class="info file"># File 'lib/safubot/twitter.rb', line 159</span>
+ <pre class="code"><span class="info file"># File 'lib/safubot/twitter.rb', line 160</span>
<span class='kw'>def</span> <span class='id client'>client</span>
<span class='ivar'>@client</span>
<span class='kw'>end</span></pre>
</td>
@@ -583,16 +709,16 @@
<tr>
<td>
<pre class="lines">
-159
160
-161</pre>
+161
+162</pre>
</td>
<td>
- <pre class="code"><span class="info file"># File 'lib/safubot/twitter.rb', line 159</span>
+ <pre class="code"><span class="info file"># File 'lib/safubot/twitter.rb', line 160</span>
<span class='kw'>def</span> <span class='id opts'>opts</span>
<span class='ivar'>@opts</span>
<span class='kw'>end</span></pre>
</td>
@@ -600,10 +726,96 @@
</table>
</div>
<span id=""></span>
+ <span id="pid-instance_method"></span>
+ <div class="method_details ">
+ <p class="signature " id="pid-instance_method">
+
+ - (<tt>Object</tt>) <strong>pid</strong> <span class="extras">(readonly)</span>
+
+
+
+</p><div class="docstring">
+ <div class="discussion">
+ <p>
+Returns the value of attribute pid
+</p>
+
+
+ </div>
+</div>
+<div class="tags">
+
+
+</div><table class="source_code">
+ <tr>
+ <td>
+ <pre class="lines">
+
+
+160
+161
+162</pre>
+ </td>
+ <td>
+ <pre class="code"><span class="info file"># File 'lib/safubot/twitter.rb', line 160</span>
+
+<span class='kw'>def</span> <span class='id pid'>pid</span>
+ <span class='ivar'>@pid</span>
+<span class='kw'>end</span></pre>
+ </td>
+ </tr>
+</table>
+</div>
+
+
+ <span id=""></span>
+ <span id="stream-instance_method"></span>
+ <div class="method_details ">
+ <p class="signature " id="stream-instance_method">
+
+ - (<tt>Object</tt>) <strong>stream</strong> <span class="extras">(readonly)</span>
+
+
+
+</p><div class="docstring">
+ <div class="discussion">
+ <p>
+Returns the value of attribute stream
+</p>
+
+
+ </div>
+</div>
+<div class="tags">
+
+
+</div><table class="source_code">
+ <tr>
+ <td>
+ <pre class="lines">
+
+
+160
+161
+162</pre>
+ </td>
+ <td>
+ <pre class="code"><span class="info file"># File 'lib/safubot/twitter.rb', line 160</span>
+
+<span class='kw'>def</span> <span class='id stream'>stream</span>
+ <span class='ivar'>@stream</span>
+<span class='kw'>end</span></pre>
+ </td>
+ </tr>
+</table>
+</div>
+
+
+ <span id=""></span>
<span id="username-instance_method"></span>
<div class="method_details ">
<p class="signature " id="username-instance_method">
- (<tt>Object</tt>) <strong>username</strong> <span class="extras">(readonly)</span>
@@ -626,16 +838,16 @@
<tr>
<td>
<pre class="lines">
-159
160
-161</pre>
+161
+162</pre>
</td>
<td>
- <pre class="code"><span class="info file"># File 'lib/safubot/twitter.rb', line 159</span>
+ <pre class="code"><span class="info file"># File 'lib/safubot/twitter.rb', line 160</span>
<span class='kw'>def</span> <span class='id username'>username</span>
<span class='ivar'>@username</span>
<span class='kw'>end</span></pre>
</td>
@@ -673,17 +885,17 @@
<tr>
<td>
<pre class="lines">
-179
180
181
-182</pre>
+182
+183</pre>
</td>
<td>
- <pre class="code"><span class="info file"># File 'lib/safubot/twitter.rb', line 179</span>
+ <pre class="code"><span class="info file"># File 'lib/safubot/twitter.rb', line 180</span>
<span class='kw'>def</span> <span class='id handle_message'>handle_message</span><span class='lparen'>(</span><span class='id message'>message</span><span class='rparen'>)</span>
<span class='kw'>return</span> <span class='kw'>if</span> <span class='id message'>message</span><span class='period'>.</span><span class='id sender'>sender</span><span class='period'>.</span><span class='id screen_name'>screen_name</span> <span class='op'>==</span> <span class='ivar'>@username</span>
<span class='const'>DirectMessage</span><span class='period'>.</span><span class='id from'>from</span><span class='lparen'>(</span><span class='id message'>message</span><span class='rparen'>)</span><span class='period'>.</span><span class='id make_request'>make_request</span>
<span class='kw'>end</span></pre>
@@ -715,16 +927,16 @@
<tr>
<td>
<pre class="lines">
-174
175
-176</pre>
+176
+177</pre>
</td>
<td>
- <pre class="code"><span class="info file"># File 'lib/safubot/twitter.rb', line 174</span>
+ <pre class="code"><span class="info file"># File 'lib/safubot/twitter.rb', line 175</span>
<span class='kw'>def</span> <span class='id handle_request'>handle_request</span><span class='lparen'>(</span><span class='id req'>req</span><span class='rparen'>)</span>
<span class='id emit'>emit</span><span class='lparen'>(</span><span class='symbol'>:request</span><span class='comma'>,</span> <span class='id req'>req</span><span class='rparen'>)</span> <span class='kw'>unless</span> <span class='id req'>req</span><span class='period'>.</span><span class='id nil?'>nil?</span> <span class='op'>||</span> <span class='id req'>req</span><span class='period'>.</span><span class='id processed'>processed</span>
<span class='kw'>end</span></pre>
</td>
@@ -756,21 +968,21 @@
<tr>
<td>
<pre class="lines">
-186
187
188
189
190
191
192
-193</pre>
+193
+194</pre>
</td>
<td>
- <pre class="code"><span class="info file"># File 'lib/safubot/twitter.rb', line 186</span>
+ <pre class="code"><span class="info file"># File 'lib/safubot/twitter.rb', line 187</span>
<span class='kw'>def</span> <span class='id handle_tweet'>handle_tweet</span><span class='lparen'>(</span><span class='id status'>status</span><span class='rparen'>)</span>
<span class='kw'>return</span> <span class='kw'>if</span> <span class='id status'>status</span><span class='period'>.</span><span class='id user'>user</span><span class='period'>.</span><span class='id screen_name'>screen_name</span> <span class='op'>==</span> <span class='ivar'>@username</span>
<span class='kw'>if</span> <span class='id status'>status</span><span class='period'>.</span><span class='id text'>text</span><span class='period'>.</span><span class='id match'>match</span><span class='lparen'>(</span><span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>@</span><span class='embexpr_beg'>#{</span><span class='ivar'>@username</span><span class='rbrace'>}</span><span class='regexp_end'>/i</span></span><span class='rparen'>)</span>
<span class='const'>Tweet</span><span class='period'>.</span><span class='id from'>from</span><span class='lparen'>(</span><span class='id status'>status</span><span class='rparen'>)</span><span class='period'>.</span><span class='id make_request'>make_request</span>
@@ -782,10 +994,84 @@
</tr>
</table>
</div>
<div class="method_details ">
+ <p class="signature " id="init_stream-instance_method">
+
+ - (<tt>Object</tt>) <strong>init_stream</strong>
+
+
+
+</p><div class="docstring">
+ <div class="discussion">
+ <p>
+Initializes the TweetStream client.
+</p>
+
+
+ </div>
+</div>
+<div class="tags">
+
+
+</div><table class="source_code">
+ <tr>
+ <td>
+ <pre class="lines">
+
+
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246</pre>
+ </td>
+ <td>
+ <pre class="code"><span class="info file"># File 'lib/safubot/twitter.rb', line 227</span>
+
+<span class='kw'>def</span> <span class='id init_stream'>init_stream</span>
+ <span class='ivar'>@stream</span> <span class='op'>=</span> <span class='const'>TweetStream</span><span class='op'>::</span><span class='const'>Client</span><span class='period'>.</span><span class='id new'>new</span><span class='lparen'>(</span><span class='ivar'>@opts</span><span class='rparen'>)</span>
+
+ <span class='ivar'>@stream</span><span class='period'>.</span><span class='id on_direct_message'>on_direct_message</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id message'>message</span><span class='op'>|</span>
+ <span class='id req'>req</span> <span class='op'>=</span> <span class='id handle_message'>handle_message</span><span class='lparen'>(</span><span class='id message'>message</span><span class='rparen'>)</span>
+ <span class='id handle_request'>handle_request</span><span class='lparen'>(</span><span class='id req'>req</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='id req'>req</span><span class='period'>.</span><span class='id is_a?'>is_a?</span> <span class='const'>Request</span>
+ <span class='kw'>end</span>
+
+ <span class='ivar'>@stream</span><span class='period'>.</span><span class='id on_error'>on_error</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id err'>err</span><span class='op'>|</span>
+ <span class='kw'>if</span> <span class='id err'>err</span><span class='period'>.</span><span class='id match'>match</span><span class='lparen'>(</span><span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>invalid status code: 401</span><span class='regexp_end'>/</span></span><span class='rparen'>)</span>
+<span class='const'>Log</span><span class='period'>.</span><span class='id error'>error</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>TweetStream authentication failure!</span><span class='tstring_end'>"</span></span>
+ <span class='kw'>else</span>
+<span class='const'>Log</span><span class='period'>.</span><span class='id error'>error</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Unhandled TweetStream error: </span><span class='embexpr_beg'>#{</span><span class='id error_report'>error_report</span><span class='lparen'>(</span><span class='gvar'>$!</span><span class='rparen'>)</span><span class='rbrace'>}</span><span class='tstring_end'>"</span></span>
+ <span class='kw'>end</span>
+ <span class='kw'>end</span>
+
+ <span class='ivar'>@stream</span><span class='period'>.</span><span class='id on_inited'>on_inited</span> <span class='kw'>do</span>
+ <span class='const'>Log</span><span class='period'>.</span><span class='id info'>info</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>TweetStream client is online at @</span><span class='embexpr_beg'>#{</span><span class='ivar'>@username</span><span class='rbrace'>}</span><span class='tstring_content'> :3</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span>
+ <span class='kw'>end</span>
+<span class='kw'>end</span></pre>
+ </td>
+ </tr>
+</table>
+</div>
+
+ <div class="method_details ">
<p class="signature " id="pull-instance_method">
- (<tt>Object</tt>) <strong>pull</strong>
@@ -808,11 +1094,10 @@
<tr>
<td>
<pre class="lines">
-209
210
211
212
213
214
@@ -822,14 +1107,15 @@
218
219
220
221
222
-223</pre>
+223
+224</pre>
</td>
<td>
- <pre class="code"><span class="info file"># File 'lib/safubot/twitter.rb', line 209</span>
+ <pre class="code"><span class="info file"># File 'lib/safubot/twitter.rb', line 210</span>
<span class='kw'>def</span> <span class='id pull'>pull</span>
<span class='kw'>begin</span>
<span class='ivar'>@client</span><span class='period'>.</span><span class='id direct_messages'>direct_messages</span><span class='period'>.</span><span class='id each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id message'>message</span><span class='op'>|</span>
<span class='id handle_message'>handle_message</span><span class='lparen'>(</span><span class='id message'>message</span><span class='rparen'>)</span>
@@ -839,11 +1125,11 @@
<span class='id handle_tweet'>handle_tweet</span><span class='lparen'>(</span><span class='id mention'>mention</span><span class='rparen'>)</span>
<span class='kw'>end</span>
<span class='kw'>rescue</span> <span class='op'>::</span><span class='const'>Twitter</span><span class='op'>::</span><span class='const'>Error</span><span class='op'>::</span><span class='const'>ServiceUnavailable</span>
<span class='const'>Log</span><span class='period'>.</span><span class='id error'>error</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Twitter: Couldn't pull tweets due to temporary service unavailability.</span><span class='tstring_end'>"</span></span>
<span class='kw'>rescue</span> <span class='const'>Exception</span> <span class='op'>=></span> <span class='id e'>e</span>
- <span class='const'>Log</span><span class='period'>.</span><span class='id error'>error</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Twitter: Unhandled error: </span><span class='embexpr_beg'>#{</span><span class='id e'>e</span><span class='rbrace'>}</span><span class='tstring_content'>\n</span><span class='embexpr_beg'>#{</span><span class='id e'>e</span><span class='period'>.</span><span class='id backtrace'>backtrace</span><span class='period'>.</span><span class='id join'>join</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>\n\t</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span><span class='rbrace'>}</span><span class='tstring_end'>"</span></span>
+ <span class='const'>Log</span><span class='period'>.</span><span class='id error'>error</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Twitter: Unhandled error: </span><span class='embexpr_beg'>#{</span><span class='id error_report'>error_report</span><span class='lparen'>(</span><span class='id e'>e</span><span class='rparen'>)</span><span class='rbrace'>}</span><span class='tstring_end'>"</span></span>
<span class='kw'>end</span>
<span class='kw'>end</span></pre>
</td>
</tr>
</table>
@@ -910,16 +1196,16 @@
<tr>
<td>
<pre class="lines">
-203
204
-205</pre>
+205
+206</pre>
</td>
<td>
- <pre class="code"><span class="info file"># File 'lib/safubot/twitter.rb', line 203</span>
+ <pre class="code"><span class="info file"># File 'lib/safubot/twitter.rb', line 204</span>
<span class='kw'>def</span> <span class='id reply'>reply</span><span class='lparen'>(</span><span class='id tweet'>tweet</span><span class='comma'>,</span> <span class='id text'>text</span><span class='rparen'>)</span>
<span class='ivar'>@client</span><span class='period'>.</span><span class='id update'>update</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='embexpr_beg'>#{</span><span class='id reply_header'>reply_header</span><span class='lparen'>(</span><span class='id tweet'>tweet</span><span class='rparen'>)</span><span class='rbrace'>}</span><span class='tstring_content'> </span><span class='embexpr_beg'>#{</span><span class='id text'>text</span><span class='rbrace'>}</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='symbol'>:in_reply_to_status_id</span> <span class='op'>=></span> <span class='id tweet'>tweet</span><span class='period'>.</span><span class='id raw'>raw</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>id</span><span class='tstring_end'>'</span></span><span class='rbracket'>]</span><span class='rparen'>)</span>
<span class='kw'>end</span></pre>
</td>
@@ -950,16 +1236,16 @@
<tr>
<td>
<pre class="lines">
-196
197
-198</pre>
+198
+199</pre>
</td>
<td>
- <pre class="code"><span class="info file"># File 'lib/safubot/twitter.rb', line 196</span>
+ <pre class="code"><span class="info file"># File 'lib/safubot/twitter.rb', line 197</span>
<span class='kw'>def</span> <span class='id reply_header'>reply_header</span><span class='lparen'>(</span><span class='id tweet'>tweet</span><span class='rparen'>)</span>
<span class='lparen'>(</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>@</span><span class='embexpr_beg'>#{</span><span class='id tweet'>tweet</span><span class='period'>.</span><span class='id username'>username</span><span class='rbrace'>}</span><span class='tstring_end'>"</span></span><span class='rbracket'>]</span> <span class='op'>+</span> <span class='lparen'>(</span><span class='id tweet'>tweet</span><span class='period'>.</span><span class='id header_mentions'>header_mentions</span> <span class='op'>-</span> <span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>@</span><span class='embexpr_beg'>#{</span><span class='ivar'>@username</span><span class='rbrace'>}</span><span class='tstring_end'>"</span></span><span class='rbracket'>]</span><span class='rparen'>)</span><span class='rparen'>)</span><span class='period'>.</span><span class='id join'>join</span>
<span class='kw'>end</span></pre>
</td>
@@ -975,11 +1261,11 @@
</p><div class="docstring">
<div class="discussion">
<p>
-Starts our TweetStream client running.
+Starts our TweetStream client running in a new process.
</p>
</div>
</div>
@@ -990,33 +1276,58 @@
<tr>
<td>
<pre class="lines">
-226
-227
-228
-229
-230
-231
-232
-233
-234
-235
-236
-237
-238
-239
-240
-241
-242
-243
-244
-245
-246
-247
-248
+267
+268
+269
+270
+271
+272
+273</pre>
+ </td>
+ <td>
+ <pre class="code"><span class="info file"># File 'lib/safubot/twitter.rb', line 267</span>
+
+<span class='kw'>def</span> <span class='id run'>run</span>
+ <span class='ivar'>@pid</span> <span class='op'>=</span> <span class='const'>Process</span><span class='period'>.</span><span class='id fork'>fork</span> <span class='kw'>do</span>
+ <span class='const'>Signal</span><span class='period'>.</span><span class='id trap'>trap</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>TERM</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span> <span class='lbrace'>{</span> <span class='id stop'>stop</span> <span class='rbrace'>}</span>
+ <span class='id init_stream'>init_stream</span>
+ <span class='id run_stream'>run_stream</span>
+ <span class='kw'>end</span>
+<span class='kw'>end</span></pre>
+ </td>
+ </tr>
+</table>
+</div>
+
+ <div class="method_details ">
+ <p class="signature " id="run_stream-instance_method">
+
+ - (<tt>Object</tt>) <strong>run_stream</strong>
+
+
+
+</p><div class="docstring">
+ <div class="discussion">
+ <p>
+Runs the TweetStream client.
+</p>
+
+
+ </div>
+</div>
+<div class="tags">
+
+
+</div><table class="source_code">
+ <tr>
+ <td>
+ <pre class="lines">
+
+
249
250
251
252
253
@@ -1025,50 +1336,33 @@
256
257
258
259
260
-261</pre>
+261
+262
+263
+264</pre>
</td>
<td>
- <pre class="code"><span class="info file"># File 'lib/safubot/twitter.rb', line 226</span>
+ <pre class="code"><span class="info file"># File 'lib/safubot/twitter.rb', line 249</span>
-<span class='kw'>def</span> <span class='id run'>run</span>
- <span class='const'>Fiber</span><span class='period'>.</span><span class='id new'>new</span> <span class='kw'>do</span>
- <span class='ivar'>@stream</span> <span class='op'>=</span> <span class='const'>TweetStream</span><span class='op'>::</span><span class='const'>Client</span><span class='period'>.</span><span class='id new'>new</span><span class='lparen'>(</span><span class='ivar'>@opts</span><span class='rparen'>)</span>
-
- <span class='ivar'>@stream</span><span class='period'>.</span><span class='id on_direct_message'>on_direct_message</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id message'>message</span><span class='op'>|</span>
-<span class='id dm'>dm</span> <span class='op'>=</span> <span class='id handle_message'>handle_message</span><span class='lparen'>(</span><span class='id message'>message</span><span class='rparen'>)</span>
-<span class='id handle_request'>handle_request</span><span class='lparen'>(</span><span class='id dm'>dm</span><span class='period'>.</span><span class='id request'>request</span><span class='rparen'>)</span>
+<span class='kw'>def</span> <span class='id run_stream'>run_stream</span>
+ <span class='kw'>begin</span>
+ <span class='ivar'>@stream</span><span class='period'>.</span><span class='id userstream'>userstream</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id status'>status</span><span class='op'>|</span>
+<span class='id req'>req</span> <span class='op'>=</span> <span class='id handle_tweet'>handle_tweet</span><span class='lparen'>(</span><span class='id status'>status</span><span class='rparen'>)</span>
+<span class='id handle_request'>handle_request</span><span class='lparen'>(</span><span class='id req'>req</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='id req'>req</span><span class='period'>.</span><span class='id is_a?'>is_a?</span> <span class='const'>Request</span>
<span class='kw'>end</span>
-
- <span class='ivar'>@stream</span><span class='period'>.</span><span class='id on_error'>on_error</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id err'>err</span><span class='op'>|</span>
-<span class='comment'># HACK (Mispy): For some reason this is a String instead of an Exception.
-</span><span class='kw'>if</span> <span class='id err'>err</span><span class='period'>.</span><span class='id match'>match</span><span class='lparen'>(</span><span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>invalid status code: 401</span><span class='regexp_end'>/</span></span><span class='rparen'>)</span>
- <span class='const'>Log</span><span class='period'>.</span><span class='id error'>error</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>TweetStream authentication failure!</span><span class='tstring_end'>"</span></span>
-<span class='kw'>else</span>
- <span class='const'>Log</span><span class='period'>.</span><span class='id error'>error</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Unhandled TweetStream error: </span><span class='embexpr_beg'>#{</span><span class='gvar'>$!</span><span class='rbrace'>}</span><span class='tstring_content'> </span><span class='embexpr_beg'>#{</span><span class='gvar'>$@</span><span class='rbrace'>}</span><span class='tstring_end'>"</span></span>
-<span class='kw'>end</span>
+ <span class='kw'>rescue</span> <span class='const'>Exception</span> <span class='op'>=></span> <span class='id e'>e</span>
+ <span class='kw'>unless</span> <span class='id e'>e</span><span class='period'>.</span><span class='id is_a?'>is_a?</span><span class='lparen'>(</span><span class='const'>Interrupt</span><span class='rparen'>)</span> <span class='op'>||</span> <span class='id e'>e</span><span class='period'>.</span><span class='id is_a?'>is_a?</span><span class='lparen'>(</span><span class='const'>SignalException</span><span class='rparen'>)</span>
+<span class='const'>Log</span><span class='period'>.</span><span class='id error'>error</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>TweetStream client exited unexpectedly: </span><span class='embexpr_beg'>#{</span><span class='id error_report'>error_report</span><span class='lparen'>(</span><span class='id e'>e</span><span class='rparen'>)</span><span class='rbrace'>}</span><span class='tstring_end'>"</span></span>
+<span class='const'>Log</span><span class='period'>.</span><span class='id error'>error</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Restarting TweetStream client in 5 seconds.</span><span class='tstring_end'>"</span></span>
+<span class='id sleep'>sleep</span> <span class='int'>5</span><span class='semicolon'>;</span> <span class='id init_stream'>init_stream</span><span class='semicolon'>;</span> <span class='id run_stream'>run_stream</span>
<span class='kw'>end</span>
-
- <span class='kw'>begin</span>
-<span class='ivar'>@stream</span><span class='period'>.</span><span class='id userstream'>userstream</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id status'>status</span><span class='op'>|</span>
- <span class='id tweet'>tweet</span> <span class='op'>=</span> <span class='id handle_tweet'>handle_tweet</span><span class='lparen'>(</span><span class='id status'>status</span><span class='rparen'>)</span>
- <span class='id handle_request'>handle_request</span><span class='lparen'>(</span><span class='id tweet'>tweet</span><span class='period'>.</span><span class='id request'>request</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='id tweet'>tweet</span><span class='period'>.</span><span class='id is_a?'>is_a?</span> <span class='const'>Tweet</span>
-<span class='kw'>end</span>
- <span class='kw'>rescue</span> <span class='const'>Exception</span> <span class='op'>=></span> <span class='id e'>e</span>
-<span class='kw'>if</span> <span class='id e'>e</span><span class='period'>.</span><span class='id is_a?'>is_a?</span> <span class='const'>Interrupt</span>
- <span class='id exit'>exit</span>
-<span class='kw'>else</span>
- <span class='const'>Log</span><span class='period'>.</span><span class='id error'>error</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>TweetStream event loop exited: </span><span class='embexpr_beg'>#{</span><span class='gvar'>$!</span><span class='rbrace'>}</span><span class='tstring_content'> </span><span class='embexpr_beg'>#{</span><span class='gvar'>$@</span><span class='rbrace'>}</span><span class='tstring_end'>"</span></span>
- <span class='const'>Log</span><span class='period'>.</span><span class='id error'>error</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Reinitialising TweetStream in 5 seconds.</span><span class='tstring_end'>"</span></span>
- <span class='const'>EM</span><span class='op'>::</span><span class='const'>Timer</span><span class='period'>.</span><span class='id new'>new</span><span class='lparen'>(</span><span class='int'>5</span><span class='rparen'>)</span> <span class='lbrace'>{</span> <span class='id run'>run</span> <span class='rbrace'>}</span>
-<span class='kw'>end</span>
- <span class='kw'>end</span>
-
- <span class='const'>Log</span><span class='period'>.</span><span class='id info'>info</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Twitter client is online at @</span><span class='embexpr_beg'>#{</span><span class='ivar'>@username</span><span class='rbrace'>}</span><span class='tstring_content'> :3</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span>
- <span class='kw'>end</span><span class='period'>.</span><span class='id resume'>resume</span>
+ <span class='kw'>else</span>
+ <span class='const'>Log</span><span class='period'>.</span><span class='id info'>info</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>TweetStream client shutdown complete.</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span>
+ <span class='kw'>end</span>
<span class='kw'>end</span></pre>
</td>
</tr>
</table>
</div>
@@ -1096,23 +1390,23 @@
<tr>
<td>
<pre class="lines">
-162
163
164
165
166
167
168
169
170
-171</pre>
+171
+172</pre>
</td>
<td>
- <pre class="code"><span class="info file"># File 'lib/safubot/twitter.rb', line 162</span>
+ <pre class="code"><span class="info file"># File 'lib/safubot/twitter.rb', line 163</span>
<span class='kw'>def</span> <span class='id send'>send</span><span class='lparen'>(</span><span class='id resp'>resp</span><span class='rparen'>)</span>
<span class='id source'>source</span> <span class='op'>=</span> <span class='id resp'>resp</span><span class='period'>.</span><span class='id request'>request</span><span class='period'>.</span><span class='id source'>source</span>
<span class='kw'>if</span> <span class='id source'>source</span><span class='period'>.</span><span class='id is_a?'>is_a?</span><span class='lparen'>(</span><span class='const'>DirectMessage</span><span class='rparen'>)</span>
<span class='ivar'>@client</span><span class='period'>.</span><span class='id direct_message_create'>direct_message_create</span><span class='lparen'>(</span><span class='id source'>source</span><span class='period'>.</span><span class='id raw'>raw</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>sender</span><span class='tstring_end'>'</span></span><span class='rbracket'>]</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>screen_name</span><span class='tstring_end'>'</span></span><span class='rbracket'>]</span><span class='comma'>,</span> <span class='id resp'>resp</span><span class='period'>.</span><span class='id text'>text</span><span class='rparen'>)</span>
@@ -1125,15 +1419,57 @@
</td>
</tr>
</table>
</div>
+ <div class="method_details ">
+ <p class="signature " id="stop-instance_method">
+
+ - (<tt>Object</tt>) <strong>stop</strong>
+
+
+
+</p><div class="docstring">
+ <div class="discussion">
+ <p>
+Shut down the TweetStream client.
+</p>
+
+
</div>
+</div>
+<div class="tags">
+
+</div><table class="source_code">
+ <tr>
+ <td>
+ <pre class="lines">
+
+
+276
+277
+278
+279</pre>
+ </td>
+ <td>
+ <pre class="code"><span class="info file"># File 'lib/safubot/twitter.rb', line 276</span>
+
+<span class='kw'>def</span> <span class='id stop'>stop</span>
+ <span class='ivar'>@stream</span><span class='period'>.</span><span class='id stop'>stop</span> <span class='kw'>if</span> <span class='ivar'>@stream</span>
+ <span class='const'>Process</span><span class='period'>.</span><span class='id kill'>kill</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>TERM</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='ivar'>@pid</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='ivar'>@pid</span>
+<span class='kw'>end</span></pre>
+ </td>
+ </tr>
+</table>
</div>
+ </div>
+
+</div>
+
<div id="footer">
- Generated on Mon Nov 28 20:20:04 2011 by
+ Generated on Tue Nov 29 11:44:04 2011 by
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
0.7.3 (ruby-1.9.2).
</div>
</body>
\ No newline at end of file