safubot 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/.yardoc/checksums +5 -5
- data/.yardoc/objects/root.dat +0 -0
- data/.yardoc/proxy_types +0 -0
- data/README.md +9 -9
- data/doc/Safubot/Bot.html +334 -218
- data/doc/Safubot/Evented.html +1 -1
- data/doc/Safubot/KnownUser.html +1 -1
- data/doc/Safubot/Log.html +1 -1
- data/doc/Safubot/Problem.html +130 -0
- data/doc/Safubot/Problematic.html +282 -0
- data/doc/Safubot/Query.html +50 -1
- data/doc/Safubot/Request.html +19 -2
- data/doc/Safubot/Response.html +19 -2
- data/doc/Safubot/Test.html +1 -1
- data/doc/Safubot/Twitter/Bot.html +248 -135
- data/doc/Safubot/Twitter/DirectMessage.html +22 -22
- data/doc/Safubot/Twitter/Tweet.html +40 -40
- data/doc/Safubot/Twitter.html +1 -1
- data/doc/Safubot/XMPP/Bot.html +47 -31
- data/doc/Safubot/XMPP/Message.html +1 -1
- data/doc/Safubot/XMPP.html +1 -1
- data/doc/Safubot.html +4 -4
- data/doc/_index.html +26 -4
- data/doc/class_list.html +1 -1
- data/doc/file.README.html +11 -10
- data/doc/index.html +11 -10
- data/doc/method_list.html +103 -79
- data/doc/top-level-namespace.html +1 -1
- data/lib/safubot/bot.rb +100 -26
- data/lib/safubot/test_helper.rb +4 -0
- data/lib/safubot/twitter.rb +6 -7
- data/lib/safubot/version.rb +1 -1
- data/lib/safubot/xmpp.rb +9 -3
- data/safubot.gemspec +1 -0
- metadata +119 -113
data/doc/Safubot/Bot.html
CHANGED
@@ -293,7 +293,7 @@ Performs appropriate dispatch operation for response type.
|
|
293
293
|
<li class="public ">
|
294
294
|
<span class="summary_signature">
|
295
295
|
|
296
|
-
<a href="#
|
296
|
+
<a href="#dispatch_error-instance_method" title="#dispatch_error (instance method)">- (Object) <strong>dispatch_error</strong>(resp, e) </a>
|
297
297
|
|
298
298
|
|
299
299
|
|
@@ -307,7 +307,8 @@ Performs appropriate dispatch operation for response type.
|
|
307
307
|
|
308
308
|
|
309
309
|
<span class="summary_desc"><div class='inline'><p>
|
310
|
-
|
310
|
+
Records an error in dispatch and emits a corresponding :dispatch_error
|
311
|
+
event.
|
311
312
|
</p>
|
312
313
|
</div></span>
|
313
314
|
|
@@ -317,7 +318,7 @@ Initialises Twitter-related functionality.
|
|
317
318
|
<li class="public ">
|
318
319
|
<span class="summary_signature">
|
319
320
|
|
320
|
-
<a href="#
|
321
|
+
<a href="#enable_twitter-instance_method" title="#enable_twitter (instance method)">- (Object) <strong>enable_twitter</strong>(opts = {}) </a>
|
321
322
|
|
322
323
|
|
323
324
|
|
@@ -331,7 +332,7 @@ Initialises Twitter-related functionality.
|
|
331
332
|
|
332
333
|
|
333
334
|
<span class="summary_desc"><div class='inline'><p>
|
334
|
-
Initialises
|
335
|
+
Initialises Twitter-related functionality.
|
335
336
|
</p>
|
336
337
|
</div></span>
|
337
338
|
|
@@ -341,14 +342,12 @@ Initialises XMPP-related functionality.
|
|
341
342
|
<li class="public ">
|
342
343
|
<span class="summary_signature">
|
343
344
|
|
344
|
-
<a href="#
|
345
|
+
<a href="#enable_xmpp-instance_method" title="#enable_xmpp (instance method)">- (Object) <strong>enable_xmpp</strong>(options = {}) </a>
|
345
346
|
|
346
347
|
|
347
348
|
|
348
349
|
</span>
|
349
350
|
|
350
|
-
<span class="note title constructor">constructor</span>
|
351
|
-
|
352
351
|
|
353
352
|
|
354
353
|
|
@@ -357,7 +356,7 @@ Initialises XMPP-related functionality.
|
|
357
356
|
|
358
357
|
|
359
358
|
<span class="summary_desc"><div class='inline'><p>
|
360
|
-
|
359
|
+
Initialises XMPP-related functionality.
|
361
360
|
</p>
|
362
361
|
</div></span>
|
363
362
|
|
@@ -367,12 +366,14 @@ A new instance of Bot.
|
|
367
366
|
<li class="public ">
|
368
367
|
<span class="summary_signature">
|
369
368
|
|
370
|
-
<a href="#
|
369
|
+
<a href="#initialize-instance_method" title="#initialize (instance method)">- (Bot) <strong>initialize</strong>(options = {}) </a>
|
371
370
|
|
372
371
|
|
373
372
|
|
374
373
|
</span>
|
375
374
|
|
375
|
+
<span class="note title constructor">constructor</span>
|
376
|
+
|
376
377
|
|
377
378
|
|
378
379
|
|
@@ -381,7 +382,7 @@ A new instance of Bot.
|
|
381
382
|
|
382
383
|
|
383
384
|
<span class="summary_desc"><div class='inline'><p>
|
384
|
-
|
385
|
+
A new instance of Bot.
|
385
386
|
</p>
|
386
387
|
</div></span>
|
387
388
|
|
@@ -391,7 +392,7 @@ Goes through each unprocessed Request and submits it for processing.
|
|
391
392
|
<li class="public ">
|
392
393
|
<span class="summary_signature">
|
393
394
|
|
394
|
-
<a href="#
|
395
|
+
<a href="#process-instance_method" title="#process (instance method)">- (Object) <strong>process</strong> </a>
|
395
396
|
|
396
397
|
|
397
398
|
|
@@ -405,7 +406,7 @@ Goes through each unprocessed Request and submits it for processing.
|
|
405
406
|
|
406
407
|
|
407
408
|
<span class="summary_desc"><div class='inline'><p>
|
408
|
-
|
409
|
+
Goes through each unprocessed Request and submits it for processing.
|
409
410
|
</p>
|
410
411
|
</div></span>
|
411
412
|
|
@@ -415,7 +416,7 @@ Processes an individual request (synchronously).
|
|
415
416
|
<li class="public ">
|
416
417
|
<span class="summary_signature">
|
417
418
|
|
418
|
-
<a href="#
|
419
|
+
<a href="#process_request-instance_method" title="#process_request (instance method)">- (Object) <strong>process_request</strong>(req) </a>
|
419
420
|
|
420
421
|
|
421
422
|
|
@@ -429,8 +430,7 @@ Processes an individual request (synchronously).
|
|
429
430
|
|
430
431
|
|
431
432
|
<span class="summary_desc"><div class='inline'><p>
|
432
|
-
|
433
|
-
Twitter AJAX API).
|
433
|
+
Processes an individual request (synchronously).
|
434
434
|
</p>
|
435
435
|
</div></span>
|
436
436
|
|
@@ -440,7 +440,7 @@ Twitter AJAX API).
|
|
440
440
|
<li class="public ">
|
441
441
|
<span class="summary_signature">
|
442
442
|
|
443
|
-
<a href="#
|
443
|
+
<a href="#pull-instance_method" title="#pull (instance method)">- (Object) <strong>pull</strong> </a>
|
444
444
|
|
445
445
|
|
446
446
|
|
@@ -454,7 +454,8 @@ Twitter AJAX API).
|
|
454
454
|
|
455
455
|
|
456
456
|
<span class="summary_desc"><div class='inline'><p>
|
457
|
-
|
457
|
+
This pulls requests from passive non-streaming sources (currently, the
|
458
|
+
Twitter AJAX API).
|
458
459
|
</p>
|
459
460
|
</div></span>
|
460
461
|
|
@@ -464,7 +465,7 @@ Dispatches all undispatched Responses.
|
|
464
465
|
<li class="public ">
|
465
466
|
<span class="summary_signature">
|
466
467
|
|
467
|
-
<a href="#
|
468
|
+
<a href="#push-instance_method" title="#push (instance method)">- (Object) <strong>push</strong> </a>
|
468
469
|
|
469
470
|
|
470
471
|
|
@@ -478,7 +479,7 @@ Dispatches all undispatched Responses.
|
|
478
479
|
|
479
480
|
|
480
481
|
<span class="summary_desc"><div class='inline'><p>
|
481
|
-
|
482
|
+
Dispatches all undispatched Responses.
|
482
483
|
</p>
|
483
484
|
</div></span>
|
484
485
|
|
@@ -488,7 +489,7 @@ Records an error and emits a corresponding :request_error event.
|
|
488
489
|
<li class="public ">
|
489
490
|
<span class="summary_signature">
|
490
491
|
|
491
|
-
<a href="#
|
492
|
+
<a href="#request_error-instance_method" title="#request_error (instance method)">- (Object) <strong>request_error</strong>(req, e) </a>
|
492
493
|
|
493
494
|
|
494
495
|
|
@@ -502,7 +503,8 @@ Records an error and emits a corresponding :request_error event.
|
|
502
503
|
|
503
504
|
|
504
505
|
<span class="summary_desc"><div class='inline'><p>
|
505
|
-
|
506
|
+
Records an error in processing and emits a corresponding :request_error
|
507
|
+
event.
|
506
508
|
</p>
|
507
509
|
</div></span>
|
508
510
|
|
@@ -512,7 +514,7 @@ Adds a response to the queue.
|
|
512
514
|
<li class="public ">
|
513
515
|
<span class="summary_signature">
|
514
516
|
|
515
|
-
<a href="#
|
517
|
+
<a href="#respond-instance_method" title="#respond (instance method)">- (Object) <strong>respond</strong>(req, text) </a>
|
516
518
|
|
517
519
|
|
518
520
|
|
@@ -526,7 +528,7 @@ Adds a response to the queue.
|
|
526
528
|
|
527
529
|
|
528
530
|
<span class="summary_desc"><div class='inline'><p>
|
529
|
-
|
531
|
+
Adds a response to the queue and dispatches it.
|
530
532
|
</p>
|
531
533
|
</div></span>
|
532
534
|
|
@@ -647,16 +649,16 @@ A new instance of Bot
|
|
647
649
|
<pre class="lines">
|
648
650
|
|
649
651
|
|
650
|
-
|
651
|
-
|
652
|
-
|
653
|
-
|
654
|
-
|
655
|
-
|
656
|
-
|
652
|
+
264
|
653
|
+
265
|
654
|
+
266
|
655
|
+
267
|
656
|
+
268
|
657
|
+
269
|
658
|
+
270</pre>
|
657
659
|
</td>
|
658
660
|
<td>
|
659
|
-
<pre class="code"><span class="info file"># File 'lib/safubot/bot.rb', line
|
661
|
+
<pre class="code"><span class="info file"># File 'lib/safubot/bot.rb', line 264</span>
|
660
662
|
|
661
663
|
<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>
|
662
664
|
<span class='id defaults'>defaults</span> <span class='op'>=</span> <span class='lbrace'>{</span> <span class='symbol'>:database</span> <span class='op'>=></span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>safubot</span><span class='tstring_end'>"</span></span> <span class='rbrace'>}</span>
|
@@ -703,12 +705,12 @@ Returns the value of attribute opts
|
|
703
705
|
<pre class="lines">
|
704
706
|
|
705
707
|
|
706
|
-
|
707
|
-
|
708
|
-
|
708
|
+
81
|
709
|
+
82
|
710
|
+
83</pre>
|
709
711
|
</td>
|
710
712
|
<td>
|
711
|
-
<pre class="code"><span class="info file"># File 'lib/safubot/bot.rb', line
|
713
|
+
<pre class="code"><span class="info file"># File 'lib/safubot/bot.rb', line 81</span>
|
712
714
|
|
713
715
|
<span class='kw'>def</span> <span class='id opts'>opts</span>
|
714
716
|
<span class='ivar'>@opts</span>
|
@@ -746,12 +748,12 @@ Returns the value of attribute twitter
|
|
746
748
|
<pre class="lines">
|
747
749
|
|
748
750
|
|
749
|
-
|
750
|
-
|
751
|
-
|
751
|
+
81
|
752
|
+
82
|
753
|
+
83</pre>
|
752
754
|
</td>
|
753
755
|
<td>
|
754
|
-
<pre class="code"><span class="info file"># File 'lib/safubot/bot.rb', line
|
756
|
+
<pre class="code"><span class="info file"># File 'lib/safubot/bot.rb', line 81</span>
|
755
757
|
|
756
758
|
<span class='kw'>def</span> <span class='id twitter'>twitter</span>
|
757
759
|
<span class='ivar'>@twitter</span>
|
@@ -789,12 +791,12 @@ Returns the value of attribute xmpp
|
|
789
791
|
<pre class="lines">
|
790
792
|
|
791
793
|
|
792
|
-
|
793
|
-
|
794
|
-
|
794
|
+
81
|
795
|
+
82
|
796
|
+
83</pre>
|
795
797
|
</td>
|
796
798
|
<td>
|
797
|
-
<pre class="code"><span class="info file"># File 'lib/safubot/bot.rb', line
|
799
|
+
<pre class="code"><span class="info file"># File 'lib/safubot/bot.rb', line 81</span>
|
798
800
|
|
799
801
|
<span class='kw'>def</span> <span class='id xmpp'>xmpp</span>
|
800
802
|
<span class='ivar'>@xmpp</span>
|
@@ -877,16 +879,16 @@ KnownUser.by_name(‘testing’)
|
|
877
879
|
<pre class="lines">
|
878
880
|
|
879
881
|
|
880
|
-
61
|
881
|
-
62
|
882
|
-
63
|
883
|
-
64
|
884
882
|
65
|
885
883
|
66
|
886
|
-
67
|
884
|
+
67
|
885
|
+
68
|
886
|
+
69
|
887
|
+
70
|
888
|
+
71</pre>
|
887
889
|
</td>
|
888
890
|
<td>
|
889
|
-
<pre class="code"><span class="info file"># File 'lib/safubot/test_helper.rb', line
|
891
|
+
<pre class="code"><span class="info file"># File 'lib/safubot/test_helper.rb', line 65</span>
|
890
892
|
|
891
893
|
<span class='kw'>def</span> <span class='id answer'>answer</span><span class='lparen'>(</span><span class='id text'>text</span><span class='comma'>,</span> <span class='id user'>user</span><span class='op'>=</span><span class='kw'>nil</span><span class='rparen'>)</span>
|
892
894
|
<span class='id user'>user</span> <span class='op'>||=</span> <span class='const'>KnownUser</span><span class='period'>.</span><span class='id by_name'>by_name</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>testing</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span>
|
@@ -964,20 +966,19 @@ The operation to be performed in a separate thread.
|
|
964
966
|
<pre class="lines">
|
965
967
|
|
966
968
|
|
967
|
-
|
968
|
-
|
969
|
-
|
970
|
-
|
971
|
-
|
972
|
-
|
973
|
-
|
974
|
-
|
975
|
-
|
976
|
-
|
977
|
-
148</pre>
|
969
|
+
211
|
970
|
+
212
|
971
|
+
213
|
972
|
+
214
|
973
|
+
215
|
974
|
+
216
|
975
|
+
217
|
976
|
+
218
|
977
|
+
219
|
978
|
+
220</pre>
|
978
979
|
</td>
|
979
980
|
<td>
|
980
|
-
<pre class="code"><span class="info file"># File 'lib/safubot/bot.rb', line
|
981
|
+
<pre class="code"><span class="info file"># File 'lib/safubot/bot.rb', line 211</span>
|
981
982
|
|
982
983
|
<span class='kw'>def</span> <span class='id concurrently'>concurrently</span><span class='lparen'>(</span><span class='id req'>req</span><span class='comma'>,</span> <span class='op'>&</span><span class='id blk'>blk</span><span class='rparen'>)</span>
|
983
984
|
<span class='const'>Thread</span><span class='period'>.</span><span class='id new'>new</span> <span class='kw'>do</span>
|
@@ -986,7 +987,6 @@ The operation to be performed in a separate thread.
|
|
986
987
|
<span class='kw'>rescue</span> <span class='const'>Exception</span> <span class='op'>=></span> <span class='id e'>e</span>
|
987
988
|
<span class='id request_error'>request_error</span><span class='lparen'>(</span><span class='id req'>req</span><span class='comma'>,</span> <span class='id e'>e</span><span class='rparen'>)</span>
|
988
989
|
<span class='kw'>end</span>
|
989
|
-
|
990
990
|
<span class='id push'>push</span>
|
991
991
|
<span class='kw'>end</span>
|
992
992
|
<span class='kw'>end</span></pre>
|
@@ -1041,37 +1041,73 @@ An undispatched Response.
|
|
1041
1041
|
<pre class="lines">
|
1042
1042
|
|
1043
1043
|
|
1044
|
-
|
1045
|
-
|
1046
|
-
|
1047
|
-
|
1048
|
-
|
1049
|
-
|
1050
|
-
|
1051
|
-
|
1052
|
-
|
1053
|
-
|
1054
|
-
|
1055
|
-
|
1056
|
-
|
1057
|
-
|
1058
|
-
|
1059
|
-
|
1060
|
-
|
1061
|
-
|
1062
|
-
|
1063
|
-
|
1064
|
-
|
1065
|
-
|
1066
|
-
|
1067
|
-
|
1044
|
+
138
|
1045
|
+
139
|
1046
|
+
140
|
1047
|
+
141
|
1048
|
+
142
|
1049
|
+
143
|
1050
|
+
144
|
1051
|
+
145
|
1052
|
+
146
|
1053
|
+
147
|
1054
|
+
148
|
1055
|
+
149
|
1056
|
+
150
|
1057
|
+
151
|
1058
|
+
152
|
1059
|
+
153
|
1060
|
+
154
|
1061
|
+
155
|
1062
|
+
156
|
1063
|
+
157
|
1064
|
+
158
|
1065
|
+
159
|
1066
|
+
160
|
1067
|
+
161
|
1068
|
+
162
|
1069
|
+
163
|
1070
|
+
164
|
1071
|
+
165
|
1072
|
+
166
|
1073
|
+
167
|
1074
|
+
168
|
1075
|
+
169
|
1076
|
+
170
|
1077
|
+
171
|
1078
|
+
172
|
1079
|
+
173
|
1080
|
+
174
|
1081
|
+
175
|
1082
|
+
176
|
1083
|
+
177
|
1084
|
+
178
|
1085
|
+
179</pre>
|
1068
1086
|
</td>
|
1069
1087
|
<td>
|
1070
|
-
<pre class="code"><span class="info file"># File 'lib/safubot/bot.rb', line
|
1088
|
+
<pre class="code"><span class="info file"># File 'lib/safubot/bot.rb', line 138</span>
|
1071
1089
|
|
1072
1090
|
<span class='kw'>def</span> <span class='id dispatch'>dispatch</span><span class='lparen'>(</span><span class='id resp'>resp</span><span class='rparen'>)</span>
|
1091
|
+
<span class='id resp'>resp</span><span class='period'>.</span><span class='id reload'>reload</span>
|
1092
|
+
<span class='kw'>if</span> <span class='id resp'>resp</span><span class='period'>.</span><span class='id dispatched'>dispatched</span>
|
1093
|
+
<span class='const'>Log</span><span class='period'>.</span><span class='id debug'>debug</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Response '</span><span class='embexpr_beg'>#{</span><span class='id resp'>resp</span><span class='period'>.</span><span class='id text'>text</span><span class='rbrace'>}</span><span class='tstring_content'>' has already been dispatched, ignoring.</span><span class='tstring_end'>"</span></span>
|
1094
|
+
<span class='kw'>return</span>
|
1095
|
+
<span class='kw'>elsif</span> <span class='id resp'>resp</span><span class='period'>.</span><span class='id dispatching'>dispatching</span>
|
1096
|
+
<span class='const'>Log</span><span class='period'>.</span><span class='id debug'>debug</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Response '</span><span class='embexpr_beg'>#{</span><span class='id resp'>resp</span><span class='period'>.</span><span class='id text'>text</span><span class='rbrace'>}</span><span class='tstring_content'>' is already in dispatch, ignoring.</span><span class='tstring_end'>"</span></span>
|
1097
|
+
<span class='kw'>return</span>
|
1098
|
+
<span class='kw'>elsif</span> <span class='id resp'>resp</span><span class='period'>.</span><span class='id problems'>problems</span><span class='period'>.</span><span class='id length'>length</span> <span class='op'>></span> <span class='int'>10</span>
|
1099
|
+
<span class='const'>Log</span><span class='period'>.</span><span class='id debug'>debug</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Response '</span><span class='embexpr_beg'>#{</span><span class='id resp'>resp</span><span class='period'>.</span><span class='id text'>text</span><span class='rbrace'>}</span><span class='tstring_content'>' encountered more than ten dispatch errors, ignoring.</span><span class='tstring_end'>"</span></span>
|
1100
|
+
<span class='kw'>return</span>
|
1101
|
+
<span class='kw'>elsif</span> <span class='op'>!</span><span class='id resp'>resp</span><span class='period'>.</span><span class='id problems'>problems</span><span class='period'>.</span><span class='id empty?'>empty?</span> <span class='op'>&&</span> <span class='lparen'>(</span><span class='const'>Time</span><span class='period'>.</span><span class='id now'>now</span> <span class='op'>-</span> <span class='id resp'>resp</span><span class='period'>.</span><span class='id last_problem'>last_problem</span><span class='period'>.</span><span class='id when'>when</span><span class='rparen'>)</span> <span class='op'><</span> <span class='int'>1</span><span class='period'>.</span><span class='id minute'>minute</span>
|
1102
|
+
<span class='const'>Log</span><span class='period'>.</span><span class='id debug'>debug</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Response '</span><span class='embexpr_beg'>#{</span><span class='id resp'>resp</span><span class='period'>.</span><span class='id text'>text</span><span class='rbrace'>}</span><span class='tstring_content'>' encountered a dispatch error <1 minute ago, ignoring.</span><span class='tstring_end'>"</span></span>
|
1103
|
+
<span class='kw'>return</span>
|
1104
|
+
<span class='kw'>end</span>
|
1105
|
+
|
1073
1106
|
<span class='kw'>begin</span>
|
1074
1107
|
<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>
|
1108
|
+
<span class='id resp'>resp</span><span class='period'>.</span><span class='id dispatching'>dispatching</span> <span class='op'>=</span> <span class='kw'>true</span>
|
1109
|
+
<span class='id resp'>resp</span><span class='period'>.</span><span class='id save'>save</span>
|
1110
|
+
|
1075
1111
|
<span class='kw'>if</span> <span class='const'>Safubot</span><span class='op'>::</span><span class='id mode'>mode</span> <span class='op'>!=</span> <span class='symbol'>:production</span>
|
1076
1112
|
<span class='const'>Log</span><span class='period'>.</span><span class='id info'>info</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='embexpr_beg'>#{</span><span class='id source'>source</span><span class='period'>.</span><span class='id class'>class</span><span class='rbrace'>}</span><span class='tstring_content'> Response to </span><span class='embexpr_beg'>#{</span><span class='id source'>source</span><span class='period'>.</span><span class='id username'>username</span><span class='rbrace'>}</span><span class='tstring_content'>: </span><span class='embexpr_beg'>#{</span><span class='id resp'>resp</span><span class='period'>.</span><span class='id text'>text</span><span class='rbrace'>}</span><span class='tstring_end'>"</span></span>
|
1077
1113
|
<span class='kw'>else</span>
|
@@ -1082,20 +1118,105 @@ An undispatched Response.
|
|
1082
1118
|
<span class='kw'>else</span>
|
1083
1119
|
<span class='id raise'>raise</span> <span class='const'>NotImplementedError</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Don't know how to send response to a </span><span class='embexpr_beg'>#{</span><span class='id source'>source</span><span class='period'>.</span><span class='id class'>class</span><span class='rbrace'>}</span><span class='tstring_content'>!</span><span class='tstring_end'>"</span></span>
|
1084
1120
|
<span class='kw'>end</span>
|
1085
|
-
<span class='kw'>end</span>
|
1086
1121
|
|
1087
|
-
|
1088
|
-
|
1122
|
+
<span class='id resp'>resp</span><span class='period'>.</span><span class='id dispatched'>dispatched</span> <span class='op'>=</span> <span class='kw'>true</span>
|
1123
|
+
<span class='id resp'>resp</span><span class='period'>.</span><span class='id save'>save</span>
|
1124
|
+
<span class='kw'>end</span>
|
1089
1125
|
<span class='kw'>rescue</span> <span class='const'>Exception</span> <span class='op'>=></span> <span class='id e'>e</span>
|
1090
|
-
<span class='
|
1091
|
-
|
1126
|
+
<span class='id dispatch_error'>dispatch_error</span><span class='lparen'>(</span><span class='id resp'>resp</span><span class='comma'>,</span> <span class='id e'>e</span><span class='rparen'>)</span>
|
1127
|
+
<span class='kw'>ensure</span>
|
1128
|
+
<span class='id resp'>resp</span><span class='period'>.</span><span class='id dispatching'>dispatching</span> <span class='op'>=</span> <span class='kw'>false</span>
|
1092
1129
|
<span class='id resp'>resp</span><span class='period'>.</span><span class='id save'>save</span>
|
1093
|
-
<span class='id emit'>emit</span><span class='lparen'>(</span><span class='symbol'>:dispatch_error</span><span class='comma'>,</span> <span class='id resp'>resp</span><span class='comma'>,</span> <span class='id e'>e</span><span class='rparen'>)</span>
|
1094
1130
|
<span class='kw'>end</span>
|
1095
1131
|
<span class='kw'>end</span></pre>
|
1096
1132
|
</td>
|
1097
1133
|
</tr>
|
1098
1134
|
</table>
|
1135
|
+
</div>
|
1136
|
+
|
1137
|
+
<div class="method_details ">
|
1138
|
+
<p class="signature " id="dispatch_error-instance_method">
|
1139
|
+
|
1140
|
+
- (<tt>Object</tt>) <strong>dispatch_error</strong>(resp, e)
|
1141
|
+
|
1142
|
+
|
1143
|
+
|
1144
|
+
</p><div class="docstring">
|
1145
|
+
<div class="discussion">
|
1146
|
+
<p>
|
1147
|
+
Records an error in dispatch and emits a corresponding :dispatch_error
|
1148
|
+
event.
|
1149
|
+
</p>
|
1150
|
+
|
1151
|
+
|
1152
|
+
</div>
|
1153
|
+
</div>
|
1154
|
+
<div class="tags">
|
1155
|
+
<h3>Parameters:</h3>
|
1156
|
+
<ul class="param">
|
1157
|
+
|
1158
|
+
<li>
|
1159
|
+
|
1160
|
+
<span class='name'>resp</span>
|
1161
|
+
|
1162
|
+
|
1163
|
+
<span class='type'></span>
|
1164
|
+
|
1165
|
+
|
1166
|
+
|
1167
|
+
—
|
1168
|
+
<div class='inline'><p>
|
1169
|
+
The Response for which the error was encountered.
|
1170
|
+
</p>
|
1171
|
+
</div>
|
1172
|
+
|
1173
|
+
</li>
|
1174
|
+
|
1175
|
+
<li>
|
1176
|
+
|
1177
|
+
<span class='name'>e</span>
|
1178
|
+
|
1179
|
+
|
1180
|
+
<span class='type'></span>
|
1181
|
+
|
1182
|
+
|
1183
|
+
|
1184
|
+
—
|
1185
|
+
<div class='inline'><p>
|
1186
|
+
The caught Exception.
|
1187
|
+
</p>
|
1188
|
+
</div>
|
1189
|
+
|
1190
|
+
</li>
|
1191
|
+
|
1192
|
+
</ul>
|
1193
|
+
|
1194
|
+
|
1195
|
+
</div><table class="source_code">
|
1196
|
+
<tr>
|
1197
|
+
<td>
|
1198
|
+
<pre class="lines">
|
1199
|
+
|
1200
|
+
|
1201
|
+
98
|
1202
|
+
99
|
1203
|
+
100
|
1204
|
+
101
|
1205
|
+
102
|
1206
|
+
103</pre>
|
1207
|
+
</td>
|
1208
|
+
<td>
|
1209
|
+
<pre class="code"><span class="info file"># File 'lib/safubot/bot.rb', line 98</span>
|
1210
|
+
|
1211
|
+
<span class='kw'>def</span> <span class='id dispatch_error'>dispatch_error</span><span class='lparen'>(</span><span class='id resp'>resp</span><span class='comma'>,</span> <span class='id e'>e</span><span class='rparen'>)</span>
|
1212
|
+
<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'>Error dispatching </span><span class='embexpr_beg'>#{</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='period'>.</span><span class='id class'>class</span><span class='rbrace'>}</span><span class='tstring_content'> '</span><span class='embexpr_beg'>#{</span><span class='id resp'>resp</span><span class='period'>.</span><span class='id text'>text</span><span class='rbrace'>}</span><span class='tstring_content'>': </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>
|
1213
|
+
<span class='id resp'>resp</span><span class='period'>.</span><span class='id add_problem'>add_problem</span><span class='lparen'>(</span><span class='id e'>e</span><span class='rparen'>)</span>
|
1214
|
+
<span class='id resp'>resp</span><span class='period'>.</span><span class='id save'>save</span>
|
1215
|
+
<span class='id emit'>emit</span><span class='lparen'>(</span><span class='symbol'>:dispatch_error</span><span class='comma'>,</span> <span class='id resp'>resp</span><span class='comma'>,</span> <span class='id e'>e</span><span class='rparen'>)</span>
|
1216
|
+
<span class='kw'>end</span></pre>
|
1217
|
+
</td>
|
1218
|
+
</tr>
|
1219
|
+
</table>
|
1099
1220
|
</div>
|
1100
1221
|
|
1101
1222
|
<div class="method_details ">
|
@@ -1123,20 +1244,22 @@ Initialises Twitter-related functionality.
|
|
1123
1244
|
<pre class="lines">
|
1124
1245
|
|
1125
1246
|
|
1126
|
-
|
1127
|
-
|
1128
|
-
|
1129
|
-
|
1130
|
-
|
1131
|
-
|
1247
|
+
246
|
1248
|
+
247
|
1249
|
+
248
|
1250
|
+
249
|
1251
|
+
250
|
1252
|
+
251
|
1253
|
+
252</pre>
|
1132
1254
|
</td>
|
1133
1255
|
<td>
|
1134
|
-
<pre class="code"><span class="info file"># File 'lib/safubot/bot.rb', line
|
1256
|
+
<pre class="code"><span class="info file"># File 'lib/safubot/bot.rb', line 246</span>
|
1135
1257
|
|
1136
1258
|
<span class='kw'>def</span> <span class='id enable_twitter'>enable_twitter</span><span class='lparen'>(</span><span class='id opts'>opts</span><span class='op'>=</span><span class='lbrace'>{</span><span class='rbrace'>}</span><span class='rparen'>)</span>
|
1137
1259
|
<span class='ivar'>@twitter</span> <span class='op'>=</span> <span class='const'>Twitter</span><span class='op'>::</span><span class='const'>Bot</span><span class='period'>.</span><span class='id new'>new</span><span class='lparen'>(</span><span class='id opts'>opts</span><span class='rparen'>)</span>
|
1138
1260
|
<span class='ivar'>@twitter</span><span class='period'>.</span><span class='id on'>on</span><span class='lparen'>(</span><span class='symbol'>:request</span><span class='rparen'>)</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id req'>req</span><span class='op'>|</span>
|
1139
|
-
<span class='id
|
1261
|
+
<span class='id process_request'>process_request</span><span class='lparen'>(</span><span class='id req'>req</span><span class='rparen'>)</span>
|
1262
|
+
<span class='id req'>req</span><span class='period'>.</span><span class='id responses'>responses</span><span class='period'>.</span><span class='id where'>where</span><span class='lparen'>(</span><span class='symbol'>:dispatched</span> <span class='op'>=></span> <span class='kw'>false</span><span class='rparen'>)</span><span class='period'>.</span><span class='id map'>map</span><span class='lparen'>(</span><span class='op'>&</span><span class='symbol'>:dispatch</span><span class='rparen'>)</span>
|
1140
1263
|
<span class='kw'>end</span>
|
1141
1264
|
<span class='kw'>end</span></pre>
|
1142
1265
|
</td>
|
@@ -1169,22 +1292,24 @@ Initialises XMPP-related functionality.
|
|
1169
1292
|
<pre class="lines">
|
1170
1293
|
|
1171
1294
|
|
1172
|
-
|
1173
|
-
|
1174
|
-
|
1175
|
-
|
1176
|
-
|
1177
|
-
|
1178
|
-
|
1295
|
+
255
|
1296
|
+
256
|
1297
|
+
257
|
1298
|
+
258
|
1299
|
+
259
|
1300
|
+
260
|
1301
|
+
261
|
1302
|
+
262</pre>
|
1179
1303
|
</td>
|
1180
1304
|
<td>
|
1181
|
-
<pre class="code"><span class="info file"># File 'lib/safubot/bot.rb', line
|
1305
|
+
<pre class="code"><span class="info file"># File 'lib/safubot/bot.rb', line 255</span>
|
1182
1306
|
|
1183
1307
|
<span class='kw'>def</span> <span class='id enable_xmpp'>enable_xmpp</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>
|
1184
1308
|
<span class='id defaults'>defaults</span> <span class='op'>=</span> <span class='lbrace'>{</span> <span class='symbol'>:jid</span> <span class='op'>=></span> <span class='kw'>nil</span><span class='comma'>,</span> <span class='symbol'>:password</span> <span class='op'>=></span> <span class='kw'>nil</span> <span class='rbrace'>}</span>
|
1185
1309
|
<span class='ivar'>@xmpp</span> <span class='op'>=</span> <span class='const'>XMPP</span><span class='op'>::</span><span class='const'>Bot</span><span class='period'>.</span><span class='id new'>new</span><span class='lparen'>(</span><span class='id defaults'>defaults</span><span class='period'>.</span><span class='id merge'>merge</span><span class='lparen'>(</span><span class='id options'>options</span><span class='rparen'>)</span><span class='rparen'>)</span>
|
1186
1310
|
<span class='ivar'>@xmpp</span><span class='period'>.</span><span class='id on'>on</span><span class='lparen'>(</span><span class='symbol'>:request</span><span class='rparen'>)</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id req'>req</span><span class='op'>|</span>
|
1187
|
-
<span class='id
|
1311
|
+
<span class='id process_request'>process_request</span><span class='lparen'>(</span><span class='id req'>req</span><span class='rparen'>)</span>
|
1312
|
+
<span class='id req'>req</span><span class='period'>.</span><span class='id responses'>responses</span><span class='period'>.</span><span class='id where'>where</span><span class='lparen'>(</span><span class='symbol'>:dispatched</span> <span class='op'>=></span> <span class='kw'>false</span><span class='rparen'>)</span><span class='period'>.</span><span class='id map'>map</span><span class='lparen'>(</span><span class='op'>&</span><span class='symbol'>:dispatch</span><span class='rparen'>)</span>
|
1188
1313
|
<span class='kw'>end</span>
|
1189
1314
|
<span class='kw'>end</span></pre>
|
1190
1315
|
</td>
|
@@ -1217,14 +1342,14 @@ Goes through each unprocessed Request and submits it for processing.
|
|
1217
1342
|
<pre class="lines">
|
1218
1343
|
|
1219
1344
|
|
1220
|
-
|
1221
|
-
|
1222
|
-
|
1223
|
-
|
1224
|
-
|
1345
|
+
187
|
1346
|
+
188
|
1347
|
+
189
|
1348
|
+
190
|
1349
|
+
191</pre>
|
1225
1350
|
</td>
|
1226
1351
|
<td>
|
1227
|
-
<pre class="code"><span class="info file"># File 'lib/safubot/bot.rb', line
|
1352
|
+
<pre class="code"><span class="info file"># File 'lib/safubot/bot.rb', line 187</span>
|
1228
1353
|
|
1229
1354
|
<span class='kw'>def</span> <span class='id process'>process</span>
|
1230
1355
|
<span class='const'>Request</span><span class='period'>.</span><span class='id where'>where</span><span class='lparen'>(</span><span class='symbol'>:processed</span> <span class='op'>=></span> <span class='kw'>false</span><span class='rparen'>)</span><span class='period'>.</span><span class='id each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id req'>req</span><span class='op'>|</span>
|
@@ -1282,29 +1407,61 @@ An unprocessed Request.
|
|
1282
1407
|
<pre class="lines">
|
1283
1408
|
|
1284
1409
|
|
1285
|
-
|
1286
|
-
|
1287
|
-
|
1288
|
-
|
1289
|
-
|
1290
|
-
|
1291
|
-
|
1292
|
-
|
1293
|
-
|
1294
|
-
|
1410
|
+
108
|
1411
|
+
109
|
1412
|
+
110
|
1413
|
+
111
|
1414
|
+
112
|
1415
|
+
113
|
1416
|
+
114
|
1417
|
+
115
|
1418
|
+
116
|
1419
|
+
117
|
1420
|
+
118
|
1421
|
+
119
|
1422
|
+
120
|
1423
|
+
121
|
1424
|
+
122
|
1425
|
+
123
|
1426
|
+
124
|
1427
|
+
125
|
1428
|
+
126
|
1429
|
+
127
|
1430
|
+
128
|
1431
|
+
129
|
1432
|
+
130
|
1433
|
+
131
|
1434
|
+
132
|
1435
|
+
133</pre>
|
1295
1436
|
</td>
|
1296
1437
|
<td>
|
1297
|
-
<pre class="code"><span class="info file"># File 'lib/safubot/bot.rb', line
|
1438
|
+
<pre class="code"><span class="info file"># File 'lib/safubot/bot.rb', line 108</span>
|
1298
1439
|
|
1299
1440
|
<span class='kw'>def</span> <span class='id process_request'>process_request</span><span class='lparen'>(</span><span class='id req'>req</span><span class='rparen'>)</span>
|
1441
|
+
<span class='id req'>req</span><span class='period'>.</span><span class='id reload'>reload</span>
|
1442
|
+
<span class='kw'>if</span> <span class='id req'>req</span><span class='period'>.</span><span class='id processed'>processed</span>
|
1443
|
+
<span class='const'>Log</span><span class='period'>.</span><span class='id debug'>debug</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Request '</span><span class='embexpr_beg'>#{</span><span class='id req'>req</span><span class='period'>.</span><span class='id text'>text</span><span class='rbrace'>}</span><span class='tstring_content'>' has already been processed, ignoring.</span><span class='tstring_end'>"</span></span>
|
1444
|
+
<span class='kw'>return</span>
|
1445
|
+
<span class='kw'>elsif</span> <span class='id req'>req</span><span class='period'>.</span><span class='id processing'>processing</span>
|
1446
|
+
<span class='const'>Log</span><span class='period'>.</span><span class='id debug'>debug</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Request '</span><span class='embexpr_beg'>#{</span><span class='id req'>req</span><span class='period'>.</span><span class='id text'>text</span><span class='rbrace'>}</span><span class='tstring_content'>' is currently in processing, ignoring.</span><span class='tstring_end'>"</span></span>
|
1447
|
+
<span class='kw'>return</span>
|
1448
|
+
<span class='kw'>end</span>
|
1449
|
+
|
1300
1450
|
<span class='kw'>begin</span>
|
1451
|
+
<span class='id req'>req</span><span class='period'>.</span><span class='id processing'>processing</span> <span class='op'>=</span> <span class='kw'>true</span>
|
1452
|
+
<span class='id req'>req</span><span class='period'>.</span><span class='id save'>save</span>
|
1301
1453
|
<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>
|
1302
1454
|
<span class='kw'>rescue</span> <span class='const'>Exception</span> <span class='op'>=></span> <span class='id e'>e</span>
|
1303
1455
|
<span class='id request_error'>request_error</span><span class='lparen'>(</span><span class='id req'>req</span><span class='comma'>,</span> <span class='id e'>e</span><span class='rparen'>)</span>
|
1456
|
+
<span class='kw'>else</span>
|
1457
|
+
<span class='id req'>req</span><span class='period'>.</span><span class='id success'>success</span> <span class='op'>=</span> <span class='kw'>true</span>
|
1304
1458
|
<span class='kw'>ensure</span>
|
1305
|
-
<span class='
|
1306
|
-
|
1307
|
-
|
1459
|
+
<span class='comment'>#if Safubot::mode == :production
|
1460
|
+
</span> <span class='id req'>req</span><span class='period'>.</span><span class='id processing'>processing</span> <span class='op'>=</span> <span class='kw'>false</span>
|
1461
|
+
<span class='id req'>req</span><span class='period'>.</span><span class='id processed'>processed</span> <span class='op'>=</span> <span class='kw'>true</span>
|
1462
|
+
<span class='id req'>req</span><span class='period'>.</span><span class='id save'>save</span>
|
1463
|
+
<span class='comment'>#end
|
1464
|
+
</span> <span class='kw'>end</span>
|
1308
1465
|
<span class='kw'>end</span></pre>
|
1309
1466
|
</td>
|
1310
1467
|
</tr>
|
@@ -1337,12 +1494,12 @@ Twitter AJAX API).
|
|
1337
1494
|
<pre class="lines">
|
1338
1495
|
|
1339
1496
|
|
1340
|
-
|
1341
|
-
|
1342
|
-
|
1497
|
+
182
|
1498
|
+
183
|
1499
|
+
184</pre>
|
1343
1500
|
</td>
|
1344
1501
|
<td>
|
1345
|
-
<pre class="code"><span class="info file"># File 'lib/safubot/bot.rb', line
|
1502
|
+
<pre class="code"><span class="info file"># File 'lib/safubot/bot.rb', line 182</span>
|
1346
1503
|
|
1347
1504
|
<span class='kw'>def</span> <span class='id pull'>pull</span>
|
1348
1505
|
<span class='ivar'>@twitter</span><span class='period'>.</span><span class='id pull'>pull</span>
|
@@ -1377,12 +1534,12 @@ Dispatches all undispatched Responses.
|
|
1377
1534
|
<pre class="lines">
|
1378
1535
|
|
1379
1536
|
|
1380
|
-
|
1381
|
-
|
1382
|
-
|
1537
|
+
203
|
1538
|
+
204
|
1539
|
+
205</pre>
|
1383
1540
|
</td>
|
1384
1541
|
<td>
|
1385
|
-
<pre class="code"><span class="info file"># File 'lib/safubot/bot.rb', line
|
1542
|
+
<pre class="code"><span class="info file"># File 'lib/safubot/bot.rb', line 203</span>
|
1386
1543
|
|
1387
1544
|
<span class='kw'>def</span> <span class='id push'>push</span>
|
1388
1545
|
<span class='const'>Response</span><span class='period'>.</span><span class='id where'>where</span><span class='lparen'>(</span><span class='symbol'>:dispatched</span> <span class='op'>=></span> <span class='kw'>false</span><span class='rparen'>)</span><span class='period'>.</span><span class='id each'>each</span><span class='lparen'>(</span><span class='op'>&</span><span class='id method'>method</span><span class='lparen'>(</span><span class='symbol'>:dispatch</span><span class='rparen'>)</span><span class='rparen'>)</span>
|
@@ -1402,7 +1559,8 @@ Dispatches all undispatched Responses.
|
|
1402
1559
|
</p><div class="docstring">
|
1403
1560
|
<div class="discussion">
|
1404
1561
|
<p>
|
1405
|
-
Records an error and emits a corresponding :request_error
|
1562
|
+
Records an error in processing and emits a corresponding :request_error
|
1563
|
+
event.
|
1406
1564
|
</p>
|
1407
1565
|
|
1408
1566
|
|
@@ -1455,19 +1613,19 @@ The caught Exception.
|
|
1455
1613
|
<pre class="lines">
|
1456
1614
|
|
1457
1615
|
|
1458
|
-
|
1459
|
-
|
1460
|
-
|
1461
|
-
|
1462
|
-
|
1463
|
-
|
1616
|
+
87
|
1617
|
+
88
|
1618
|
+
89
|
1619
|
+
90
|
1620
|
+
91
|
1621
|
+
92</pre>
|
1464
1622
|
</td>
|
1465
1623
|
<td>
|
1466
|
-
<pre class="code"><span class="info file"># File 'lib/safubot/bot.rb', line
|
1624
|
+
<pre class="code"><span class="info file"># File 'lib/safubot/bot.rb', line 87</span>
|
1467
1625
|
|
1468
1626
|
<span class='kw'>def</span> <span class='id request_error'>request_error</span><span class='lparen'>(</span><span class='id req'>req</span><span class='comma'>,</span> <span class='id e'>e</span><span class='rparen'>)</span>
|
1469
|
-
<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'>Error processing </span><span class='embexpr_beg'>#{</span><span class='id req'>req</span><span class='period'>.</span><span class='id source'>source</span><span class='period'>.</span><span class='id class'>class</span><span class='rbrace'>}</span><span class='tstring_content'> '</span><span class='embexpr_beg'>#{</span><span class='id req'>req</span><span class='period'>.</span><span class='id text'>text</span><span class='rbrace'>}</span><span class='tstring_content'>': </span><span class='embexpr_beg'>#{</span><span class='id
|
1470
|
-
<span class='id req'>req</span><span class='period'>.</span><span class='id
|
1627
|
+
<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'>Error processing </span><span class='embexpr_beg'>#{</span><span class='id req'>req</span><span class='period'>.</span><span class='id source'>source</span><span class='period'>.</span><span class='id class'>class</span><span class='rbrace'>}</span><span class='tstring_content'> '</span><span class='embexpr_beg'>#{</span><span class='id req'>req</span><span class='period'>.</span><span class='id text'>text</span><span class='rbrace'>}</span><span class='tstring_content'>': </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>
|
1628
|
+
<span class='id req'>req</span><span class='period'>.</span><span class='id add_problem'>add_problem</span><span class='lparen'>(</span><span class='id e'>e</span><span class='rparen'>)</span>
|
1471
1629
|
<span class='id req'>req</span><span class='period'>.</span><span class='id save'>save</span>
|
1472
1630
|
<span class='id emit'>emit</span><span class='lparen'>(</span><span class='symbol'>:request_error</span><span class='comma'>,</span> <span class='id req'>req</span><span class='comma'>,</span> <span class='id e'>e</span><span class='rparen'>)</span>
|
1473
1631
|
<span class='kw'>end</span></pre>
|
@@ -1486,7 +1644,7 @@ The caught Exception.
|
|
1486
1644
|
</p><div class="docstring">
|
1487
1645
|
<div class="discussion">
|
1488
1646
|
<p>
|
1489
|
-
Adds a response to the queue.
|
1647
|
+
Adds a response to the queue and dispatches it.
|
1490
1648
|
</p>
|
1491
1649
|
|
1492
1650
|
|
@@ -1539,59 +1697,17 @@ Contents of the response.
|
|
1539
1697
|
<pre class="lines">
|
1540
1698
|
|
1541
1699
|
|
1542
|
-
|
1543
|
-
|
1544
|
-
|
1545
|
-
|
1700
|
+
197
|
1701
|
+
198
|
1702
|
+
199
|
1703
|
+
200</pre>
|
1546
1704
|
</td>
|
1547
1705
|
<td>
|
1548
|
-
<pre class="code"><span class="info file"># File 'lib/safubot/bot.rb', line
|
1706
|
+
<pre class="code"><span class="info file"># File 'lib/safubot/bot.rb', line 197</span>
|
1549
1707
|
|
1550
1708
|
<span class='kw'>def</span> <span class='id respond'>respond</span><span class='lparen'>(</span><span class='id req'>req</span><span class='comma'>,</span> <span class='id text'>text</span><span class='rparen'>)</span>
|
1551
1709
|
<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='embexpr_beg'>#{</span><span class='id req'>req</span><span class='period'>.</span><span class='id user'>user</span><span class='period'>.</span><span class='id name'>name</span><span class='rbrace'>}</span><span class='tstring_content'>: </span><span class='embexpr_beg'>#{</span><span class='id req'>req</span><span class='period'>.</span><span class='id text'>text</span><span class='rbrace'>}</span><span class='tstring_content'>\nsafubot: </span><span class='embexpr_beg'>#{</span><span class='id text'>text</span><span class='rbrace'>}</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span>
|
1552
|
-
<span class='const'>Response</span><span class='period'>.</span><span class='id create'>create</span><span class='lparen'>(</span><span class='symbol'>:request</span> <span class='op'>=></span> <span class='id req'>req</span><span class='comma'>,</span> <span class='symbol'>:text</span> <span class='op'>=></span> <span class='id text'>text</span><span class='rparen'>)</span>
|
1553
|
-
<span class='kw'>end</span></pre>
|
1554
|
-
</td>
|
1555
|
-
</tr>
|
1556
|
-
</table>
|
1557
|
-
</div>
|
1558
|
-
|
1559
|
-
<div class="method_details ">
|
1560
|
-
<p class="signature " id="respond_now-instance_method">
|
1561
|
-
|
1562
|
-
- (<tt>Object</tt>) <strong>respond_now</strong>(req, text)
|
1563
|
-
|
1564
|
-
|
1565
|
-
|
1566
|
-
</p><div class="docstring">
|
1567
|
-
<div class="discussion">
|
1568
|
-
<p>
|
1569
|
-
Respond + push
|
1570
|
-
</p>
|
1571
|
-
|
1572
|
-
|
1573
|
-
</div>
|
1574
|
-
</div>
|
1575
|
-
<div class="tags">
|
1576
|
-
|
1577
|
-
|
1578
|
-
</div><table class="source_code">
|
1579
|
-
<tr>
|
1580
|
-
<td>
|
1581
|
-
<pre class="lines">
|
1582
|
-
|
1583
|
-
|
1584
|
-
124
|
1585
|
-
125
|
1586
|
-
126
|
1587
|
-
127</pre>
|
1588
|
-
</td>
|
1589
|
-
<td>
|
1590
|
-
<pre class="code"><span class="info file"># File 'lib/safubot/bot.rb', line 124</span>
|
1591
|
-
|
1592
|
-
<span class='kw'>def</span> <span class='id respond_now'>respond_now</span><span class='lparen'>(</span><span class='id req'>req</span><span class='comma'>,</span> <span class='id text'>text</span><span class='rparen'>)</span>
|
1593
|
-
<span class='id respond'>respond</span><span class='lparen'>(</span><span class='id req'>req</span><span class='comma'>,</span> <span class='id text'>text</span><span class='rparen'>)</span>
|
1594
|
-
<span class='id push'>push</span>
|
1710
|
+
<span class='id dispatch'>dispatch</span><span class='lparen'>(</span><span class='const'>Response</span><span class='period'>.</span><span class='id create'>create</span><span class='lparen'>(</span><span class='symbol'>:request</span> <span class='op'>=></span> <span class='id req'>req</span><span class='comma'>,</span> <span class='symbol'>:text</span> <span class='op'>=></span> <span class='id text'>text</span><span class='rparen'>)</span><span class='rparen'>)</span>
|
1595
1711
|
<span class='kw'>end</span></pre>
|
1596
1712
|
</td>
|
1597
1713
|
</tr>
|
@@ -1623,17 +1739,17 @@ Calls run_nowait and then waits for all child processes.
|
|
1623
1739
|
<pre class="lines">
|
1624
1740
|
|
1625
1741
|
|
1626
|
-
|
1627
|
-
|
1628
|
-
|
1629
|
-
|
1630
|
-
|
1631
|
-
|
1632
|
-
|
1633
|
-
|
1742
|
+
230
|
1743
|
+
231
|
1744
|
+
232
|
1745
|
+
233
|
1746
|
+
234
|
1747
|
+
235
|
1748
|
+
236
|
1749
|
+
237</pre>
|
1634
1750
|
</td>
|
1635
1751
|
<td>
|
1636
|
-
<pre class="code"><span class="info file"># File 'lib/safubot/bot.rb', line
|
1752
|
+
<pre class="code"><span class="info file"># File 'lib/safubot/bot.rb', line 230</span>
|
1637
1753
|
|
1638
1754
|
<span class='kw'>def</span> <span class='id run'>run</span>
|
1639
1755
|
<span class='id run_nowait'>run_nowait</span>
|
@@ -1674,14 +1790,14 @@ processes.
|
|
1674
1790
|
<pre class="lines">
|
1675
1791
|
|
1676
1792
|
|
1677
|
-
|
1678
|
-
|
1679
|
-
|
1680
|
-
|
1681
|
-
|
1793
|
+
223
|
1794
|
+
224
|
1795
|
+
225
|
1796
|
+
226
|
1797
|
+
227</pre>
|
1682
1798
|
</td>
|
1683
1799
|
<td>
|
1684
|
-
<pre class="code"><span class="info file"># File 'lib/safubot/bot.rb', line
|
1800
|
+
<pre class="code"><span class="info file"># File 'lib/safubot/bot.rb', line 223</span>
|
1685
1801
|
|
1686
1802
|
<span class='kw'>def</span> <span class='id run_nowait'>run_nowait</span>
|
1687
1803
|
<span class='id pull'>pull</span><span class='semicolon'>;</span> <span class='id process'>process</span><span class='semicolon'>;</span> <span class='id push'>push</span>
|
@@ -1718,13 +1834,13 @@ Shuts down the streaming processes.
|
|
1718
1834
|
<pre class="lines">
|
1719
1835
|
|
1720
1836
|
|
1721
|
-
|
1722
|
-
|
1723
|
-
|
1724
|
-
|
1837
|
+
240
|
1838
|
+
241
|
1839
|
+
242
|
1840
|
+
243</pre>
|
1725
1841
|
</td>
|
1726
1842
|
<td>
|
1727
|
-
<pre class="code"><span class="info file"># File 'lib/safubot/bot.rb', line
|
1843
|
+
<pre class="code"><span class="info file"># File 'lib/safubot/bot.rb', line 240</span>
|
1728
1844
|
|
1729
1845
|
<span class='kw'>def</span> <span class='id stop'>stop</span>
|
1730
1846
|
<span class='ivar'>@twitter</span><span class='period'>.</span><span class='id stop'>stop</span> <span class='kw'>if</span> <span class='ivar'>@twitter</span>
|
@@ -1740,7 +1856,7 @@ Shuts down the streaming processes.
|
|
1740
1856
|
</div>
|
1741
1857
|
|
1742
1858
|
<div id="footer">
|
1743
|
-
Generated on
|
1859
|
+
Generated on Thu Dec 1 18:19:17 2011 by
|
1744
1860
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
1745
1861
|
0.7.3 (ruby-1.9.2).
|
1746
1862
|
</div>
|