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 CHANGED
@@ -19,10 +19,12 @@ task :console do
19
19
  end
20
20
  end
21
21
 
22
- desc "Generate documentation"
23
- YARD::Rake::YardocTask.new do |t|
24
- t.files = ['lib/**/*.rb']
25
- t.options = ['--no-private', '--protected', '--markup', 'markdown']
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", :page => page(options))
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", :page => page(options))
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)}", :page => page(options))
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", :page => page(options))
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", :page => page(options), :filter => 'featured')
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)}", :page => page(options))
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('+'))}", :page => page(opts))
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", :page => page(options))
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", :page => page(options))
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", :page => page(options))
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", :page => page(options))
19
+ get("/tracks", options)
19
20
  end
20
21
 
21
22
  # Requests a particular track
@@ -45,10 +45,5 @@ module ShufflerFM
45
45
  raise ArgumentError, 'An API key must be provided' if key.nil?
46
46
  @key = key
47
47
  end
48
-
49
- private
50
- def page(options)
51
- Integer(options.fetch(:page) { 1 })
52
- end
53
48
  end
54
49
  end
@@ -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
@@ -1,3 +1,3 @@
1
1
  module ShufflerFM
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end