bts-scrobbler2 0.0.4
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/README.rdoc +155 -0
- data/Rakefile +8 -0
- data/VERSION.yml +4 -0
- data/generators/acceptance_test/USAGE +9 -0
- data/generators/acceptance_test/acceptance_test_generator.rb +57 -0
- data/generators/acceptance_test/templates/acceptance_test.rb.erb +14 -0
- data/generators/resource/USAGE +8 -0
- data/generators/resource/resource_generator.rb +47 -0
- data/generators/resource/templates/resource.rb.erb +11 -0
- data/generators/resource/templates/spec.rb.erb +22 -0
- data/lib/scrobbler2.rb +23 -0
- data/lib/scrobbler2/album.rb +11 -0
- data/lib/scrobbler2/artist.rb +26 -0
- data/lib/scrobbler2/auth.rb +19 -0
- data/lib/scrobbler2/base.rb +100 -0
- data/lib/scrobbler2/event.rb +12 -0
- data/lib/scrobbler2/geo.rb +15 -0
- data/lib/scrobbler2/group.rb +14 -0
- data/lib/scrobbler2/library.rb +12 -0
- data/lib/scrobbler2/playlist.rb +10 -0
- data/lib/scrobbler2/tag.rb +18 -0
- data/lib/scrobbler2/track.rb +13 -0
- data/lib/scrobbler2/user.rb +29 -0
- data/lib/scrobbler2/venue.rb +12 -0
- data/test/acceptance/album/info_test.rb +56 -0
- data/test/acceptance/artist/add_tags_test.rb +14 -0
- data/test/acceptance/artist/events_test.rb +47 -0
- data/test/acceptance/artist/info_test.rb +53 -0
- data/test/acceptance/artist/shouts_test.rb +48 -0
- data/test/acceptance/artist/similar_artists_test.rb +20 -0
- data/test/acceptance/artist/tags_test.rb +24 -0
- data/test/acceptance/artist/top_albums_test.rb +34 -0
- data/test/acceptance/artist/top_fans.rb +19 -0
- data/test/acceptance/artist/top_tags.rb +18 -0
- data/test/acceptance/artist/top_tracks.rb +47 -0
- data/test/acceptance/auth/auth_test.rb +21 -0
- data/test/acceptance/event/info_test.rb +66 -0
- data/test/acceptance/event/shouts_test.rb +49 -0
- data/test/acceptance/geo/events_test.rb +14 -0
- data/test/acceptance/geo/top_artists_test.rb +16 -0
- data/test/acceptance/geo/top_tracks_test.rb +16 -0
- data/test/acceptance/group/members_test.rb +60 -0
- data/test/acceptance/group/weekly_album_chart_test.rb +61 -0
- data/test/acceptance/group/weekly_artist_chart_test.rb +54 -0
- data/test/acceptance/group/weekly_chart_list_test.rb +39 -0
- data/test/acceptance/group/weekly_track_chart_test.rb +61 -0
- data/test/acceptance/library/albums_test.rb +34 -0
- data/test/acceptance/library/artists_test.rb +33 -0
- data/test/acceptance/library/tracks_test.rb +33 -0
- data/test/acceptance/playlist/fetch_test.rb +68 -0
- data/test/acceptance/shared/album.rb +41 -0
- data/test/acceptance/shared/artist.rb +16 -0
- data/test/acceptance/shared/paged_result.rb +16 -0
- data/test/acceptance/shared/top_fans.rb +29 -0
- data/test/acceptance/shared/top_tags.rb +23 -0
- data/test/acceptance/shared/track.rb +23 -0
- data/test/acceptance/tag/similar_test.rb +15 -0
- data/test/acceptance/tag/top_albums_test.rb +37 -0
- data/test/acceptance/tag/top_artists_test.rb +31 -0
- data/test/acceptance/tag/top_tags_test.rb +32 -0
- data/test/acceptance/tag/top_tracks_test.rb +33 -0
- data/test/acceptance/tag/weekly_artist_chart.rb +54 -0
- data/test/acceptance/tag/weekly_chart_list.rb +39 -0
- data/test/acceptance/test_helper.rb +15 -0
- data/test/acceptance/track/info_test.rb +47 -0
- data/test/acceptance/track/similar_test.rb +22 -0
- data/test/acceptance/track/top_fans_test.rb +23 -0
- data/test/acceptance/track/top_tags_test.rb +24 -0
- data/test/acceptance/user/events_test.rb +27 -0
- data/test/acceptance/user/friends_test.rb +14 -0
- data/test/acceptance/user/info_test.rb +19 -0
- data/test/acceptance/user/loved_tracks_test.rb +14 -0
- data/test/acceptance/user/neighbours_test.rb +14 -0
- data/test/acceptance/user/past_events_test.rb +14 -0
- data/test/acceptance/user/playlists_test.rb +14 -0
- data/test/acceptance/user/recent_tracks_test.rb +14 -0
- data/test/acceptance/user/recommended_artists_test.rb +16 -0
- data/test/acceptance/user/recommended_events_test.rb +16 -0
- data/test/acceptance/user/shouts_test.rb +14 -0
- data/test/acceptance/user/top_albums_test.rb +14 -0
- data/test/acceptance/user/top_artists_test.rb +14 -0
- data/test/acceptance/user/top_tags_test.rb +14 -0
- data/test/acceptance/user/top_tracks_test.rb +14 -0
- data/test/acceptance/user/weekly_album_chart_test.rb +14 -0
- data/test/acceptance/user/weekly_artist_chart_test.rb +14 -0
- data/test/acceptance/user/weekly_chart_list_test.rb +14 -0
- data/test/acceptance/user/weekly_track_chart_test.rb +14 -0
- data/test/acceptance/venue/events_test.rb +14 -0
- data/test/acceptance/venue/past_events_test.rb +14 -0
- data/test/generators/test_acceptance_test_generator.rb +46 -0
- data/test/generators/test_generator_helper.rb +29 -0
- data/test/generators/test_resource_generator.rb +71 -0
- data/test/unit/album_spec.rb +17 -0
- data/test/unit/artist_spec.rb +62 -0
- data/test/unit/auth_spec.rb +22 -0
- data/test/unit/base_spec.rb +193 -0
- data/test/unit/event_spec.rb +23 -0
- data/test/unit/geo_spec.rb +36 -0
- data/test/unit/group_spec.rb +38 -0
- data/test/unit/library_spec.rb +27 -0
- data/test/unit/playlist_spec.rb +18 -0
- data/test/unit/spec_helper.rb +7 -0
- data/test/unit/tag_spec.rb +50 -0
- data/test/unit/track_spec.rb +33 -0
- data/test/unit/user_spec.rb +148 -0
- data/test/unit/venue_spec.rb +29 -0
- metadata +260 -0
@@ -0,0 +1,15 @@
|
|
1
|
+
module Scrobbler2
|
2
|
+
class Geo < Base
|
3
|
+
|
4
|
+
def initialize()
|
5
|
+
@query = {}#TODO eg. {:artist => artist, :track => track}
|
6
|
+
end
|
7
|
+
|
8
|
+
has_resource :events, :root => "events"
|
9
|
+
|
10
|
+
has_resource :top_artists, :root => "topartists"
|
11
|
+
|
12
|
+
has_resource :top_tracks, :root => "toptracks"
|
13
|
+
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module Scrobbler2
|
2
|
+
class Group < Base
|
3
|
+
|
4
|
+
def initialize(group_name)
|
5
|
+
@query = {:group => group_name}
|
6
|
+
end
|
7
|
+
|
8
|
+
has_resource :members, :root => 'members'
|
9
|
+
has_resource :weekly_album_chart, :root => 'weeklyalbumchart'
|
10
|
+
has_resource :weekly_artist_chart, :root => 'weeklyartistchart'
|
11
|
+
has_resource :weekly_track_chart, :root => 'weeklytrackchart'
|
12
|
+
has_resource :weekly_chart_list, :root => 'weeklychartlist'
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
|
2
|
+
module Scrobbler2
|
3
|
+
class Tag < Base
|
4
|
+
|
5
|
+
def initialize(tag)
|
6
|
+
@query = {:tag => tag}
|
7
|
+
end
|
8
|
+
|
9
|
+
has_singleton_resource :top_tags, :root => 'toptags'
|
10
|
+
has_resource :similar, :root => 'similar'
|
11
|
+
has_resource :top_artists, :root => 'topartists'
|
12
|
+
has_resource :top_albums, :root => 'topalbums'
|
13
|
+
has_resource :top_tracks, :root => 'toptracks'
|
14
|
+
has_resource :weekly_artist_chart, :root => 'weeklyartistchart'
|
15
|
+
has_resource :weekly_chart_list, :root => 'weeklychartlist'
|
16
|
+
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module Scrobbler2
|
2
|
+
class Track < Base
|
3
|
+
|
4
|
+
def initialize(artist, track)
|
5
|
+
@query = {:artist => artist, :track => track}
|
6
|
+
end
|
7
|
+
|
8
|
+
has_resource :info, :root => 'track'
|
9
|
+
has_resource :similar, :root => 'similartracks'
|
10
|
+
has_resource :top_fans, :root => 'topfans'
|
11
|
+
has_resource :top_tags, :root => 'toptags'
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module Scrobbler2
|
2
|
+
class User < Base
|
3
|
+
|
4
|
+
def initialize(username)
|
5
|
+
@query = {:user => username}
|
6
|
+
end
|
7
|
+
|
8
|
+
has_resource :events, :root => "events"
|
9
|
+
has_resource :info, :root=>"user", :auth=>true, :query => {}
|
10
|
+
has_resource :friends, :root => "friends"
|
11
|
+
has_resource :loved_tracks, :root => "lovedtracks"
|
12
|
+
has_resource :neighbours, :root => "neighbours"
|
13
|
+
has_resource :past_events, :root => "events"
|
14
|
+
has_resource :playlists, :root => "playlists"
|
15
|
+
has_resource :recent_tracks, :root => "recenttracks"
|
16
|
+
has_resource :recommended_artists, :root => "recommendedartists", :auth => true, :query => {}
|
17
|
+
has_resource :recommended_events, :root => "recommendedevents", :auth => true, :query => {}
|
18
|
+
has_resource :shouts, :root => "shouts"
|
19
|
+
has_resource :top_albums, :root => "topalbums"
|
20
|
+
has_resource :top_artists, :root => "topartists"
|
21
|
+
has_resource :top_tags, :root => "toptags"
|
22
|
+
has_resource :top_tracks, :root => "toptracks"
|
23
|
+
has_resource :weekly_album_chart, :root => "weeklyalbumchart"
|
24
|
+
has_resource :weekly_artist_chart, :root => "weeklyartistchart"
|
25
|
+
has_resource :weekly_chart_list, :root => "weeklychartlist"
|
26
|
+
has_resource :weekly_track_chart, :root => "weeklytrackchart"
|
27
|
+
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../test_helper.rb'
|
2
|
+
|
3
|
+
describe "Album info for Ride the Lightning" do
|
4
|
+
|
5
|
+
before(:all) do #We only want to hit the webservice once.
|
6
|
+
@album = Scrobbler2::Album.new "Metallica", "Ride The Lightning"
|
7
|
+
@info = @album.info
|
8
|
+
# puts "INFO: #{@info.inspect} \n"
|
9
|
+
end
|
10
|
+
|
11
|
+
it "should be hash" do
|
12
|
+
@info.should be_kind_of Hash
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should have name 'Metallica'" do
|
16
|
+
@info["name"].should == "Ride the Lightning"
|
17
|
+
end
|
18
|
+
|
19
|
+
it "should have artist 'Metallica'" do
|
20
|
+
@info["artist"].should == "Metallica"
|
21
|
+
end
|
22
|
+
|
23
|
+
|
24
|
+
it "should have mbid '456efd39-f0dc-4b4d-87c7-82bbc562d8f3'" do
|
25
|
+
@info["mbid"].should == '456efd39-f0dc-4b4d-87c7-82bbc562d8f3'
|
26
|
+
end
|
27
|
+
|
28
|
+
it "should have url 'http://www.last.fm/music/Metallica'" do
|
29
|
+
@info["url"].should == 'http://www.last.fm/music/Metallica/Ride+the+Lightning'
|
30
|
+
end
|
31
|
+
|
32
|
+
it "should have listeners" do
|
33
|
+
@info.should have_key("listeners")
|
34
|
+
end
|
35
|
+
|
36
|
+
it "should have playcount" do
|
37
|
+
@info.should have_key("playcount")
|
38
|
+
end
|
39
|
+
|
40
|
+
it "should have images" do
|
41
|
+
@info["image"].should be_kind_of Array
|
42
|
+
@info["image"][0].should be_kind_of Hash
|
43
|
+
@info["image"][0]['size'].should be_kind_of String
|
44
|
+
@info["image"][0]['#text'].should be_kind_of String
|
45
|
+
#@info["image"][0]['#text'].should == 'http://userserve-ak.last.fm/serve/34/9527793.jpg'
|
46
|
+
end
|
47
|
+
|
48
|
+
it "should have toptags" do
|
49
|
+
pending "TopTags breaks parser" do
|
50
|
+
@info["toptags"].should be_kind_of Hash
|
51
|
+
@info["toptags"]["tags"].should be_kind_of Array
|
52
|
+
@info["toptags"]["tags"][0].should have_key('name')
|
53
|
+
@info["toptags"]["tags"][0].should have_key('url')
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../test_helper.rb'
|
2
|
+
|
3
|
+
describe "Add tag 'test' to Metallica" do
|
4
|
+
|
5
|
+
before(:all) do #We only want to hit the webservice once.
|
6
|
+
@artist = Scrobbler2::Artist.new "Metallica"
|
7
|
+
end
|
8
|
+
|
9
|
+
it "should be able to add a tag" do
|
10
|
+
@artist.add_tags ["test"]
|
11
|
+
#TODO: We should probably remove tags before we start, check the tags are applied, and then reset the tags in after(:all)
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../test_helper.rb'
|
2
|
+
|
3
|
+
describe "Events for Metallica" do
|
4
|
+
|
5
|
+
before(:all) do #We only want to hit the webservice once.
|
6
|
+
@artist = Scrobbler2::Artist.new "Metallica"
|
7
|
+
@events = @artist.events
|
8
|
+
end
|
9
|
+
|
10
|
+
it "should return a Hash" do
|
11
|
+
@events.should be_kind_of(Hash)
|
12
|
+
end
|
13
|
+
|
14
|
+
it "should have artist Metallica" do
|
15
|
+
@events['artist'].should == "Metallica"
|
16
|
+
end
|
17
|
+
|
18
|
+
it "should have total" do
|
19
|
+
@events.should have_key('total')
|
20
|
+
end
|
21
|
+
|
22
|
+
it "should have array of events" do
|
23
|
+
@events.should have_key('event')
|
24
|
+
@events['event'].should be_a_kind_of(Array)
|
25
|
+
@events['event'].length.should > 0
|
26
|
+
end
|
27
|
+
|
28
|
+
describe "an event" do
|
29
|
+
|
30
|
+
before(:each) do
|
31
|
+
@event = @events['event'][0]
|
32
|
+
end
|
33
|
+
|
34
|
+
it "should have a url" do
|
35
|
+
@event.should have_key('url')
|
36
|
+
end
|
37
|
+
|
38
|
+
it "should have an array of artists" do
|
39
|
+
@event.should have_key('artists')
|
40
|
+
end
|
41
|
+
|
42
|
+
it "should have a title" do
|
43
|
+
@event.should have_key('title')
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../test_helper.rb'
|
2
|
+
|
3
|
+
describe "Artist info for Metallica" do
|
4
|
+
|
5
|
+
before(:all) do #We only want to hit the webservice once.
|
6
|
+
@artist = Scrobbler2::Artist.new "Metallica"
|
7
|
+
@info = @artist.info
|
8
|
+
# puts "INFO: #{@info.inspect} \n"
|
9
|
+
end
|
10
|
+
|
11
|
+
it "should be hash" do
|
12
|
+
@info.should be_kind_of Hash
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should have name 'Metallica'" do
|
16
|
+
@info["name"].should == "Metallica"
|
17
|
+
end
|
18
|
+
|
19
|
+
it "should have mbid '65f4f0c5-ef9e-490c-aee3-909e7ae6b2ab'" do
|
20
|
+
@info["mbid"].should == '65f4f0c5-ef9e-490c-aee3-909e7ae6b2ab'
|
21
|
+
end
|
22
|
+
|
23
|
+
it "should have url 'http://www.last.fm/music/Metallica'" do
|
24
|
+
@info["url"].should == 'http://www.last.fm/music/Metallica'
|
25
|
+
end
|
26
|
+
|
27
|
+
it "should have stats" do
|
28
|
+
@info["stats"].should be_kind_of Hash
|
29
|
+
@info["stats"]["listeners"].should_not be_nil
|
30
|
+
@info["stats"]["playcount"].should_not be_nil
|
31
|
+
end
|
32
|
+
|
33
|
+
it "should have similar artists" do
|
34
|
+
@info["similar"].should be_kind_of Hash
|
35
|
+
@info["similar"]["artist"].should be_kind_of Array
|
36
|
+
@info["similar"]["artist"][0]["name"].should be_kind_of String
|
37
|
+
end
|
38
|
+
|
39
|
+
it "should have images" do
|
40
|
+
@info["image"].should be_kind_of Array
|
41
|
+
@info["image"][0].should be_kind_of Hash
|
42
|
+
@info["image"][0]['size'].should be_kind_of String
|
43
|
+
@info["image"][0]['#text'].should be_kind_of String
|
44
|
+
#@info["image"][0]['#text'].should == 'http://userserve-ak.last.fm/serve/34/9527793.jpg'
|
45
|
+
end
|
46
|
+
|
47
|
+
it "should have bio" do
|
48
|
+
@info["bio"].should be_kind_of Hash
|
49
|
+
@info["bio"]["summary"].match('metal band').should_not be_nil
|
50
|
+
@info["bio"]["content"].match('James Hetfield,').should_not be_nil
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../test_helper.rb'
|
2
|
+
|
3
|
+
describe "Shouts for Not Squares" do
|
4
|
+
|
5
|
+
before(:all) do #We only want to hit the webservice once.
|
6
|
+
@artist = Scrobbler2::Artist.new "Not Squares"
|
7
|
+
@shouts = @artist.shouts
|
8
|
+
# puts "#{@shouts.inspect}"
|
9
|
+
end
|
10
|
+
|
11
|
+
it "should return a Hash" do
|
12
|
+
@shouts.should be_kind_of(Hash)
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should have artist Not Squares" do
|
16
|
+
@shouts['artist'].should == "Not Squares"
|
17
|
+
end
|
18
|
+
|
19
|
+
it "should have total" do
|
20
|
+
@shouts.should have_key('total')
|
21
|
+
end
|
22
|
+
|
23
|
+
it "should have array of shouts" do
|
24
|
+
@shouts.should have_key('shout')
|
25
|
+
@shouts['shout'].should be_a_kind_of(Array)
|
26
|
+
@shouts['shout'].length.should > 0
|
27
|
+
end
|
28
|
+
|
29
|
+
describe "a shout" do
|
30
|
+
|
31
|
+
before(:each) do
|
32
|
+
@shout = @shouts['shout'][0]
|
33
|
+
end
|
34
|
+
|
35
|
+
it "should have a body" do
|
36
|
+
@shout.should have_key('body')
|
37
|
+
end
|
38
|
+
|
39
|
+
it "should have a author" do
|
40
|
+
@shout.should have_key('author')
|
41
|
+
end
|
42
|
+
|
43
|
+
it "should have a date" do
|
44
|
+
@shout.should have_key('date')
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../test_helper.rb'
|
2
|
+
|
3
|
+
describe "Similar artists for Metallica" do
|
4
|
+
|
5
|
+
before(:all) do #We only want to hit the webservice once.
|
6
|
+
@artist = Scrobbler2::Artist.new "Metallica"
|
7
|
+
@similar = @artist.similar
|
8
|
+
# puts "Similar: #{@similar.inspect} \n"
|
9
|
+
end
|
10
|
+
|
11
|
+
it "should be a Hash" do
|
12
|
+
@similar.should be_kind_of Hash
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should have an array of tags" do
|
16
|
+
pending "XML parses currently broken for similar artists"
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../test_helper.rb'
|
2
|
+
|
3
|
+
describe "User's tags for Metallica" do
|
4
|
+
|
5
|
+
before(:all) do #We only want to hit the webservice once.
|
6
|
+
@artist = Scrobbler2::Artist.new "Metallica"
|
7
|
+
@tags = @artist.tags
|
8
|
+
# puts "TAGS: #{@tags.inspect} \n"
|
9
|
+
end
|
10
|
+
|
11
|
+
it "should be a Hash" do
|
12
|
+
@tags.should be_kind_of(Hash)
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should have artist 'Metallica'" do
|
16
|
+
@tags['artist'].should == 'Metallica'
|
17
|
+
end
|
18
|
+
|
19
|
+
it "should have an array of tags" do
|
20
|
+
@tags['tag'].should be_kind_of(Array)
|
21
|
+
end
|
22
|
+
|
23
|
+
|
24
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../test_helper.rb'
|
2
|
+
|
3
|
+
describe "Top Albums for Metallica" do
|
4
|
+
|
5
|
+
before(:all) do #We only want to hit the webservice once.
|
6
|
+
@artist = Scrobbler2::Artist.new "Metallica"
|
7
|
+
@albums = @artist.top_albums
|
8
|
+
# puts "Top Albums: #{@albums.inspect} \n"
|
9
|
+
end
|
10
|
+
|
11
|
+
it "should be a Hash" do
|
12
|
+
@albums.should be_kind_of(Hash)
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should have artist 'Metallica'" do
|
16
|
+
@albums["artist"].should == 'Metallica'
|
17
|
+
end
|
18
|
+
|
19
|
+
it "should contain an array of albums" do
|
20
|
+
@albums["album"].should be_kind_of(Array)
|
21
|
+
end
|
22
|
+
|
23
|
+
it "should contain 'Ride the Lightning'" do
|
24
|
+
rtl = @albums["album"].find { |album| album['name'] == 'Ride the Lightning' }
|
25
|
+
rtl.should_not be_nil
|
26
|
+
|
27
|
+
rtl['artist'].should be_kind_of(Hash)
|
28
|
+
rtl['artist']['name'].should == 'Metallica'
|
29
|
+
|
30
|
+
rtl['url'].should == "http://www.last.fm/music/Metallica/Ride+the+Lightning"
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
|