lastfm 1.6.1 → 1.7.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +6 -3
- data/lastfm.gemspec +1 -1
- data/lib/lastfm/util.rb +23 -3
- data/spec/method_specs/album_spec.rb +1 -1
- data/spec/method_specs/artist_spec.rb +6 -6
- data/spec/method_specs/event_spec.rb +2 -2
- data/spec/method_specs/geo_spec.rb +1 -1
- data/spec/method_specs/library_spec.rb +2 -2
- data/spec/method_specs/tag_spec.rb +1 -1
- data/spec/method_specs/track_spec.rb +61 -16
- data/spec/method_specs/user_spec.rb +32 -18
- data/spec/util_spec.rb +79 -12
- metadata +40 -17
- data/.document +0 -5
- data/VERSION +0 -1
data/README.rdoc
CHANGED
@@ -11,11 +11,14 @@ A Ruby interface for Last.fm Web Services v2.0
|
|
11
11
|
|
12
12
|
# open 'http://www.last.fm/api/auth/?api_key=xxxxxxxxxxx&token=xxxxxxxx' and grant the application
|
13
13
|
|
14
|
-
lastfm.session = lastfm.auth.get_session(token)['key']
|
14
|
+
lastfm.session = lastfm.auth.get_session(:token => token)['key']
|
15
15
|
|
16
|
+
lastfm.track.love(:artist => 'Hujiko Pro', :track => 'acid acid 7riddim')
|
17
|
+
lastfm.track.scrobble(:artist => 'Hujiko Pro', :track => 'acid acid 7riddim')
|
18
|
+
lastfm.track.update_now_playing(:artist => 'Hujiko Pro', :track => 'acid acid 7riddim')
|
19
|
+
|
20
|
+
# deprecated style
|
16
21
|
lastfm.track.love('Hujiko Pro', 'acid acid 7riddim')
|
17
|
-
lastfm.track.scrobble('Hujiko Pro', 'acid acid 7riddim')
|
18
|
-
lastfm.track.update_now_playing('Hujiko Pro', 'acid acid 7riddim')
|
19
22
|
|
20
23
|
== Supported API Methods
|
21
24
|
|
data/lastfm.gemspec
CHANGED
@@ -12,7 +12,7 @@ Gem::Specification.new do |gem|
|
|
12
12
|
gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
13
13
|
gem.name = %q{lastfm}
|
14
14
|
gem.require_paths = ["lib"]
|
15
|
-
gem.version = "1.
|
15
|
+
gem.version = "1.7.0"
|
16
16
|
|
17
17
|
gem.add_dependency "xml-simple"
|
18
18
|
gem.add_dependency "httparty"
|
data/lib/lastfm/util.rb
CHANGED
@@ -5,11 +5,31 @@ class Lastfm
|
|
5
5
|
end
|
6
6
|
|
7
7
|
def self.build_options(args, mandatory, optional)
|
8
|
+
if args.first.is_a?(Hash)
|
9
|
+
build_options_from_hash(args.first, mandatory, optional)
|
10
|
+
else
|
11
|
+
build_options_from_array(args, mandatory, optional)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.build_options_from_hash(options, mandatory, optional)
|
16
|
+
mandatory.each do |name|
|
17
|
+
raise ArgumentError.new("%s is required" % name) unless options[name]
|
18
|
+
end
|
19
|
+
|
20
|
+
optional.each do |name, value|
|
21
|
+
options[name] ||= value.kind_of?(Proc) ? value.call : value
|
22
|
+
end
|
23
|
+
|
24
|
+
options
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.build_options_from_array(values, mandatory, optional)
|
8
28
|
options = {}
|
9
29
|
|
10
30
|
mandatory.each_with_index do |name, index|
|
11
|
-
raise ArgumentError.new('%s is required' % name) unless
|
12
|
-
options[name] =
|
31
|
+
raise ArgumentError.new('%s is required' % name) unless values[index]
|
32
|
+
options[name] = values[index]
|
13
33
|
end
|
14
34
|
|
15
35
|
optional.each_with_index do |name, index|
|
@@ -17,7 +37,7 @@ class Lastfm
|
|
17
37
|
if value.kind_of?(Proc)
|
18
38
|
value = value.call
|
19
39
|
end
|
20
|
-
options[name[0]] =
|
40
|
+
options[name[0]] = values[index + mandatory.size] || value
|
21
41
|
end
|
22
42
|
|
23
43
|
options
|
@@ -13,7 +13,7 @@ describe '#album' do
|
|
13
13
|
:artist => 'Cher', :album => 'Believe'
|
14
14
|
}).and_return(make_response('album_get_info'))
|
15
15
|
|
16
|
-
album = @lastfm.album.get_info('Cher', 'Believe')
|
16
|
+
album = @lastfm.album.get_info(:artist => 'Cher', :album => 'Believe')
|
17
17
|
album['name'].should == 'Believe'
|
18
18
|
album['artist'].should == 'Cher'
|
19
19
|
album['id'].should == '2026126'
|
@@ -13,7 +13,7 @@ describe '#artist' do
|
|
13
13
|
:artist => 'Cher'
|
14
14
|
}).and_return(make_response('artist_get_info'))
|
15
15
|
|
16
|
-
artist = @lastfm.artist.get_info('Cher')
|
16
|
+
artist = @lastfm.artist.get_info(:artist => 'Cher')
|
17
17
|
artist['name'].should == 'Cher'
|
18
18
|
artist['mbid'].should == 'bfcc6d75-a6a5-4bc6-8282-47aec8531818'
|
19
19
|
artist['url'].should == 'http://www.last.fm/music/Cher'
|
@@ -27,7 +27,7 @@ describe '#artist' do
|
|
27
27
|
:artist => 'Cher'
|
28
28
|
}).and_return(make_response('artist_get_events'))
|
29
29
|
|
30
|
-
events = @lastfm.artist.get_events('Cher')
|
30
|
+
events = @lastfm.artist.get_events(:artist => 'Cher')
|
31
31
|
events.size.should == 1
|
32
32
|
events[0]['title'].should == 'Cher'
|
33
33
|
events[0]['artists'].size.should == 2
|
@@ -51,7 +51,7 @@ describe '#artist' do
|
|
51
51
|
:artist => 'kid606'
|
52
52
|
}).and_return(make_response('artist_get_similar'))
|
53
53
|
|
54
|
-
artists = @lastfm.artist.get_similar('kid606')
|
54
|
+
artists = @lastfm.artist.get_similar(:artist => 'kid606')
|
55
55
|
artists.size.should == 2
|
56
56
|
artists[1]['name'].should == 'Venetian Snares'
|
57
57
|
artists[1]['mbid'].should == '56abaa47-0101-463b-b37e-e961136fec39'
|
@@ -60,7 +60,7 @@ describe '#artist' do
|
|
60
60
|
artists[1]['image'].should == ['http://userserve-ak.last.fm/serve/160/211799.jpg']
|
61
61
|
end
|
62
62
|
end
|
63
|
-
|
63
|
+
|
64
64
|
describe '#get_tags' do
|
65
65
|
it 'should get artist tags' do
|
66
66
|
@lastfm.should_receive(:request).with('artist.getTags', {
|
@@ -70,7 +70,7 @@ describe '#artist' do
|
|
70
70
|
:autocorrect => nil
|
71
71
|
}).and_return(make_response('artist_get_tags'))
|
72
72
|
|
73
|
-
tags = @lastfm.artist.get_tags('zebrahead', 'test')
|
73
|
+
tags = @lastfm.artist.get_tags(:artist => 'zebrahead', :user => 'test')
|
74
74
|
tags.size.should == 2
|
75
75
|
tags[0]['name'].should == 'punk'
|
76
76
|
tags[1]['name'].should == 'Awesome'
|
@@ -85,7 +85,7 @@ describe '#artist' do
|
|
85
85
|
:page => 3,
|
86
86
|
}).and_return(make_response('artist_search'))
|
87
87
|
|
88
|
-
tracks = @lastfm.artist.search('RADWIMPS', 10, 3)
|
88
|
+
tracks = @lastfm.artist.search(:artist => 'RADWIMPS', :limit => 10, :page => 3)
|
89
89
|
tracks['results']['for'].should == 'RADWIMPS'
|
90
90
|
tracks['results']['totalResults'].should == '3'
|
91
91
|
tracks['results']['artistmatches']['artist'].size.should == 3
|
@@ -10,8 +10,8 @@ describe '#event' do
|
|
10
10
|
@lastfm.should_receive(:request).with('event.getInfo', {
|
11
11
|
:event => 1073657
|
12
12
|
}).and_return(make_response('event_get_info'))
|
13
|
-
info = @lastfm.event.get_info(1073657)
|
13
|
+
info = @lastfm.event.get_info(:event => 1073657)
|
14
14
|
info['title'].should == 'Neko Case'
|
15
15
|
end
|
16
16
|
end
|
17
|
-
end
|
17
|
+
end
|
@@ -16,7 +16,7 @@ describe '#geo' do
|
|
16
16
|
:page => nil
|
17
17
|
}).and_return(make_response('geo_get_events'))
|
18
18
|
|
19
|
-
events = @lastfm.geo.get_events('Boulder')
|
19
|
+
events = @lastfm.geo.get_events(:location => 'Boulder')
|
20
20
|
events.size.should == 1
|
21
21
|
events[0]['title'].should == 'Transistor Festival'
|
22
22
|
events[0]['artists'].size.should == 2
|
@@ -16,7 +16,7 @@ describe '#library' do
|
|
16
16
|
:limit => nil,
|
17
17
|
:page => nil
|
18
18
|
}).and_return(make_response('library_get_tracks'))
|
19
|
-
tracks = @lastfm.library.get_tracks('test', 'foo', 'bar')
|
19
|
+
tracks = @lastfm.library.get_tracks(:user => 'test', :artist => 'foo', :album => 'bar')
|
20
20
|
tracks[0]['name'].should == 'Learning to Live'
|
21
21
|
tracks.size.should == 1
|
22
22
|
end
|
@@ -29,7 +29,7 @@ describe '#library' do
|
|
29
29
|
:limit => nil,
|
30
30
|
:page => nil
|
31
31
|
}).and_return(make_response('library_get_artists'))
|
32
|
-
artists = @lastfm.library.get_artists('test')
|
32
|
+
artists = @lastfm.library.get_artists(:user => 'test')
|
33
33
|
artists[1]['name'].should == 'Dark Castle'
|
34
34
|
artists.size.should == 2
|
35
35
|
end
|
@@ -15,7 +15,7 @@ describe '#tag' do
|
|
15
15
|
:page => nil
|
16
16
|
}).and_return(make_response('tag_get_top_artists'))
|
17
17
|
|
18
|
-
artists = @lastfm.tag.get_top_artists('Disco')
|
18
|
+
artists = @lastfm.tag.get_top_artists(:tag => 'Disco')
|
19
19
|
artists.size.should == 5
|
20
20
|
artists[0]['name'].should == 'Bee Gees'
|
21
21
|
artists[0]['url'].should == 'http://www.last.fm/music/Bee+Gees'
|
@@ -15,7 +15,11 @@ describe '#track' do
|
|
15
15
|
:tags => 'aaa,bbb,ccc'
|
16
16
|
}, :post, true, true).and_return(@ok_response)
|
17
17
|
|
18
|
-
@lastfm.track.add_tags(
|
18
|
+
@lastfm.track.add_tags(
|
19
|
+
:artist => 'foo artist',
|
20
|
+
:track => 'foo track',
|
21
|
+
:tags => 'aaa,bbb,ccc'
|
22
|
+
).should be_true
|
19
23
|
end
|
20
24
|
end
|
21
25
|
|
@@ -26,7 +30,7 @@ describe '#track' do
|
|
26
30
|
:track => 'foo track',
|
27
31
|
}, :post, true, true).and_return(@ok_response)
|
28
32
|
|
29
|
-
@lastfm.track.ban('foo artist', 'foo track').should be_true
|
33
|
+
@lastfm.track.ban(:artist => 'foo artist', :track => 'foo track').should be_true
|
30
34
|
end
|
31
35
|
end
|
32
36
|
|
@@ -38,7 +42,10 @@ describe '#track' do
|
|
38
42
|
:username => 'youpy',
|
39
43
|
}).and_return(make_response('track_get_info'))
|
40
44
|
|
41
|
-
track = @lastfm.track.get_info(
|
45
|
+
track = @lastfm.track.get_info(
|
46
|
+
:artist => 'Cher',
|
47
|
+
:track => 'Believe',
|
48
|
+
:username => 'youpy')
|
42
49
|
track['name'].should == 'Believe'
|
43
50
|
track['album']['image'].size.should == 4
|
44
51
|
track['album']['image'].first['size'].should == 'small'
|
@@ -54,7 +61,10 @@ describe '#track' do
|
|
54
61
|
:username => 'youpy',
|
55
62
|
}).and_return(make_response('track_get_info_force_array'))
|
56
63
|
|
57
|
-
track = @lastfm.track.get_info(
|
64
|
+
track = @lastfm.track.get_info(
|
65
|
+
:artist => 'Cher',
|
66
|
+
:track => 'Believe',
|
67
|
+
:username => 'youpy')
|
58
68
|
track['album']['image'].size.should == 1
|
59
69
|
track['album']['image'].first['size'].should == 'small'
|
60
70
|
track['album']['image'].first['content'].should == 'http://userserve-ak.last.fm/serve/64s/8674593.jpg'
|
@@ -70,7 +80,9 @@ describe '#track' do
|
|
70
80
|
:track => 'One More Cup of Coffee'
|
71
81
|
}).and_return(make_response('track_get_correction'))
|
72
82
|
|
73
|
-
corrections = @lastfm.track.get_correction(
|
83
|
+
corrections = @lastfm.track.get_correction(
|
84
|
+
:artist => 'White Stripes',
|
85
|
+
:track => 'One More Cup of Coffee')
|
74
86
|
correction = corrections.first
|
75
87
|
|
76
88
|
corrections.size.should eql(1)
|
@@ -87,7 +99,9 @@ describe '#track' do
|
|
87
99
|
:track => 'Believe',
|
88
100
|
}).and_return(make_response('track_get_similar'))
|
89
101
|
|
90
|
-
tracks = @lastfm.track.get_similar(
|
102
|
+
tracks = @lastfm.track.get_similar(
|
103
|
+
:artist => 'Cher',
|
104
|
+
:track => 'Believe')
|
91
105
|
tracks.size.should == 5
|
92
106
|
tracks.first['name'].should == 'Strong Enough'
|
93
107
|
tracks.first['image'][1]['content'].should == 'http://userserve-ak.last.fm/serve/64s/8674593.jpg'
|
@@ -102,7 +116,9 @@ describe '#track' do
|
|
102
116
|
:track => 'foo track',
|
103
117
|
}, :get, true, true).and_return(make_response('track_get_tags'))
|
104
118
|
|
105
|
-
tags = @lastfm.track.get_tags(
|
119
|
+
tags = @lastfm.track.get_tags(
|
120
|
+
:artist => 'foo artist',
|
121
|
+
:track => 'foo track')
|
106
122
|
tags.size.should == 2
|
107
123
|
tags[0]['name'].should == 'swedish'
|
108
124
|
tags[0]['url'].should == 'http://www.last.fm/tag/swedish'
|
@@ -116,7 +132,9 @@ describe '#track' do
|
|
116
132
|
:track => 'foo track',
|
117
133
|
}).and_return(make_response('track_get_top_fans'))
|
118
134
|
|
119
|
-
users = @lastfm.track.get_top_fans(
|
135
|
+
users = @lastfm.track.get_top_fans(
|
136
|
+
:artist => 'foo artist',
|
137
|
+
:track => 'foo track')
|
120
138
|
users.size.should == 2
|
121
139
|
users[0]['name'].should == 'Through0glass'
|
122
140
|
end
|
@@ -129,7 +147,9 @@ describe '#track' do
|
|
129
147
|
:track => 'foo track',
|
130
148
|
}).and_return(make_response('track_get_top_tags'))
|
131
149
|
|
132
|
-
tags = @lastfm.track.get_top_tags(
|
150
|
+
tags = @lastfm.track.get_top_tags(
|
151
|
+
:artist => 'foo artist',
|
152
|
+
:track => 'foo track')
|
133
153
|
tags.size.should == 2
|
134
154
|
tags[0]['name'].should == 'alternative'
|
135
155
|
tags[0]['count'].should == '100'
|
@@ -144,7 +164,9 @@ describe '#track' do
|
|
144
164
|
:track => 'foo track',
|
145
165
|
}, :post, true, true).and_return(@ok_response)
|
146
166
|
|
147
|
-
@lastfm.track.love(
|
167
|
+
@lastfm.track.love(
|
168
|
+
:artist => 'foo artist',
|
169
|
+
:track => 'foo track').should be_true
|
148
170
|
end
|
149
171
|
end
|
150
172
|
|
@@ -156,7 +178,10 @@ describe '#track' do
|
|
156
178
|
:tag => 'aaa'
|
157
179
|
}, :post, true, true).and_return(@ok_response)
|
158
180
|
|
159
|
-
@lastfm.track.remove_tag(
|
181
|
+
@lastfm.track.remove_tag(
|
182
|
+
:artist => 'foo artist',
|
183
|
+
:track => 'foo track',
|
184
|
+
:tag => 'aaa').should be_true
|
160
185
|
end
|
161
186
|
end
|
162
187
|
|
@@ -169,7 +194,10 @@ describe '#track' do
|
|
169
194
|
:page => 3,
|
170
195
|
}).and_return(make_response('track_search'))
|
171
196
|
|
172
|
-
tracks = @lastfm.track.search(
|
197
|
+
tracks = @lastfm.track.search(
|
198
|
+
:track => 'Believe',
|
199
|
+
:limit => 10,
|
200
|
+
:page => 3)
|
173
201
|
tracks['results']['for'].should == 'Believe'
|
174
202
|
tracks['results']['totalResults'].should == '40540'
|
175
203
|
tracks['results']['trackmatches']['track'].size.should == 2
|
@@ -186,7 +214,11 @@ describe '#track' do
|
|
186
214
|
:recipient => 'foo@example.com',
|
187
215
|
}, :post, true, true).and_return(@ok_response)
|
188
216
|
|
189
|
-
@lastfm.track.share(
|
217
|
+
@lastfm.track.share(
|
218
|
+
:artist => 'foo artist',
|
219
|
+
:track => 'foo track',
|
220
|
+
:recipient => 'foo@example.com',
|
221
|
+
:message => 'this is a message').should be_true
|
190
222
|
end
|
191
223
|
end
|
192
224
|
|
@@ -204,7 +236,13 @@ describe '#track' do
|
|
204
236
|
:albumArtist => nil,
|
205
237
|
}, :post, true, true).and_return(@ok_response)
|
206
238
|
|
207
|
-
@lastfm.track.scrobble(
|
239
|
+
@lastfm.track.scrobble(
|
240
|
+
:artist => 'foo artist',
|
241
|
+
:track => 'foo track',
|
242
|
+
:timestamp => time,
|
243
|
+
:album => 'foo album',
|
244
|
+
:trackNumber => 1,
|
245
|
+
:mbid => '0383dadf-2a4e-4d10-a46a-e9e041da8eb3')
|
208
246
|
end
|
209
247
|
end
|
210
248
|
|
@@ -220,7 +258,12 @@ describe '#track' do
|
|
220
258
|
:albumArtist => nil,
|
221
259
|
}, :post, true, true).and_return(@ok_response)
|
222
260
|
|
223
|
-
@lastfm.track.update_now_playing(
|
261
|
+
@lastfm.track.update_now_playing(
|
262
|
+
:artist =>'foo artist',
|
263
|
+
:track => 'foo track',
|
264
|
+
:album => 'foo album',
|
265
|
+
:trackNumber => 1,
|
266
|
+
:mbid => '0383dadf-2a4e-4d10-a46a-e9e041da8eb3')
|
224
267
|
end
|
225
268
|
end
|
226
269
|
|
@@ -231,7 +274,9 @@ describe '#track' do
|
|
231
274
|
:track => 'foo track',
|
232
275
|
}, :post, true, true).and_return(@ok_response)
|
233
276
|
|
234
|
-
@lastfm.track.unlove(
|
277
|
+
@lastfm.track.unlove(
|
278
|
+
:artist => 'foo artist',
|
279
|
+
:track => 'foo track').should be_true
|
235
280
|
end
|
236
281
|
end
|
237
282
|
end
|
@@ -10,7 +10,7 @@ describe '#user' do
|
|
10
10
|
describe '#get_info' do
|
11
11
|
it 'should get user info' do
|
12
12
|
@lastfm.should_receive(:request).with('user.getInfo', {:user => 'test'}).and_return(make_response('user_get_info'))
|
13
|
-
info = @lastfm.user.get_info('test')
|
13
|
+
info = @lastfm.user.get_info(:user => 'test')
|
14
14
|
info['id'].should == '1000002'
|
15
15
|
end
|
16
16
|
end
|
@@ -24,7 +24,9 @@ describe '#user' do
|
|
24
24
|
:page => nil
|
25
25
|
}).and_return(make_response('user_get_top_artists'))
|
26
26
|
|
27
|
-
artists = @lastfm.user.get_top_artists(
|
27
|
+
artists = @lastfm.user.get_top_artists(
|
28
|
+
:user => 'test',
|
29
|
+
:period => 'overall')
|
28
30
|
|
29
31
|
artists.size.should == 3
|
30
32
|
artists[0]['name'].should == 'Pain of Salvation'
|
@@ -37,7 +39,7 @@ describe '#user' do
|
|
37
39
|
artists[2]['playcount'].should == '959'
|
38
40
|
end
|
39
41
|
end
|
40
|
-
|
42
|
+
|
41
43
|
describe '#get_personal_tags' do
|
42
44
|
it 'should get user\'s tagged artists' do
|
43
45
|
@lastfm.should_receive(:request).with('user.getPersonalTags', {
|
@@ -48,7 +50,9 @@ describe '#user' do
|
|
48
50
|
:page => nil
|
49
51
|
}).and_return(make_response('user_get_personal_tags_artists'))
|
50
52
|
|
51
|
-
artists = @lastfm.user.get_personal_tags(
|
53
|
+
artists = @lastfm.user.get_personal_tags(
|
54
|
+
:user => 'test',
|
55
|
+
:tag => 'rock')
|
52
56
|
artists[0]['name'].should == 'Afghan Whigs'
|
53
57
|
artists[0]['url'].should == 'http://www.last.fm/music/Afghan+Whigs'
|
54
58
|
artists[1]['name'].should == 'Jeff The Brotherhood'
|
@@ -64,11 +68,14 @@ describe '#user' do
|
|
64
68
|
:page => nil
|
65
69
|
}).and_return(make_response('user_get_personal_tags_albums'))
|
66
70
|
|
67
|
-
albums = @lastfm.user.get_personal_tags(
|
71
|
+
albums = @lastfm.user.get_personal_tags(
|
72
|
+
:user => 'test',
|
73
|
+
:tag => 'hip-hop',
|
74
|
+
:taggingtype => 'album')
|
68
75
|
albums[0]['name'].should == 'DJ Bizkid Presents: The Best of Atmosphere'
|
69
76
|
albums.size.should == 1
|
70
77
|
end
|
71
|
-
|
78
|
+
|
72
79
|
it 'should get user\'s tagged tracks' do
|
73
80
|
@lastfm.should_receive(:request).with('user.getPersonalTags', {
|
74
81
|
:user => 'test',
|
@@ -78,7 +85,10 @@ describe '#user' do
|
|
78
85
|
:page => nil
|
79
86
|
}).and_return(make_response('user_get_personal_tags_tracks'))
|
80
87
|
|
81
|
-
tracks = @lastfm.user.get_personal_tags(
|
88
|
+
tracks = @lastfm.user.get_personal_tags(
|
89
|
+
:user => 'test',
|
90
|
+
:tag => 'jazz',
|
91
|
+
:taggingtype => 'track')
|
82
92
|
tracks[0]['name'].should == 'Come Together'
|
83
93
|
tracks[1]['name'].should == 'Dione'
|
84
94
|
tracks[1]['duration'].should == '450'
|
@@ -95,7 +105,9 @@ describe '#user' do
|
|
95
105
|
:page => nil
|
96
106
|
}).and_return(make_response('user_get_top_albums'))
|
97
107
|
|
98
|
-
albums = @lastfm.user.get_top_albums(
|
108
|
+
albums = @lastfm.user.get_top_albums(
|
109
|
+
:user => 'test',
|
110
|
+
:period => 'overall')
|
99
111
|
|
100
112
|
albums.size.should == 2
|
101
113
|
|
@@ -108,7 +120,7 @@ describe '#user' do
|
|
108
120
|
albums[1]['artist']['name'].should == 'Pain of Salvation'
|
109
121
|
end
|
110
122
|
end
|
111
|
-
|
123
|
+
|
112
124
|
describe '#get_top_tracks' do
|
113
125
|
it 'should get user\'s top tracks' do
|
114
126
|
@lastfm.should_receive(:request).with('user.getTopTracks', {
|
@@ -118,7 +130,9 @@ describe '#user' do
|
|
118
130
|
:page => nil
|
119
131
|
}).and_return(make_response('user_get_top_tracks'))
|
120
132
|
|
121
|
-
tracks = @lastfm.user.get_top_tracks(
|
133
|
+
tracks = @lastfm.user.get_top_tracks(
|
134
|
+
:user => 'test',
|
135
|
+
:period => '7day')
|
122
136
|
|
123
137
|
tracks.size.should == 2
|
124
138
|
|
@@ -131,7 +145,7 @@ describe '#user' do
|
|
131
145
|
tracks[1]['artist']['name'].should == 'Oupa & Tony Crow'
|
132
146
|
end
|
133
147
|
end
|
134
|
-
|
148
|
+
|
135
149
|
describe '#get_loved_tracks' do
|
136
150
|
it 'should get user\'s loved tracks' do
|
137
151
|
@lastfm.should_receive(:request).with('user.getLovedTracks', {
|
@@ -141,7 +155,7 @@ describe '#user' do
|
|
141
155
|
:page => nil
|
142
156
|
}).and_return(make_response('user_get_loved_tracks'))
|
143
157
|
|
144
|
-
tracks = @lastfm.user.get_loved_tracks('test'
|
158
|
+
tracks = @lastfm.user.get_loved_tracks(:user => 'test')
|
145
159
|
|
146
160
|
tracks.size.should == 2
|
147
161
|
|
@@ -153,7 +167,7 @@ describe '#user' do
|
|
153
167
|
tracks[1]['name'].should == 'Working Titles'
|
154
168
|
tracks[1]['artist']['name'].should == 'Damien Jurado'
|
155
169
|
end
|
156
|
-
end
|
170
|
+
end
|
157
171
|
|
158
172
|
describe '#get_friends' do
|
159
173
|
it 'should get user\'s friends' do
|
@@ -163,7 +177,7 @@ describe '#user' do
|
|
163
177
|
:page => nil,
|
164
178
|
:limit => nil
|
165
179
|
}).and_return(make_response('user_get_friends'))
|
166
|
-
friends = @lastfm.user.get_friends('test')
|
180
|
+
friends = @lastfm.user.get_friends(:user => 'test')
|
167
181
|
friends.size.should == 1
|
168
182
|
friends[0]['name'].should == 'polaroide'
|
169
183
|
end
|
@@ -177,7 +191,7 @@ describe '#user' do
|
|
177
191
|
:page => nil,
|
178
192
|
:limit => nil
|
179
193
|
}).and_return(make_response('user_get_neighbours'))
|
180
|
-
neighbours = @lastfm.user.get_neighbours('rj')
|
194
|
+
neighbours = @lastfm.user.get_neighbours(:user => 'rj')
|
181
195
|
neighbours.size.should == 5
|
182
196
|
neighbours[0]['name'].should == 'willywongi'
|
183
197
|
end
|
@@ -192,19 +206,19 @@ describe '#user' do
|
|
192
206
|
:to => nil,
|
193
207
|
:from => nil
|
194
208
|
}).and_return(make_response('user_get_recent_tracks'))
|
195
|
-
tracks = @lastfm.user.get_recent_tracks('test')
|
209
|
+
tracks = @lastfm.user.get_recent_tracks(:user => 'test')
|
196
210
|
tracks[1]['artist']['content'].should == 'Kylie Minogue'
|
197
211
|
tracks.size.should == 2
|
198
212
|
end
|
199
213
|
end
|
200
|
-
|
214
|
+
|
201
215
|
describe '#get_top_tags' do
|
202
216
|
it 'should get user\'s top tags' do
|
203
217
|
@lastfm.should_receive(:request).with('user.getTopTags', {
|
204
218
|
:user => 'test',
|
205
219
|
:limit => nil
|
206
220
|
}).and_return(make_response('user_get_top_tags'))
|
207
|
-
tags = @lastfm.user.get_top_tags('test')
|
221
|
+
tags = @lastfm.user.get_top_tags(:user => 'test')
|
208
222
|
tags[0]['name'].should == 'rock'
|
209
223
|
tags[0]['count'].should == '19'
|
210
224
|
tags[1]['count'].should == '15'
|
data/spec/util_spec.rb
CHANGED
@@ -6,27 +6,94 @@ describe Lastfm::Util do
|
|
6
6
|
end
|
7
7
|
|
8
8
|
describe '.build_options' do
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
9
|
+
describe 'with array' do
|
10
|
+
it 'should build options' do
|
11
|
+
subject.build_options(
|
12
|
+
['foo', nil],
|
13
|
+
[:foo],
|
14
|
+
[[:bar, 'xxx'], [:baz, nil]
|
15
|
+
]).should == {
|
15
16
|
:foo => 'foo',
|
16
17
|
:bar => 'xxx',
|
17
18
|
:baz => nil,
|
18
19
|
}
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'should use proc object to set optional value' do
|
23
|
+
subject.build_options(
|
24
|
+
['foo', nil],
|
25
|
+
[:foo],
|
26
|
+
[[:bar, Proc.new { 'xxx' }]
|
27
|
+
]).should == {
|
28
|
+
:foo => 'foo',
|
29
|
+
:bar => 'xxx',
|
30
|
+
}
|
31
|
+
end
|
32
|
+
|
33
|
+
it 'should raise error if required option is not passed' do
|
34
|
+
lambda {
|
35
|
+
subject.build_options(
|
36
|
+
[],
|
37
|
+
[:foo],
|
38
|
+
[[:bar, 'xxx'], [:baz, nil]
|
39
|
+
])
|
40
|
+
}.should raise_error('foo is required')
|
41
|
+
end
|
19
42
|
end
|
20
43
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
44
|
+
describe 'with hash' do
|
45
|
+
it 'should build options' do
|
46
|
+
subject.build_options(
|
47
|
+
[
|
48
|
+
{
|
49
|
+
:foo => 'foo',
|
50
|
+
:bar => nil,
|
51
|
+
:baz => 'baz'
|
52
|
+
}
|
53
|
+
],
|
54
|
+
[:foo],
|
55
|
+
[
|
56
|
+
[:bar, 'xxx'],
|
57
|
+
[:baz, nil]
|
58
|
+
]).should == {
|
27
59
|
:foo => 'foo',
|
28
60
|
:bar => 'xxx',
|
61
|
+
:baz => 'baz',
|
29
62
|
}
|
63
|
+
end
|
64
|
+
|
65
|
+
it 'should use proc object to set optional value' do
|
66
|
+
subject.build_options(
|
67
|
+
[
|
68
|
+
{
|
69
|
+
:foo => 'foo',
|
70
|
+
:bar => nil,
|
71
|
+
}
|
72
|
+
],
|
73
|
+
[:foo],
|
74
|
+
[[:bar, Proc.new { 'xxx' }]
|
75
|
+
]).should == {
|
76
|
+
:foo => 'foo',
|
77
|
+
:bar => 'xxx',
|
78
|
+
}
|
79
|
+
end
|
80
|
+
|
81
|
+
it 'should raise error if required option is not passed' do
|
82
|
+
lambda {
|
83
|
+
subject.build_options(
|
84
|
+
[
|
85
|
+
{
|
86
|
+
:bar => nil,
|
87
|
+
:baz => 'baz'
|
88
|
+
}
|
89
|
+
],
|
90
|
+
[:foo],
|
91
|
+
[
|
92
|
+
[:bar, 'xxx'],
|
93
|
+
[:baz, nil]
|
94
|
+
])
|
95
|
+
}.should raise_error('foo is required')
|
96
|
+
end
|
30
97
|
end
|
31
98
|
end
|
32
99
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lastfm
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.7.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-07-23 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: xml-simple
|
16
|
-
requirement:
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,15 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements:
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
25
30
|
- !ruby/object:Gem::Dependency
|
26
31
|
name: httparty
|
27
|
-
requirement:
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
28
33
|
none: false
|
29
34
|
requirements:
|
30
35
|
- - ! '>='
|
@@ -32,10 +37,15 @@ dependencies:
|
|
32
37
|
version: '0'
|
33
38
|
type: :runtime
|
34
39
|
prerelease: false
|
35
|
-
version_requirements:
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
36
46
|
- !ruby/object:Gem::Dependency
|
37
47
|
name: activesupport
|
38
|
-
requirement:
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
39
49
|
none: false
|
40
50
|
requirements:
|
41
51
|
- - ! '>='
|
@@ -43,10 +53,15 @@ dependencies:
|
|
43
53
|
version: 3.0.3
|
44
54
|
type: :runtime
|
45
55
|
prerelease: false
|
46
|
-
version_requirements:
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 3.0.3
|
47
62
|
- !ruby/object:Gem::Dependency
|
48
63
|
name: rspec
|
49
|
-
requirement:
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
50
65
|
none: false
|
51
66
|
requirements:
|
52
67
|
- - ~>
|
@@ -54,10 +69,15 @@ dependencies:
|
|
54
69
|
version: 2.8.0
|
55
70
|
type: :development
|
56
71
|
prerelease: false
|
57
|
-
version_requirements:
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ~>
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: 2.8.0
|
58
78
|
- !ruby/object:Gem::Dependency
|
59
79
|
name: rake
|
60
|
-
requirement:
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
61
81
|
none: false
|
62
82
|
requirements:
|
63
83
|
- - ! '>='
|
@@ -65,7 +85,12 @@ dependencies:
|
|
65
85
|
version: '0'
|
66
86
|
type: :development
|
67
87
|
prerelease: false
|
68
|
-
version_requirements:
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ! '>='
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
69
94
|
description: A ruby interface for Last.fm web services version 2.0
|
70
95
|
email:
|
71
96
|
- youpy@buycheapviagraonlinenow.com
|
@@ -73,7 +98,6 @@ executables: []
|
|
73
98
|
extensions: []
|
74
99
|
extra_rdoc_files: []
|
75
100
|
files:
|
76
|
-
- .document
|
77
101
|
- .gitignore
|
78
102
|
- .rspec
|
79
103
|
- .travis.yml
|
@@ -81,7 +105,6 @@ files:
|
|
81
105
|
- LICENSE
|
82
106
|
- README.rdoc
|
83
107
|
- Rakefile
|
84
|
-
- VERSION
|
85
108
|
- lastfm.gemspec
|
86
109
|
- lib/lastfm.rb
|
87
110
|
- lib/lastfm/method_category/album.rb
|
@@ -157,7 +180,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
157
180
|
version: '0'
|
158
181
|
segments:
|
159
182
|
- 0
|
160
|
-
hash: -
|
183
|
+
hash: -2486390308130313809
|
161
184
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
162
185
|
none: false
|
163
186
|
requirements:
|
@@ -166,10 +189,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
166
189
|
version: '0'
|
167
190
|
segments:
|
168
191
|
- 0
|
169
|
-
hash: -
|
192
|
+
hash: -2486390308130313809
|
170
193
|
requirements: []
|
171
194
|
rubyforge_project:
|
172
|
-
rubygems_version: 1.8.
|
195
|
+
rubygems_version: 1.8.24
|
173
196
|
signing_key:
|
174
197
|
specification_version: 3
|
175
198
|
summary: A ruby interface for Last.fm web services version 2.0
|
data/.document
DELETED
data/VERSION
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
1.6.1
|