shuffler_fm 0.0.1 → 0.0.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/Rakefile +6 -4
- data/lib/shuffler_fm/api/artists.rb +8 -6
- data/lib/shuffler_fm/api/blogs.rb +9 -6
- data/lib/shuffler_fm/api/channels.rb +7 -4
- data/lib/shuffler_fm/api/charts.rb +6 -4
- data/lib/shuffler_fm/api/genres.rb +2 -2
- data/lib/shuffler_fm/api/tracks.rb +3 -2
- data/lib/shuffler_fm/api.rb +0 -5
- data/lib/shuffler_fm/request.rb +7 -1
- data/lib/shuffler_fm/version.rb +1 -1
- data/spec/fixtures/vcr_cassettes/api.yml +72 -3
- data/spec/fixtures/vcr_cassettes/artists.yml +25 -71
- data/spec/fixtures/vcr_cassettes/blogs.yml +53 -53
- data/spec/fixtures/vcr_cassettes/channels.yml +20 -20
- data/spec/fixtures/vcr_cassettes/charts.yml +24 -24
- data/spec/fixtures/vcr_cassettes/genres.yml +19 -19
- data/spec/fixtures/vcr_cassettes/tracks.yml +18 -18
- data/spec/helper.rb +1 -1
- data/spec/shuffler_fm/api/artists_spec.rb +3 -3
- data/spec/shuffler_fm/api_spec.rb +16 -0
- data/spec/shuffler_fm/middleware/error_handler_spec.rb +1 -1
- metadata +183 -187
data/Rakefile
CHANGED
@@ -19,10 +19,12 @@ task :console do
|
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
22
|
+
namespace :doc do
|
23
|
+
desc "Generate documentation"
|
24
|
+
YARD::Rake::YardocTask.new do |t|
|
25
|
+
t.files = ['lib/**/*.rb']
|
26
|
+
t.options = ['--no-private', '--protected', '--markup', 'markdown']
|
27
|
+
end
|
26
28
|
end
|
27
29
|
|
28
30
|
#
|
@@ -5,12 +5,13 @@ module ShufflerFM
|
|
5
5
|
# Requests a list of artists
|
6
6
|
#
|
7
7
|
# @param [Hash] options
|
8
|
-
# @option options [Integer] :page The page to request on paginated operation responses
|
8
|
+
# @option options [Integer] :page The page to request on paginated operation responses. First page is page 1.
|
9
|
+
# @option options [Integer] :per_page The page size. Default is 50, maximum is 100.
|
9
10
|
#
|
10
11
|
# @return [Array] a list of artists
|
11
12
|
#
|
12
13
|
def artists(options = {})
|
13
|
-
get("/artists",
|
14
|
+
get("/artists", options)
|
14
15
|
end
|
15
16
|
|
16
17
|
# Requests a particular artist
|
@@ -29,24 +30,25 @@ module ShufflerFM
|
|
29
30
|
#
|
30
31
|
# @param [Integer] id the artist id
|
31
32
|
# @param [Hash] options
|
32
|
-
# @option options [Integer] :page The page to request on paginated operation responses
|
33
|
+
# @option options [Integer] :page The page to request on paginated operation responses. First page is page 1.
|
34
|
+
# @option options [Integer] :per_page The page size. Default is 50, maximum is 100.
|
33
35
|
#
|
34
36
|
# @return [Array] an array of results
|
35
37
|
#
|
36
38
|
def artist_blogs(id, options= {})
|
37
|
-
get("artists/#{Integer(id)}/blogs",
|
39
|
+
get("artists/#{Integer(id)}/blogs", options)
|
38
40
|
end
|
39
41
|
|
40
42
|
# Search artists
|
41
43
|
#
|
42
44
|
# @param [String] q your query
|
43
45
|
# @param [Hash] options
|
44
|
-
# @option options [Integer] :page The page to request on paginated operation responses
|
46
|
+
# @option options [Integer] :page The page to request on paginated operation responses. First page is page 1.
|
45
47
|
#
|
46
48
|
# @return [Array] an array of results
|
47
49
|
#
|
48
50
|
def search_artists(q, options = {})
|
49
|
-
get("/artists?q=#{String(q)}",
|
51
|
+
get("/artists?q=#{String(q)}", options)
|
50
52
|
end
|
51
53
|
end
|
52
54
|
end
|
@@ -5,23 +5,25 @@ module ShufflerFM
|
|
5
5
|
# Requests a list of blogs
|
6
6
|
#
|
7
7
|
# @param [Hash] options
|
8
|
-
# @option options [Integer] :page The page to request on paginated operation responses
|
8
|
+
# @option options [Integer] :page The page to request on paginated operation responses. First page is page 1.
|
9
|
+
# @option options [Integer] :per_page The page size. Default is 50, maximum is 100.
|
9
10
|
#
|
10
11
|
# @return [Array] a list of blogs
|
11
12
|
#
|
12
13
|
def blogs(options = {})
|
13
|
-
get("/blogs",
|
14
|
+
get("/blogs", options)
|
14
15
|
end
|
15
16
|
|
16
17
|
# Requests a list of featured blogs
|
17
18
|
#
|
18
19
|
# @param [Hash] options
|
19
|
-
# @option options [Integer] :page The page to request on paginated operation responses
|
20
|
+
# @option options [Integer] :page The page to request on paginated operation responses. First page is page 1.
|
21
|
+
# @option options [Integer] :per_page The page size. Default is 50, maximum is 100.
|
20
22
|
#
|
21
23
|
# @return [Array] a list of featured blogs
|
22
24
|
#
|
23
25
|
def featured_blogs(options = {})
|
24
|
-
get("/blogs",
|
26
|
+
get("/blogs", options.merge(:filter => 'featured'))
|
25
27
|
end
|
26
28
|
|
27
29
|
# Requests a particular blog
|
@@ -40,12 +42,13 @@ module ShufflerFM
|
|
40
42
|
#
|
41
43
|
# @param [String] q your query
|
42
44
|
# @param [Hash] options
|
43
|
-
# @option options [Integer] :page The page to request on paginated operation responses
|
45
|
+
# @option options [Integer] :page The page to request on paginated operation responses. First page is page 1.
|
46
|
+
# @option options [Integer] :per_page The page size. Default is 50, maximum is 100.
|
44
47
|
#
|
45
48
|
# @return [Array] an array of results
|
46
49
|
#
|
47
50
|
def search_blogs(q, options = {})
|
48
|
-
get("/blogs?q=#{String(q)}",
|
51
|
+
get("/blogs?q=#{String(q)}", options)
|
49
52
|
end
|
50
53
|
end
|
51
54
|
end
|
@@ -7,7 +7,8 @@ module ShufflerFM
|
|
7
7
|
# @param [String] key The channel key.
|
8
8
|
# Can be on of the following: mp3, youtube, vimeo, soundcloud or officialfm
|
9
9
|
# @param [Hash] options
|
10
|
-
# @option options [Integer] :page The page to request on paginated operation responses
|
10
|
+
# @option options [Integer] :page The page to request on paginated operation responses. First page is page 1.
|
11
|
+
# @option options [Integer] :per_page The page size. Default is 50, maximum is 100.
|
11
12
|
#
|
12
13
|
# @return [Array] an array with the channel's activity stream
|
13
14
|
#
|
@@ -22,7 +23,8 @@ module ShufflerFM
|
|
22
23
|
#
|
23
24
|
# @param [String] key The channel key.
|
24
25
|
# @param [Hash] options
|
25
|
-
# @option options [Integer] :page The page to request on paginated operation responses
|
26
|
+
# @option options [Integer] :page The page to request on paginated operation responses. First page is page 1.
|
27
|
+
# @option options [Integer] :per_page The page size. Default is 50, maximum is 100.
|
26
28
|
#
|
27
29
|
# @return [Array] an array with the channel's activity stream
|
28
30
|
#
|
@@ -37,7 +39,8 @@ module ShufflerFM
|
|
37
39
|
#
|
38
40
|
# @param key The channel key.
|
39
41
|
# @param [Hash] options
|
40
|
-
# @option options [Integer] :page The page to request on paginated operation responses
|
42
|
+
# @option options [Integer] :page The page to request on paginated operation responses. First page is page 1.
|
43
|
+
# @option options [Integer] :per_page The page size. Default is 50, maximum is 100.
|
41
44
|
#
|
42
45
|
# @return [Array] an array with the channel's activity stream
|
43
46
|
#
|
@@ -65,7 +68,7 @@ module ShufflerFM
|
|
65
68
|
private
|
66
69
|
def channel(*args)
|
67
70
|
key, query, opts = process_args(args)
|
68
|
-
get((key == :genre ? "channels/" : "channels/#{key}:") << "#{String(query.join('+'))}",
|
71
|
+
get((key == :genre ? "channels/" : "channels/#{key}:") << "#{String(query.join('+'))}", opts)
|
69
72
|
rescue ShufflerFM::NotFound
|
70
73
|
[]
|
71
74
|
end
|
@@ -5,23 +5,25 @@ module ShufflerFM
|
|
5
5
|
# Lists popular tracks charts
|
6
6
|
#
|
7
7
|
# @param [Hash] options
|
8
|
-
# @option options [Integer] :page The page to request on paginated operation responses
|
8
|
+
# @option options [Integer] :page The page to request on paginated operation responses. First page is page 1.
|
9
|
+
# @option options [Integer] :per_page The page size. Default is 50, maximum is 100.
|
9
10
|
#
|
10
11
|
# @return [Array] a list of tracks merged with chart metadata
|
11
12
|
#
|
12
13
|
def popular_charts(options = {})
|
13
|
-
get("/charts/popular",
|
14
|
+
get("/charts/popular", options)
|
14
15
|
end
|
15
16
|
|
16
17
|
# Lists tracks that were recently added to the popular list
|
17
18
|
#
|
18
19
|
# @param [Hash] options
|
19
|
-
# @option options [Integer] :page The page to request on paginated operation responses
|
20
|
+
# @option options [Integer] :page The page to request on paginated operation responses. First page is page 1.
|
21
|
+
# @option options [Integer] :per_page The page size. Default is 50, maximum is 100.
|
20
22
|
#
|
21
23
|
# @return [Array] a list of tracks merged with chart metadata
|
22
24
|
#
|
23
25
|
def popular_charts_newest(options = {})
|
24
|
-
get("/charts/new",
|
26
|
+
get("/charts/new", options)
|
25
27
|
end
|
26
28
|
end
|
27
29
|
end
|
@@ -4,12 +4,12 @@ module ShufflerFM
|
|
4
4
|
# Requests a list of genres
|
5
5
|
#
|
6
6
|
# @param [Hash] options
|
7
|
-
# @option options [Integer] :page The page to request on paginated operation responses
|
7
|
+
# @option options [Integer] :page The page to request on paginated operation responses. First page is page 1.
|
8
8
|
#
|
9
9
|
# @return [Array] a list of genres
|
10
10
|
#
|
11
11
|
def genres(options = {})
|
12
|
-
get("/genres",
|
12
|
+
get("/genres", options)
|
13
13
|
end
|
14
14
|
|
15
15
|
# Requests a particular genre
|
@@ -5,7 +5,8 @@ module ShufflerFM
|
|
5
5
|
# Requests a list of tracks
|
6
6
|
#
|
7
7
|
# @param [Hash] options
|
8
|
-
# @option options [Integer] :page The page to request on paginated operation responses
|
8
|
+
# @option options [Integer] :page The page to request on paginated operation responses. First page is page 1.
|
9
|
+
# @option options [Integer] :per_page The page size. Default is 50, maximum is 100.
|
9
10
|
#
|
10
11
|
# @return [Array] a list of tracks
|
11
12
|
#
|
@@ -15,7 +16,7 @@ module ShufflerFM
|
|
15
16
|
# tracks = api.tracks(page: 2)
|
16
17
|
#
|
17
18
|
def tracks(options = {})
|
18
|
-
get("/tracks",
|
19
|
+
get("/tracks", options)
|
19
20
|
end
|
20
21
|
|
21
22
|
# Requests a particular track
|
data/lib/shuffler_fm/api.rb
CHANGED
data/lib/shuffler_fm/request.rb
CHANGED
@@ -16,10 +16,16 @@ module ShufflerFM
|
|
16
16
|
private
|
17
17
|
def request(method, path, options = {})
|
18
18
|
response = http_connection.send(method) do |request|
|
19
|
-
request.url("#{API.version}/#{path}", options)
|
19
|
+
request.url("#{API.version}/#{path}", process_options(options))
|
20
20
|
end
|
21
21
|
|
22
22
|
response.body
|
23
23
|
end
|
24
|
+
|
25
|
+
def process_options(options)
|
26
|
+
#shuffler.fm REST API v1 determins the the first page on a paginated resource is 0.
|
27
|
+
#We are abstracting that to start on page 1.
|
28
|
+
options.merge(:page => Integer(options.delete(:page) { 1 }) - 1)
|
29
|
+
end
|
24
30
|
end
|
25
31
|
end
|
data/lib/shuffler_fm/version.rb
CHANGED