officialfm 0.0.1
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.
- data/.document +5 -0
- data/.gitignore +26 -0
- data/Gemfile +3 -0
- data/LICENSE +20 -0
- data/README.md +84 -0
- data/Rakefile +14 -0
- data/changelog.md +6 -0
- data/lib/officialfm/client.rb +57 -0
- data/lib/officialfm/playlists.rb +55 -0
- data/lib/officialfm/tracks.rb +82 -0
- data/lib/officialfm/users.rb +97 -0
- data/lib/officialfm/version.rb +3 -0
- data/lib/officialfm.rb +30 -0
- data/officialfm.gemspec +32 -0
- data/test/fixtures/charts.json +1552 -0
- data/test/fixtures/latest.json +1552 -0
- data/test/fixtures/playlist.json +20 -0
- data/test/fixtures/playlist_votes.json +21 -0
- data/test/fixtures/playlists.json +92 -0
- data/test/fixtures/track.json +33 -0
- data/test/fixtures/track_votes.json +306 -0
- data/test/fixtures/tracks.json +157 -0
- data/test/fixtures/user.json +22 -0
- data/test/fixtures/user_contacts.json +40 -0
- data/test/fixtures/user_playlists.json +38 -0
- data/test/fixtures/user_subscribers.json +40 -0
- data/test/fixtures/user_subscriptions.json +40 -0
- data/test/fixtures/user_tracks.json +66 -0
- data/test/helper.rb +42 -0
- data/test/playlists_test.rb +32 -0
- data/test/tracks_test.rb +48 -0
- data/test/users_test.rb +73 -0
- metadata +225 -0
@@ -0,0 +1,40 @@
|
|
1
|
+
[
|
2
|
+
{
|
3
|
+
"birthdate":null,
|
4
|
+
"city":"Geneva",
|
5
|
+
"comments_count":126,
|
6
|
+
"country_id":"CH",
|
7
|
+
"created_at":"2007-02-15 14:55:11 UTC",
|
8
|
+
"dropbox":false,
|
9
|
+
"gender":"male",
|
10
|
+
"id":33,
|
11
|
+
"name":"Mental Groove Records",
|
12
|
+
"picture_absolute_url":"http://cdn.official.fm/user_avatars/0/33_small.jpg",
|
13
|
+
"playlist_votes_count":90,
|
14
|
+
"playlists_count":42,
|
15
|
+
"pro":true,
|
16
|
+
"profile":"est. 1989, from Miss Kittin to Imperial Tiger Orchestra, we got them all!",
|
17
|
+
"status":"label",
|
18
|
+
"tracks_count":104,
|
19
|
+
"url":"http://www.mentalgroove.ch",
|
20
|
+
"votes_count":2681 },
|
21
|
+
{
|
22
|
+
"birthdate":null,
|
23
|
+
"city":"Montreal",
|
24
|
+
"comments_count":1,
|
25
|
+
"country_id":"CA",
|
26
|
+
"created_at":"2008-10-09 21:41:29 UTC",
|
27
|
+
"dropbox":true,
|
28
|
+
"gender":"none",
|
29
|
+
"id":11774,
|
30
|
+
"name":"Peters",
|
31
|
+
"picture_absolute_url":"http://cdn.official.fm/user_avatars/11/11774_small.jpg",
|
32
|
+
"playlist_votes_count":1,
|
33
|
+
"playlists_count":0,
|
34
|
+
"pro":false,
|
35
|
+
"profile":"We are quite aware that it sounds like the classical band story, but ours is true. Peters started when four lads (The Netherlands, Venezuela, France and Switzerland) decided to form a band to avoid being dead bored at school. It was a bit like at three everyone grabs an instrument and rock! Kind of funny considering that none of us knew how to play. But who needs that to play indie tunes anyway?\n\nThree months later, we were on stage for our first gig and, ever since that night, it has been quite hard to loose this addiction to sweat, pleasure and final satisfaction (hey, don\'t get confused! We are still talking about performing music on stage)\n\nWe have done numerous gigs in clubs and festivals, in Switzerland and abroad, for one person (yes, indeed) or for a few thousands and issued, as of today, two EP and two albums.\n\nHaving a band and being on the road is cool, you should try too. It has led us to discover places we would never have known and share the stage with bands such as Suede (UK), Ghinzu (Belgium), Dover (Spain), Liquido (Germany), The Godfathers (UK), Poni Hoax (France), Shed Seven (UK), A.S.Dragon (France), Salad (UK), Lovebugs (CH), The Sheer (NL) and many others.",
|
36
|
+
"status":"artist",
|
37
|
+
"tracks_count":0,
|
38
|
+
"url":"http://www.peters-theband.com",
|
39
|
+
"votes_count":10 }
|
40
|
+
]
|
@@ -0,0 +1,38 @@
|
|
1
|
+
[
|
2
|
+
{
|
3
|
+
"comments_count":0,
|
4
|
+
"created_at":"2009-09-15 22:41:48 UTC",
|
5
|
+
"description":"dd",
|
6
|
+
"id":20828,
|
7
|
+
"large_embed_code":"<iframe name=\"fairplayer\" width=\"220\" height=\"350\" scrolling=\"no\" frameborder=\"0\" src=\"http://official.fm/playlist/20828?fairplayer=large\"></iframe>",
|
8
|
+
"length":9575,
|
9
|
+
"mini_embed_code":"<iframe name=\"fairplayer\" width=\"34\" height=\"18\" scrolling=\"no\" frameborder=\"0\" src=\"http://official.fm/playlist/20828?fairplayer=mini\"></iframe>",
|
10
|
+
"name":"I like",
|
11
|
+
"picture_absolute_url":"http://cdn.official.fm/playlist_pictures/20/20828_small.jpg",
|
12
|
+
"plays_count":61,
|
13
|
+
"shuffle":false,
|
14
|
+
"small_embed_code":"<iframe name=\"fairplayer\" width=\"100%\" height=\"40\" scrolling=\"no\" frameborder=\"0\" src=\"http://official.fm/playlist/20828?fairplayer=small\"></iframe>",
|
15
|
+
"standard_embed_code":"<iframe name=\"fairplayer\" width=\"160\" height=\"240\" scrolling=\"no\" frameborder=\"0\" src=\"http://official.fm/playlist/20828?fairplayer=standard\"></iframe>",
|
16
|
+
"tracks_count":32,
|
17
|
+
"tracks_list":"220813,137550,164700,5291,110978,97012,95959,111033,78490,94884,80096,62578,111082,79428,77445,69845,56600,4683,27023,18098,38493,33206,58267,63088,10643,20376,51111,33624,7470,4806,24907,2853",
|
18
|
+
"user_id":8735,
|
19
|
+
"votes_count":0 },
|
20
|
+
{
|
21
|
+
"comments_count":0,
|
22
|
+
"created_at":"2009-12-20 17:17:21 UTC",
|
23
|
+
"description":null,
|
24
|
+
"id":25263,
|
25
|
+
"large_embed_code":"<iframe name=\"fairplayer\" width=\"220\" height=\"350\" scrolling=\"no\" frameborder=\"0\" src=\"http://official.fm/playlist/25263?fairplayer=large\"></iframe>",
|
26
|
+
"length":9655,
|
27
|
+
"mini_embed_code":"<iframe name=\"fairplayer\" width=\"34\" height=\"18\" scrolling=\"no\" frameborder=\"0\" src=\"http://official.fm/playlist/25263?fairplayer=mini\"></iframe>",
|
28
|
+
"name":"deep mixes",
|
29
|
+
"picture_absolute_url":"http://cdn.official.fm/playlist_pictures/25/25263_small.jpg",
|
30
|
+
"plays_count":16,
|
31
|
+
"shuffle":false,
|
32
|
+
"small_embed_code":"<iframe name=\"fairplayer\" width=\"100%\" height=\"40\" scrolling=\"no\" frameborder=\"0\" src=\"http://official.fm/playlist/25263?fairplayer=small\"></iframe>",
|
33
|
+
"standard_embed_code":"<iframe name=\"fairplayer\" width=\"160\" height=\"240\" scrolling=\"no\" frameborder=\"0\" src=\"http://official.fm/playlist/25263?fairplayer=standard\"></iframe>",
|
34
|
+
"tracks_count":2,
|
35
|
+
"tracks_list":"14570,33029",
|
36
|
+
"user_id":8735,
|
37
|
+
"votes_count":1 }
|
38
|
+
]
|
@@ -0,0 +1,40 @@
|
|
1
|
+
[
|
2
|
+
{
|
3
|
+
"birthdate":null,
|
4
|
+
"city":"Grenoble, france",
|
5
|
+
"comments_count":55,
|
6
|
+
"country_id":"FR",
|
7
|
+
"created_at":"2007-06-12 19:38:17 UTC",
|
8
|
+
"dropbox":true,
|
9
|
+
"gender":"male",
|
10
|
+
"id":394,
|
11
|
+
"name":"DJ INBEATWIN",
|
12
|
+
"picture_absolute_url":"http://cdn.official.fm/user_avatars/0/394_small.jpg",
|
13
|
+
"playlist_votes_count":60,
|
14
|
+
"playlists_count":4,
|
15
|
+
"pro":false,
|
16
|
+
"profile":"Formerly a US and Detroit Techno DJ now moving to play whatever catches his hear and moves his heart. Expect to hear all kinds of musics here ! \n\nParticular interest on Tropicalia, Disco, Psyche Rock, Electro, Dub, Cold Wave, Punk Funk etc etc........................\n\nRunning a weekly show on Radio Campus Grenoble each thursday 8:30pm to 9:30pm.",
|
17
|
+
"status":"artist",
|
18
|
+
"tracks_count":44,
|
19
|
+
"url":"http://contortyourself.free.fr",
|
20
|
+
"votes_count":568 },
|
21
|
+
{
|
22
|
+
"birthdate":null,
|
23
|
+
"city":"Geneva",
|
24
|
+
"comments_count":0,
|
25
|
+
"country_id":"CH",
|
26
|
+
"created_at":"2007-07-09 08:38:51 UTC",
|
27
|
+
"dropbox":false,
|
28
|
+
"gender":"female",
|
29
|
+
"id":1132,
|
30
|
+
"name":"jenny",
|
31
|
+
"picture_absolute_url":"http://cdn.official.fm/user_avatars/1/1132_small.jpg",
|
32
|
+
"playlist_votes_count":0,
|
33
|
+
"playlists_count":5,
|
34
|
+
"pro":false,
|
35
|
+
"profile":"",
|
36
|
+
"status":"member",
|
37
|
+
"tracks_count":0,
|
38
|
+
"url":"",
|
39
|
+
"votes_count":1 }
|
40
|
+
]
|
@@ -0,0 +1,40 @@
|
|
1
|
+
[
|
2
|
+
{
|
3
|
+
"birthdate":"1968-08-28",
|
4
|
+
"city":"Geneva",
|
5
|
+
"comments_count":20,
|
6
|
+
"country_id":"CH",
|
7
|
+
"created_at":"2007-02-16 18:22:10 UTC",
|
8
|
+
"dropbox":false,
|
9
|
+
"gender":"male",
|
10
|
+
"id":38,
|
11
|
+
"name":"JFG",
|
12
|
+
"picture_absolute_url":"http://cdn.official.fm/user_avatars/0/38_small.jpg",
|
13
|
+
"playlist_votes_count":8,
|
14
|
+
"playlists_count":20,
|
15
|
+
"pro":false,
|
16
|
+
"profile":"Freelance CTO, Junior tastemaker!",
|
17
|
+
"status":"member",
|
18
|
+
"tracks_count":0,
|
19
|
+
"url":"",
|
20
|
+
"votes_count":440 },
|
21
|
+
{
|
22
|
+
"birthdate":null,
|
23
|
+
"city":null,
|
24
|
+
"comments_count":0,
|
25
|
+
"country_id":"CH",
|
26
|
+
"created_at":"2007-07-03 05:06:26 UTC",
|
27
|
+
"dropbox":false,
|
28
|
+
"gender":null,
|
29
|
+
"id":964,
|
30
|
+
"name":"Sumo",
|
31
|
+
"picture_absolute_url":"http://cdn.official.fm/user_avatars/0/964_small.jpg",
|
32
|
+
"playlist_votes_count":0,
|
33
|
+
"playlists_count":0,
|
34
|
+
"pro":false,
|
35
|
+
"profile":"",
|
36
|
+
"status":"member",
|
37
|
+
"tracks_count":0,
|
38
|
+
"url":"http://www.myspace.com/sumomusic",
|
39
|
+
"votes_count":0 }
|
40
|
+
]
|
@@ -0,0 +1,66 @@
|
|
1
|
+
[
|
2
|
+
{
|
3
|
+
"artist_string":"Hercules and Love Affair",
|
4
|
+
"buy_url":"",
|
5
|
+
"comments_count":0,
|
6
|
+
"concatinated_genres":"Electronic,House",
|
7
|
+
"concatinated_tags":null,
|
8
|
+
"country_id":"US",
|
9
|
+
"created_at":"2008-08-08 17:13:58 UTC",
|
10
|
+
"derived_type":"original",
|
11
|
+
"description":"Remixed by Chab (http://www.myspace.com/chabmusic)",
|
12
|
+
"downloadable":true,
|
13
|
+
"downloads_count":232,
|
14
|
+
"id":11204,
|
15
|
+
"large_embed_code":"<iframe name=\"fairplayer\" width=\"220\" height=\"350\" scrolling=\"no\" frameborder=\"0\" src=\"http://official.fm/track/11204?fairplayer=large\">iframe>",
|
16
|
+
"length":461,
|
17
|
+
"mini_embed_code":"<iframe name=\"fairplayer\" width=\"34\" height=\"18\" scrolling=\"no\" frameborder=\"0\" src=\"http://official.fm/track/11204?fairplayer=mini\">iframe>",
|
18
|
+
"original_track_id":null,
|
19
|
+
"picture_absolute_url":"http://cdn.official.fm/track_pictures/11/11204_small.jpg",
|
20
|
+
"playlists_count":9,
|
21
|
+
"plays_count":252,
|
22
|
+
"pr_url":"http://www.dfarecords.com",
|
23
|
+
"small_embed_code":"<iframe name=\"fairplayer\" width=\"100%\" height=\"40\" scrolling=\"no\" frameborder=\"0\" src=\"http://official.fm/track/11204?fairplayer=small\">iframe>",
|
24
|
+
"standard_embed_code":"<iframe name=\"fairplayer\" width=\"160\" height=\"240\" scrolling=\"no\" frameborder=\"0\" src=\"http://official.fm/track/11204?fairplayer=standard\">iframe>",
|
25
|
+
"title":"Blind (Chab Remix)",
|
26
|
+
"url_1":"",
|
27
|
+
"url_1_name":"",
|
28
|
+
"url_2":"",
|
29
|
+
"url_2_name":"",
|
30
|
+
"user_id":8735,
|
31
|
+
"votes_count":12,
|
32
|
+
"web_url":"http://herculesandloveaffair.com"
|
33
|
+
},
|
34
|
+
{
|
35
|
+
"artist_string":"The Cure",
|
36
|
+
"buy_url":"",
|
37
|
+
"comments_count":0,
|
38
|
+
"concatinated_genres":"Pop",
|
39
|
+
"concatinated_tags":null,
|
40
|
+
"country_id":"UK",
|
41
|
+
"created_at":"2010-04-30 20:48:56 UTC",
|
42
|
+
"derived_type":"original",
|
43
|
+
"description":"",
|
44
|
+
"downloadable":false,
|
45
|
+
"downloads_count":0,
|
46
|
+
"id":106832,
|
47
|
+
"large_embed_code":"<iframe name=\"fairplayer\" width=\"220\" height=\"350\" scrolling=\"no\" frameborder=\"0\" src=\"http://official.fm/track/106832?fairplayer=large\">iframe>",
|
48
|
+
"length":411,
|
49
|
+
"mini_embed_code":"<iframe name=\"fairplayer\" width=\"34\" height=\"18\" scrolling=\"no\" frameborder=\"0\" src=\"http://official.fm/track/106832?fairplayer=mini\">iframe>",
|
50
|
+
"original_track_id":null,
|
51
|
+
"picture_absolute_url":"http://cdn.official.fm/track_pictures/106/106832_small.jpg",
|
52
|
+
"playlists_count":1,
|
53
|
+
"plays_count":46,
|
54
|
+
"pr_url":"",
|
55
|
+
"small_embed_code":"<iframe name=\"fairplayer\" width=\"100%\" height=\"40\" scrolling=\"no\" frameborder=\"0\" src=\"http://official.fm/track/106832?fairplayer=small\">iframe>",
|
56
|
+
"standard_embed_code":"<iframe name=\"fairplayer\" width=\"160\" height=\"240\" scrolling=\"no\" frameborder=\"0\" src=\"http://official.fm/track/106832?fairplayer=standard\">iframe>",
|
57
|
+
"title":"The top",
|
58
|
+
"url_1":"",
|
59
|
+
"url_1_name":"",
|
60
|
+
"url_2":"",
|
61
|
+
"url_2_name":"",
|
62
|
+
"user_id":8735,
|
63
|
+
"votes_count":1,
|
64
|
+
"web_url":""
|
65
|
+
}
|
66
|
+
]
|
data/test/helper.rb
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'test/unit'
|
3
|
+
require 'shoulda'
|
4
|
+
require 'matchy'
|
5
|
+
require 'fakeweb'
|
6
|
+
begin require 'redgreen'; rescue LoadError; end
|
7
|
+
|
8
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
9
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
10
|
+
require 'officialfm'
|
11
|
+
|
12
|
+
FakeWeb.allow_net_connect = false
|
13
|
+
|
14
|
+
def officialfm_test_client
|
15
|
+
OfficialFM::Client.new(:api_key => 'GNXbH3zYb25F1I7KVEEN')
|
16
|
+
end
|
17
|
+
|
18
|
+
def fixture_file(filename)
|
19
|
+
return '' if filename == ''
|
20
|
+
file_path = File.expand_path(File.dirname(__FILE__) + '/fixtures/' + filename)
|
21
|
+
File.read(file_path)
|
22
|
+
end
|
23
|
+
|
24
|
+
def officialfm_url(url)
|
25
|
+
url =~ /^http/ ? url : "http://api.official.fm#{url}"
|
26
|
+
end
|
27
|
+
|
28
|
+
def stub_get(url, filename, options={})
|
29
|
+
opts = {
|
30
|
+
:body => fixture_file(filename),
|
31
|
+
:content_type => 'application/json; charset=utf-8'
|
32
|
+
}.merge(options)
|
33
|
+
FakeWeb.register_uri(:get, officialfm_url(url), opts)
|
34
|
+
end
|
35
|
+
|
36
|
+
def stub_post(url, filename, options={})
|
37
|
+
opts = {
|
38
|
+
:body => fixture_file(filename),
|
39
|
+
:content_type => 'application/json; charset=utf-8'
|
40
|
+
}.merge(options)
|
41
|
+
FakeWeb.register_uri(:post, officialfm_url(url), opts)
|
42
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
class PlaylistsTests < Test::Unit::TestCase
|
4
|
+
|
5
|
+
context "When using the official.fm API and working with Playlists" do
|
6
|
+
setup do
|
7
|
+
@client = officialfm_test_client
|
8
|
+
end
|
9
|
+
|
10
|
+
should "search for 5 playlists with the 'R&B Mixtape' search term" do
|
11
|
+
stub_get('http://api.official.fm/search/playlists/R%26B+Mixtape?key=GNXbH3zYb25F1I7KVEEN&format=json&api_max_responses=5', 'playlists.json')
|
12
|
+
tracks = @client.playlists('R&B Mixtape', :limit => 5)
|
13
|
+
tracks.length.should == 5
|
14
|
+
tracks[0].running_time.should == 4167
|
15
|
+
tracks[3].tracks[1].should == 40057
|
16
|
+
end
|
17
|
+
|
18
|
+
should "get info on HLSTRS Timeless mixtape" do
|
19
|
+
stub_get('http://api.official.fm/playlist/55569?key=GNXbH3zYb25F1I7KVEEN&format=json&api_embed_codes=', 'playlist.json')
|
20
|
+
playlist = @client.playlist(55569)
|
21
|
+
playlist.shuffle.should == false
|
22
|
+
playlist.user_id.should == 46269
|
23
|
+
end
|
24
|
+
|
25
|
+
should "get playlist votes on HLSTRS Timeless mixtape" do
|
26
|
+
stub_get('http://api.official.fm/playlist/55569/votes?key=GNXbH3zYb25F1I7KVEEN&format=json&api_max_responses=', 'playlist_votes.json')
|
27
|
+
votes = @client.playlist_votes(55569)
|
28
|
+
votes[0].name.should == 'VALERIAN'
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
data/test/tracks_test.rb
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
class TracksTest < Test::Unit::TestCase
|
4
|
+
|
5
|
+
context "When using the official.fm API and working with Tracks" do
|
6
|
+
setup do
|
7
|
+
@client = officialfm_test_client
|
8
|
+
end
|
9
|
+
|
10
|
+
should "search for 5 tracks with the 'Quelque Chose' search term" do
|
11
|
+
stub_get('http://api.official.fm/search/tracks/Quelque+Chose?key=GNXbH3zYb25F1I7KVEEN&format=json&api_max_responses=5', 'tracks.json')
|
12
|
+
tracks = @client.tracks('Quelque Chose', :limit => 5)
|
13
|
+
tracks.length.should == 5
|
14
|
+
tracks[0].artist_string.should == 'Radio Sympa'
|
15
|
+
tracks[4].title.should == 'Manhattan'
|
16
|
+
# interestingly, the search turns up nothing about QuelqueChoseD'HasBeen :/
|
17
|
+
end
|
18
|
+
|
19
|
+
should "look up informations about my favorite SomethingALaMode mix" do
|
20
|
+
stub_get('http://api.official.fm/track/60526?key=GNXbH3zYb25F1I7KVEEN&format=json&api_embed_codes=', 'track.json')
|
21
|
+
track = @client.track(60526)
|
22
|
+
# yes, for some reason there's a double-escaped backslash in there. Don't ask, don't tell.
|
23
|
+
track.title.should == "QuelqueChosed\'HasBeen"
|
24
|
+
track.artist_string.should == 'Various Artist'
|
25
|
+
end
|
26
|
+
|
27
|
+
should "retrieve a list of 3 users who voted for QuelqueChoseD'HasBeen" do
|
28
|
+
stub_get('http://api.official.fm/track/60526/votes?key=GNXbH3zYb25F1I7KVEEN&format=json&api_max_responses=3', 'track_votes.json')
|
29
|
+
users = @client.track_votes(60526, :limit => 3)
|
30
|
+
users[0].city.should == "Geneva"
|
31
|
+
users[1].profile.should == "co-founder @official.fm"
|
32
|
+
users[2].id.should == 7615
|
33
|
+
end
|
34
|
+
|
35
|
+
should "retrieve 50 latest tracks from the 'electronic' charts" do
|
36
|
+
stub_get('http://api.official.fm/tracks/charts?key=GNXbH3zYb25F1I7KVEEN&format=json&charting=month&genre=&country=&api_embed_codes=&api_max_responses=', 'charts.json')
|
37
|
+
tracks = @client.charts('month')
|
38
|
+
tracks.length.should == 50 # the API's default
|
39
|
+
end
|
40
|
+
|
41
|
+
should "retrieve 50 last posted tracks" do
|
42
|
+
stub_get('http://api.official.fm/tracks/latest?key=GNXbH3zYb25F1I7KVEEN&format=json&genre=&country=&api_embed_codes=&api_max_responses=', 'charts.json')
|
43
|
+
tracks = @client.latest()
|
44
|
+
tracks.length.should == 50 # the API's default
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
end
|
data/test/users_test.rb
ADDED
@@ -0,0 +1,73 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
class UsersTest < Test::Unit::TestCase
|
4
|
+
|
5
|
+
context "When using the official.fm API and working with Users" do
|
6
|
+
setup do
|
7
|
+
@client = officialfm_test_client
|
8
|
+
end
|
9
|
+
|
10
|
+
should "retrieve information about a specific user" do
|
11
|
+
stub_get('http://api.official.fm/user/chab?key=GNXbH3zYb25F1I7KVEEN&format=json', 'user.json')
|
12
|
+
user = @client.user('chab')
|
13
|
+
user.name.should == 'Chab'
|
14
|
+
# let's hope he doesn't change sex
|
15
|
+
user.gender.should == 'male'
|
16
|
+
user.status.should == 'artist'
|
17
|
+
user.country_id.should == 'CH'
|
18
|
+
end
|
19
|
+
|
20
|
+
should "retrieve information about a specific user as well" do
|
21
|
+
stub_get('http://api.official.fm/search/users/chab?key=GNXbH3zYb25F1I7KVEEN&format=json&api_max_responses=1', 'user.json')
|
22
|
+
# this should work as well, 'chab' is an exact match so the first result oughta be correct
|
23
|
+
user = @client.users('chab', :limit => 1)[0]
|
24
|
+
user.name.should == 'Chab'
|
25
|
+
user.gender.should == 'male'
|
26
|
+
user.status.should == 'artist'
|
27
|
+
# let's hope he doesn't move away
|
28
|
+
user.country_id.should == 'CH'
|
29
|
+
end
|
30
|
+
|
31
|
+
should "retrieve the first two tracks of chab" do
|
32
|
+
stub_get('http://api.official.fm/user/chab/tracks?key=GNXbH3zYb25F1I7KVEEN&format=json&api_embed_codes=&api_max_responses=2', 'user_tracks.json')
|
33
|
+
tracks = @client.user_tracks('chab', :limit => 2)
|
34
|
+
tracks.size.should == 2
|
35
|
+
tracks[0].title.should == 'Blind (Chab Remix)'
|
36
|
+
tracks[0].artist_string.should == 'Hercules and Love Affair'
|
37
|
+
end
|
38
|
+
|
39
|
+
should "retrieve the first two playlists of chab" do
|
40
|
+
stub_get('http://api.official.fm/user/chab/playlists?key=GNXbH3zYb25F1I7KVEEN&format=json&api_embed_codes=&api_max_responses=2', 'user_playlists.json')
|
41
|
+
playlists = @client.user_playlists('chab', :limit => 2)
|
42
|
+
playlists.size.should == 2
|
43
|
+
playlists[0].name.should == 'I like'
|
44
|
+
playlists[1].user_id.should == 8735 # chab's user id
|
45
|
+
end
|
46
|
+
|
47
|
+
should "retrieve the first two contacts of chab" do
|
48
|
+
stub_get('http://api.official.fm/user/chab/contacts?key=GNXbH3zYb25F1I7KVEEN&format=json&api_max_responses=2', 'user_contacts.json')
|
49
|
+
contacts = @client.user_contacts('chab', :limit => 2)
|
50
|
+
contacts.size.should == 2
|
51
|
+
contacts[0].name.should == 'Mental Groove Records'
|
52
|
+
contacts[1].status.should == 'artist'
|
53
|
+
end
|
54
|
+
|
55
|
+
should "retrieve the first two subscribers of chab" do
|
56
|
+
stub_get('http://api.official.fm/user/chab/subscribers?key=GNXbH3zYb25F1I7KVEEN&format=json&api_max_responses=2', 'user_subscribers.json')
|
57
|
+
subscribers = @client.user_subscribers('chab', :limit => 2)
|
58
|
+
subscribers.size.should == 2
|
59
|
+
subscribers[0].id.should == 394
|
60
|
+
subscribers[1].name.should == 'jenny'
|
61
|
+
end
|
62
|
+
|
63
|
+
should "retrieve the first two subscriptions of chab" do
|
64
|
+
stub_get('http://api.official.fm/user/chab/subscriptions?key=GNXbH3zYb25F1I7KVEEN&format=json&api_max_responses=2', 'user_subscriptions.json')
|
65
|
+
subscriptions = @client.user_subscriptions('chab', :limit => 2)
|
66
|
+
subscriptions.size.should == 2
|
67
|
+
subscriptions[0].profile.should == 'Freelance CTO, Junior tastemaker!'
|
68
|
+
subscriptions[1].url.should == 'http://www.myspace.com/sumomusic'
|
69
|
+
end
|
70
|
+
|
71
|
+
end
|
72
|
+
|
73
|
+
end
|
metadata
ADDED
@@ -0,0 +1,225 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: officialfm
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease:
|
5
|
+
version: 0.0.1
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Amos Wenger
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
|
13
|
+
date: 2011-03-23 00:00:00 +01:00
|
14
|
+
default_executable:
|
15
|
+
dependencies:
|
16
|
+
- !ruby/object:Gem::Dependency
|
17
|
+
name: faraday
|
18
|
+
prerelease: false
|
19
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
20
|
+
none: false
|
21
|
+
requirements:
|
22
|
+
- - ~>
|
23
|
+
- !ruby/object:Gem::Version
|
24
|
+
version: 0.5.3
|
25
|
+
type: :runtime
|
26
|
+
version_requirements: *id001
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: faraday_middleware
|
29
|
+
prerelease: false
|
30
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
31
|
+
none: false
|
32
|
+
requirements:
|
33
|
+
- - ~>
|
34
|
+
- !ruby/object:Gem::Version
|
35
|
+
version: 0.3.0
|
36
|
+
type: :runtime
|
37
|
+
version_requirements: *id002
|
38
|
+
- !ruby/object:Gem::Dependency
|
39
|
+
name: hashie
|
40
|
+
prerelease: false
|
41
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
42
|
+
none: false
|
43
|
+
requirements:
|
44
|
+
- - ~>
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: 1.0.0
|
47
|
+
type: :runtime
|
48
|
+
version_requirements: *id003
|
49
|
+
- !ruby/object:Gem::Dependency
|
50
|
+
name: oauth2
|
51
|
+
prerelease: false
|
52
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
53
|
+
none: false
|
54
|
+
requirements:
|
55
|
+
- - ~>
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
version: 0.1.0
|
58
|
+
type: :runtime
|
59
|
+
version_requirements: *id004
|
60
|
+
- !ruby/object:Gem::Dependency
|
61
|
+
name: bundler
|
62
|
+
prerelease: false
|
63
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
64
|
+
none: false
|
65
|
+
requirements:
|
66
|
+
- - ~>
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: "1.0"
|
69
|
+
type: :development
|
70
|
+
version_requirements: *id005
|
71
|
+
- !ruby/object:Gem::Dependency
|
72
|
+
name: fakeweb
|
73
|
+
prerelease: false
|
74
|
+
requirement: &id006 !ruby/object:Gem::Requirement
|
75
|
+
none: false
|
76
|
+
requirements:
|
77
|
+
- - ~>
|
78
|
+
- !ruby/object:Gem::Version
|
79
|
+
version: "1.3"
|
80
|
+
type: :development
|
81
|
+
version_requirements: *id006
|
82
|
+
- !ruby/object:Gem::Dependency
|
83
|
+
name: jnunemaker-matchy
|
84
|
+
prerelease: false
|
85
|
+
requirement: &id007 !ruby/object:Gem::Requirement
|
86
|
+
none: false
|
87
|
+
requirements:
|
88
|
+
- - ~>
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
version: "0.4"
|
91
|
+
type: :development
|
92
|
+
version_requirements: *id007
|
93
|
+
- !ruby/object:Gem::Dependency
|
94
|
+
name: json_pure
|
95
|
+
prerelease: false
|
96
|
+
requirement: &id008 !ruby/object:Gem::Requirement
|
97
|
+
none: false
|
98
|
+
requirements:
|
99
|
+
- - ~>
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: "1.4"
|
102
|
+
type: :development
|
103
|
+
version_requirements: *id008
|
104
|
+
- !ruby/object:Gem::Dependency
|
105
|
+
name: rake
|
106
|
+
prerelease: false
|
107
|
+
requirement: &id009 !ruby/object:Gem::Requirement
|
108
|
+
none: false
|
109
|
+
requirements:
|
110
|
+
- - ~>
|
111
|
+
- !ruby/object:Gem::Version
|
112
|
+
version: "0.8"
|
113
|
+
type: :development
|
114
|
+
version_requirements: *id009
|
115
|
+
- !ruby/object:Gem::Dependency
|
116
|
+
name: shoulda
|
117
|
+
prerelease: false
|
118
|
+
requirement: &id010 !ruby/object:Gem::Requirement
|
119
|
+
none: false
|
120
|
+
requirements:
|
121
|
+
- - ~>
|
122
|
+
- !ruby/object:Gem::Version
|
123
|
+
version: "2.11"
|
124
|
+
type: :development
|
125
|
+
version_requirements: *id010
|
126
|
+
- !ruby/object:Gem::Dependency
|
127
|
+
name: test-unit
|
128
|
+
prerelease: false
|
129
|
+
requirement: &id011 !ruby/object:Gem::Requirement
|
130
|
+
none: false
|
131
|
+
requirements:
|
132
|
+
- - ~>
|
133
|
+
- !ruby/object:Gem::Version
|
134
|
+
version: "2.1"
|
135
|
+
type: :development
|
136
|
+
version_requirements: *id011
|
137
|
+
description: Unofficial Ruby wrapper for the official.fm API
|
138
|
+
email:
|
139
|
+
- ndd@rylliog.cz
|
140
|
+
executables: []
|
141
|
+
|
142
|
+
extensions: []
|
143
|
+
|
144
|
+
extra_rdoc_files: []
|
145
|
+
|
146
|
+
files:
|
147
|
+
- .document
|
148
|
+
- .gitignore
|
149
|
+
- Gemfile
|
150
|
+
- LICENSE
|
151
|
+
- README.md
|
152
|
+
- Rakefile
|
153
|
+
- changelog.md
|
154
|
+
- lib/officialfm.rb
|
155
|
+
- lib/officialfm/client.rb
|
156
|
+
- lib/officialfm/playlists.rb
|
157
|
+
- lib/officialfm/tracks.rb
|
158
|
+
- lib/officialfm/users.rb
|
159
|
+
- lib/officialfm/version.rb
|
160
|
+
- officialfm.gemspec
|
161
|
+
- test/fixtures/charts.json
|
162
|
+
- test/fixtures/latest.json
|
163
|
+
- test/fixtures/playlist.json
|
164
|
+
- test/fixtures/playlist_votes.json
|
165
|
+
- test/fixtures/playlists.json
|
166
|
+
- test/fixtures/track.json
|
167
|
+
- test/fixtures/track_votes.json
|
168
|
+
- test/fixtures/tracks.json
|
169
|
+
- test/fixtures/user.json
|
170
|
+
- test/fixtures/user_contacts.json
|
171
|
+
- test/fixtures/user_playlists.json
|
172
|
+
- test/fixtures/user_subscribers.json
|
173
|
+
- test/fixtures/user_subscriptions.json
|
174
|
+
- test/fixtures/user_tracks.json
|
175
|
+
- test/helper.rb
|
176
|
+
- test/playlists_test.rb
|
177
|
+
- test/tracks_test.rb
|
178
|
+
- test/users_test.rb
|
179
|
+
has_rdoc: true
|
180
|
+
homepage: http://github.com/nddrylliog/officialfm-ruby
|
181
|
+
licenses: []
|
182
|
+
|
183
|
+
post_install_message:
|
184
|
+
rdoc_options: []
|
185
|
+
|
186
|
+
require_paths:
|
187
|
+
- lib
|
188
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
189
|
+
none: false
|
190
|
+
requirements:
|
191
|
+
- - ">="
|
192
|
+
- !ruby/object:Gem::Version
|
193
|
+
version: "0"
|
194
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
195
|
+
none: false
|
196
|
+
requirements:
|
197
|
+
- - ">="
|
198
|
+
- !ruby/object:Gem::Version
|
199
|
+
version: 1.3.6
|
200
|
+
requirements: []
|
201
|
+
|
202
|
+
rubyforge_project:
|
203
|
+
rubygems_version: 1.6.2
|
204
|
+
signing_key:
|
205
|
+
specification_version: 3
|
206
|
+
summary: Unofficial wrapper for the official.fm API
|
207
|
+
test_files:
|
208
|
+
- test/fixtures/charts.json
|
209
|
+
- test/fixtures/latest.json
|
210
|
+
- test/fixtures/playlist.json
|
211
|
+
- test/fixtures/playlist_votes.json
|
212
|
+
- test/fixtures/playlists.json
|
213
|
+
- test/fixtures/track.json
|
214
|
+
- test/fixtures/track_votes.json
|
215
|
+
- test/fixtures/tracks.json
|
216
|
+
- test/fixtures/user.json
|
217
|
+
- test/fixtures/user_contacts.json
|
218
|
+
- test/fixtures/user_playlists.json
|
219
|
+
- test/fixtures/user_subscribers.json
|
220
|
+
- test/fixtures/user_subscriptions.json
|
221
|
+
- test/fixtures/user_tracks.json
|
222
|
+
- test/helper.rb
|
223
|
+
- test/playlists_test.rb
|
224
|
+
- test/tracks_test.rb
|
225
|
+
- test/users_test.rb
|