nestling 0.1.1 → 0.1.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.
@@ -4,7 +4,7 @@ module Nestling
4
4
 
5
5
  METHOD_PREFIX = "artist/"
6
6
 
7
- METHODS = {
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
@@ -3,7 +3,6 @@ module Nestling
3
3
  attr_reader :client
4
4
 
5
5
  METHOD_PREFIX = ""
6
- METHODS = {}
7
6
 
8
7
  class << self
9
8
  def define_api_methods(methods)
@@ -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, data = @http.get(path, {'User-Agent' => USER_AGENT})
38
- hash = MultiJson.decode(data)
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"]
@@ -2,13 +2,12 @@ module Nestling
2
2
  class Playlist < Base
3
3
  METHOD_PREFIX = "playlist/"
4
4
 
5
- METHODS = {
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
- METHODS = {
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
 
@@ -2,11 +2,10 @@ module Nestling
2
2
  class Track < Base
3
3
  METHOD_PREFIX = "track/"
4
4
 
5
- METHODS = {
5
+ define_api_methods({
6
6
  :profile => { :collection => false, :key => "track" },
7
- }
7
+ })
8
8
 
9
- define_api_methods METHODS
10
9
  end
11
10
  end
12
11
 
@@ -2,7 +2,7 @@ module Nestling
2
2
  module Version
3
3
  MAJOR = 0
4
4
  MINOR = 1
5
- PATCH = 1
5
+ PATCH = 2
6
6
 
7
7
  STRING = [MAJOR, MINOR, PATCH].compact.join('.')
8
8
  end
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
- Net::HTTP.any_instance.stubs(:get).returns([{}, ret])
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)