]> git.r.bdr.sh - rbdr/lyricli.rb/blob - doc/Lyricli/Sources/Rdio.html
Gemification, Basically works.
[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.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 23
323 24
324 25
325 26
326 27</pre>
327 </td>
328 <td>
329 <pre class="code"><span class="info file"># File 'lib/lyricli/sources/rdio.rb', line 23</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'>Lyricli</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='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 <span id="name-class_method"></span>
349 <div class="method_details first">
350 <h3 class="signature first" id="name-class_method">
351
352 + (<tt>Object</tt>) <strong>name</strong>
353
354
355
356
357
358 </h3><div class="docstring">
359 <div class="discussion">
360 <p>
361 Returns the value of attribute name
362 </p>
363
364
365 </div>
366 </div>
367 <div class="tags">
368
369
370 </div><table class="source_code">
371 <tr>
372 <td>
373 <pre class="lines">
374
375
376 6
377 7
378 8</pre>
379 </td>
380 <td>
381 <pre class="code"><span class="info file"># File 'lib/lyricli/sources/rdio.rb', line 6</span>
382
383 <span class='kw'>def</span> <span class='id identifier rubyid_name'>name</span>
384 <span class='ivar'>@name</span>
385 <span class='kw'>end</span></pre>
386 </td>
387 </tr>
388 </table>
389 </div>
390
391 </div>
392
393
394 <div id="class_method_details" class="method_details_list">
395 <h2>Class Method Details</h2>
396
397
398 <div class="method_details first">
399 <h3 class="signature first" id="create_auth_token-class_method">
400
401 + (<tt>Object</tt>) <strong>create_auth_token</strong>
402
403
404
405
406
407 </h3><div class="docstring">
408 <div class="discussion">
409 <p>
410 Signs in to rdio with our credentials and requests access for a new auth
411 token.
412 </p>
413
414
415 </div>
416 </div>
417 <div class="tags">
418
419
420 </div><table class="source_code">
421 <tr>
422 <td>
423 <pre class="lines">
424
425
426 46
427 47
428 48
429 49
430 50
431 51
432 52
433 53
434 54
435 55
436 56
437 57
438 58
439 59
440 60
441 61
442 62</pre>
443 </td>
444 <td>
445 <pre class="code"><span class="info file"># File 'lib/lyricli/sources/rdio.rb', line 46</span>
446
447 <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>
448 <span class='ivar'>@rdio</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>
449
450 <span class='comment'># Request Authorization
451 </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>
452 <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>
453 <span class='id identifier rubyid_puts'>puts</span> <span class='id identifier rubyid_auth_url'>auth_url</span>
454 <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>
455
456 <span class='comment'># Request Code, Obtain Token
457 </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>
458 <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>
459 <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>
460
461 <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>
462 <span class='id identifier rubyid_token'>token</span>
463 <span class='kw'>end</span></pre>
464 </td>
465 </tr>
466 </table>
467 </div>
468
469 <div class="method_details ">
470 <h3 class="signature " id="enable-class_method">
471
472 + (<tt>Object</tt>) <strong>enable</strong>
473
474
475
476
477
478 </h3><div class="docstring">
479 <div class="discussion">
480 <p>
481 The enable method should run all of the tasks needed to validate the
482 source. In the case of Rdio it has to authenticate with OAuth.
483 </p>
484
485
486 </div>
487 </div>
488 <div class="tags">
489
490
491 </div><table class="source_code">
492 <tr>
493 <td>
494 <pre class="lines">
495
496
497 13
498 14
499 15
500 16
501 17
502 18
503 19
504 20</pre>
505 </td>
506 <td>
507 <pre class="code"><span class="info file"># File 'lib/lyricli/sources/rdio.rb', line 13</span>
508
509 <span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_enable'>enable</span>
510 <span class='comment'># Validation Code
511 </span> <span class='ivar'>@config</span> <span class='op'>=</span> <span class='const'>Lyricli</span><span class='op'>::</span><span class='const'>Configuration</span><span class='period'>.</span><span class='id identifier rubyid_instance'>instance</span>
512 <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>
513 <span class='id identifier rubyid_create_auth_token'>create_auth_token</span>
514 <span class='kw'>end</span>
515
516 <span class='kw'>end</span></pre>
517 </td>
518 </tr>
519 </table>
520 </div>
521
522 <div class="method_details ">
523 <h3 class="signature " id="reset-class_method">
524
525 + (<tt>Object</tt>) <strong>reset</strong>
526
527
528
529
530
531 </h3><div class="docstring">
532 <div class="discussion">
533 <p>
534 The reset method resets any configurations it may have
535 </p>
536
537
538 </div>
539 </div>
540 <div class="tags">
541
542
543 </div><table class="source_code">
544 <tr>
545 <td>
546 <pre class="lines">
547
548
549 40
550 41
551 42</pre>
552 </td>
553 <td>
554 <pre class="code"><span class="info file"># File 'lib/lyricli/sources/rdio.rb', line 40</span>
555
556 <span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_reset'>reset</span>
557 <span class='comment'># Reset Code
558 </span><span class='kw'>end</span></pre>
559 </td>
560 </tr>
561 </table>
562 </div>
563
564 </div>
565
566 <div id="instance_method_details" class="method_details_list">
567 <h2>Instance Method Details</h2>
568
569
570 <div class="method_details first">
571 <h3 class="signature first" id="current_track-instance_method">
572
573 - (<tt>Hash</tt>) <strong>current_track</strong>
574
575
576
577
578
579 </h3><div class="docstring">
580 <div class="discussion">
581 <p>
582 The current_track method should return the name of the current artist and
583 song.
584 </p>
585
586
587 </div>
588 </div>
589 <div class="tags">
590
591 <p class="tag_title">Returns:</p>
592 <ul class="return">
593
594 <li>
595
596
597 <span class='type'>(<tt>Hash</tt>)</span>
598
599
600
601 &mdash;
602 <div class='inline'><p>
603 A hash containing the current `:song` and `:artist`.
604 </p>
605 </div>
606
607 </li>
608
609 </ul>
610
611 </div><table class="source_code">
612 <tr>
613 <td>
614 <pre class="lines">
615
616
617 32
618 33
619 34
620 35
621 36
622 37</pre>
623 </td>
624 <td>
625 <pre class="code"><span class="info file"># File 'lib/lyricli/sources/rdio.rb', line 32</span>
626
627 <span class='kw'>def</span> <span class='id identifier rubyid_current_track'>current_track</span>
628 <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>
629 <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>
630 <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>
631 <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>
632 <span class='kw'>end</span></pre>
633 </td>
634 </tr>
635 </table>
636 </div>
637
638 </div>
639
640 </div>
641
642 <div id="footer">
643 Generated on Fri Oct 5 22:31:14 2012 by
644 <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
645 0.8.1 (ruby-1.9.2).
646 </div>
647
648 </body>
649 </html>