nestling 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/nestling/artist.rb +2 -4
- data/lib/nestling/base.rb +0 -1
- data/lib/nestling/client.rb +2 -2
- data/lib/nestling/playlist.rb +2 -3
- data/lib/nestling/song.rb +2 -3
- data/lib/nestling/track.rb +2 -3
- data/lib/nestling/version.rb +1 -1
- data/test/helper.rb +3 -1
- data/test/test_artist.rb +740 -100
- data/test/test_client.rb +2 -2
- data/test/test_playlist.rb +112 -16
- data/test/test_song.rb +112 -16
- data/test/test_track.rb +36 -8
- metadata +37 -11
data/lib/nestling/artist.rb
CHANGED
@@ -4,7 +4,7 @@ module Nestling
|
|
4
4
|
|
5
5
|
METHOD_PREFIX = "artist/"
|
6
6
|
|
7
|
-
|
7
|
+
define_api_methods({
|
8
8
|
:biographies => { :collection => true },
|
9
9
|
:blogs => { :collection => true },
|
10
10
|
:familiarity => { :collection => false, :key => "artist" },
|
@@ -24,9 +24,7 @@ module Nestling
|
|
24
24
|
:top_terms => { :collection => true, :key => "terms" },
|
25
25
|
:urls => { :collection => false },
|
26
26
|
:video => { :collection => true }
|
27
|
-
}
|
28
|
-
|
29
|
-
define_api_methods METHODS
|
27
|
+
})
|
30
28
|
|
31
29
|
def initialize(name, client)
|
32
30
|
name.kind_of?(::Hash) ? @id = name[:id] : @name = name
|
data/lib/nestling/base.rb
CHANGED
data/lib/nestling/client.rb
CHANGED
@@ -34,8 +34,8 @@ module Nestling
|
|
34
34
|
|
35
35
|
def get(meth, params = {})
|
36
36
|
path = "/api/v4/#{meth}?" << convert_params(params)
|
37
|
-
response
|
38
|
-
hash = MultiJson.decode(
|
37
|
+
response = @http.get(path, {'User-Agent' => USER_AGENT})
|
38
|
+
hash = MultiJson.decode(response.body)
|
39
39
|
|
40
40
|
if (code = hash["response"]["status"]["code"].to_i) != 0
|
41
41
|
raise ERRNO[code], hash["response"]["status"]["message"]
|
data/lib/nestling/playlist.rb
CHANGED
@@ -2,13 +2,12 @@ module Nestling
|
|
2
2
|
class Playlist < Base
|
3
3
|
METHOD_PREFIX = "playlist/"
|
4
4
|
|
5
|
-
|
5
|
+
define_api_methods({
|
6
6
|
:static => { :collection => true, :key => "songs" },
|
7
7
|
:dynamic => { :collection => true, :key => "songs" },
|
8
8
|
:session_info => { :collection => false, :key => "terms" }
|
9
|
-
}
|
9
|
+
})
|
10
10
|
|
11
|
-
define_api_methods METHODS
|
12
11
|
end
|
13
12
|
end
|
14
13
|
|
data/lib/nestling/song.rb
CHANGED
@@ -2,13 +2,12 @@ module Nestling
|
|
2
2
|
class Song < Base
|
3
3
|
METHOD_PREFIX = "song/"
|
4
4
|
|
5
|
-
|
5
|
+
define_api_methods({
|
6
6
|
:search => { :collection => true, :key => "songs" },
|
7
7
|
:profile => { :collection => true, :key => "songs" },
|
8
8
|
:identify => { :collection => true, :key => "songs" }
|
9
|
-
}
|
9
|
+
})
|
10
10
|
|
11
|
-
define_api_methods METHODS
|
12
11
|
end
|
13
12
|
end
|
14
13
|
|
data/lib/nestling/track.rb
CHANGED
data/lib/nestling/version.rb
CHANGED
data/test/helper.rb
CHANGED
@@ -2,9 +2,11 @@ require File.join(File.dirname(__FILE__), '..', 'lib', 'nestling')
|
|
2
2
|
|
3
3
|
require 'minitest/autorun'
|
4
4
|
require 'mocha'
|
5
|
+
require 'ostruct'
|
5
6
|
|
6
7
|
def stub_http_get(ret)
|
7
|
-
|
8
|
+
response = OpenStruct.new({:body => ret})
|
9
|
+
Net::HTTP.any_instance.stubs(:get).returns(response)
|
8
10
|
end
|
9
11
|
|
10
12
|
def expect_request(resp, req, opts = nil)
|