safubot 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (91) hide show
  1. data/.gitignore +5 -0
  2. data/Gemfile +4 -0
  3. data/LICENSE.md +19 -0
  4. data/README.md +43 -0
  5. data/Rakefile +1 -0
  6. data/doc/Gemfile.html +119 -0
  7. data/doc/Object.html +171 -0
  8. data/doc/Rakefile.html +117 -0
  9. data/doc/Safubot.html +173 -0
  10. data/doc/Safubot/Bot.html +827 -0
  11. data/doc/Safubot/Evented.html +346 -0
  12. data/doc/Safubot/KnownUser.html +344 -0
  13. data/doc/Safubot/Log.html +254 -0
  14. data/doc/Safubot/Query.html +217 -0
  15. data/doc/Safubot/Request.html +201 -0
  16. data/doc/Safubot/Response.html +174 -0
  17. data/doc/Safubot/Test.html +244 -0
  18. data/doc/Safubot/Twitter.html +153 -0
  19. data/doc/Safubot/Twitter/Bot.html +591 -0
  20. data/doc/Safubot/Twitter/DirectMessage.html +327 -0
  21. data/doc/Safubot/Twitter/Tweet.html +522 -0
  22. data/doc/Safubot/XMPP.html +153 -0
  23. data/doc/Safubot/XMPP/Bot.html +403 -0
  24. data/doc/Safubot/XMPP/Message.html +298 -0
  25. data/doc/created.rid +14 -0
  26. data/doc/foo_rb.html +115 -0
  27. data/doc/images/add.png +0 -0
  28. data/doc/images/brick.png +0 -0
  29. data/doc/images/brick_link.png +0 -0
  30. data/doc/images/bug.png +0 -0
  31. data/doc/images/bullet_black.png +0 -0
  32. data/doc/images/bullet_toggle_minus.png +0 -0
  33. data/doc/images/bullet_toggle_plus.png +0 -0
  34. data/doc/images/date.png +0 -0
  35. data/doc/images/delete.png +0 -0
  36. data/doc/images/find.png +0 -0
  37. data/doc/images/loadingAnimation.gif +0 -0
  38. data/doc/images/macFFBgHack.png +0 -0
  39. data/doc/images/package.png +0 -0
  40. data/doc/images/page_green.png +0 -0
  41. data/doc/images/page_white_text.png +0 -0
  42. data/doc/images/page_white_width.png +0 -0
  43. data/doc/images/plugin.png +0 -0
  44. data/doc/images/ruby.png +0 -0
  45. data/doc/images/tag_blue.png +0 -0
  46. data/doc/images/tag_green.png +0 -0
  47. data/doc/images/transparent.png +0 -0
  48. data/doc/images/wrench.png +0 -0
  49. data/doc/images/wrench_orange.png +0 -0
  50. data/doc/images/zoom.png +0 -0
  51. data/doc/index.html +112 -0
  52. data/doc/js/darkfish.js +153 -0
  53. data/doc/js/jquery.js +18 -0
  54. data/doc/js/navigation.js +142 -0
  55. data/doc/js/search.js +94 -0
  56. data/doc/js/search_index.js +1 -0
  57. data/doc/js/searcher.js +228 -0
  58. data/doc/lib/safubot/bot_rb.html +115 -0
  59. data/doc/lib/safubot/evented_rb.html +115 -0
  60. data/doc/lib/safubot/known_user_rb.html +115 -0
  61. data/doc/lib/safubot/log_rb.html +115 -0
  62. data/doc/lib/safubot/safubot_rb.html +115 -0
  63. data/doc/lib/safubot/spec/bot_spec_rb.html +115 -0
  64. data/doc/lib/safubot/spec/twitter_spec_rb.html +137 -0
  65. data/doc/lib/safubot/test_helper_rb.html +115 -0
  66. data/doc/lib/safubot/twitter_rb.html +115 -0
  67. data/doc/lib/safubot/version_rb.html +115 -0
  68. data/doc/lib/safubot/xmpp_rb.html +115 -0
  69. data/doc/lib/safubot_rb.html +115 -0
  70. data/doc/rdoc.css +543 -0
  71. data/doc/table_of_contents.html +224 -0
  72. data/lib/safubot.rb +20 -0
  73. data/lib/safubot/bot.rb +177 -0
  74. data/lib/safubot/evented.rb +52 -0
  75. data/lib/safubot/known_user.rb +27 -0
  76. data/lib/safubot/log.rb +21 -0
  77. data/lib/safubot/test_helper.rb +62 -0
  78. data/lib/safubot/twitter.rb +279 -0
  79. data/lib/safubot/version.rb +3 -0
  80. data/lib/safubot/xmpp.rb +144 -0
  81. data/safubot.gemspec +32 -0
  82. data/spec/fixtures/twitter/direct_message +1 -0
  83. data/spec/fixtures/twitter/tweet +1 -0
  84. data/spec/fixtures/xmpp/message +3 -0
  85. data/spec/helper.rb +12 -0
  86. data/spec/safubot/bot_spec.rb +41 -0
  87. data/spec/safubot/evented_spec.rb +45 -0
  88. data/spec/safubot/known_user_spec.rb +22 -0
  89. data/spec/safubot/twitter_spec.rb +60 -0
  90. data/spec/safubot/xmpp_spec.rb +35 -0
  91. metadata +260 -0
@@ -0,0 +1,346 @@
1
+ <!DOCTYPE html>
2
+
3
+ <html>
4
+ <head>
5
+ <meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
6
+
7
+ <title>Module: Safubot::Evented</title>
8
+
9
+ <link type="text/css" media="screen" href="../rdoc.css" rel="stylesheet">
10
+
11
+ <script type="text/javascript">
12
+ var rdoc_rel_prefix = "../";
13
+ </script>
14
+
15
+ <script type="text/javascript" charset="utf-8" src="../js/jquery.js"></script>
16
+ <script type="text/javascript" charset="utf-8" src="../js/navigation.js"></script>
17
+ <script type="text/javascript" charset="utf-8" src="../js/search_index.js"></script>
18
+ <script type="text/javascript" charset="utf-8" src="../js/search.js"></script>
19
+ <script type="text/javascript" charset="utf-8" src="../js/searcher.js"></script>
20
+ <script type="text/javascript" charset="utf-8" src="../js/darkfish.js"></script>
21
+
22
+
23
+ <body id="top" class="module">
24
+ <nav id="metadata">
25
+ <nav id="home-section" class="section">
26
+ <h3 class="section-header">
27
+ <a href="../index.html">Home</a>
28
+ <a href="../table_of_contents.html#classes">Classes</a>
29
+ <a href="../table_of_contents.html#methods">Methods</a>
30
+ </h3>
31
+ </nav>
32
+
33
+
34
+ <nav id="search-section" class="section project-section" class="initially-hidden">
35
+ <form action="#" method="get" accept-charset="utf-8">
36
+ <h3 class="section-header">
37
+ <input type="text" name="search" placeholder="Search" id="search-field"
38
+ title="Type to search, Up and Down to navigate, Enter to load">
39
+ </h3>
40
+ </form>
41
+
42
+ <ul id="search-results" class="initially-hidden"></ul>
43
+ </nav>
44
+
45
+
46
+ <div id="file-metadata">
47
+ <nav id="file-list-section" class="section">
48
+ <h3 class="section-header">Defined In</h3>
49
+ <ul>
50
+ <li>lib/safubot/evented.rb
51
+ </ul>
52
+ </nav>
53
+
54
+
55
+ </div>
56
+
57
+ <div id="class-metadata">
58
+
59
+
60
+
61
+ <!-- Method Quickref -->
62
+ <nav id="method-list-section" class="section">
63
+ <h3 class="section-header">Methods</h3>
64
+
65
+ <ul class="link-list">
66
+
67
+ <li><a href="#method-i-bind">#bind</a>
68
+
69
+ <li><a href="#method-i-emit">#emit</a>
70
+
71
+ <li><a href="#method-i-on">#on</a>
72
+
73
+ <li><a href="#method-i-once">#once</a>
74
+
75
+ <li><a href="#method-i-unbind">#unbind</a>
76
+
77
+ </ul>
78
+ </nav>
79
+
80
+ </div>
81
+
82
+ <div id="project-metadata">
83
+ <nav id="fileindex-section" class="section project-section">
84
+ <h3 class="section-header">Pages</h3>
85
+
86
+ <ul>
87
+
88
+ <li class="file"><a href="../Gemfile.html">Gemfile</a>
89
+
90
+ <li class="file"><a href="../Rakefile.html">Rakefile</a>
91
+
92
+ </ul>
93
+ </nav>
94
+
95
+ <nav id="classindex-section" class="section project-section">
96
+ <h3 class="section-header">Class and Module Index</h3>
97
+
98
+ <ul class="link-list">
99
+
100
+ <li><a href="../Safubot.html">Safubot</a>
101
+
102
+ <li><a href="../Safubot/Bot.html">Safubot::Bot</a>
103
+
104
+ <li><a href="../Safubot/Evented.html">Safubot::Evented</a>
105
+
106
+ <li><a href="../Safubot/KnownUser.html">Safubot::KnownUser</a>
107
+
108
+ <li><a href="../Safubot/Log.html">Safubot::Log</a>
109
+
110
+ <li><a href="../Safubot/Query.html">Safubot::Query</a>
111
+
112
+ <li><a href="../Safubot/Request.html">Safubot::Request</a>
113
+
114
+ <li><a href="../Safubot/Response.html">Safubot::Response</a>
115
+
116
+ <li><a href="../Safubot/Test.html">Safubot::Test</a>
117
+
118
+ <li><a href="../Safubot/Twitter.html">Safubot::Twitter</a>
119
+
120
+ <li><a href="../Safubot/Twitter/Bot.html">Safubot::Twitter::Bot</a>
121
+
122
+ <li><a href="../Safubot/Twitter/DirectMessage.html">Safubot::Twitter::DirectMessage</a>
123
+
124
+ <li><a href="../Safubot/Twitter/Tweet.html">Safubot::Twitter::Tweet</a>
125
+
126
+ <li><a href="../Safubot/XMPP.html">Safubot::XMPP</a>
127
+
128
+ <li><a href="../Safubot/XMPP/Bot.html">Safubot::XMPP::Bot</a>
129
+
130
+ <li><a href="../Safubot/XMPP/Message.html">Safubot::XMPP::Message</a>
131
+
132
+ <li><a href="../Object.html">Object</a>
133
+
134
+ </ul>
135
+ </nav>
136
+
137
+ </div>
138
+ </nav>
139
+
140
+ <div id="documentation">
141
+ <h1 class="module">module Safubot::Evented</h1>
142
+
143
+ <div id="description" class="description">
144
+
145
+ <p>A mixin granting simple event firing and handler binding.</p>
146
+
147
+ </div><!-- description -->
148
+
149
+
150
+
151
+
152
+ <section id="5Buntitled-5D" class="documentation-section">
153
+
154
+
155
+
156
+
157
+
158
+
159
+
160
+
161
+ <!-- Methods -->
162
+
163
+ <section id="public-instance-5Buntitled-5D-method-details" class="method-section section">
164
+ <h3 class="section-header">Public Instance Methods</h3>
165
+
166
+
167
+ <div id="method-i-bind" class="method-detail ">
168
+
169
+ <div class="method-heading">
170
+ <span class="method-name">bind</span><span
171
+ class="method-args">(evid, handler)</span>
172
+ <span class="method-click-advice">click to toggle source</span>
173
+ </div>
174
+
175
+
176
+ <div class="method-description">
177
+
178
+ <p>Binds an event handler, which is a Hash of the form:</p>
179
+
180
+ <pre class="ruby">{ :<span class="ruby-identifier">evid</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-constant">Symbol</span>, :<span class="ruby-identifier">id</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-constant">Symbol</span>, :<span class="ruby-identifier">repeat</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-constant">Boolean</span>, :<span class="ruby-identifier">proc</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-constant">Proc</span> }
181
+ </pre>
182
+
183
+ <p>See on and once for sugar.</p>
184
+
185
+
186
+
187
+ <div class="method-source-code" id="bind-source">
188
+ <pre><span class="ruby-comment"># File lib/safubot/evented.rb, line 10</span>
189
+ <span class="ruby-keyword">def</span> <span class="ruby-identifier">bind</span>(<span class="ruby-identifier">evid</span>, <span class="ruby-identifier">handler</span>)
190
+ <span class="ruby-ivar">@handlers</span> <span class="ruby-operator">||=</span> {}
191
+ <span class="ruby-ivar">@handlers</span>[<span class="ruby-identifier">evid</span>] <span class="ruby-operator">||=</span> {}
192
+ <span class="ruby-identifier">handler</span>[<span class="ruby-value">:evid</span>] = <span class="ruby-identifier">evid</span>
193
+ <span class="ruby-identifier">handler</span>[<span class="ruby-value">:id</span>] <span class="ruby-operator">||=</span> <span class="ruby-ivar">@handlers</span>[<span class="ruby-identifier">evid</span>].<span class="ruby-identifier">length</span>
194
+ <span class="ruby-ivar">@handlers</span>[<span class="ruby-identifier">evid</span>][<span class="ruby-identifier">handler</span>[<span class="ruby-value">:id</span>]] = <span class="ruby-identifier">handler</span>
195
+ <span class="ruby-keyword">end</span></pre>
196
+ </div><!-- bind-source -->
197
+
198
+ </div>
199
+
200
+
201
+
202
+
203
+ </div><!-- bind-method -->
204
+
205
+
206
+ <div id="method-i-emit" class="method-detail ">
207
+
208
+ <div class="method-heading">
209
+ <span class="method-name">emit</span><span
210
+ class="method-args">(evid, *args)</span>
211
+ <span class="method-click-advice">click to toggle source</span>
212
+ </div>
213
+
214
+
215
+ <div class="method-description">
216
+
217
+ <p>Fires an evid event with the given arguments.</p>
218
+
219
+
220
+
221
+ <div class="method-source-code" id="emit-source">
222
+ <pre><span class="ruby-comment"># File lib/safubot/evented.rb, line 36</span>
223
+ <span class="ruby-keyword">def</span> <span class="ruby-identifier">emit</span>(<span class="ruby-identifier">evid</span>, *<span class="ruby-identifier">args</span>)
224
+ <span class="ruby-keyword">return</span> <span class="ruby-keyword">unless</span> <span class="ruby-ivar">@handlers</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-ivar">@handlers</span>[<span class="ruby-identifier">evid</span>]
225
+ <span class="ruby-ivar">@handlers</span>[<span class="ruby-identifier">evid</span>].<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">id</span>, <span class="ruby-identifier">handler</span><span class="ruby-operator">|</span>
226
+ <span class="ruby-keyword">begin</span>
227
+ <span class="ruby-identifier">handler</span>[<span class="ruby-value">:proc</span>].<span class="ruby-identifier">call</span>(*<span class="ruby-identifier">args</span>)
228
+ <span class="ruby-keyword">ensure</span>
229
+ <span class="ruby-ivar">@handlers</span>[<span class="ruby-identifier">evid</span>].<span class="ruby-identifier">delete</span>(<span class="ruby-identifier">id</span>) <span class="ruby-keyword">if</span> <span class="ruby-operator">!</span><span class="ruby-identifier">handler</span>[<span class="ruby-value">:repeat</span>]
230
+ <span class="ruby-keyword">end</span>
231
+ <span class="ruby-keyword">end</span>
232
+ <span class="ruby-keyword">end</span></pre>
233
+ </div><!-- emit-source -->
234
+
235
+ </div>
236
+
237
+
238
+
239
+
240
+ </div><!-- emit-method -->
241
+
242
+
243
+ <div id="method-i-on" class="method-detail ">
244
+
245
+ <div class="method-heading">
246
+ <span class="method-name">on</span><span
247
+ class="method-args">(evid, opts={}, &callback)</span>
248
+ <span class="method-click-advice">click to toggle source</span>
249
+ </div>
250
+
251
+
252
+ <div class="method-description">
253
+
254
+ <p>Binds a block to the specified event id. Returns the bound handler.</p>
255
+
256
+
257
+
258
+ <div class="method-source-code" id="on-source">
259
+ <pre><span class="ruby-comment"># File lib/safubot/evented.rb, line 25</span>
260
+ <span class="ruby-keyword">def</span> <span class="ruby-identifier">on</span>(<span class="ruby-identifier">evid</span>, <span class="ruby-identifier">opts</span>={}, &amp;<span class="ruby-identifier">callback</span>)
261
+ <span class="ruby-identifier">bind</span>(<span class="ruby-identifier">evid</span>, { <span class="ruby-value">:repeat</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-keyword">true</span>, <span class="ruby-value">:proc</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">callback</span> }.<span class="ruby-identifier">merge</span>(<span class="ruby-identifier">opts</span>))
262
+ <span class="ruby-keyword">end</span></pre>
263
+ </div><!-- on-source -->
264
+
265
+ </div>
266
+
267
+
268
+
269
+
270
+ </div><!-- on-method -->
271
+
272
+
273
+ <div id="method-i-once" class="method-detail ">
274
+
275
+ <div class="method-heading">
276
+ <span class="method-name">once</span><span
277
+ class="method-args">(evid, opts={}, &callback)</span>
278
+ <span class="method-click-advice">click to toggle source</span>
279
+ </div>
280
+
281
+
282
+ <div class="method-description">
283
+
284
+ <p>Binds a block to the specified event id, to be executed only once. Returns
285
+ the bound handler.</p>
286
+
287
+
288
+
289
+ <div class="method-source-code" id="once-source">
290
+ <pre><span class="ruby-comment"># File lib/safubot/evented.rb, line 31</span>
291
+ <span class="ruby-keyword">def</span> <span class="ruby-identifier">once</span>(<span class="ruby-identifier">evid</span>, <span class="ruby-identifier">opts</span>={}, &amp;<span class="ruby-identifier">callback</span>)
292
+ <span class="ruby-identifier">bind</span>(<span class="ruby-identifier">evid</span>, { <span class="ruby-value">:repeat</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-keyword">false</span>, <span class="ruby-value">:proc</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">callback</span> }.<span class="ruby-identifier">merge</span>(<span class="ruby-identifier">opts</span>))
293
+ <span class="ruby-keyword">end</span></pre>
294
+ </div><!-- once-source -->
295
+
296
+ </div>
297
+
298
+
299
+
300
+
301
+ </div><!-- once-method -->
302
+
303
+
304
+ <div id="method-i-unbind" class="method-detail ">
305
+
306
+ <div class="method-heading">
307
+ <span class="method-name">unbind</span><span
308
+ class="method-args">(handler)</span>
309
+ <span class="method-click-advice">click to toggle source</span>
310
+ </div>
311
+
312
+
313
+ <div class="method-description">
314
+
315
+ <p>Unbinds the given handler.</p>
316
+
317
+
318
+
319
+ <div class="method-source-code" id="unbind-source">
320
+ <pre><span class="ruby-comment"># File lib/safubot/evented.rb, line 19</span>
321
+ <span class="ruby-keyword">def</span> <span class="ruby-identifier">unbind</span>(<span class="ruby-identifier">handler</span>)
322
+ <span class="ruby-ivar">@handlers</span>[<span class="ruby-identifier">handler</span>[<span class="ruby-value">:evid</span>]].<span class="ruby-identifier">delete</span>(<span class="ruby-identifier">handler</span>[<span class="ruby-value">:id</span>])
323
+ <span class="ruby-keyword">end</span></pre>
324
+ </div><!-- unbind-source -->
325
+
326
+ </div>
327
+
328
+
329
+
330
+
331
+ </div><!-- unbind-method -->
332
+
333
+
334
+ </section><!-- public-instance-method-details -->
335
+
336
+ </section><!-- 5Buntitled-5D -->
337
+
338
+ </div><!-- documentation -->
339
+
340
+
341
+ <footer id="validator-badges">
342
+ <p><a href="http://validator.w3.org/check/referer">[Validate]</a>
343
+ <p>Generated by <a href="https://github.com/rdoc/rdoc">RDoc</a> 3.11.
344
+ <p>Generated with the <a href="http://deveiate.org/projects/Darkfish-Rdoc/">Darkfish Rdoc Generator</a> 3.
345
+ </footer>
346
+
@@ -0,0 +1,344 @@
1
+ <!DOCTYPE html>
2
+
3
+ <html>
4
+ <head>
5
+ <meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
6
+
7
+ <title>Class: Safubot::KnownUser</title>
8
+
9
+ <link type="text/css" media="screen" href="../rdoc.css" rel="stylesheet">
10
+
11
+ <script type="text/javascript">
12
+ var rdoc_rel_prefix = "../";
13
+ </script>
14
+
15
+ <script type="text/javascript" charset="utf-8" src="../js/jquery.js"></script>
16
+ <script type="text/javascript" charset="utf-8" src="../js/navigation.js"></script>
17
+ <script type="text/javascript" charset="utf-8" src="../js/search_index.js"></script>
18
+ <script type="text/javascript" charset="utf-8" src="../js/search.js"></script>
19
+ <script type="text/javascript" charset="utf-8" src="../js/searcher.js"></script>
20
+ <script type="text/javascript" charset="utf-8" src="../js/darkfish.js"></script>
21
+
22
+
23
+ <body id="top" class="class">
24
+ <nav id="metadata">
25
+ <nav id="home-section" class="section">
26
+ <h3 class="section-header">
27
+ <a href="../index.html">Home</a>
28
+ <a href="../table_of_contents.html#classes">Classes</a>
29
+ <a href="../table_of_contents.html#methods">Methods</a>
30
+ </h3>
31
+ </nav>
32
+
33
+
34
+ <nav id="search-section" class="section project-section" class="initially-hidden">
35
+ <form action="#" method="get" accept-charset="utf-8">
36
+ <h3 class="section-header">
37
+ <input type="text" name="search" placeholder="Search" id="search-field"
38
+ title="Type to search, Up and Down to navigate, Enter to load">
39
+ </h3>
40
+ </form>
41
+
42
+ <ul id="search-results" class="initially-hidden"></ul>
43
+ </nav>
44
+
45
+
46
+ <div id="file-metadata">
47
+ <nav id="file-list-section" class="section">
48
+ <h3 class="section-header">Defined In</h3>
49
+ <ul>
50
+ <li>lib/safubot/xmpp.rb
51
+ <li>lib/safubot/known_user.rb
52
+ <li>lib/safubot/twitter.rb
53
+ </ul>
54
+ </nav>
55
+
56
+
57
+ </div>
58
+
59
+ <div id="class-metadata">
60
+
61
+ <nav id="parent-class-section" class="section">
62
+ <h3 class="section-header">Parent</h3>
63
+
64
+ <p class="link"><a href="../Object.html">Object</a>
65
+
66
+ </nav>
67
+
68
+ <!-- Included Modules -->
69
+ <nav id="includes-section" class="section">
70
+ <h3 class="section-header">Included Modules</h3>
71
+
72
+ <ul class="link-list">
73
+
74
+
75
+ <li><span class="include">MongoMapper::Document</span>
76
+
77
+
78
+ </ul>
79
+ </nav>
80
+
81
+ <!-- Method Quickref -->
82
+ <nav id="method-list-section" class="section">
83
+ <h3 class="section-header">Methods</h3>
84
+
85
+ <ul class="link-list">
86
+
87
+ <li><a href="#method-c-by_twitter">::by_twitter</a>
88
+
89
+ <li><a href="#method-c-by_xmpp">::by_xmpp</a>
90
+
91
+ <li><a href="#method-i-merge">#merge</a>
92
+
93
+ <li><a href="#method-i-tweets">#tweets</a>
94
+
95
+ </ul>
96
+ </nav>
97
+
98
+ </div>
99
+
100
+ <div id="project-metadata">
101
+ <nav id="fileindex-section" class="section project-section">
102
+ <h3 class="section-header">Pages</h3>
103
+
104
+ <ul>
105
+
106
+ <li class="file"><a href="../Gemfile.html">Gemfile</a>
107
+
108
+ <li class="file"><a href="../Rakefile.html">Rakefile</a>
109
+
110
+ </ul>
111
+ </nav>
112
+
113
+ <nav id="classindex-section" class="section project-section">
114
+ <h3 class="section-header">Class and Module Index</h3>
115
+
116
+ <ul class="link-list">
117
+
118
+ <li><a href="../Safubot.html">Safubot</a>
119
+
120
+ <li><a href="../Safubot/Bot.html">Safubot::Bot</a>
121
+
122
+ <li><a href="../Safubot/Evented.html">Safubot::Evented</a>
123
+
124
+ <li><a href="../Safubot/KnownUser.html">Safubot::KnownUser</a>
125
+
126
+ <li><a href="../Safubot/Log.html">Safubot::Log</a>
127
+
128
+ <li><a href="../Safubot/Query.html">Safubot::Query</a>
129
+
130
+ <li><a href="../Safubot/Request.html">Safubot::Request</a>
131
+
132
+ <li><a href="../Safubot/Response.html">Safubot::Response</a>
133
+
134
+ <li><a href="../Safubot/Test.html">Safubot::Test</a>
135
+
136
+ <li><a href="../Safubot/Twitter.html">Safubot::Twitter</a>
137
+
138
+ <li><a href="../Safubot/Twitter/Bot.html">Safubot::Twitter::Bot</a>
139
+
140
+ <li><a href="../Safubot/Twitter/DirectMessage.html">Safubot::Twitter::DirectMessage</a>
141
+
142
+ <li><a href="../Safubot/Twitter/Tweet.html">Safubot::Twitter::Tweet</a>
143
+
144
+ <li><a href="../Safubot/XMPP.html">Safubot::XMPP</a>
145
+
146
+ <li><a href="../Safubot/XMPP/Bot.html">Safubot::XMPP::Bot</a>
147
+
148
+ <li><a href="../Safubot/XMPP/Message.html">Safubot::XMPP::Message</a>
149
+
150
+ <li><a href="../Object.html">Object</a>
151
+
152
+ </ul>
153
+ </nav>
154
+
155
+ </div>
156
+ </nav>
157
+
158
+ <div id="documentation">
159
+ <h1 class="class">class Safubot::KnownUser</h1>
160
+
161
+ <div id="description" class="description">
162
+
163
+ <p>General identity cache. Extended by service-specific modules. A single
164
+ class to allow for linking of identity between services.</p>
165
+
166
+ </div><!-- description -->
167
+
168
+
169
+
170
+
171
+ <section id="5Buntitled-5D" class="documentation-section">
172
+
173
+
174
+
175
+
176
+
177
+
178
+
179
+
180
+ <!-- Methods -->
181
+
182
+ <section id="public-class-5Buntitled-5D-method-details" class="method-section section">
183
+ <h3 class="section-header">Public Class Methods</h3>
184
+
185
+
186
+ <div id="method-c-by_twitter" class="method-detail ">
187
+
188
+ <div class="method-heading">
189
+ <span class="method-name">by_twitter</span><span
190
+ class="method-args">(name_or_id)</span>
191
+ <span class="method-click-advice">click to toggle source</span>
192
+ </div>
193
+
194
+
195
+ <div class="method-description">
196
+
197
+ <p>Retrieve or construct a <a href="KnownUser.html">KnownUser</a> by the given
198
+ <a href="Twitter.html">Twitter</a> screen name. @param name_or_id The <a
199
+ href="Twitter.html">Twitter</a> screen_name (String) or id (Integer).</p>
200
+
201
+
202
+
203
+ <div class="method-source-code" id="by_twitter-source">
204
+ <pre><span class="ruby-comment"># File lib/safubot/twitter.rb, line 11</span>
205
+ <span class="ruby-keyword">def</span> <span class="ruby-identifier">by_twitter</span>(<span class="ruby-identifier">name_or_id</span>)
206
+ <span class="ruby-identifier">user</span> = <span class="ruby-keyword">if</span> <span class="ruby-identifier">name_or_id</span>.<span class="ruby-identifier">is_a?</span> <span class="ruby-constant">String</span>
207
+ <span class="ruby-constant">KnownUser</span>.<span class="ruby-identifier">where</span>(<span class="ruby-string">'twitter.screen_name'</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">name_or_id</span>).<span class="ruby-identifier">first</span>
208
+ <span class="ruby-keyword">else</span>
209
+ <span class="ruby-constant">KnownUser</span>.<span class="ruby-identifier">where</span>(<span class="ruby-string">'twitter.id'</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">name_or_id</span>).<span class="ruby-identifier">first</span>
210
+ <span class="ruby-keyword">end</span>
211
+
212
+ <span class="ruby-keyword">if</span> <span class="ruby-identifier">user</span>.<span class="ruby-identifier">nil?</span>
213
+ <span class="ruby-identifier">details</span> = <span class="ruby-operator">::</span><span class="ruby-constant">Twitter</span>.<span class="ruby-identifier">user</span>(<span class="ruby-identifier">name_or_id</span>)
214
+ <span class="ruby-comment"># This second lookup is necessary as the screen_name that comes back from</span>
215
+ <span class="ruby-comment"># Twitter.user might not be the same as the one we were originally provided</span>
216
+ <span class="ruby-comment"># with.</span>
217
+ <span class="ruby-identifier">user</span> = <span class="ruby-constant">KnownUser</span>.<span class="ruby-identifier">where</span>(<span class="ruby-string">'twitter.screen_name'</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">details</span>.<span class="ruby-identifier">screen_name</span>).<span class="ruby-identifier">first</span> <span class="ruby-operator">||</span>
218
+ <span class="ruby-constant">KnownUser</span>.<span class="ruby-identifier">create</span>(<span class="ruby-value">:twitter</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">details</span>.<span class="ruby-identifier">attrs</span>, <span class="ruby-value">:name</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">details</span>.<span class="ruby-identifier">screen_name</span>)
219
+ <span class="ruby-keyword">end</span>
220
+
221
+ <span class="ruby-identifier">user</span>
222
+ <span class="ruby-keyword">end</span></pre>
223
+ </div><!-- by_twitter-source -->
224
+
225
+ </div>
226
+
227
+
228
+
229
+
230
+ </div><!-- by_twitter-method -->
231
+
232
+
233
+ <div id="method-c-by_xmpp" class="method-detail ">
234
+
235
+ <div class="method-heading">
236
+ <span class="method-name">by_xmpp</span><span
237
+ class="method-args">(jid)</span>
238
+ <span class="method-click-advice">click to toggle source</span>
239
+ </div>
240
+
241
+
242
+ <div class="method-description">
243
+
244
+ <p>Retrieves or creates a <a href="KnownUser.html">KnownUser</a> by an <a
245
+ href="XMPP.html">XMPP</a> JID string.</p>
246
+
247
+
248
+
249
+ <div class="method-source-code" id="by_xmpp-source">
250
+ <pre><span class="ruby-comment"># File lib/safubot/xmpp.rb, line 11</span>
251
+ <span class="ruby-keyword">def</span> <span class="ruby-identifier">by_xmpp</span>(<span class="ruby-identifier">jid</span>)
252
+ <span class="ruby-identifier">jid</span> = <span class="ruby-identifier">jid</span>.<span class="ruby-identifier">split</span>(<span class="ruby-string">'/'</span>)[<span class="ruby-value">0</span>]
253
+ <span class="ruby-constant">KnownUser</span>.<span class="ruby-identifier">where</span>(<span class="ruby-string">'jid'</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">jid</span>).<span class="ruby-identifier">first</span> <span class="ruby-operator">||</span>
254
+ <span class="ruby-constant">KnownUser</span>.<span class="ruby-identifier">create</span>(<span class="ruby-value">:jid</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">jid</span>, <span class="ruby-value">:name</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">jid</span>.<span class="ruby-identifier">split</span>(<span class="ruby-string">'@'</span>)[<span class="ruby-value">0</span>])
255
+ <span class="ruby-keyword">end</span></pre>
256
+ </div><!-- by_xmpp-source -->
257
+
258
+ </div>
259
+
260
+
261
+
262
+
263
+ </div><!-- by_xmpp-method -->
264
+
265
+
266
+ </section><!-- public-class-method-details -->
267
+
268
+ <section id="public-instance-5Buntitled-5D-method-details" class="method-section section">
269
+ <h3 class="section-header">Public Instance Methods</h3>
270
+
271
+
272
+ <div id="method-i-merge" class="method-detail ">
273
+
274
+ <div class="method-heading">
275
+ <span class="method-name">merge</span><span
276
+ class="method-args">(user)</span>
277
+ <span class="method-click-advice">click to toggle source</span>
278
+ </div>
279
+
280
+
281
+ <div class="method-description">
282
+
283
+ <p>Combines the service-specific identities of two users to form a cohesive
284
+ picture of an individual.</p>
285
+
286
+
287
+
288
+ <div class="method-source-code" id="merge-source">
289
+ <pre><span class="ruby-comment"># File lib/safubot/known_user.rb, line 10</span>
290
+ <span class="ruby-keyword">def</span> <span class="ruby-identifier">merge</span>(<span class="ruby-identifier">user</span>)
291
+ <span class="ruby-keyword">end</span></pre>
292
+ </div><!-- merge-source -->
293
+
294
+ </div>
295
+
296
+
297
+
298
+
299
+ </div><!-- merge-method -->
300
+
301
+
302
+ <div id="method-i-tweets" class="method-detail ">
303
+
304
+ <div class="method-heading">
305
+ <span class="method-name">tweets</span><span
306
+ class="method-args">()</span>
307
+ <span class="method-click-advice">click to toggle source</span>
308
+ </div>
309
+
310
+
311
+ <div class="method-description">
312
+
313
+ <p>Plucky query with Tweets scoped to this user’s twitter id.</p>
314
+
315
+
316
+
317
+ <div class="method-source-code" id="tweets-source">
318
+ <pre><span class="ruby-comment"># File lib/safubot/twitter.rb, line 32</span>
319
+ <span class="ruby-keyword">def</span> <span class="ruby-identifier">tweets</span>
320
+ <span class="ruby-constant">Twitter</span><span class="ruby-operator">::</span><span class="ruby-constant">Tweet</span>.<span class="ruby-identifier">where</span>(<span class="ruby-string">'raw.user.id'</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier">twitter</span>[<span class="ruby-string">'id'</span>])
321
+ <span class="ruby-keyword">end</span></pre>
322
+ </div><!-- tweets-source -->
323
+
324
+ </div>
325
+
326
+
327
+
328
+
329
+ </div><!-- tweets-method -->
330
+
331
+
332
+ </section><!-- public-instance-method-details -->
333
+
334
+ </section><!-- 5Buntitled-5D -->
335
+
336
+ </div><!-- documentation -->
337
+
338
+
339
+ <footer id="validator-badges">
340
+ <p><a href="http://validator.w3.org/check/referer">[Validate]</a>
341
+ <p>Generated by <a href="https://github.com/rdoc/rdoc">RDoc</a> 3.11.
342
+ <p>Generated with the <a href="http://deveiate.org/projects/Darkfish-Rdoc/">Darkfish Rdoc Generator</a> 3.
343
+ </footer>
344
+