meta-spotify 0.3.0 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,6 +1,7 @@
1
1
  $:.unshift File.dirname(__FILE__)
2
2
 
3
3
  require 'httparty'
4
+ require 'uri'
4
5
 
5
6
  module MetaSpotify
6
7
 
@@ -20,7 +21,10 @@ module MetaSpotify
20
21
  item_name = self.name.downcase.gsub(/^.*::/,'')
21
22
  query = {:q => string}
22
23
  query[:page] = opts[:page].to_s if opts.has_key? :page
23
- result = get("/search/#{API_VERSION}/#{item_name}", :query => query, :format => :xml)
24
+ result = get("/search/#{API_VERSION}/#{item_name}",
25
+ :query => query,
26
+ :format => :xml,
27
+ :query_string_normalizer => self.method(:normalize))
24
28
  raise_errors(result)
25
29
  result = result[item_name+'s']
26
30
  items = []
@@ -87,11 +91,21 @@ module MetaSpotify
87
91
  raise BadRequestError.new('406 - The requested format isn\'t available')
88
92
  when 500
89
93
  raise ServerError.new('500 - The server encountered an unexpected problem')
94
+ when 502
95
+ raise ServerError.new('502 - The API internally received a bad response')
90
96
  when 503
91
97
  raise ServerError.new('503 - The API is temporarily unavailable')
92
98
  end
93
99
  end
94
100
 
101
+ def self.normalize(query)
102
+ stack = []
103
+ query.each do |key, value|
104
+ stack.push "#{key}=#{URI.encode_www_form_component value}"
105
+ end
106
+ stack.join("&")
107
+ end
108
+
95
109
  end
96
110
 
97
111
  class MetaSpotifyError < StandardError
@@ -1,3 +1,3 @@
1
1
  module MetaSpotify
2
- VERSION = "0.3.0"
2
+ VERSION = "0.3.1"
3
3
  end
@@ -31,7 +31,7 @@ class TestArtist < Test::Unit::TestCase
31
31
  context "a single result" do
32
32
  setup do
33
33
  FakeWeb.register_uri(:get,
34
- "http://ws.spotify.com/search/1/artist?q=1200%20Micrograms",
34
+ "http://ws.spotify.com/search/1/artist?q=1200+Micrograms",
35
35
  :body => fixture_file("artist_search_one_result.xml"))
36
36
  @results = MetaSpotify::Artist.search('1200 Micrograms')
37
37
  end
@@ -56,7 +56,7 @@ class TestArtist < Test::Unit::TestCase
56
56
  end
57
57
  end
58
58
  end
59
-
59
+
60
60
  context "looking up an artist" do
61
61
  setup do
62
62
  FakeWeb.register_uri(:get,
@@ -75,7 +75,7 @@ class TestArtist < Test::Unit::TestCase
75
75
  end
76
76
  end
77
77
  end
78
-
78
+
79
79
  context "looking up an artist with detailed album information" do
80
80
  setup do
81
81
  FakeWeb.register_uri(:get,
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: meta-spotify
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-10-09 00:00:00.000000000 Z
12
+ date: 2013-03-16 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: httparty
16
- requirement: &70213547995960 !ruby/object:Gem::Requirement
16
+ requirement: &70318309136740 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>'
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0.8'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70213547995960
24
+ version_requirements: *70318309136740
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: shoulda
27
- requirement: &70213547995140 !ruby/object:Gem::Requirement
27
+ requirement: &70318309132920 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: 2.10.2
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *70213547995140
35
+ version_requirements: *70318309132920
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: fakeweb
38
- requirement: &70213547994460 !ruby/object:Gem::Requirement
38
+ requirement: &70318309142920 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,7 +43,7 @@ dependencies:
43
43
  version: 1.2.4
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *70213547994460
46
+ version_requirements: *70318309142920
47
47
  description: ! "A ruby wrapper for the Spotify Metadata API.\n See
48
48
  https://developer.spotify.com/technologies/web-api/\n for
49
49
  API documentation."