lastfm 1.1.1 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -59,6 +59,8 @@ It supports methods which require {authentication}[http://www.last.fm/api/authen
59
59
  * {user.getFriends}[http://www.lastfm.jp/api/show?service=263]
60
60
  * {user.getRecentTracks}[http://www.lastfm.jp/api/show?service=278]
61
61
  * {user.getNeighbours}[http://www.lastfm.jp/api/show?service=264]
62
+ * {user.getTopArtists}[http://www.lastfm.jp/api/show/user.getTopArtists]
63
+ * {user.getTopAlbuns}[http://www.lastfm.jp/api/show/user.getTopAlbums]
62
64
 
63
65
  === Geo
64
66
 
@@ -95,6 +97,7 @@ It supports methods which require {authentication}[http://www.last.fm/api/authen
95
97
  * {magnolia-fan}[https://github.com/magnolia-fan]
96
98
  * {garyadamshannon}[https://github.com/garyadamshannon]
97
99
  * {Garthex}[https://github.com/Garthex]
100
+ * {lfzawacki}[https://github.com/lfzawacki]
98
101
 
99
102
  == Note on Patches/Pull Requests
100
103
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.1.1
1
+ 1.2.0
@@ -5,6 +5,14 @@ class Lastfm
5
5
  response.xml['user'][0]
6
6
  end
7
7
 
8
+ regular_method :get_top_albums, [:user], [[:period, nil], [:limit, nil], [:page, nil]] do |response|
9
+ response.xml['topalbums']['album']
10
+ end
11
+
12
+ regular_method :get_top_artists, [:user], [[:period, nil], [:limit, nil], [:page, nil]] do |response|
13
+ response.xml['topartists']['artist']
14
+ end
15
+
8
16
  regular_method :get_friends, [:user], [[:recenttracks, nil], [:limit, nil], [:page, nil]] do |response|
9
17
  response.xml['friends']['user']
10
18
  end
@@ -0,0 +1,29 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <lfm status="ok">
3
+ <topalbums user="test" type="overall">
4
+ <album rank="1">
5
+ <name>The Wall</name>
6
+ <playcount>536</playcount>
7
+ <mbid>639f0d06-53bd-32a5-8f65-1db785743ab0</mbid>
8
+ <url>http://www.last.fm/music/Pink+Floyd/The+Wall</url>
9
+ <artist>
10
+ <name>Pink Floyd</name>
11
+ <mbid>83d91898-7763-47d7-b03b-b92132375c47</mbid>
12
+ <url>http://www.last.fm/music/Pink+Floyd</url>
13
+ </artist>
14
+ <image size="small">http://userserve-ak.last.fm/serve/34s/70211546.png</image>
15
+ </album>
16
+ <album rank="2">
17
+ <name>The Perfect Element, Part I</name>
18
+ <playcount>524</playcount>
19
+ <mbid>3039a1a9-a8d2-4560-81c7-b0af31f692b3</mbid>
20
+ <url>http://www.last.fm/music/Pain+Of+Salvation/The+Perfect+Element%2C+Part+I</url>
21
+ <artist>
22
+ <name>Pain of Salvation</name>
23
+ <mbid>f7c65346-9631-4220-9188-5e90baae58d5</mbid>
24
+ <url>http://www.last.fm/music/Pain+of+Salvation</url>
25
+ </artist>
26
+ <image size="small">http://userserve-ak.last.fm/serve/34s/66884232.png</image>
27
+ </album>
28
+ </topalbums>
29
+ </lfm>
@@ -0,0 +1,29 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <lfm status="ok">
3
+ <topartists user="test" type="overall">
4
+ <artist rank="1">
5
+ <name>Pain of Salvation</name>
6
+ <playcount>1354</playcount>
7
+ <mbid>28503ab7-8bf2-4666-a7bd-2644bfc7cb1d</mbid>
8
+ <url>f7c65346-9631-4220-9188-5e90baae58d5</url>
9
+ <streamable>1</streamable>
10
+ <image size="small">http://userserve-ak.last.fm/serve/34/53572699.png</image>
11
+ </artist>
12
+ <artist rank="2">
13
+ <name>Opeth</name>
14
+ <playcount>1186</playcount>
15
+ <mbid>c14b4180-dc87-481e-b17a-64e4150f90f6</mbid>
16
+ <url>http://www.last.fm/music/Opeth</url>
17
+ <streamable>1</streamable>
18
+ <image size="small">http://userserve-ak.last.fm/serve/34/66663756.png</image>
19
+ </artist>
20
+ <artist rank="3">
21
+ <name>Nevermore</name>
22
+ <playcount>959</playcount>
23
+ <mbid>7d093650-89be-4108-842b-ba7f5367504b</mbid>
24
+ <url>http://www.last.fm/music/Nevermore</url>
25
+ <streamable>1</streamable>
26
+ <image size="small">http://userserve-ak.last.fm/serve/34/239749.jpg</image>
27
+ </artist>
28
+ </topartists>
29
+ </lfm>
@@ -468,6 +468,52 @@ XML
468
468
  end
469
469
  end
470
470
 
471
+ describe '#get_top_artists' do
472
+ it 'should get user\'s top artists' do
473
+ @lastfm.should_receive(:request).with('user.getTopArtists', {
474
+ :user => 'test',
475
+ :period => 'overall',
476
+ :limit => nil,
477
+ :page => nil
478
+ }).and_return(make_response('user_get_top_artists'))
479
+
480
+ artists = @lastfm.user.get_top_artists('test', 'overall', nil, nil)
481
+
482
+ artists.size.should == 3
483
+ artists[0]['name'].should == "Pain of Salvation"
484
+ artists[0]['playcount'].should == '1354'
485
+
486
+ artists[1]['name'].should == "Opeth"
487
+ artists[1]['playcount'].should == '1186'
488
+
489
+ artists[2]['name'].should == "Nevermore"
490
+ artists[2]['playcount'].should == '959'
491
+ end
492
+ end
493
+
494
+ describe '#get_top_albums' do
495
+ it 'should get user\'s top albums' do
496
+ @lastfm.should_receive(:request).with('user.getTopAlbums', {
497
+ :user => 'test',
498
+ :period => 'overall',
499
+ :limit => nil,
500
+ :page => nil
501
+ }).and_return(make_response('user_get_top_albums'))
502
+
503
+ albums = @lastfm.user.get_top_albums('test', 'overall', nil, nil)
504
+
505
+ albums.size.should == 2
506
+
507
+ albums[0]['rank'].should == '1'
508
+ albums[0]['name'].should == 'The Wall'
509
+ albums[0]['artist']['name'].should == 'Pink Floyd'
510
+
511
+ albums[1]['rank'].should == '2'
512
+ albums[1]['name'].should == 'The Perfect Element, Part I'
513
+ albums[1]['artist']['name'].should == 'Pain of Salvation'
514
+ end
515
+ end
516
+
471
517
  describe '#get_friends' do
472
518
  it 'should get user\'s friends' do
473
519
  @lastfm.should_receive(:request).with('user.getFriends', {
metadata CHANGED
@@ -4,10 +4,10 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 1
7
- - 1
8
- - 1
7
+ - 2
8
+ - 0
9
9
  segments_generated: true
10
- version: 1.1.1
10
+ version: 1.2.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - youpy
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2012-01-24 00:00:00 +09:00
18
+ date: 2012-01-27 00:00:00 +09:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -152,6 +152,8 @@ files:
152
152
  - spec/fixtures/user_get_info.xml
153
153
  - spec/fixtures/user_get_neighbours.xml
154
154
  - spec/fixtures/user_get_recent_tracks.xml
155
+ - spec/fixtures/user_get_top_albums.xml
156
+ - spec/fixtures/user_get_top_artists.xml
155
157
  - spec/lastfm_spec.rb
156
158
  - spec/method_category_spec.rb
157
159
  - spec/response_spec.rb