scrobbler 0.1.0

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 (59) hide show
  1. data/History.txt +1 -0
  2. data/Manifest.txt +58 -0
  3. data/README.txt +71 -0
  4. data/Rakefile +89 -0
  5. data/examples/album.rb +18 -0
  6. data/examples/artist.rb +14 -0
  7. data/examples/tag.rb +12 -0
  8. data/examples/track.rb +7 -0
  9. data/examples/user.rb +15 -0
  10. data/lib/scrobbler.rb +13 -0
  11. data/lib/scrobbler/album.rb +143 -0
  12. data/lib/scrobbler/artist.rb +127 -0
  13. data/lib/scrobbler/base.rb +29 -0
  14. data/lib/scrobbler/chart.rb +31 -0
  15. data/lib/scrobbler/rest.rb +47 -0
  16. data/lib/scrobbler/tag.rb +104 -0
  17. data/lib/scrobbler/track.rb +96 -0
  18. data/lib/scrobbler/user.rb +192 -0
  19. data/lib/scrobbler/version.rb +9 -0
  20. data/setup.rb +1585 -0
  21. data/test/fixtures/xml/album/info.xml +70 -0
  22. data/test/fixtures/xml/artist/fans.xml +18 -0
  23. data/test/fixtures/xml/artist/similar.xml +39 -0
  24. data/test/fixtures/xml/artist/topalbums.xml +36 -0
  25. data/test/fixtures/xml/artist/toptags.xml +18 -0
  26. data/test/fixtures/xml/artist/toptracks.xml +27 -0
  27. data/test/fixtures/xml/tag/topalbums.xml +39 -0
  28. data/test/fixtures/xml/tag/topartists.xml +39 -0
  29. data/test/fixtures/xml/tag/toptags.xml +252 -0
  30. data/test/fixtures/xml/tag/toptracks.xml +30 -0
  31. data/test/fixtures/xml/track/fans.xml +28 -0
  32. data/test/fixtures/xml/track/toptags.xml +33 -0
  33. data/test/fixtures/xml/user/friends.xml +21 -0
  34. data/test/fixtures/xml/user/neighbours.xml +18 -0
  35. data/test/fixtures/xml/user/profile.xml +12 -0
  36. data/test/fixtures/xml/user/recentbannedtracks.xml +24 -0
  37. data/test/fixtures/xml/user/recentlovedtracks.xml +24 -0
  38. data/test/fixtures/xml/user/recenttracks.xml +27 -0
  39. data/test/fixtures/xml/user/systemrecs.xml +18 -0
  40. data/test/fixtures/xml/user/topalbums.xml +42 -0
  41. data/test/fixtures/xml/user/topartists.xml +30 -0
  42. data/test/fixtures/xml/user/toptags.xml +18 -0
  43. data/test/fixtures/xml/user/toptracks.xml +27 -0
  44. data/test/fixtures/xml/user/weeklyalbumchart.xml +35 -0
  45. data/test/fixtures/xml/user/weeklyalbumchart_from_1138536002_to_1139140802.xml +35 -0
  46. data/test/fixtures/xml/user/weeklyartistchart.xml +38 -0
  47. data/test/fixtures/xml/user/weeklyartistchart_from_1138536002_to_1139140802.xml +59 -0
  48. data/test/fixtures/xml/user/weeklychartlist.xml +74 -0
  49. data/test/fixtures/xml/user/weeklytrackchart.xml +35 -0
  50. data/test/fixtures/xml/user/weeklytrackchart_from_1138536002_to_1139140802.xml +35 -0
  51. data/test/mocks/rest.rb +26 -0
  52. data/test/test_helper.rb +17 -0
  53. data/test/unit/album_test.rb +86 -0
  54. data/test/unit/artist_test.rb +82 -0
  55. data/test/unit/chart_test.rb +34 -0
  56. data/test/unit/tag_test.rb +65 -0
  57. data/test/unit/track_test.rb +42 -0
  58. data/test/unit/user_test.rb +291 -0
  59. metadata +120 -0
@@ -0,0 +1,34 @@
1
+ require File.dirname(__FILE__) + '/../test_helper.rb'
2
+
3
+ class TestChart < Test::Unit::TestCase
4
+
5
+ def setup
6
+ @chart = Scrobbler::Chart.new('1108296002', '1108900802')
7
+ end
8
+
9
+ test 'should require from' do
10
+ assert_raise(ArgumentError) { Scrobbler::Chart.new('', '1108900802') }
11
+ end
12
+
13
+ test 'should require to' do
14
+ assert_raise(ArgumentError) { Scrobbler::Chart.new('1108296002', '') }
15
+ end
16
+
17
+ test 'should be able to parse to and from that are unix timestamp strings' do
18
+ chart = Scrobbler::Chart.new('1108296002', '1108900802')
19
+ assert_equal(1108296002, chart.from)
20
+ assert_equal(1108900802, chart.to)
21
+ end
22
+
23
+ test 'should be able to parse to and from that are unix timestamp fixnums' do
24
+ chart = Scrobbler::Chart.new(1108296002, 1108900802)
25
+ assert_equal(1108296002, chart.from)
26
+ assert_equal(1108900802, chart.to)
27
+ end
28
+
29
+ test 'should be able to parse to and from that are times' do
30
+ chart = Scrobbler::Chart.new(Time.at(1108296002), Time.at(1108900802))
31
+ assert_equal(1108296002, chart.from)
32
+ assert_equal(1108900802, chart.to)
33
+ end
34
+ end
@@ -0,0 +1,65 @@
1
+ require File.dirname(__FILE__) + '/../test_helper.rb'
2
+
3
+ class TestTag < Test::Unit::TestCase
4
+ def setup
5
+ @tag = Scrobbler::Tag.new('rock')
6
+ end
7
+
8
+ test 'should be able to find the top tags for the entire system' do
9
+ assert_equal(249, Scrobbler::Tag.top_tags.size)
10
+ assert_equal('rock', Scrobbler::Tag.top_tags.first.name)
11
+ assert_equal('878660', Scrobbler::Tag.top_tags.first.count)
12
+ assert_equal('http://www.last.fm/tag/rock', Scrobbler::Tag.top_tags.first.url)
13
+ end
14
+
15
+ test 'should require name' do
16
+ assert_raise(ArgumentError) { Scrobbler::Tag.new('') }
17
+ end
18
+
19
+ test 'should have name' do
20
+ assert_equal('rock', @tag.name)
21
+ end
22
+
23
+ test 'should have api path' do
24
+ assert_equal('/1.0/tag/rock', @tag.api_path)
25
+ end
26
+
27
+ test 'should escape api path' do
28
+ assert_equal('/1.0/tag/rock+and+roll', Scrobbler::Tag.new('rock and roll').api_path)
29
+ end
30
+
31
+ test 'should be able to find top artists for a tag' do
32
+ assert_equal(6, @tag.top_artists.size)
33
+ assert_equal('Red Hot Chili Peppers', @tag.top_artists.first.name)
34
+ assert_equal('5740', @tag.top_artists.first.count)
35
+ assert_equal('yes', @tag.top_artists.first.streamable)
36
+ assert_equal('8bfac288-ccc5-448d-9573-c33ea2aa5c30', @tag.top_artists.first.mbid)
37
+ assert_equal('http://www.last.fm/music/Red+Hot+Chili+Peppers', @tag.top_artists.first.url)
38
+ assert_equal('http://static3.last.fm/storable/image/184200/small.jpg', @tag.top_artists.first.thumbnail)
39
+ assert_equal('http://panther1.last.fm/proposedimages/sidebar/6/1274/552019.jpg', @tag.top_artists.first.image)
40
+ end
41
+
42
+ test 'should be able to find top albums for a tag' do
43
+ assert_equal(3, @tag.top_albums.size)
44
+ assert_equal('Californication', @tag.top_albums.first.name)
45
+ assert_equal('Red Hot Chili Peppers', @tag.top_albums.first.artist)
46
+ assert_equal('8bfac288-ccc5-448d-9573-c33ea2aa5c30', @tag.top_albums.first.artist_mbid)
47
+ assert_equal('http://www.last.fm/music/Red+Hot+Chili+Peppers/Californication', @tag.top_albums.first.url)
48
+ assert_equal('http://panther1.last.fm/coverart/50x50/4791.jpg', @tag.top_albums.first.image(:small))
49
+ assert_equal('http://cdn.last.fm/coverart/130x130/4791.jpg', @tag.top_albums.first.image(:medium))
50
+ assert_equal('http://cdn.last.fm/coverart/300x300/4791.jpg', @tag.top_albums.first.image(:large))
51
+ end
52
+
53
+ test 'should be able to find top tracks for a tag' do
54
+ assert_equal(3, @tag.top_tracks.size)
55
+ first = @tag.top_tracks.first
56
+ assert_equal('Once Upon a Time', first.name)
57
+ assert_equal('1076', first.count)
58
+ assert_equal('no', first.streamable)
59
+ assert_equal('Frank Zappa', first.artist)
60
+ assert_equal('e20747e7-55a4-452e-8766-7b985585082d', first.artist_mbid)
61
+ assert_equal('http://www.last.fm/music/Frank+Zappa/_/Once+Upon+a+Time', first.url)
62
+ assert_equal('http://ec1.images-amazon.com/images/P/B0000009TN.01._SCMZZZZZZZ_.jpg', first.thumbnail)
63
+ assert_equal('http://ec1.images-amazon.com/images/P/B0000009TN.01._SCMZZZZZZZ_.jpg', first.image)
64
+ end
65
+ end
@@ -0,0 +1,42 @@
1
+ require File.dirname(__FILE__) + '/../test_helper.rb'
2
+
3
+ class TestTrack < Test::Unit::TestCase
4
+ def setup
5
+ @track = Scrobbler::Track.new('Carrie Underwood', 'Before He Cheats')
6
+ end
7
+
8
+ test 'should require the artist name' do
9
+ assert_raises(ArgumentError) { Scrobbler::Track.new('', 'Before He Cheats') }
10
+ end
11
+
12
+ test 'should require the track name' do
13
+ assert_raises(ArgumentError) { Scrobbler::Track.new('Carrie Underwood', '') }
14
+ end
15
+
16
+ test "should know the artist" do
17
+ assert_equal('Carrie Underwood', @track.artist)
18
+ end
19
+
20
+ test 'should know the name' do
21
+ assert_equal('Before He Cheats', @track.name)
22
+ end
23
+
24
+ test 'should have api path' do
25
+ assert_equal('/1.0/track/Carrie+Underwood/Before+He+Cheats', @track.api_path)
26
+ end
27
+
28
+ test 'should have fans' do
29
+ assert_equal(5, @track.fans.size)
30
+ assert_equal('frozenice', @track.fans.first.username)
31
+ assert_equal('http://www.last.fm/user/frozenice/', @track.fans.first.url)
32
+ assert_equal('http://panther1.last.fm/avatar/54e8d2cafc363336e15fef0a48d30706.jpg', @track.fans.first.avatar)
33
+ assert_equal('909', @track.fans.first.weight)
34
+ end
35
+
36
+ test 'should have top tags' do
37
+ assert_equal(6, @track.tags.size)
38
+ assert_equal('country', @track.tags.first.name)
39
+ assert_equal('100', @track.tags.first.count)
40
+ assert_equal('http://www.last.fm/tag/country', @track.tags.first.url)
41
+ end
42
+ end
@@ -0,0 +1,291 @@
1
+ require File.dirname(__FILE__) + '/../test_helper.rb'
2
+
3
+ class TestUser < Test::Unit::TestCase
4
+
5
+ def setup
6
+ @user = Scrobbler::User.new('jnunemaker')
7
+ end
8
+
9
+ test 'should be able to find one user' do
10
+ assert_equal(@user.username, Scrobbler::User.find('jnunemaker').username)
11
+ end
12
+
13
+ test 'should be able to find multiple users' do
14
+ users = Scrobbler::User.find('jnunemaker', 'oaknd1', 'wharle')
15
+ assert_equal(%w{jnunemaker oaknd1 wharle}, users.collect(&:username))
16
+ end
17
+
18
+ test 'should be able to find multiple users using an array' do
19
+ users = Scrobbler::User.find(%w{jnunemaker oaknd1 wharle})
20
+ assert_equal(%w{jnunemaker oaknd1 wharle}, users.collect(&:username))
21
+ end
22
+
23
+ test 'should be able to load profile while finding' do
24
+ user = Scrobbler::User.find('jnunemaker', :include_profile => true)
25
+ assert_equal(@user.username, user.username)
26
+ assert_equal('3017870', user.id)
27
+ end
28
+
29
+ test 'should be able to load profile while finding multiple users' do
30
+ users = Scrobbler::User.find('jnunemaker', 'oaknd1', 'wharle', :include_profile => true)
31
+ assert_equal(3, users.size)
32
+ end
33
+
34
+ test 'should require a username' do
35
+ assert_raise(ArgumentError) { Scrobbler::User.new('') }
36
+ end
37
+
38
+ test 'should have api path' do
39
+ assert_equal('/1.0/user/jnunemaker', @user.api_path)
40
+ end
41
+
42
+ test 'should know the correct current events addresses' do
43
+ assert_equal('http://ws.audioscrobbler.com/1.0/user/jnunemaker/events.ics', @user.current_events(:ical))
44
+ assert_equal('http://ws.audioscrobbler.com/1.0/user/jnunemaker/events.ics', @user.current_events(:ics))
45
+ assert_equal('http://ws.audioscrobbler.com/1.0/user/jnunemaker/events.rss', @user.current_events(:rss))
46
+ end
47
+
48
+ test 'should know the correct friends events addresses' do
49
+ assert_equal('http://ws.audioscrobbler.com/1.0/user/jnunemaker/friendevents.ics', @user.friends_events(:ical))
50
+ assert_equal('http://ws.audioscrobbler.com/1.0/user/jnunemaker/friendevents.ics', @user.friends_events(:ics))
51
+ assert_equal('http://ws.audioscrobbler.com/1.0/user/jnunemaker/friendevents.rss', @user.friends_events(:rss))
52
+ end
53
+
54
+ test 'should know the correct recommended events addresses' do
55
+ assert_equal('http://ws.audioscrobbler.com/1.0/user/jnunemaker/eventsysrecs.ics', @user.recommended_events(:ical))
56
+ assert_equal('http://ws.audioscrobbler.com/1.0/user/jnunemaker/eventsysrecs.ics', @user.recommended_events(:ics))
57
+ assert_equal('http://ws.audioscrobbler.com/1.0/user/jnunemaker/eventsysrecs.rss', @user.recommended_events(:rss))
58
+ end
59
+
60
+ test 'should be able to include profile during initialization' do
61
+ user = Scrobbler::User.new('jnunemaker', :include_profile => true)
62
+ assert_equal('3017870', user.id)
63
+ assert_equal('4', user.cluster)
64
+ assert_equal('http://www.last.fm/user/jnunemaker/', user.url)
65
+ assert_equal('John Nunemaker', user.realname)
66
+ assert_equal('d5bbe280b7a41d4a87253361692ef105b983cf1a', user.mbox_sha1sum)
67
+ assert_equal('Dec 8, 2005', user.registered)
68
+ assert_equal('1134050307', user.registered_unixtime)
69
+ assert_equal('25', user.age)
70
+ assert_equal('m', user.gender)
71
+ assert_equal('United States', user.country)
72
+ assert_equal('13267', user.playcount)
73
+ assert_equal('http://panther1.last.fm/avatar/5cb420de0855dadf6bcb1090d8ff02bb.jpg', user.avatar)
74
+ end
75
+
76
+ test 'should be able to load users profile' do
77
+ @user.load_profile
78
+ assert_equal('3017870', @user.id)
79
+ assert_equal('4', @user.cluster)
80
+ assert_equal('http://www.last.fm/user/jnunemaker/', @user.url)
81
+ assert_equal('John Nunemaker', @user.realname)
82
+ assert_equal('d5bbe280b7a41d4a87253361692ef105b983cf1a', @user.mbox_sha1sum)
83
+ assert_equal('Dec 8, 2005', @user.registered)
84
+ assert_equal('1134050307', @user.registered_unixtime)
85
+ assert_equal('25', @user.age)
86
+ assert_equal('m', @user.gender)
87
+ assert_equal('United States', @user.country)
88
+ assert_equal('13267', @user.playcount)
89
+ assert_equal('http://panther1.last.fm/avatar/5cb420de0855dadf6bcb1090d8ff02bb.jpg', @user.avatar)
90
+ end
91
+
92
+ test "should be able to get a user's top artists" do
93
+ assert_equal(3, @user.top_artists.size)
94
+ first = @user.top_artists.first
95
+ assert_equal('Dixie Chicks', first.name)
96
+ assert_equal('3248ed2d-bada-41b5-a7b6-ac88faa1f1ac', first.mbid)
97
+ assert_equal('592', first.playcount)
98
+ assert_equal('1', first.rank)
99
+ assert_equal('http://www.last.fm/music/Dixie+Chicks', first.url)
100
+ assert_equal('http://static3.last.fm/storable/image/182497/small.jpg', first.thumbnail)
101
+ assert_equal('http://panther1.last.fm/proposedimages/sidebar/6/4037/512759.jpg', first.image)
102
+ end
103
+
104
+ test 'should be able to get top albums' do
105
+ assert_equal(3, @user.top_albums.size)
106
+ first = @user.top_albums.first
107
+ assert_equal('LeAnn Rimes', first.artist)
108
+ assert_equal('9092d8e1-9b38-4372-a96d-000b8561a8bc', first.artist_mbid)
109
+ assert_equal('This Woman', first.name)
110
+ assert_equal('080a4038-5156-460a-8dd5-daaa7d16b6a6', first.mbid)
111
+ assert_equal('297', first.playcount)
112
+ assert_equal('1', first.rank)
113
+ assert_equal('http://www.last.fm/music/LeAnn+Rimes/This+Woman', first.url)
114
+ assert_equal('http://images.amazon.com/images/P/B00067BD8K.01._SCMZZZZZZZ_.jpg', first.image(:small))
115
+ assert_equal('http://images.amazon.com/images/P/B00067BD8K.01._SCMZZZZZZZ_.jpg', first.image(:medium))
116
+ assert_equal('http://images.amazon.com/images/P/B00067BD8K.01._SCMZZZZZZZ_.jpg', first.image(:large))
117
+ end
118
+
119
+ test 'should be able to get top tracks' do
120
+ assert_equal(3, @user.top_tracks.size)
121
+ first = @user.top_tracks.first
122
+ assert_equal("Probably Wouldn't Be This Way", first.name)
123
+ assert_equal('LeAnn Rimes', first.artist)
124
+ assert_equal('9092d8e1-9b38-4372-a96d-000b8561a8bc', first.artist_mbid)
125
+ assert_equal("", first.mbid)
126
+ assert_equal('61', first.playcount)
127
+ assert_equal('1', first.rank)
128
+ assert_equal('http://www.last.fm/music/LeAnn+Rimes/_/Probably+Wouldn%27t+Be+This+Way', first.url)
129
+ end
130
+
131
+ test 'should be able to get top tags' do
132
+ assert_equal(3, @user.top_tags.size)
133
+ first = @user.top_tags.first
134
+ assert_equal("country", first.name)
135
+ assert_equal("6", first.count)
136
+ assert_equal("http://www.last.fm/tag/country", first.url)
137
+ end
138
+
139
+ # not implemented
140
+ test 'should be able to get top tags for artist' do
141
+ end
142
+ # not implemented
143
+ test 'should be able to get top tags for album' do
144
+ end
145
+ # not implemented
146
+ test 'should be able to get top tags for track' do
147
+ end
148
+
149
+ test 'should have friends' do
150
+ assert_equal(3, @user.friends.size)
151
+ first = @user.friends.first
152
+ assert_equal('oaknd1', first.username)
153
+ assert_equal('http://www.last.fm/user/oaknd1/', first.url)
154
+ assert_equal('http://panther1.last.fm/avatar/1894043b3e8995c51f7bb5e3210ef97a.jpg', first.avatar)
155
+ end
156
+
157
+ test 'should have neighbours' do
158
+ assert_equal(3, @user.neighbours.size)
159
+ first = @user.neighbours.first
160
+ assert_equal('xBluejeanbabyx', first.username)
161
+ assert_equal('http://www.last.fm/user/xBluejeanbabyx/', first.url)
162
+ assert_equal('http://panther1.last.fm/avatar/d4de2144dc9b651b02d5d633124f0205.jpg', first.avatar)
163
+ end
164
+
165
+ test 'should have recent tracks' do
166
+ assert_equal(3, @user.recent_tracks.size)
167
+ first = @user.recent_tracks.first
168
+ assert_equal('Recovering the Satellites', first.name)
169
+ assert_equal('Counting Crows', first.artist)
170
+ assert_equal('a0327dc2-dc76-44d5-aec6-47cd2dff1469', first.artist_mbid)
171
+ assert_equal('', first.mbid)
172
+ assert_equal('328bc43b-a81a-4dc0-844f-1a27880e5fb2', first.album_mbid)
173
+ assert_equal('Recovering the Satellites', first.album)
174
+ assert_equal('http://www.last.fm/music/Counting+Crows/_/Recovering+the+Satellites', first.url)
175
+ assert_equal(Time.mktime(2007, 5, 4, 21, 1, 00), first.date)
176
+ assert_equal('1178312462', first.date_uts)
177
+ end
178
+
179
+ test 'should have recent banned tracks' do
180
+ assert_equal(3, @user.recent_banned_tracks.size)
181
+ first = @user.recent_banned_tracks.first
182
+ assert_equal('Dress Rehearsal Rag', first.name)
183
+ assert_equal('Leonard Cohen', first.artist)
184
+ assert_equal('65314b12-0e08-43fa-ba33-baaa7b874c15', first.artist_mbid)
185
+ assert_equal('', first.mbid)
186
+ assert_equal('http://www.last.fm/music/Leonard+Cohen/_/Dress+Rehearsal+Rag', first.url)
187
+ assert_equal(Time.mktime(2006, 9, 27, 14, 19, 00), first.date)
188
+ assert_equal('1159366744', first.date_uts)
189
+ end
190
+
191
+ test 'should have recent loved tracks' do
192
+ assert_equal(3, @user.recent_loved_tracks.size)
193
+ first = @user.recent_loved_tracks.first
194
+ assert_equal('Am I Missing', first.name)
195
+ assert_equal('Dashboard Confessional', first.artist)
196
+ assert_equal('50549203-9602-451c-b49f-ff031ba8635c', first.artist_mbid)
197
+ assert_equal('', first.mbid)
198
+ assert_equal('http://www.last.fm/music/Dashboard+Confessional/_/Am+I+Missing', first.url)
199
+ assert_equal(Time.mktime(2006, 9, 26, 17, 43, 00), first.date)
200
+ assert_equal('1159292606', first.date_uts)
201
+ end
202
+
203
+ test 'should have recommendations' do
204
+ assert_equal(3, @user.recommendations.size)
205
+ first = @user.recommendations.first
206
+ assert_equal('Kaiser Chiefs', first.name)
207
+ assert_equal('90218af4-4d58-4821-8d41-2ee295ebbe21', first.mbid)
208
+ assert_equal('http://www.last.fm/music/Kaiser+Chiefs', first.url)
209
+ end
210
+
211
+ test 'should have charts' do
212
+ assert_equal(71, @user.charts.size)
213
+ first = @user.charts.first
214
+ assert_equal(1134302403, first.from)
215
+ assert_equal(1134907203, first.to)
216
+ end
217
+
218
+ test 'should have weekly artist chart' do
219
+ chart = @user.weekly_artist_chart
220
+ assert_equal(5, chart.size)
221
+ first = chart.first
222
+ assert_equal('Rascal Flatts', first.name)
223
+ assert_equal('6e0ae159-8449-4262-bba5-18ec87fa529f', first.mbid)
224
+ assert_equal('1', first.chartposition)
225
+ assert_equal('25', first.playcount)
226
+ assert_equal('http://www.last.fm/music/Rascal+Flatts', first.url)
227
+ end
228
+
229
+ test 'should have weekly artist chart for past weeks' do
230
+ chart = @user.weekly_artist_chart(1138536002, 1139140802)
231
+ assert_equal(8, chart.size)
232
+ first = chart.first
233
+ assert_equal('Jenny Lewis with The Watson Twins', first.name)
234
+ assert_equal('4b179fe2-dfa5-40b1-b6db-b56dbc3b5f09', first.mbid)
235
+ assert_equal('1', first.chartposition)
236
+ assert_equal('48', first.playcount)
237
+ assert_equal('http://www.last.fm/music/Jenny+Lewis+with+The+Watson+Twins', first.url)
238
+ end
239
+
240
+ test 'should have weekly album chart' do
241
+ chart = @user.weekly_album_chart
242
+ assert_equal(4, chart.size)
243
+ first = chart.first
244
+ assert_equal('Reba McEntire', first.artist)
245
+ assert_equal('3ec17e85-9284-4f4c-8831-4e56c2354cdb', first.artist_mbid)
246
+ assert_equal("Reba #1's", first.name)
247
+ assert_equal('', first.mbid)
248
+ assert_equal('1', first.chartposition)
249
+ assert_equal('13', first.playcount)
250
+ assert_equal('http://www.last.fm/music/Reba+McEntire/Reba%2B%25231%2527s', first.url)
251
+ end
252
+
253
+ test 'should have weekly album chart for past weeks' do
254
+ chart = @user.weekly_album_chart(1138536002, 1139140802)
255
+ assert_equal(4, chart.size)
256
+ first = chart.first
257
+ assert_equal('Jewel', first.artist)
258
+ assert_equal('abae8575-ec8a-4736-abc3-1ad5093a68aa', first.artist_mbid)
259
+ assert_equal("0304", first.name)
260
+ assert_equal('52b3f067-9d82-488c-9747-6d608d9b9486', first.mbid)
261
+ assert_equal('1', first.chartposition)
262
+ assert_equal('13', first.playcount)
263
+ assert_equal('http://www.last.fm/music/Jewel/0304', first.url)
264
+ end
265
+
266
+ test 'should have track album chart' do
267
+ chart = @user.weekly_track_chart
268
+ assert_equal(4, chart.size)
269
+ first = chart.first
270
+ assert_equal('Rebecca St. James', first.artist)
271
+ assert_equal('302716e4-a702-4bbc-baac-591f8a8e20bc', first.artist_mbid)
272
+ assert_equal('Omega', first.name)
273
+ assert_equal('', first.mbid)
274
+ assert_equal('1', first.chartposition)
275
+ assert_equal('2', first.playcount)
276
+ assert_equal('http://www.last.fm/music/Rebecca+St.+James/_/Omega', first.url)
277
+ end
278
+
279
+ test 'should have weekly track chart for past weeks' do
280
+ chart = @user.weekly_track_chart(1138536002, 1139140802)
281
+ assert_equal(4, chart.size)
282
+ first = chart.first
283
+ assert_equal('Natasha Bedingfield', first.artist)
284
+ assert_equal('8b477559-946e-4ef2-9fe1-446cff8fdd79', first.artist_mbid)
285
+ assert_equal('Unwritten', first.name)
286
+ assert_equal('', first.mbid)
287
+ assert_equal('1', first.chartposition)
288
+ assert_equal('8', first.playcount)
289
+ assert_equal('http://www.last.fm/music/Natasha+Bedingfield/_/Unwritten', first.url)
290
+ end
291
+ end
metadata ADDED
@@ -0,0 +1,120 @@
1
+ --- !ruby/object:Gem::Specification
2
+ rubygems_version: 0.9.2
3
+ specification_version: 1
4
+ name: scrobbler
5
+ version: !ruby/object:Gem::Version
6
+ version: 0.1.0
7
+ date: 2007-05-10 00:00:00 -04:00
8
+ summary: wrapper for audioscrobbler (last.fm) web services
9
+ require_paths:
10
+ - lib
11
+ email: nunemaker@gmail.com
12
+ homepage: http://scrobbler.rubyforge.org
13
+ rubyforge_project: scrobbler
14
+ description: wrapper for audioscrobbler (last.fm) web services
15
+ autorequire:
16
+ default_executable:
17
+ bindir: bin
18
+ has_rdoc: true
19
+ required_ruby_version: !ruby/object:Gem::Version::Requirement
20
+ requirements:
21
+ - - ">"
22
+ - !ruby/object:Gem::Version
23
+ version: 0.0.0
24
+ version:
25
+ platform: ruby
26
+ signing_key:
27
+ cert_chain:
28
+ post_install_message:
29
+ authors:
30
+ - nunemaker
31
+ files:
32
+ - History.txt
33
+ - Manifest.txt
34
+ - README.txt
35
+ - Rakefile
36
+ - setup.rb
37
+ - examples/album.rb
38
+ - examples/artist.rb
39
+ - examples/tag.rb
40
+ - examples/track.rb
41
+ - examples/user.rb
42
+ - lib/scrobbler.rb
43
+ - lib/scrobbler/album.rb
44
+ - lib/scrobbler/artist.rb
45
+ - lib/scrobbler/base.rb
46
+ - lib/scrobbler/chart.rb
47
+ - lib/scrobbler/rest.rb
48
+ - lib/scrobbler/tag.rb
49
+ - lib/scrobbler/track.rb
50
+ - lib/scrobbler/user.rb
51
+ - lib/scrobbler/version.rb
52
+ - test/test_helper.rb
53
+ - test/fixtures/xml/album/info.xml
54
+ - test/fixtures/xml/artist/fans.xml
55
+ - test/fixtures/xml/artist/similar.xml
56
+ - test/fixtures/xml/artist/topalbums.xml
57
+ - test/fixtures/xml/artist/toptags.xml
58
+ - test/fixtures/xml/artist/toptracks.xml
59
+ - test/fixtures/xml/tag/topalbums.xml
60
+ - test/fixtures/xml/tag/topartists.xml
61
+ - test/fixtures/xml/tag/toptags.xml
62
+ - test/fixtures/xml/tag/toptracks.xml
63
+ - test/fixtures/xml/track/fans.xml
64
+ - test/fixtures/xml/track/toptags.xml
65
+ - test/fixtures/xml/user/friends.xml
66
+ - test/fixtures/xml/user/neighbours.xml
67
+ - test/fixtures/xml/user/profile.xml
68
+ - test/fixtures/xml/user/recentbannedtracks.xml
69
+ - test/fixtures/xml/user/recentlovedtracks.xml
70
+ - test/fixtures/xml/user/recenttracks.xml
71
+ - test/fixtures/xml/user/systemrecs.xml
72
+ - test/fixtures/xml/user/topalbums.xml
73
+ - test/fixtures/xml/user/topartists.xml
74
+ - test/fixtures/xml/user/toptags.xml
75
+ - test/fixtures/xml/user/toptracks.xml
76
+ - test/fixtures/xml/user/weeklyalbumchart.xml
77
+ - test/fixtures/xml/user/weeklyalbumchart_from_1138536002_to_1139140802.xml
78
+ - test/fixtures/xml/user/weeklyartistchart.xml
79
+ - test/fixtures/xml/user/weeklyartistchart_from_1138536002_to_1139140802.xml
80
+ - test/fixtures/xml/user/weeklychartlist.xml
81
+ - test/fixtures/xml/user/weeklytrackchart.xml
82
+ - test/fixtures/xml/user/weeklytrackchart_from_1138536002_to_1139140802.xml
83
+ - test/mocks/rest.rb
84
+ - test/unit/album_test.rb
85
+ - test/unit/artist_test.rb
86
+ - test/unit/chart_test.rb
87
+ - test/unit/tag_test.rb
88
+ - test/unit/track_test.rb
89
+ - test/unit/user_test.rb
90
+ test_files:
91
+ - test/test_helper.rb
92
+ rdoc_options: []
93
+
94
+ extra_rdoc_files: []
95
+
96
+ executables: []
97
+
98
+ extensions: []
99
+
100
+ requirements: []
101
+
102
+ dependencies:
103
+ - !ruby/object:Gem::Dependency
104
+ name: hpricot
105
+ version_requirement:
106
+ version_requirements: !ruby/object:Gem::Version::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: 0.4.86
111
+ version:
112
+ - !ruby/object:Gem::Dependency
113
+ name: activesupport
114
+ version_requirement:
115
+ version_requirements: !ruby/object:Gem::Version::Requirement
116
+ requirements:
117
+ - - ">="
118
+ - !ruby/object:Gem::Version
119
+ version: 1.4.2
120
+ version: