rspotify 0.7.0 → 0.7.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3821a59eda0417ad48c54dfedcb48f81e7b9a20d
4
- data.tar.gz: c00df9a3e146bec3f253d6837295e7b2b1ee8291
3
+ metadata.gz: 4976cbb938eca04f4a36e3084052c4ed1fb0d119
4
+ data.tar.gz: 0f6d2a0a7a6a5a73eda3d8e5a26ca4e6070c0de1
5
5
  SHA512:
6
- metadata.gz: 639c192ff705248d9567659cbec7acfb799ed97c185810efb73fe380e64d5302894111bb0a79cc8a6567f0e22e87177663db1a5816dcd233eb70c388bba14771
7
- data.tar.gz: 3331bbe544c3ca3ad49cdeb3802effc5c223c16d9345e354a161d165b8b77b16f66057a81b47247a89ad0424083ad922611afcad620702af16176208830a8771
6
+ metadata.gz: fa34c1e3e875b2bf8d34a65d0f524473a5d28aaf7b997da6f30b2c7d0de4024bf965523cf23f9ff1368138042eaee4702fcc561012746b8f155687533f9ac3f4
7
+ data.tar.gz: 7d3a74a7c1308fcabb2297f6968f9e6bebb87c88d4175305b971682f4116f8db37de6ad900676be3e61f79ad7db4ac4c665ab9a52cd156a7aab5842d67864283
data/README.md CHANGED
@@ -28,7 +28,7 @@ artists = RSpotify::Artist.search('Arctic Monkeys')
28
28
  arctic_monkeys = artists.first
29
29
  arctic_monkeys.popularity #=> 74
30
30
  arctic_monkeys.genres #=> ["Alternative Pop/Rock", "Indie", ...]
31
- arctic_monkeys.top_tracks[:US] #=> (Track array)
31
+ arctic_monkeys.top_tracks(:US) #=> (Track array)
32
32
 
33
33
  albums = arctic_monkeys.albums
34
34
  albums.first.name #=> "AM"
@@ -51,7 +51,7 @@ albums = RSpotify::Album.search('The Wall')
51
51
  tracks = RSpotify::Track.search('Thriller')
52
52
  ```
53
53
 
54
- If you prefer, you can find them directly by id:
54
+ Find by id:
55
55
 
56
56
  ```ruby
57
57
  arctic_monkeys = RSpotify::Artist.find('7Ln80lUS6He07XvHI8qqHH')
@@ -81,7 +81,7 @@ Then just copy and paste them like so:
81
81
  ```ruby
82
82
  RSpotify.authenticate("<your_client_id>", "<your_client_secret>")
83
83
 
84
- # Now you can access any public playlist and much more!
84
+ # Now you can access any public playlist and much more
85
85
 
86
86
  playlist = RSpotify::Playlist.find('wizzler', '00wHcTN0zQiun4xri9pmvX')
87
87
  playlist.name #=> "Movie Soundtrack Masterpieces"
data/lib/rspotify.rb CHANGED
@@ -27,7 +27,6 @@ module RSpotify
27
27
  end
28
28
 
29
29
  VERBS.each do |verb|
30
-
31
30
  define_singleton_method verb do |path, *params|
32
31
  url = API_URI + path
33
32
  response = RestClient.send(verb, url, *params)
data/lib/rspotify/base.rb CHANGED
@@ -58,10 +58,10 @@ module RSpotify
58
58
 
59
59
  # Returns array of RSpotify objects matching the query, ordered by popularity
60
60
  #
61
- # @param query [String]
62
- # @param type [String]
63
- # @param limit [Integer]
64
- # @param offset [Integer]
61
+ # @param query [String] The search query's keywords.
62
+ # @param type [String] Valid types are: album, artist and track
63
+ # @param limit [Integer] Maximum number of objects to return. Minimum: 1. Maximum: 50.
64
+ # @param offset [Integer] The index of the first object to return. Use with limit to get the next set of objects.
65
65
  # @return [Array<Album>, Array<Artist>, Array<Track>]
66
66
  #
67
67
  # @example
@@ -73,6 +73,11 @@ module RSpotify
73
73
  # albums = RSpotify::Base.search('AM', 'album', 10)
74
74
  # albums.size #=> 10
75
75
  def self.search(query, type, limit = 20, offset = 0)
76
+ if limit < 1 || limit > 50
77
+ warn "Limit must be between 1 and 50"
78
+ return false
79
+ end
80
+
76
81
  pluralized_type = "#{type}s"
77
82
  type_class = RSpotify.const_get(type.capitalize)
78
83
 
@@ -123,13 +128,13 @@ module RSpotify
123
128
  # track.instance_variable_get("@popularity") #=> 62
124
129
  def method_missing(method_name, *args)
125
130
  attr = "@#{method_name}"
126
- super unless instance_variable_defined? attr
131
+ super unless instance_variable_defined? attr
127
132
 
128
- attr_value = instance_variable_get attr
133
+ attr_value = instance_variable_get attr
129
134
  return attr_value unless attr_value.nil?
130
135
 
131
136
  complete!
132
- instance_variable_get attr
137
+ instance_variable_get attr
133
138
  end
134
139
 
135
140
  # Overrides Object#respond_to? to also consider methods dynamically generated by {#method_missing}
@@ -26,7 +26,7 @@ module RSpotify
26
26
  end
27
27
 
28
28
  # Spotify does not support search for playlists. Prints warning and returns false
29
- def self.search(*args)
29
+ def self.search(*)
30
30
  warn 'Spotify API does not support search for playlists'
31
31
  false
32
32
  end
data/lib/rspotify/user.rb CHANGED
@@ -16,7 +16,7 @@ module RSpotify
16
16
  end
17
17
 
18
18
  # Spotify does not support search for users. Prints warning and returns false
19
- def self.search(*args)
19
+ def self.search(*)
20
20
  warn 'Spotify API does not support search for users'
21
21
  false
22
22
  end
@@ -1,3 +1,3 @@
1
1
  module RSpotify
2
- VERSION = '0.7.0'
2
+ VERSION = '0.7.1'
3
3
  end
@@ -16,7 +16,7 @@ describe RSpotify::Playlist do
16
16
  expect(@playlist.collaborative) .to eq false
17
17
  expect(@playlist.external_urls['spotify']) .to eq 'http://open.spotify.com/user/wizzler/playlist/00wHcTN0zQiun4xri9pmvX'
18
18
  expect(@playlist.description) .to match /Iconic soundtracks featured in some of the greatest movies/
19
- expect(@playlist.followers['total']) .to eq 12
19
+ expect(@playlist.followers['total']) .to be > 0
20
20
  expect(@playlist.href) .to eq 'https://api.spotify.com/v1/users/wizzler/playlists/00wHcTN0zQiun4xri9pmvX'
21
21
  expect(@playlist.id) .to eq '00wHcTN0zQiun4xri9pmvX'
22
22
  expect(@playlist.images.first['url']) .to match %r{https://dv72vokf4bztv\.cloudfront}
@@ -10,7 +10,7 @@ describe RSpotify::Track do
10
10
  it 'should find track with correct attributes' do
11
11
  expect(@track.available_markets) .to include *%w(AD AT BE BG CA EE ES FR GR MC TW US)
12
12
  expect(@track.disc_number) .to eq 1
13
- expect(@track.duration_ms) .to eq 272394
13
+ expect(@track.duration_ms) .to eq 272_394
14
14
  expect(@track.explicit) .to eq false
15
15
  expect(@track.external_ids['isrc']) .to eq 'GBCEL1300362'
16
16
  expect(@track.external_urls['spotify']) .to eq 'https://open.spotify.com/track/3jfr0TF6DQcOLat8gGn7E2'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rspotify
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 0.7.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Guilherme Sad
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-06-27 00:00:00.000000000 Z
11
+ date: 2014-06-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest_client