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.
Files changed (117) hide show
  1. data/.gitignore +1 -0
  2. data/README.rdoc +155 -0
  3. data/Rakefile +8 -0
  4. data/TODO +23 -0
  5. data/VERSION.yml +4 -0
  6. data/generators/acceptance_test/USAGE +9 -0
  7. data/generators/acceptance_test/acceptance_test_generator.rb +57 -0
  8. data/generators/acceptance_test/templates/acceptance_test.rb.erb +14 -0
  9. data/generators/resource/USAGE +8 -0
  10. data/generators/resource/resource_generator.rb +47 -0
  11. data/generators/resource/templates/resource.rb.erb +11 -0
  12. data/generators/resource/templates/spec.rb.erb +22 -0
  13. data/lib/scrobbler2.rb +23 -0
  14. data/lib/scrobbler2/album.rb +11 -0
  15. data/lib/scrobbler2/artist.rb +26 -0
  16. data/lib/scrobbler2/auth.rb +19 -0
  17. data/lib/scrobbler2/base.rb +100 -0
  18. data/lib/scrobbler2/event.rb +12 -0
  19. data/lib/scrobbler2/geo.rb +15 -0
  20. data/lib/scrobbler2/group.rb +14 -0
  21. data/lib/scrobbler2/library.rb +12 -0
  22. data/lib/scrobbler2/playlist.rb +10 -0
  23. data/lib/scrobbler2/tag.rb +18 -0
  24. data/lib/scrobbler2/track.rb +13 -0
  25. data/lib/scrobbler2/user.rb +29 -0
  26. data/lib/scrobbler2/venue.rb +12 -0
  27. data/script/console +10 -0
  28. data/script/destroy +14 -0
  29. data/script/generate +14 -0
  30. data/scrobbler2.gemspec +243 -0
  31. data/tasks/jeweler.rake +15 -0
  32. data/tasks/rcov.rake +9 -0
  33. data/tasks/rdoc.rake +7 -0
  34. data/tasks/tests.rake +10 -0
  35. data/test/acceptance/album/info_test.rb +56 -0
  36. data/test/acceptance/artist/add_tags_test.rb +14 -0
  37. data/test/acceptance/artist/events_test.rb +47 -0
  38. data/test/acceptance/artist/info_test.rb +53 -0
  39. data/test/acceptance/artist/shouts_test.rb +48 -0
  40. data/test/acceptance/artist/similar_artists_test.rb +20 -0
  41. data/test/acceptance/artist/tags_test.rb +24 -0
  42. data/test/acceptance/artist/top_albums_test.rb +34 -0
  43. data/test/acceptance/artist/top_fans.rb +19 -0
  44. data/test/acceptance/artist/top_tags.rb +18 -0
  45. data/test/acceptance/artist/top_tracks.rb +47 -0
  46. data/test/acceptance/auth/auth_test.rb +21 -0
  47. data/test/acceptance/event/info_test.rb +66 -0
  48. data/test/acceptance/event/shouts_test.rb +49 -0
  49. data/test/acceptance/geo/events_test.rb +14 -0
  50. data/test/acceptance/geo/top_artists_test.rb +16 -0
  51. data/test/acceptance/geo/top_tracks_test.rb +16 -0
  52. data/test/acceptance/group/members_test.rb +60 -0
  53. data/test/acceptance/group/weekly_album_chart_test.rb +61 -0
  54. data/test/acceptance/group/weekly_artist_chart_test.rb +54 -0
  55. data/test/acceptance/group/weekly_chart_list_test.rb +39 -0
  56. data/test/acceptance/group/weekly_track_chart_test.rb +61 -0
  57. data/test/acceptance/library/albums_test.rb +34 -0
  58. data/test/acceptance/library/artists_test.rb +33 -0
  59. data/test/acceptance/library/tracks_test.rb +33 -0
  60. data/test/acceptance/playlist/fetch_test.rb +68 -0
  61. data/test/acceptance/shared/album.rb +41 -0
  62. data/test/acceptance/shared/artist.rb +16 -0
  63. data/test/acceptance/shared/paged_result.rb +16 -0
  64. data/test/acceptance/shared/top_fans.rb +29 -0
  65. data/test/acceptance/shared/top_tags.rb +23 -0
  66. data/test/acceptance/shared/track.rb +23 -0
  67. data/test/acceptance/tag/similar_test.rb +15 -0
  68. data/test/acceptance/tag/top_albums_test.rb +37 -0
  69. data/test/acceptance/tag/top_artists_test.rb +31 -0
  70. data/test/acceptance/tag/top_tags_test.rb +32 -0
  71. data/test/acceptance/tag/top_tracks_test.rb +33 -0
  72. data/test/acceptance/tag/weekly_artist_chart.rb +54 -0
  73. data/test/acceptance/tag/weekly_chart_list.rb +39 -0
  74. data/test/acceptance/test_helper.rb +15 -0
  75. data/test/acceptance/track/info_test.rb +47 -0
  76. data/test/acceptance/track/similar_test.rb +22 -0
  77. data/test/acceptance/track/top_fans_test.rb +23 -0
  78. data/test/acceptance/track/top_tags_test.rb +24 -0
  79. data/test/acceptance/user/events_test.rb +27 -0
  80. data/test/acceptance/user/friends_test.rb +14 -0
  81. data/test/acceptance/user/info_test.rb +19 -0
  82. data/test/acceptance/user/loved_tracks_test.rb +14 -0
  83. data/test/acceptance/user/neighbours_test.rb +14 -0
  84. data/test/acceptance/user/past_events_test.rb +14 -0
  85. data/test/acceptance/user/playlists_test.rb +14 -0
  86. data/test/acceptance/user/recent_tracks_test.rb +14 -0
  87. data/test/acceptance/user/recommended_artists_test.rb +16 -0
  88. data/test/acceptance/user/recommended_events_test.rb +16 -0
  89. data/test/acceptance/user/shouts_test.rb +14 -0
  90. data/test/acceptance/user/top_albums_test.rb +14 -0
  91. data/test/acceptance/user/top_artists_test.rb +14 -0
  92. data/test/acceptance/user/top_tags_test.rb +14 -0
  93. data/test/acceptance/user/top_tracks_test.rb +14 -0
  94. data/test/acceptance/user/weekly_album_chart_test.rb +14 -0
  95. data/test/acceptance/user/weekly_artist_chart_test.rb +14 -0
  96. data/test/acceptance/user/weekly_chart_list_test.rb +14 -0
  97. data/test/acceptance/user/weekly_track_chart_test.rb +14 -0
  98. data/test/acceptance/venue/events_test.rb +14 -0
  99. data/test/acceptance/venue/past_events_test.rb +14 -0
  100. data/test/generators/test_acceptance_test_generator.rb +46 -0
  101. data/test/generators/test_generator_helper.rb +29 -0
  102. data/test/generators/test_resource_generator.rb +71 -0
  103. data/test/unit/album_spec.rb +17 -0
  104. data/test/unit/artist_spec.rb +62 -0
  105. data/test/unit/auth_spec.rb +22 -0
  106. data/test/unit/base_spec.rb +193 -0
  107. data/test/unit/event_spec.rb +23 -0
  108. data/test/unit/geo_spec.rb +36 -0
  109. data/test/unit/group_spec.rb +38 -0
  110. data/test/unit/library_spec.rb +27 -0
  111. data/test/unit/playlist_spec.rb +18 -0
  112. data/test/unit/spec_helper.rb +7 -0
  113. data/test/unit/tag_spec.rb +50 -0
  114. data/test/unit/track_spec.rb +33 -0
  115. data/test/unit/user_spec.rb +148 -0
  116. data/test/unit/venue_spec.rb +29 -0
  117. metadata +272 -0
@@ -0,0 +1,21 @@
1
+ require File.dirname(__FILE__) + '/../test_helper.rb'
2
+
3
+ describe "Authorization" do
4
+
5
+ it "should authorize" do
6
+ auth = Scrobbler2::Auth.new
7
+ token = auth.token
8
+ puts "Auth Token #{token} \n"
9
+ token.should_not be_nil
10
+ puts "Now go to #{auth.url} and authorise\n"
11
+
12
+ gets #Wait for enter
13
+
14
+ session = auth.session
15
+ puts "Session: #{session.inspect} \n"
16
+ session.should be_kind_of(Hash)
17
+ session['key'].should_not be_nil
18
+ end
19
+
20
+ end
21
+
@@ -0,0 +1,66 @@
1
+ require File.dirname(__FILE__) + '/../test_helper.rb'
2
+
3
+ describe "Event info for 328799" do
4
+
5
+ before(:all) do #We only want to hit the webservice once.
6
+ @event = Scrobbler2::Event.new "328799"
7
+ @info = @event.info
8
+ end
9
+
10
+ it "should be hash" do
11
+ @info.should be_kind_of Hash
12
+ end
13
+
14
+ it "should have id '328799'" do
15
+ @info["id"].should == "328799"
16
+ end
17
+
18
+ it "should have title 'Philip Glass'" do
19
+ @info["title"].should == "Philip Glass"
20
+ end
21
+
22
+ it "should have artists" do
23
+ @info["artists"].should be_kind_of(Hash)
24
+ @info["artists"]['artist'].should be_kind_of(Array)
25
+ @info["artists"]['artist'][0].should == "Philip Glass"
26
+
27
+ @info["artists"]['headliner'].should == "Philip Glass"
28
+ end
29
+
30
+ it "should have venue" do
31
+ @info["venue"].should be_kind_of(Hash)
32
+ @info["venue"]["name"].should == "Barbican Centre"
33
+ end
34
+
35
+ it "should have startDate" do
36
+ @info.should have_key "startDate"
37
+ end
38
+
39
+ it "should have url" do
40
+ @info.should have_key "url"
41
+ end
42
+
43
+ it "should have reviews" do
44
+ @info.should have_key "reviews"
45
+ end
46
+
47
+ it "should have attendance" do
48
+ @info.should have_key "attendance"
49
+ end
50
+
51
+ it "should have description" do
52
+ @info.should have_key "description"
53
+ end
54
+
55
+
56
+
57
+
58
+ it "should have images" do
59
+ @info["image"].should be_kind_of Array
60
+ @info["image"][0].should be_kind_of Hash
61
+ @info["image"][0]['size'].should be_kind_of String
62
+ @info["image"][0]['#text'].should be_kind_of String
63
+ #@info["image"][0]['#text'].should == 'http://userserve-ak.last.fm/serve/34/9527793.jpg'
64
+ end
65
+
66
+ end
@@ -0,0 +1,49 @@
1
+ require File.dirname(__FILE__) + '/../test_helper.rb'
2
+
3
+ describe "Shouts for event 328799" do
4
+
5
+ before(:all) do #We only want to hit the webservice once.
6
+ @event = Scrobbler2::Event.new "328799"
7
+ @shouts = @event.shouts
8
+ # puts "INFO: #{@info.inspect} \n"
9
+ end
10
+
11
+
12
+ it "should return a Hash" do
13
+ @shouts.should be_kind_of(Hash)
14
+ end
15
+
16
+ it "should have event 328799" do
17
+ @shouts['event'].should == "328799"
18
+ end
19
+
20
+ it "should have total" do
21
+ @shouts.should have_key('total')
22
+ end
23
+
24
+ it "should have array of shouts" do
25
+ @shouts.should have_key('shout')
26
+ @shouts['shout'].should be_a_kind_of(Array)
27
+ @shouts['shout'].length.should > 0
28
+ end
29
+
30
+ describe "a shout" do
31
+
32
+ before(:each) do
33
+ @shout = @shouts['shout'][0]
34
+ end
35
+
36
+ it "should have a body" do
37
+ @shout.should have_key('body')
38
+ end
39
+
40
+ it "should have a author" do
41
+ @shout.should have_key('author')
42
+ end
43
+
44
+ it "should have a date" do
45
+ @shout.should have_key('date')
46
+ end
47
+ end
48
+
49
+ end
@@ -0,0 +1,14 @@
1
+ require File.dirname(__FILE__) + '/../test_helper.rb'
2
+
3
+ describe "events for geo location=belfast" do
4
+
5
+ before(:all) do #We only want to hit the webservice once.
6
+ @geo = Scrobbler2::Geo.new
7
+ @events = @geo.events :location => "belfast"
8
+ end
9
+
10
+ it "should be hash" do
11
+ @events.should be_kind_of Hash
12
+ end
13
+
14
+ end
@@ -0,0 +1,16 @@
1
+ require File.dirname(__FILE__) + '/../test_helper.rb'
2
+
3
+ describe "top_artists for geo country=ireland" do
4
+
5
+ before(:all) do #We only want to hit the webservice once.
6
+ @geo = Scrobbler2::Geo.new
7
+ @top_artists = @geo.top_artists :country => "ireland"
8
+ end
9
+
10
+ it "should be hash" do
11
+ pending "broken" do
12
+ @top_artists.should be_kind_of Hash
13
+ end
14
+ end
15
+
16
+ end
@@ -0,0 +1,16 @@
1
+ require File.dirname(__FILE__) + '/../test_helper.rb'
2
+
3
+ describe "top_tracks for geo country=ireland" do
4
+
5
+ before(:all) do #We only want to hit the webservice once.
6
+ @geo = Scrobbler2::Geo.new
7
+ @top_tracks = @geo.top_tracks :country => "ireland"
8
+ end
9
+
10
+ it "should be hash" do
11
+ pending "broken" do
12
+ @top_tracks.should be_kind_of Hash
13
+ end
14
+ end
15
+
16
+ end
@@ -0,0 +1,60 @@
1
+ require File.dirname(__FILE__) + '/../test_helper.rb'
2
+
3
+ describe "Members for group stubborn tiny lights" do
4
+
5
+ before(:all) do #We only want to hit the webservice once.
6
+ @group = Scrobbler2::Group.new "stubborn tiny lights"
7
+ @info = @group.members
8
+ end
9
+
10
+ it "should be hash" do
11
+ @info.should be_kind_of Hash
12
+ end
13
+
14
+ it "should have for 'stubborn tiny lights'" do
15
+ @info["for"].should == "stubborn tiny lights"
16
+ end
17
+
18
+ it "should have page" do
19
+ @info.should have_key('page')
20
+ end
21
+
22
+ it "should have perPage" do
23
+ @info.should have_key('perPage')
24
+ end
25
+
26
+ it "should have totalPages" do
27
+ @info.should have_key('totalPages')
28
+ end
29
+
30
+ it "should have a list of users" do
31
+ @info.should have_key('user')
32
+ @info['user'].should be_kind_of(Array)
33
+ end
34
+
35
+ describe "a user" do
36
+ before(:each) do
37
+ @user = @info['user'][0]
38
+ end
39
+
40
+ it "should have name" do
41
+ @user.should have_key('name')
42
+ end
43
+
44
+ it "should have realname" do
45
+ @user.should have_key('realname')
46
+ end
47
+
48
+ it "should have images" do
49
+ @user["image"].should be_kind_of Array
50
+ @user["image"][0].should be_kind_of Hash
51
+ @user["image"][0]['size'].should be_kind_of String
52
+ @user["image"][0]['#text'].should be_kind_of String
53
+ end
54
+
55
+ it "should have url" do
56
+ @user.should have_key('url')
57
+ end
58
+
59
+ end
60
+ end
@@ -0,0 +1,61 @@
1
+ require File.dirname(__FILE__) + '/../test_helper.rb'
2
+
3
+ describe "Weekly album chart for group 'Metal Drummers'" do
4
+
5
+ before(:all) do #We only want to hit the webservice once.
6
+ @group = Scrobbler2::Group.new "Metal Drummers"
7
+ @chart = @group.weekly_album_chart
8
+ end
9
+
10
+ it "should be hash" do
11
+ @chart.should be_kind_of Hash
12
+ end
13
+
14
+ it "should have group 'Metal Drummers'" do
15
+ @chart["group"].should == "Metal Drummers"
16
+ end
17
+
18
+ it "should have from" do
19
+ @chart.should have_key("from")
20
+ end
21
+
22
+ it "should have to" do
23
+ @chart.should have_key("to")
24
+ end
25
+
26
+ it "should have a list of albums" do
27
+ @chart.should have_key('album')
28
+ @chart['album'].should be_kind_of(Array)
29
+ end
30
+
31
+ describe "album" do
32
+ before(:each) do
33
+ @album = @chart['album'][0]
34
+ end
35
+
36
+ it "should have artist" do
37
+ @album.should have_key 'artist'
38
+ @album['artist'].should be_kind_of(Hash)
39
+ @album['artist'].should have_key('mbid')
40
+ @album['artist'].should have_key('#text')
41
+ end
42
+
43
+ it "should have name" do
44
+ @album.should have_key 'name'
45
+ end
46
+
47
+ it "should have mbid" do
48
+ @album.should have_key 'mbid'
49
+ end
50
+
51
+ it "should have playcount" do
52
+ @album.should have_key 'playcount'
53
+ end
54
+
55
+ it "should have url" do
56
+ @album.should have_key 'url'
57
+ end
58
+
59
+ end
60
+
61
+ end
@@ -0,0 +1,54 @@
1
+ require File.dirname(__FILE__) + '/../test_helper.rb'
2
+
3
+ describe "Weekly artist chart for group 'stubborn tiny lights'" do
4
+
5
+ before(:all) do #We only want to hit the webservice once.
6
+ @group = Scrobbler2::Group.new "stubborn tiny lights"
7
+ @chart = @group.weekly_artist_chart
8
+ end
9
+
10
+ it "should be hash" do
11
+ @chart.should be_kind_of Hash
12
+ end
13
+
14
+ it "should have group 'stubborn tiny lights'" do
15
+ @chart["group"].should == "stubborn tiny lights"
16
+ end
17
+
18
+ it "should have from" do
19
+ @chart.should have_key("from")
20
+ end
21
+
22
+ it "should have to" do
23
+ @chart.should have_key("to")
24
+ end
25
+
26
+ it "should have a list of artists" do
27
+ @chart.should have_key('artist')
28
+ @chart['artist'].should be_kind_of(Array)
29
+ end
30
+
31
+ describe "artist" do
32
+ before(:each) do
33
+ @artist = @chart['artist'][0]
34
+ end
35
+
36
+ it "should have name" do
37
+ @artist.should have_key 'name'
38
+ end
39
+
40
+ it "should have mbid" do
41
+ @artist.should have_key 'mbid'
42
+ end
43
+
44
+ it "should have playcount" do
45
+ @artist.should have_key 'playcount'
46
+ end
47
+
48
+ it "should have url" do
49
+ @artist.should have_key 'url'
50
+ end
51
+
52
+ end
53
+
54
+ end
@@ -0,0 +1,39 @@
1
+ require File.dirname(__FILE__) + '/../test_helper.rb'
2
+
3
+ describe "Weekly chart list for group 'stubborn tiny lights'" do
4
+
5
+ before(:all) do #We only want to hit the webservice once.
6
+ @group = Scrobbler2::Group.new "stubborn tiny lights"
7
+ @list = @group.weekly_chart_list
8
+ end
9
+
10
+ it "should be hash" do
11
+ @list.should be_kind_of Hash
12
+ end
13
+
14
+ it "should have group 'stubborn tiny lights'" do
15
+ @list["group"].should == "stubborn tiny lights"
16
+ end
17
+
18
+
19
+ it "should have a list of charts" do
20
+ @list.should have_key('chart')
21
+ @list['chart'].should be_kind_of(Array)
22
+ end
23
+
24
+ describe "chart" do
25
+ before(:each) do
26
+ @chart = @list['chart'][0]
27
+ end
28
+
29
+ it "should have from" do
30
+ @chart.should have_key 'from'
31
+ end
32
+
33
+ it "should have to" do
34
+ @chart.should have_key 'to'
35
+ end
36
+
37
+ end
38
+
39
+ end
@@ -0,0 +1,61 @@
1
+ require File.dirname(__FILE__) + '/../test_helper.rb'
2
+
3
+ describe "Weekly track chart for group 'stubborn tiny lights'" do
4
+
5
+ before(:all) do #We only want to hit the webservice once.
6
+ @group = Scrobbler2::Group.new "stubborn tiny lights"
7
+ @chart = @group.weekly_track_chart
8
+ end
9
+
10
+ it "should be hash" do
11
+ @chart.should be_kind_of Hash
12
+ end
13
+
14
+ it "should have group 'stubborn tiny lights'" do
15
+ @chart["group"].should == "stubborn tiny lights"
16
+ end
17
+
18
+ it "should have from" do
19
+ @chart.should have_key("from")
20
+ end
21
+
22
+ it "should have to" do
23
+ @chart.should have_key("to")
24
+ end
25
+
26
+ it "should have a list of trackss" do
27
+ @chart.should have_key('track')
28
+ @chart['track'].should be_kind_of(Array)
29
+ end
30
+
31
+ describe "track" do
32
+ before(:each) do
33
+ @track = @chart['track'][0]
34
+ end
35
+
36
+ it "should have artist" do
37
+ @track.should have_key 'artist'
38
+ @track['artist'].should be_kind_of(Hash)
39
+ @track['artist'].should have_key('mbid')
40
+ @track['artist'].should have_key('#text')
41
+ end
42
+
43
+ it "should have name" do
44
+ @track.should have_key 'name'
45
+ end
46
+
47
+ it "should have mbid" do
48
+ @track.should have_key 'mbid'
49
+ end
50
+
51
+ it "should have playcount" do
52
+ @track.should have_key 'playcount'
53
+ end
54
+
55
+ it "should have url" do
56
+ @track.should have_key 'url'
57
+ end
58
+
59
+ end
60
+
61
+ end