]> git.r.bdr.sh - rbdr/lyricli.rb/blob - doc/Lyricli/Sources/Rdio.html
Adds some documentation
[rbdr/lyricli.rb] / doc / Lyricli / Sources / Rdio.html
1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
4 <head>
5 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
6 <title>
7 Class: Lyricli::Sources::Rdio
8
9 &mdash; Documentation by YARD 0.8.2.1
10
11 </title>
12
13 <link rel="stylesheet" href="../../css/style.css" type="text/css" media="screen" charset="utf-8" />
14
15 <link rel="stylesheet" href="../../css/common.css" type="text/css" media="screen" charset="utf-8" />
16
17 <script type="text/javascript" charset="utf-8">
18 hasFrames = window.top.frames.main ? true : false;
19 relpath = '../../';
20 framesUrl = "../../frames.html#!" + escape(window.location.href);
21 </script>
22
23
24 <script type="text/javascript" charset="utf-8" src="../../js/jquery.js"></script>
25
26 <script type="text/javascript" charset="utf-8" src="../../js/app.js"></script>
27
28
29 </head>
30 <body>
31 <div id="header">
32 <div id="menu">
33
34 <a href="../../_index.html">Index (R)</a> &raquo;
35 <span class='title'><span class='object_link'><a href="../../Lyricli.html" title="Lyricli (module)">Lyricli</a></span></span> &raquo; <span class='title'><span class='object_link'><a href="../Sources.html" title="Lyricli::Sources (module)">Sources</a></span></span>
36 &raquo;
37 <span class="title">Rdio</span>
38
39
40 <div class="noframes"><span class="title">(</span><a href="." target="_top">no frames</a><span class="title">)</span></div>
41 </div>
42
43 <div id="search">
44
45 <a class="full_list_link" id="class_list_link"
46 href="../../class_list.html">
47 Class List
48 </a>
49
50 <a class="full_list_link" id="method_list_link"
51 href="../../method_list.html">
52 Method List
53 </a>
54
55 <a class="full_list_link" id="file_list_link"
56 href="../../file_list.html">
57 File List
58 </a>
59
60 </div>
61 <div class="clear"></div>
62 </div>
63
64 <iframe id="search_frame"></iframe>
65
66 <div id="content"><h1>Class: Lyricli::Sources::Rdio
67
68
69
70 </h1>
71
72 <dl class="box">
73
74 <dt class="r1">Inherits:</dt>
75 <dd class="r1">
76 <span class="inheritName">Object</span>
77
78 <ul class="fullTree">
79 <li>Object</li>
80
81 <li class="next">Lyricli::Sources::Rdio</li>
82
83 </ul>
84 <a href="#" class="inheritanceTree">show all</a>
85
86 </dd>
87
88
89
90
91
92
93
94
95
96 <dt class="r2 last">Defined in:</dt>
97 <dd class="r2 last">lib/lyricli/sources/rdio.rb</dd>
98
99 </dl>
100 <div class="clear"></div>
101
102
103
104
105
106 <h2>Class Attribute Summary <small>(<a href="#" class="summary_toggle">collapse</a>)</small></h2>
107 <ul class="summary">
108
109 <li class="public ">
110 <span class="summary_signature">
111
112 <a href="#name-class_method" title="name (class method)">+ (Object) <strong>name</strong> </a>
113
114
115
116 </span>
117
118
119
120
121
122
123
124
125
126
127
128
129 <span class="summary_desc"><div class='inline'><p>
130 Returns the value of attribute name.
131 </p>
132 </div></span>
133
134 </li>
135
136
137 </ul>
138
139
140
141
142
143 <h2>
144 Class Method Summary
145 <small>(<a href="#" class="summary_toggle">collapse</a>)</small>
146 </h2>
147
148 <ul class="summary">
149
150 <li class="public ">
151 <span class="summary_signature">
152
153 <a href="#create_auth_token-class_method" title="create_auth_token (class method)">+ (Object) <strong>create_auth_token</strong> </a>
154
155
156
157 </span>
158
159
160
161
162
163
164
165
166
167 <span class="summary_desc"><div class='inline'><p>
168 Signs in to rdio with our credentials and requests access for a new auth
169 token.
170 </p>
171 </div></span>
172
173 </li>
174
175
176 <li class="public ">
177 <span class="summary_signature">
178
179 <a href="#enable-class_method" title="enable (class method)">+ (Object) <strong>enable</strong> </a>
180
181
182
183 </span>
184
185
186
187
188
189
190
191
192
193 <span class="summary_desc"><div class='inline'><p>
194 The enable method should run all of the tasks needed to validate the
195 source.
196 </p>
197 </div></span>
198
199 </li>
200
201
202 <li class="public ">
203 <span class="summary_signature">
204
205 <a href="#reset-class_method" title="reset (class method)">+ (Object) <strong>reset</strong> </a>
206
207
208
209 </span>
210
211
212
213
214
215
216
217
218
219 <span class="summary_desc"><div class='inline'><p>
220 The reset method resets any configurations it may have.
221 </p>
222 </div></span>
223
224 </li>
225
226
227 </ul>
228
229 <h2>
230 Instance Method Summary
231 <small>(<a href="#" class="summary_toggle">collapse</a>)</small>
232 </h2>
233
234 <ul class="summary">
235
236 <li class="public ">
237 <span class="summary_signature">
238
239 <a href="#current_track-instance_method" title="#current_track (instance method)">- (Hash) <strong>current_track</strong> </a>
240
241
242
243 </span>
244
245
246
247
248
249
250
251
252
253 <span class="summary_desc"><div class='inline'><p>
254 The current_track method should return the name of the current artist and
255 song.
256 </p>
257 </div></span>
258
259 </li>
260
261
262 <li class="public ">
263 <span class="summary_signature">
264
265 <a href="#initialize-instance_method" title="#initialize (instance method)">- (Rdio) <strong>initialize</strong> </a>
266
267
268
269 </span>
270
271
272 <span class="note title constructor">constructor</span>
273
274
275
276
277
278
279
280
281 <span class="summary_desc"><div class='inline'><p>
282 Instantiates everything it needs to run.
283 </p>
284 </div></span>
285
286 </li>
287
288
289 </ul>
290
291
292 <div id="constructor_details" class="method_details_list">
293 <h2>Constructor Details</h2>
294
295 <div class="method_details first">
296 <h3 class="signature first" id="initialize-instance_method">
297
298 - (<tt><span class='object_link'><a href="" title="Lyricli::Sources::Rdio (class)">Rdio</a></span></tt>) <strong>initialize</strong>
299
300
301
302
303
304 </h3><div class="docstring">
305 <div class="discussion">
306 <p>
307 Instantiates everything it needs to run.
308 </p>
309
310
311 </div>
312 </div>
313 <div class="tags">
314
315
316 </div><table class="source_code">
317 <tr>
318 <td>
319 <pre class="lines">
320
321
322 27
323 28
324 29
325 30
326 31</pre>
327 </td>
328 <td>
329 <pre class="code"><span class="info file"># File 'lib/lyricli/sources/rdio.rb', line 27</span>
330
331 <span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span>
332 <span class='ivar'>@name</span> <span class='op'>=</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>rdio</span><span class='tstring_end'>'</span></span>
333 <span class='ivar'>@config</span> <span class='op'>=</span> <span class='const'>Configuration</span><span class='period'>.</span><span class='id identifier rubyid_instance'>instance</span>
334 <span class='ivar'>@rdio</span> <span class='op'>=</span> <span class='op'>::</span><span class='const'>Rdio</span><span class='op'>::</span><span class='const'>SimpleRdio</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='lbracket'>[</span><span class='ivar'>@config</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>rdio_key</span><span class='tstring_end'>&quot;</span></span><span class='rbracket'>]</span><span class='comma'>,</span> <span class='ivar'>@config</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>rdio_secret</span><span class='tstring_end'>&quot;</span></span><span class='rbracket'>]</span><span class='rbracket'>]</span><span class='comma'>,</span> <span class='ivar'>@config</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>rdio_auth_token</span><span class='tstring_end'>&quot;</span></span><span class='rbracket'>]</span><span class='rparen'>)</span>
335 <span class='kw'>end</span></pre>
336 </td>
337 </tr>
338 </table>
339 </div>
340
341 </div>
342
343 <div id="class_attr_details" class="attr_details">
344 <h2>Class Attribute Details</h2>
345
346
347 <span id="name=-class_method"></span>
348 <div class="method_details first">
349 <h3 class="signature first" id="name-class_method">
350
351 + (<tt>Object</tt>) <strong>name</strong>
352
353
354
355
356
357 </h3><div class="docstring">
358 <div class="discussion">
359 <p>
360 Returns the value of attribute name
361 </p>
362
363
364 </div>
365 </div>
366 <div class="tags">
367
368
369 </div><table class="source_code">
370 <tr>
371 <td>
372 <pre class="lines">
373
374
375 6
376 7
377 8</pre>
378 </td>
379 <td>
380 <pre class="code"><span class="info file"># File 'lib/lyricli/sources/rdio.rb', line 6</span>
381
382 <span class='kw'>def</span> <span class='id identifier rubyid_name'>name</span>
383 <span class='ivar'>@name</span>
384 <span class='kw'>end</span></pre>
385 </td>
386 </tr>
387 </table>
388 </div>
389
390 </div>
391
392
393 <div id="class_method_details" class="method_details_list">
394 <h2>Class Method Details</h2>
395
396
397 <div class="method_details first">
398 <h3 class="signature first" id="create_auth_token-class_method">
399
400 + (<tt>Object</tt>) <strong>create_auth_token</strong>
401
402
403
404
405
406 </h3><div class="docstring">
407 <div class="discussion">
408 <p>
409 Signs in to rdio with our credentials and requests access for a new auth
410 token.
411 </p>
412
413
414 </div>
415 </div>
416 <div class="tags">
417
418
419 </div><table class="source_code">
420 <tr>
421 <td>
422 <pre class="lines">
423
424
425 51
426 52
427 53
428 54
429 55
430 56
431 57
432 58
433 59
434 60
435 61
436 62
437 63
438 64
439 65
440 66
441 67</pre>
442 </td>
443 <td>
444 <pre class="code"><span class="info file"># File 'lib/lyricli/sources/rdio.rb', line 51</span>
445
446 <span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_create_auth_token'>create_auth_token</span>
447 <span class='id identifier rubyid_rdio'>rdio</span> <span class='op'>=</span> <span class='op'>::</span><span class='const'>Rdio</span><span class='op'>::</span><span class='const'>SimpleRdio</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='lbracket'>[</span><span class='ivar'>@config</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>rdio_key</span><span class='tstring_end'>&quot;</span></span><span class='rbracket'>]</span><span class='comma'>,</span> <span class='ivar'>@config</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>rdio_secret</span><span class='tstring_end'>&quot;</span></span><span class='rbracket'>]</span><span class='rbracket'>]</span><span class='comma'>,</span> <span class='ivar'>@config</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>rdio_auth_token</span><span class='tstring_end'>&quot;</span></span><span class='rbracket'>]</span><span class='rparen'>)</span>
448
449 <span class='comment'># Request Authorization
450 </span> <span class='id identifier rubyid_puts'>puts</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Follow this URL to authorize lyricli:</span><span class='tstring_end'>&quot;</span></span>
451 <span class='id identifier rubyid_auth_url'>auth_url</span> <span class='op'>=</span> <span class='id identifier rubyid_rdio'>rdio</span><span class='period'>.</span><span class='id identifier rubyid_begin_authentication'>begin_authentication</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>oob</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span>
452 <span class='id identifier rubyid_puts'>puts</span> <span class='id identifier rubyid_auth_url'>auth_url</span>
453 <span class='op'>::</span><span class='const'>Launchy</span><span class='period'>.</span><span class='id identifier rubyid_open'>open</span><span class='lparen'>(</span><span class='id identifier rubyid_auth_url'>auth_url</span><span class='rparen'>)</span>
454
455 <span class='comment'># Request Code, Obtain Token
456 </span> <span class='id identifier rubyid_print'>print</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Please type the authorization code: </span><span class='tstring_end'>&quot;</span></span>
457 <span class='id identifier rubyid_auth_code'>auth_code</span> <span class='op'>=</span> <span class='id identifier rubyid_gets'>gets</span><span class='period'>.</span><span class='id identifier rubyid_chomp'>chomp</span>
458 <span class='id identifier rubyid_token'>token</span> <span class='op'>=</span> <span class='id identifier rubyid_rdio'>rdio</span><span class='period'>.</span><span class='id identifier rubyid_complete_authentication'>complete_authentication</span><span class='lparen'>(</span><span class='id identifier rubyid_auth_code'>auth_code</span><span class='rparen'>)</span>
459
460 <span class='ivar'>@config</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>rdio_auth_token</span><span class='tstring_end'>&quot;</span></span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='id identifier rubyid_token'>token</span>
461 <span class='id identifier rubyid_token'>token</span>
462 <span class='kw'>end</span></pre>
463 </td>
464 </tr>
465 </table>
466 </div>
467
468 <div class="method_details ">
469 <h3 class="signature " id="enable-class_method">
470
471 + (<tt>Object</tt>) <strong>enable</strong>
472
473
474
475
476
477 </h3><div class="docstring">
478 <div class="discussion">
479 <p>
480 The enable method should run all of the tasks needed to validate the
481 source. In the case of Rdio it has to authenticate with OAuth.
482 </p>
483
484
485 </div>
486 </div>
487 <div class="tags">
488
489
490 </div><table class="source_code">
491 <tr>
492 <td>
493 <pre class="lines">
494
495
496 13
497 14
498 15
499 16
500 17
501 18
502 19
503 20
504 21
505 22
506 23
507 24</pre>
508 </td>
509 <td>
510 <pre class="code"><span class="info file"># File 'lib/lyricli/sources/rdio.rb', line 13</span>
511
512 <span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_enable'>enable</span>
513 <span class='comment'># Validation Code
514 </span> <span class='ivar'>@config</span> <span class='op'>=</span> <span class='const'>Configuration</span><span class='period'>.</span><span class='id identifier rubyid_instance'>instance</span>
515 <span class='kw'>unless</span> <span class='ivar'>@config</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>rdio_auth_token</span><span class='tstring_end'>&quot;</span></span><span class='rbracket'>]</span> <span class='op'>&amp;&amp;</span> <span class='op'>!</span><span class='ivar'>@config</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>rdio_auth_token</span><span class='tstring_end'>&quot;</span></span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_empty?'>empty?</span>
516 <span class='id identifier rubyid_create_auth_token'>create_auth_token</span>
517 <span class='kw'>end</span>
518
519 <span class='id identifier rubyid_puts'>puts</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>***</span><span class='tstring_end'>&quot;</span></span>
520 <span class='id identifier rubyid_puts'>puts</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Hello, rdio tends to be a bit aggressive and tends to have trouble with other sources. If you're having trouble, you can disable it temporarily. You will not have to reauthenticate.</span><span class='tstring_end'>&quot;</span></span>
521 <span class='id identifier rubyid_puts'>puts</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>***</span><span class='tstring_end'>&quot;</span></span>
522
523 <span class='kw'>end</span></pre>
524 </td>
525 </tr>
526 </table>
527 </div>
528
529 <div class="method_details ">
530 <h3 class="signature " id="reset-class_method">
531
532 + (<tt>Object</tt>) <strong>reset</strong>
533
534
535
536
537
538 </h3><div class="docstring">
539 <div class="discussion">
540 <p>
541 The reset method resets any configurations it may have
542 </p>
543
544
545 </div>
546 </div>
547 <div class="tags">
548
549
550 </div><table class="source_code">
551 <tr>
552 <td>
553 <pre class="lines">
554
555
556 44
557 45
558 46
559 47</pre>
560 </td>
561 <td>
562 <pre class="code"><span class="info file"># File 'lib/lyricli/sources/rdio.rb', line 44</span>
563
564 <span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_reset'>reset</span>
565 <span class='ivar'>@config</span> <span class='op'>=</span> <span class='const'>Configuration</span><span class='period'>.</span><span class='id identifier rubyid_instance'>instance</span>
566 <span class='ivar'>@config</span><span class='period'>.</span><span class='id identifier rubyid_delete'>delete</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>rdio_auth_token</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
567 <span class='kw'>end</span></pre>
568 </td>
569 </tr>
570 </table>
571 </div>
572
573 </div>
574
575 <div id="instance_method_details" class="method_details_list">
576 <h2>Instance Method Details</h2>
577
578
579 <div class="method_details first">
580 <h3 class="signature first" id="current_track-instance_method">
581
582 - (<tt>Hash</tt>) <strong>current_track</strong>
583
584
585
586
587
588 </h3><div class="docstring">
589 <div class="discussion">
590 <p>
591 The current_track method should return the name of the current artist and
592 song.
593 </p>
594
595
596 </div>
597 </div>
598 <div class="tags">
599
600 <p class="tag_title">Returns:</p>
601 <ul class="return">
602
603 <li>
604
605
606 <span class='type'>(<tt>Hash</tt>)</span>
607
608
609
610 &mdash;
611 <div class='inline'><p>
612 A hash containing the current `:song` and `:artist`.
613 </p>
614 </div>
615
616 </li>
617
618 </ul>
619
620 </div><table class="source_code">
621 <tr>
622 <td>
623 <pre class="lines">
624
625
626 36
627 37
628 38
629 39
630 40
631 41</pre>
632 </td>
633 <td>
634 <pre class="code"><span class="info file"># File 'lib/lyricli/sources/rdio.rb', line 36</span>
635
636 <span class='kw'>def</span> <span class='id identifier rubyid_current_track'>current_track</span>
637 <span class='id identifier rubyid_response'>response</span> <span class='op'>=</span> <span class='ivar'>@rdio</span><span class='period'>.</span><span class='id identifier rubyid_call'>call</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>currentUser</span><span class='tstring_end'>'</span></span><span class='comma'>,</span> <span class='lbrace'>{</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>extras</span><span class='tstring_end'>'</span></span> <span class='op'>=&gt;</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>lastSongPlayed</span><span class='tstring_end'>'</span></span><span class='rbrace'>}</span><span class='rparen'>)</span>
638 <span class='id identifier rubyid_artist'>artist</span> <span class='op'>=</span> <span class='id identifier rubyid_response'>response</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>result</span><span class='tstring_end'>&quot;</span></span><span class='rbracket'>]</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>lastSongPlayed</span><span class='tstring_end'>&quot;</span></span><span class='rbracket'>]</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>artist</span><span class='tstring_end'>&quot;</span></span><span class='rbracket'>]</span>
639 <span class='id identifier rubyid_song'>song</span> <span class='op'>=</span> <span class='id identifier rubyid_response'>response</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>result</span><span class='tstring_end'>&quot;</span></span><span class='rbracket'>]</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>lastSongPlayed</span><span class='tstring_end'>&quot;</span></span><span class='rbracket'>]</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>name</span><span class='tstring_end'>&quot;</span></span><span class='rbracket'>]</span>
640 <span class='lbrace'>{</span><span class='label'>artist:</span> <span class='id identifier rubyid_artist'>artist</span><span class='comma'>,</span> <span class='label'>song:</span> <span class='id identifier rubyid_song'>song</span><span class='rbrace'>}</span>
641 <span class='kw'>end</span></pre>
642 </td>
643 </tr>
644 </table>
645 </div>
646
647 </div>
648
649 </div>
650
651 <div id="footer">
652 Generated on Sat Oct 6 02:05:51 2012 by
653 <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
654 0.8.2.1 (ruby-1.9.2).
655 </div>
656
657 </body>
658 </html>