]> git.r.bdr.sh - rbdr/lyricli.rb/blob - doc/Lyricli/Sources/Rdio.html
Merge pull request #3 from orlando/master
[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 <h2>Overview</h2><div class="docstring">
103 <div class="discussion">
104 <p>
105 This is the Source for rdio
106 </p>
107
108
109 </div>
110 </div>
111 <div class="tags">
112
113
114 </div>
115
116
117
118 <h2>Class Attribute Summary <small>(<a href="#" class="summary_toggle">collapse</a>)</small></h2>
119 <ul class="summary">
120
121 <li class="public ">
122 <span class="summary_signature">
123
124 <a href="#name-class_method" title="name (class method)">+ (Object) <strong>name</strong> </a>
125
126
127
128 </span>
129
130
131
132
133
134
135
136
137
138
139
140
141 <span class="summary_desc"><div class='inline'><p>
142 Returns the value of attribute name.
143 </p>
144 </div></span>
145
146 </li>
147
148
149 </ul>
150
151
152
153
154
155 <h2>
156 Class Method Summary
157 <small>(<a href="#" class="summary_toggle">collapse</a>)</small>
158 </h2>
159
160 <ul class="summary">
161
162 <li class="public ">
163 <span class="summary_signature">
164
165 <a href="#create_auth_token-class_method" title="create_auth_token (class method)">+ (Object) <strong>create_auth_token</strong> </a>
166
167
168
169 </span>
170
171
172
173
174
175
176
177
178
179 <span class="summary_desc"><div class='inline'><p>
180 Signs in to rdio with our credentials and requests access for a new auth
181 token.
182 </p>
183 </div></span>
184
185 </li>
186
187
188 <li class="public ">
189 <span class="summary_signature">
190
191 <a href="#enable-class_method" title="enable (class method)">+ (Object) <strong>enable</strong> </a>
192
193
194
195 </span>
196
197
198
199
200
201
202
203
204
205 <span class="summary_desc"><div class='inline'><p>
206 The enable method should run all of the tasks needed to validate the
207 source.
208 </p>
209 </div></span>
210
211 </li>
212
213
214 <li class="public ">
215 <span class="summary_signature">
216
217 <a href="#reset-class_method" title="reset (class method)">+ (Object) <strong>reset</strong> </a>
218
219
220
221 </span>
222
223
224
225
226
227
228
229
230
231 <span class="summary_desc"><div class='inline'><p>
232 The reset method resets any configurations it may have.
233 </p>
234 </div></span>
235
236 </li>
237
238
239 </ul>
240
241 <h2>
242 Instance Method Summary
243 <small>(<a href="#" class="summary_toggle">collapse</a>)</small>
244 </h2>
245
246 <ul class="summary">
247
248 <li class="public ">
249 <span class="summary_signature">
250
251 <a href="#current_track-instance_method" title="#current_track (instance method)">- (Hash) <strong>current_track</strong> </a>
252
253
254
255 </span>
256
257
258
259
260
261
262
263
264
265 <span class="summary_desc"><div class='inline'><p>
266 The current_track method should return the name of the current artist and
267 song.
268 </p>
269 </div></span>
270
271 </li>
272
273
274 <li class="public ">
275 <span class="summary_signature">
276
277 <a href="#initialize-instance_method" title="#initialize (instance method)">- (Rdio) <strong>initialize</strong> </a>
278
279
280
281 </span>
282
283
284 <span class="note title constructor">constructor</span>
285
286
287
288
289
290
291
292
293 <span class="summary_desc"><div class='inline'><p>
294 Instantiates everything it needs to run.
295 </p>
296 </div></span>
297
298 </li>
299
300
301 </ul>
302
303
304 <div id="constructor_details" class="method_details_list">
305 <h2>Constructor Details</h2>
306
307 <div class="method_details first">
308 <h3 class="signature first" id="initialize-instance_method">
309
310 - (<tt><span class='object_link'><a href="" title="Lyricli::Sources::Rdio (class)">Rdio</a></span></tt>) <strong>initialize</strong>
311
312
313
314
315
316 </h3><div class="docstring">
317 <div class="discussion">
318 <p>
319 Instantiates everything it needs to run.
320 </p>
321
322
323 </div>
324 </div>
325 <div class="tags">
326
327
328 </div><table class="source_code">
329 <tr>
330 <td>
331 <pre class="lines">
332
333
334 29
335 30
336 31
337 32
338 33</pre>
339 </td>
340 <td>
341 <pre class="code"><span class="info file"># File 'lib/lyricli/sources/rdio.rb', line 29</span>
342
343 <span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span>
344 <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>
345 <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>
346 <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>
347 <span class='kw'>end</span></pre>
348 </td>
349 </tr>
350 </table>
351 </div>
352
353 </div>
354
355 <div id="class_attr_details" class="attr_details">
356 <h2>Class Attribute Details</h2>
357
358
359 <span id="name=-class_method"></span>
360 <div class="method_details first">
361 <h3 class="signature first" id="name-class_method">
362
363 + (<tt>Object</tt>) <strong>name</strong>
364
365
366
367
368
369 </h3><div class="docstring">
370 <div class="discussion">
371 <p>
372 Returns the value of attribute name
373 </p>
374
375
376 </div>
377 </div>
378 <div class="tags">
379
380
381 </div><table class="source_code">
382 <tr>
383 <td>
384 <pre class="lines">
385
386
387 8
388 9
389 10</pre>
390 </td>
391 <td>
392 <pre class="code"><span class="info file"># File 'lib/lyricli/sources/rdio.rb', line 8</span>
393
394 <span class='kw'>def</span> <span class='id identifier rubyid_name'>name</span>
395 <span class='ivar'>@name</span>
396 <span class='kw'>end</span></pre>
397 </td>
398 </tr>
399 </table>
400 </div>
401
402 </div>
403
404
405 <div id="class_method_details" class="method_details_list">
406 <h2>Class Method Details</h2>
407
408
409 <div class="method_details first">
410 <h3 class="signature first" id="create_auth_token-class_method">
411
412 + (<tt>Object</tt>) <strong>create_auth_token</strong>
413
414
415
416
417
418 </h3><div class="docstring">
419 <div class="discussion">
420 <p>
421 Signs in to rdio with our credentials and requests access for a new auth
422 token.
423 </p>
424
425
426 </div>
427 </div>
428 <div class="tags">
429
430
431 </div><table class="source_code">
432 <tr>
433 <td>
434 <pre class="lines">
435
436
437 54
438 55
439 56
440 57
441 58
442 59
443 60
444 61
445 62
446 63
447 64
448 65
449 66
450 67
451 68
452 69
453 70</pre>
454 </td>
455 <td>
456 <pre class="code"><span class="info file"># File 'lib/lyricli/sources/rdio.rb', line 54</span>
457
458 <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>
459 <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>
460
461 <span class='comment'># Request Authorization
462 </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>
463 <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>
464 <span class='id identifier rubyid_puts'>puts</span> <span class='id identifier rubyid_auth_url'>auth_url</span>
465 <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>
466
467 <span class='comment'># Request Code, Obtain Token
468 </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>
469 <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>
470 <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>
471
472 <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>
473 <span class='id identifier rubyid_token'>token</span>
474 <span class='kw'>end</span></pre>
475 </td>
476 </tr>
477 </table>
478 </div>
479
480 <div class="method_details ">
481 <h3 class="signature " id="enable-class_method">
482
483 + (<tt>Object</tt>) <strong>enable</strong>
484
485
486
487
488
489 </h3><div class="docstring">
490 <div class="discussion">
491 <p>
492 The enable method should run all of the tasks needed to validate the
493 source. In the case of Rdio it has to authenticate with OAuth.
494 </p>
495
496
497 </div>
498 </div>
499 <div class="tags">
500
501
502 </div><table class="source_code">
503 <tr>
504 <td>
505 <pre class="lines">
506
507
508 15
509 16
510 17
511 18
512 19
513 20
514 21
515 22
516 23
517 24
518 25
519 26</pre>
520 </td>
521 <td>
522 <pre class="code"><span class="info file"># File 'lib/lyricli/sources/rdio.rb', line 15</span>
523
524 <span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_enable'>enable</span>
525 <span class='comment'># Validation Code
526 </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>
527 <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>
528 <span class='id identifier rubyid_create_auth_token'>create_auth_token</span>
529 <span class='kw'>end</span>
530
531 <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>
532 <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>
533 <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>
534
535 <span class='kw'>end</span></pre>
536 </td>
537 </tr>
538 </table>
539 </div>
540
541 <div class="method_details ">
542 <h3 class="signature " id="reset-class_method">
543
544 + (<tt>Object</tt>) <strong>reset</strong>
545
546
547
548
549
550 </h3><div class="docstring">
551 <div class="discussion">
552 <p>
553 The reset method resets any configurations it may have
554 </p>
555
556
557 </div>
558 </div>
559 <div class="tags">
560
561
562 </div><table class="source_code">
563 <tr>
564 <td>
565 <pre class="lines">
566
567
568 47
569 48
570 49
571 50</pre>
572 </td>
573 <td>
574 <pre class="code"><span class="info file"># File 'lib/lyricli/sources/rdio.rb', line 47</span>
575
576 <span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_reset'>reset</span>
577 <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>
578 <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>
579 <span class='kw'>end</span></pre>
580 </td>
581 </tr>
582 </table>
583 </div>
584
585 </div>
586
587 <div id="instance_method_details" class="method_details_list">
588 <h2>Instance Method Details</h2>
589
590
591 <div class="method_details first">
592 <h3 class="signature first" id="current_track-instance_method">
593
594 - (<tt>Hash</tt>) <strong>current_track</strong>
595
596
597
598
599
600 </h3><div class="docstring">
601 <div class="discussion">
602 <p>
603 The current_track method should return the name of the current artist and
604 song.
605 </p>
606
607
608 </div>
609 </div>
610 <div class="tags">
611
612 <p class="tag_title">Returns:</p>
613 <ul class="return">
614
615 <li>
616
617
618 <span class='type'>(<tt>Hash</tt>)</span>
619
620
621
622 &mdash;
623 <div class='inline'><p>
624 A hash containing the current `:song` and `:artist`.
625 </p>
626 </div>
627
628 </li>
629
630 </ul>
631
632 </div><table class="source_code">
633 <tr>
634 <td>
635 <pre class="lines">
636
637
638 39
639 40
640 41
641 42
642 43
643 44</pre>
644 </td>
645 <td>
646 <pre class="code"><span class="info file"># File 'lib/lyricli/sources/rdio.rb', line 39</span>
647
648 <span class='kw'>def</span> <span class='id identifier rubyid_current_track'>current_track</span>
649 <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>
650 <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>
651 <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>
652 <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>
653 <span class='kw'>end</span></pre>
654 </td>
655 </tr>
656 </table>
657 </div>
658
659 </div>
660
661 </div>
662
663 <div id="footer">
664 Generated on Sat Oct 6 03:20:24 2012 by
665 <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
666 0.8.2.1 (ruby-1.9.2).
667 </div>
668
669 </body>
670 </html>