turntabler 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG.md +5 -0
- data/README.md +11 -19
- data/examples/Gemfile.lock +1 -1
- data/lib/turntabler/client.rb +19 -4
- data/lib/turntabler/version.rb +1 -1
- metadata +33 -3
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -36,9 +36,9 @@ This project was built from the ground-up by Rubyists for Rubyists. While prior
|
|
36
36
|
projects in other languages were used for guidance on some of the implementation,
|
37
37
|
the design is meant to take advantage of the various features offered by Ruby 1.9+.
|
38
38
|
|
39
|
-
|
39
|
+
At a high level, this project features:
|
40
40
|
|
41
|
-
* Evented, non-blocking
|
41
|
+
* Evented, non-blocking I/O
|
42
42
|
* Fiber-aware, untangled callbacks
|
43
43
|
* Interactive console support
|
44
44
|
* Clean, object-oriented APIs
|
@@ -177,25 +177,17 @@ directory in the repository.
|
|
177
177
|
|
178
178
|
So you may be asking "Why another Turntable.FM API library?" or "Why re-build
|
179
179
|
this in Ruby when you have a stable Javascript project?" Simply put, I felt that
|
180
|
-
|
181
|
-
document were missing in
|
180
|
+
many of the high-level details highlighted in the Description section of this
|
181
|
+
document were missing in existing libraries.
|
182
182
|
|
183
|
-
|
183
|
+
Some of those details include evented I/O, untangled callbacks, object-oriented
|
184
|
+
APIs, external API consistency, internal state management, auto lazy-loading, etc.
|
185
|
+
This library also strives to be a complete implementation, easy to use / play
|
186
|
+
around with, and generally just put together a more organized fashion.
|
184
187
|
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
My personal belief is that none of these libraries reflect the simplicity that
|
190
|
-
you can build libraries with in Ruby. Those include evented I/O, untangled
|
191
|
-
callbacks, object-oriented APIs, external API consistency, internal state
|
192
|
-
management, auto lazy-loading, etc. Some of these libraries are also either
|
193
|
-
incomplete implementations, difficult to use / play around with, or generally
|
194
|
-
just put together as a script instead of an organized library.
|
195
|
-
|
196
|
-
However, by no means does that mean I'm attempting to belittle the efforts put
|
197
|
-
forth by these authors -- all of their work provided the foundation necessary to
|
198
|
-
build out this project.
|
188
|
+
By no means does this discredit the significance of the efforts put forth by the
|
189
|
+
authors of these existing libraries -- all of their work provided the foundation
|
190
|
+
necessary to build out this project.
|
199
191
|
|
200
192
|
### Authentication
|
201
193
|
|
data/examples/Gemfile.lock
CHANGED
data/lib/turntabler/client.rb
CHANGED
@@ -401,18 +401,33 @@ module Turntabler
|
|
401
401
|
|
402
402
|
# Finds songs that match the given query.
|
403
403
|
#
|
404
|
-
# @
|
404
|
+
# @note The user must be entered in a room to search for songs
|
405
|
+
# @param [String] query The query string to search for. This should just be the title of the song if :artist is specified.
|
405
406
|
# @param [Hash] options The configuration options for the search
|
407
|
+
# @option options [String] :artist The name of the artist for the song
|
408
|
+
# @option options [Fixnum] :duration The length, in minutes, of the song
|
406
409
|
# @option options [Fixnum] :page The page number to get from the results
|
407
410
|
# @return [Array<Turntabler::Song>]
|
408
411
|
# @raise [ArgumentError] if an invalid option is specified
|
409
|
-
# @raise [Turntabler::Error] if the command fails
|
412
|
+
# @raise [Turntabler::Error] if the user is not in a room or the command fails
|
410
413
|
# @example
|
411
|
-
#
|
414
|
+
# # Less accurate, general query search
|
415
|
+
# client.search_song('Like a Rolling Stone by Bob Dylan') # => [#<Turntabler::Song ...>, ...]
|
416
|
+
#
|
417
|
+
# # More accurate, explicit title / artist search
|
418
|
+
# client.search_song('Like a Rolling Stone', :artist => 'Bob Dylan') # => [#<Turntabler::Song ...>, ...]
|
412
419
|
def search_song(query, options = {})
|
413
|
-
assert_valid_keys(options, :page)
|
420
|
+
assert_valid_keys(options, :artist, :duration, :page)
|
414
421
|
options = {:page => 1}.merge(options)
|
415
422
|
|
423
|
+
raise(Turntabler::Error, 'User must be in a room to search for songs') unless room
|
424
|
+
|
425
|
+
if artist = options[:artist]
|
426
|
+
query = "title: #{query}"
|
427
|
+
query << " artist: #{artist}"
|
428
|
+
end
|
429
|
+
query << " duration: #{options[:duration]}" if options[:duration]
|
430
|
+
|
416
431
|
api('file.search', :query => query, :page => options[:page])
|
417
432
|
|
418
433
|
# Wait for the async callback
|
data/lib/turntabler/version.rb
CHANGED
metadata
CHANGED
@@ -1,8 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: turntabler
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
+
hash: 31
|
4
5
|
prerelease:
|
5
|
-
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 1
|
9
|
+
- 2
|
10
|
+
version: 0.1.2
|
6
11
|
platform: ruby
|
7
12
|
authors:
|
8
13
|
- Aaron Pfeifer
|
@@ -10,7 +15,7 @@ autorequire:
|
|
10
15
|
bindir: bin
|
11
16
|
cert_chain: []
|
12
17
|
|
13
|
-
date: 2012-
|
18
|
+
date: 2012-12-01 00:00:00 Z
|
14
19
|
dependencies:
|
15
20
|
- !ruby/object:Gem::Dependency
|
16
21
|
name: em-synchrony
|
@@ -20,6 +25,9 @@ dependencies:
|
|
20
25
|
requirements:
|
21
26
|
- - ">="
|
22
27
|
- !ruby/object:Gem::Version
|
28
|
+
hash: 3
|
29
|
+
segments:
|
30
|
+
- 0
|
23
31
|
version: "0"
|
24
32
|
type: :runtime
|
25
33
|
version_requirements: *id001
|
@@ -31,6 +39,9 @@ dependencies:
|
|
31
39
|
requirements:
|
32
40
|
- - ">="
|
33
41
|
- !ruby/object:Gem::Version
|
42
|
+
hash: 3
|
43
|
+
segments:
|
44
|
+
- 0
|
34
45
|
version: "0"
|
35
46
|
type: :runtime
|
36
47
|
version_requirements: *id002
|
@@ -42,6 +53,9 @@ dependencies:
|
|
42
53
|
requirements:
|
43
54
|
- - ">="
|
44
55
|
- !ruby/object:Gem::Version
|
56
|
+
hash: 3
|
57
|
+
segments:
|
58
|
+
- 0
|
45
59
|
version: "0"
|
46
60
|
type: :runtime
|
47
61
|
version_requirements: *id003
|
@@ -53,6 +67,9 @@ dependencies:
|
|
53
67
|
requirements:
|
54
68
|
- - ">="
|
55
69
|
- !ruby/object:Gem::Version
|
70
|
+
hash: 3
|
71
|
+
segments:
|
72
|
+
- 0
|
56
73
|
version: "0"
|
57
74
|
type: :development
|
58
75
|
version_requirements: *id004
|
@@ -64,6 +81,10 @@ dependencies:
|
|
64
81
|
requirements:
|
65
82
|
- - ~>
|
66
83
|
- !ruby/object:Gem::Version
|
84
|
+
hash: 21
|
85
|
+
segments:
|
86
|
+
- 2
|
87
|
+
- 11
|
67
88
|
version: "2.11"
|
68
89
|
type: :development
|
69
90
|
version_requirements: *id005
|
@@ -75,6 +96,9 @@ dependencies:
|
|
75
96
|
requirements:
|
76
97
|
- - ">="
|
77
98
|
- !ruby/object:Gem::Version
|
99
|
+
hash: 3
|
100
|
+
segments:
|
101
|
+
- 0
|
78
102
|
version: "0"
|
79
103
|
type: :development
|
80
104
|
version_requirements: *id006
|
@@ -154,17 +178,23 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
154
178
|
requirements:
|
155
179
|
- - ">="
|
156
180
|
- !ruby/object:Gem::Version
|
181
|
+
hash: 3
|
182
|
+
segments:
|
183
|
+
- 0
|
157
184
|
version: "0"
|
158
185
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
159
186
|
none: false
|
160
187
|
requirements:
|
161
188
|
- - ">="
|
162
189
|
- !ruby/object:Gem::Version
|
190
|
+
hash: 3
|
191
|
+
segments:
|
192
|
+
- 0
|
163
193
|
version: "0"
|
164
194
|
requirements: []
|
165
195
|
|
166
196
|
rubyforge_project:
|
167
|
-
rubygems_version: 1.
|
197
|
+
rubygems_version: 1.7.2
|
168
198
|
signing_key:
|
169
199
|
specification_version: 3
|
170
200
|
summary: Turntable.FM API for Ruby
|