dance 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/Gemfile +0 -1
- data/README.markdown +2 -0
- data/dance.gemspec +3 -1
- data/lib/dance.rb +2 -1
- data/lib/dance/artists.rb +8 -0
- data/lib/dance/client.rb +3 -6
- data/lib/dance/errors.rb +34 -0
- data/lib/dance/genres.rb +17 -1
- data/lib/dance/tracks.rb +3 -0
- data/lib/dance/user.rb +35 -0
- data/lib/dance/version.rb +1 -1
- data/spec/spec_helper.rb +48 -0
- data/spec/support/vcr.rb +8 -0
- metadata +28 -3
- data/lib/dance/users.rb +0 -25
data/.gitignore
CHANGED
data/Gemfile
CHANGED
data/README.markdown
CHANGED
data/dance.gemspec
CHANGED
@@ -4,7 +4,7 @@ require "dance"
|
|
4
4
|
|
5
5
|
Gem::Specification.new do |s|
|
6
6
|
s.name = "dance"
|
7
|
-
s.version = "0.1.
|
7
|
+
s.version = "0.1.1"
|
8
8
|
s.authors = ["Ethan Turkeltaub"]
|
9
9
|
s.email = ["ethan.turkeltaub@gmail.com"]
|
10
10
|
s.homepage = "http://github.com/eturk/dance"
|
@@ -20,6 +20,8 @@ Gem::Specification.new do |s|
|
|
20
20
|
|
21
21
|
s.add_dependency "httparty"
|
22
22
|
s.add_development_dependency "rspec"
|
23
|
+
s.add_development_dependency "webmock"
|
24
|
+
s.add_development_dependency "vcr"
|
23
25
|
|
24
26
|
# s.add_runtime_dependency "rest-client"
|
25
27
|
end
|
data/lib/dance.rb
CHANGED
data/lib/dance/artists.rb
CHANGED
@@ -1,9 +1,17 @@
|
|
1
1
|
module Dance
|
2
2
|
class Artists < Client
|
3
3
|
|
4
|
+
# Returns information on the given artist.
|
5
|
+
# GET /artists/:id
|
4
6
|
def self.info(id)
|
5
7
|
get('/artists/' + id.to_s)
|
6
8
|
end
|
7
9
|
|
10
|
+
# Returns a list of tracks by the given artist.
|
11
|
+
# GET /artists/:id/tracks
|
12
|
+
def self.tracks(id)
|
13
|
+
get('/artists/' + id.to_s + '/tracks')
|
14
|
+
end
|
15
|
+
|
8
16
|
end
|
9
17
|
end
|
data/lib/dance/client.rb
CHANGED
@@ -1,12 +1,11 @@
|
|
1
1
|
module Dance
|
2
2
|
class Client
|
3
3
|
include HTTParty
|
4
|
-
|
5
|
-
base_uri 'console.fm/api/
|
6
|
-
default_params :api_key => @key
|
4
|
+
|
5
|
+
base_uri 'console.fm/api/v2'
|
7
6
|
|
8
7
|
def initialize(key)
|
9
|
-
|
8
|
+
self.class.default_params :api_key => key
|
10
9
|
end
|
11
10
|
|
12
11
|
def artists
|
@@ -24,7 +23,5 @@ module Dance
|
|
24
23
|
def tracks
|
25
24
|
Tracks
|
26
25
|
end
|
27
|
-
|
28
26
|
end
|
29
|
-
|
30
27
|
end
|
data/lib/dance/errors.rb
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
module Dance
|
2
|
+
class Error < StandardError
|
3
|
+
attr_reader :http_Headers
|
4
|
+
|
5
|
+
def initialize(message, http_headers)
|
6
|
+
@http_headers = Hash[http_headers]
|
7
|
+
super(message)
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
class VerifyAuthentic < Error
|
12
|
+
end
|
13
|
+
|
14
|
+
class CheckParams < Error
|
15
|
+
end
|
16
|
+
|
17
|
+
class NoRecord < Error
|
18
|
+
end
|
19
|
+
|
20
|
+
class Deprecated < Error
|
21
|
+
end
|
22
|
+
|
23
|
+
class VersionNotAllowed < Error
|
24
|
+
end
|
25
|
+
|
26
|
+
class NotAuthorized < Error
|
27
|
+
end
|
28
|
+
|
29
|
+
class NotAuthenticated < Error
|
30
|
+
end
|
31
|
+
|
32
|
+
class InvalidRequest < Error
|
33
|
+
end
|
34
|
+
end
|
data/lib/dance/genres.rb
CHANGED
@@ -1,13 +1,29 @@
|
|
1
1
|
module Dance
|
2
2
|
class Genres < Client
|
3
|
-
|
3
|
+
|
4
|
+
# Returns a list of all of the genres.
|
5
|
+
# GET /genres
|
4
6
|
def self.all
|
5
7
|
get('/genres')
|
6
8
|
end
|
7
9
|
|
10
|
+
# Returns information on the given genre.
|
11
|
+
# GET /genres/:id
|
8
12
|
def self.info(id)
|
9
13
|
get('/genres/' + id.to_s)
|
10
14
|
end
|
15
|
+
|
16
|
+
# Returns a list of tracks under the given genre.
|
17
|
+
# GET /genres/:id/tracks
|
18
|
+
def self.tracks(id)
|
19
|
+
get('/genres/' + id.to_s + '/tracks')
|
20
|
+
end
|
21
|
+
|
22
|
+
# Returns a list of artists that have tracks under the given genre.
|
23
|
+
# GET /genres/:id/artists
|
24
|
+
def self.artists(id)
|
25
|
+
get('/genres/' + id.to_s + '/artists')
|
26
|
+
end
|
11
27
|
|
12
28
|
end
|
13
29
|
end
|
data/lib/dance/tracks.rb
CHANGED
data/lib/dance/user.rb
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
module Dance
|
2
|
+
class User < Client
|
3
|
+
|
4
|
+
# Authenticates a user based on a Facebook token and the user's ID.
|
5
|
+
# POST /user/authenticate
|
6
|
+
def self.authenticate(options={})
|
7
|
+
post('/user/authenticate', options)
|
8
|
+
end
|
9
|
+
|
10
|
+
# Returns information on the authenticated user.
|
11
|
+
# GET /user/current
|
12
|
+
def self.current
|
13
|
+
get('/user/current')
|
14
|
+
end
|
15
|
+
|
16
|
+
# Returns the Facebook information of the authenticated user.
|
17
|
+
# GET /user/current/facebook
|
18
|
+
def self.facebook
|
19
|
+
get('/user/current/facebook')
|
20
|
+
end
|
21
|
+
|
22
|
+
# Returns the favorites of the authenticated user.
|
23
|
+
# GET /user/current/favorites
|
24
|
+
def self.favorites
|
25
|
+
get('/user/current/favorites')
|
26
|
+
end
|
27
|
+
|
28
|
+
# Returns the history of the authenticated user.
|
29
|
+
# GET /user/current/history
|
30
|
+
def self.history
|
31
|
+
get('/user/current/history')
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
end
|
data/lib/dance/version.rb
CHANGED
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
$:.unshift File.expand_path('../../lib', __FILE__)
|
2
|
+
|
3
|
+
require 'dance'
|
4
|
+
require 'rspec'
|
5
|
+
require 'webmock/rspec'
|
6
|
+
require 'vcr'
|
7
|
+
|
8
|
+
endpoint = 'console.fm/api/v2'
|
9
|
+
|
10
|
+
def a_delete(path)
|
11
|
+
a_request(:delete, endpoint + path)
|
12
|
+
end
|
13
|
+
|
14
|
+
def a_get(path)
|
15
|
+
a_request(:get, endpoint + path)
|
16
|
+
end
|
17
|
+
|
18
|
+
def a_post(path)
|
19
|
+
a_request(:post, endpoint + path)
|
20
|
+
end
|
21
|
+
|
22
|
+
def a_put(path)
|
23
|
+
a_request(:put, endpoint + path)
|
24
|
+
end
|
25
|
+
|
26
|
+
def stub_delete(path)
|
27
|
+
stub_request(:delete, endpoint + path)
|
28
|
+
end
|
29
|
+
|
30
|
+
def stub_get(path)
|
31
|
+
stub_request(:get, endpoint + path)
|
32
|
+
end
|
33
|
+
|
34
|
+
def stub_post(path)
|
35
|
+
stub_request(:post, endpoint + path)
|
36
|
+
end
|
37
|
+
|
38
|
+
def stub_put(path)
|
39
|
+
stub_request(:put, endpoint + path)
|
40
|
+
end
|
41
|
+
|
42
|
+
def fixture_path
|
43
|
+
File.expand_path("../fixtures", __FILE__)
|
44
|
+
end
|
45
|
+
|
46
|
+
def fixture(file)
|
47
|
+
File.new(fixture_path + '/' + file)
|
48
|
+
end
|
data/spec/support/vcr.rb
ADDED
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: dance
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.1.
|
5
|
+
version: 0.1.1
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Ethan Turkeltaub
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-
|
13
|
+
date: 2011-11-08 00:00:00 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: httparty
|
@@ -34,6 +34,28 @@ dependencies:
|
|
34
34
|
version: "0"
|
35
35
|
type: :development
|
36
36
|
version_requirements: *id002
|
37
|
+
- !ruby/object:Gem::Dependency
|
38
|
+
name: webmock
|
39
|
+
prerelease: false
|
40
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ">="
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: "0"
|
46
|
+
type: :development
|
47
|
+
version_requirements: *id003
|
48
|
+
- !ruby/object:Gem::Dependency
|
49
|
+
name: vcr
|
50
|
+
prerelease: false
|
51
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
52
|
+
none: false
|
53
|
+
requirements:
|
54
|
+
- - ">="
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: "0"
|
57
|
+
type: :development
|
58
|
+
version_requirements: *id004
|
37
59
|
description: A library for communicating with the Console.fm API.
|
38
60
|
email:
|
39
61
|
- ethan.turkeltaub@gmail.com
|
@@ -52,10 +74,13 @@ files:
|
|
52
74
|
- lib/dance.rb
|
53
75
|
- lib/dance/artists.rb
|
54
76
|
- lib/dance/client.rb
|
77
|
+
- lib/dance/errors.rb
|
55
78
|
- lib/dance/genres.rb
|
56
79
|
- lib/dance/tracks.rb
|
57
|
-
- lib/dance/
|
80
|
+
- lib/dance/user.rb
|
58
81
|
- lib/dance/version.rb
|
82
|
+
- spec/spec_helper.rb
|
83
|
+
- spec/support/vcr.rb
|
59
84
|
homepage: http://github.com/eturk/dance
|
60
85
|
licenses: []
|
61
86
|
|
data/lib/dance/users.rb
DELETED
@@ -1,25 +0,0 @@
|
|
1
|
-
module Dance
|
2
|
-
class Users < Client
|
3
|
-
|
4
|
-
def self.all
|
5
|
-
get('/users')
|
6
|
-
end
|
7
|
-
|
8
|
-
def self.current
|
9
|
-
get('/users/current')
|
10
|
-
end
|
11
|
-
|
12
|
-
def self.favorites
|
13
|
-
get('/users/current/favorites')
|
14
|
-
end
|
15
|
-
|
16
|
-
def self.facebook
|
17
|
-
get('/users/current/facebook')
|
18
|
-
end
|
19
|
-
|
20
|
-
def self.twitter
|
21
|
-
get('/users/current/twitter')
|
22
|
-
end
|
23
|
-
|
24
|
-
end
|
25
|
-
end
|